]> git.donarmstrong.com Git - mothur.git/commitdiff
moved mothur's source into a folder to make grabbing just the source easier on github
authorSarah Westcott <mothur.westcott@gmail.com>
Wed, 2 May 2012 15:38:02 +0000 (11:38 -0400)
committerSarah Westcott <mothur.westcott@gmail.com>
Wed, 2 May 2012 15:38:02 +0000 (11:38 -0400)
651 files changed:
Mothur.xcodeproj/project.pbxproj
ace.cpp [deleted file]
ace.h [deleted file]
aligncommand.cpp [deleted file]
aligncommand.h [deleted file]
alignment.cpp [deleted file]
alignment.hpp [deleted file]
alignmentcell.cpp [deleted file]
alignmentcell.hpp [deleted file]
alignmentdb.cpp [deleted file]
alignmentdb.h [deleted file]
amovacommand.cpp [deleted file]
amovacommand.h [deleted file]
anosimcommand.cpp [deleted file]
anosimcommand.h [deleted file]
averagelinkage.cpp [deleted file]
bayesian.cpp [deleted file]
bayesian.h [deleted file]
bellerophon.cpp [deleted file]
bellerophon.h [deleted file]
bergerparker.cpp [deleted file]
bergerparker.h [deleted file]
binsequencecommand.cpp [deleted file]
binsequencecommand.h [deleted file]
blastalign.cpp [deleted file]
blastalign.hpp [deleted file]
blastdb.cpp [deleted file]
blastdb.hpp [deleted file]
boneh.cpp [deleted file]
boneh.h [deleted file]
bootstrap.cpp [deleted file]
bootstrap.h [deleted file]
bsplvb.f [deleted file]
bsplvd.f [deleted file]
bstick.cpp [deleted file]
bstick.h [deleted file]
bvalue.f [deleted file]
calculator.cpp [deleted file]
calculator.h [deleted file]
canberra.cpp [deleted file]
canberra.h [deleted file]
catchallcommand.cpp [deleted file]
catchallcommand.h [deleted file]
ccode.cpp [deleted file]
ccode.h [deleted file]
chao1.cpp [deleted file]
chao1.h [deleted file]
chimera.cpp [deleted file]
chimera.h [deleted file]
chimerabellerophoncommand.cpp [deleted file]
chimerabellerophoncommand.h [deleted file]
chimeraccodecommand.cpp [deleted file]
chimeraccodecommand.h [deleted file]
chimeracheckcommand.cpp [deleted file]
chimeracheckcommand.h [deleted file]
chimeracheckrdp.cpp [deleted file]
chimeracheckrdp.h [deleted file]
chimeraperseuscommand.cpp [deleted file]
chimeraperseuscommand.h [deleted file]
chimerapintailcommand.cpp [deleted file]
chimerapintailcommand.h [deleted file]
chimerarealigner.cpp [deleted file]
chimerarealigner.h [deleted file]
chimeraslayer.cpp [deleted file]
chimeraslayer.h [deleted file]
chimeraslayercommand.cpp [deleted file]
chimeraslayercommand.h [deleted file]
chimerauchimecommand.cpp [deleted file]
chimerauchimecommand.h [deleted file]
chopseqscommand.cpp [deleted file]
chopseqscommand.h [deleted file]
classify.cpp [deleted file]
classify.h [deleted file]
classifyotucommand.cpp [deleted file]
classifyotucommand.h [deleted file]
classifyseqscommand.cpp [deleted file]
classifyseqscommand.h [deleted file]
classifytreecommand.cpp [deleted file]
classifytreecommand.h [deleted file]
clearcut.cpp [deleted file]
clearcut.h [deleted file]
clearcutcommand.cpp [deleted file]
clearcutcommand.h [deleted file]
clearmemorycommand.cpp [deleted file]
clearmemorycommand.h [deleted file]
cluster.cpp [deleted file]
cluster.hpp [deleted file]
clusterclassic.cpp [deleted file]
clusterclassic.h [deleted file]
clustercommand.cpp [deleted file]
clustercommand.h [deleted file]
clusterdoturcommand.cpp [deleted file]
clusterdoturcommand.h [deleted file]
clusterfragmentscommand.cpp [deleted file]
clusterfragmentscommand.h [deleted file]
clustersplitcommand.cpp [deleted file]
clustersplitcommand.h [deleted file]
cmdargs.cpp [deleted file]
cmdargs.h [deleted file]
collect.cpp [deleted file]
collect.h [deleted file]
collectcommand.cpp [deleted file]
collectcommand.h [deleted file]
collectdisplay.h [deleted file]
collectorscurvedata.h [deleted file]
collectsharedcommand.cpp [deleted file]
collectsharedcommand.h [deleted file]
command.hpp [deleted file]
commandfactory.cpp [deleted file]
commandfactory.hpp [deleted file]
commandoptionparser.cpp [deleted file]
commandoptionparser.hpp [deleted file]
commandparameter.h [deleted file]
common.h [deleted file]
completelinkage.cpp [deleted file]
consensus.cpp [deleted file]
consensus.h [deleted file]
consensusseqscommand.cpp [deleted file]
consensusseqscommand.h [deleted file]
cooccurrencecommand.cpp [deleted file]
cooccurrencecommand.h [deleted file]
corraxescommand.cpp [deleted file]
corraxescommand.h [deleted file]
countgroupscommand.cpp [deleted file]
countgroupscommand.h [deleted file]
countseqscommand.cpp [deleted file]
countseqscommand.h [deleted file]
coverage.cpp [deleted file]
coverage.h [deleted file]
createdatabasecommand.cpp [deleted file]
createdatabasecommand.h [deleted file]
currentfile.h [deleted file]
database.cpp [deleted file]
database.hpp [deleted file]
datavector.hpp [deleted file]
daxpy.f [deleted file]
dayhoff.h [deleted file]
ddot.f [deleted file]
decalc.cpp [deleted file]
decalc.h [deleted file]
deconvolutecommand.cpp [deleted file]
deconvolutecommand.h [deleted file]
degapseqscommand.cpp [deleted file]
degapseqscommand.h [deleted file]
deuniqueseqscommand.cpp [deleted file]
deuniqueseqscommand.h [deleted file]
deuniquetreecommand.cpp [deleted file]
deuniquetreecommand.h [deleted file]
display.h [deleted file]
dist.h [deleted file]
distancecommand.cpp [deleted file]
distancecommand.h [deleted file]
distancedb.cpp [deleted file]
distancedb.hpp [deleted file]
distclearcut.cpp [deleted file]
distclearcut.h [deleted file]
dlibshuff.cpp [deleted file]
dlibshuff.h [deleted file]
dmat.cpp [deleted file]
dmat.h [deleted file]
dpbfa.f [deleted file]
dpbsl.f [deleted file]
eachgapdist.h [deleted file]
eachgapdistignorens.h [deleted file]
eachgapignore.h [deleted file]
efron.cpp [deleted file]
efron.h [deleted file]
endiannessmacros.h [deleted file]
engine.cpp [deleted file]
engine.hpp [deleted file]
fasta.cpp [deleted file]
fasta.h [deleted file]
fastamap.cpp [deleted file]
fastamap.h [deleted file]
fileoutput.cpp [deleted file]
fileoutput.h [deleted file]
filters.h [deleted file]
filterseqscommand.cpp [deleted file]
filterseqscommand.h [deleted file]
flowdata.cpp [deleted file]
flowdata.h [deleted file]
formatcolumn.cpp [deleted file]
formatcolumn.h [deleted file]
formatmatrix.h [deleted file]
formatphylip.cpp [deleted file]
formatphylip.h [deleted file]
fullmatrix.cpp [deleted file]
fullmatrix.h [deleted file]
geom.cpp [deleted file]
geom.h [deleted file]
getcommandinfocommand.cpp [deleted file]
getcommandinfocommand.h [deleted file]
getcurrentcommand.cpp [deleted file]
getcurrentcommand.h [deleted file]
getgroupcommand.cpp [deleted file]
getgroupcommand.h [deleted file]
getgroupscommand.cpp [deleted file]
getgroupscommand.h [deleted file]
getlabelcommand.cpp [deleted file]
getlabelcommand.h [deleted file]
getlineagecommand.cpp [deleted file]
getlineagecommand.h [deleted file]
getlistcountcommand.cpp [deleted file]
getlistcountcommand.h [deleted file]
getopt_long.cpp [deleted file]
getopt_long.h [deleted file]
getoturepcommand.cpp [deleted file]
getoturepcommand.h [deleted file]
getotuscommand.cpp [deleted file]
getotuscommand.h [deleted file]
getrabundcommand.cpp [deleted file]
getrabundcommand.h [deleted file]
getrelabundcommand.cpp [deleted file]
getrelabundcommand.h [deleted file]
getsabundcommand.cpp [deleted file]
getsabundcommand.h [deleted file]
getseqscommand.cpp [deleted file]
getseqscommand.h [deleted file]
getsharedotucommand.cpp [deleted file]
getsharedotucommand.h [deleted file]
goodscoverage.cpp [deleted file]
goodscoverage.h [deleted file]
gotohoverlap.cpp [deleted file]
gotohoverlap.hpp [deleted file]
gower.cpp [deleted file]
gower.h [deleted file]
groupmap.cpp [deleted file]
groupmap.h [deleted file]
hamming.cpp [deleted file]
hamming.h [deleted file]
hcluster.cpp [deleted file]
hcluster.h [deleted file]
hclustercommand.cpp [deleted file]
hclustercommand.h [deleted file]
heatmap.cpp [deleted file]
heatmap.h [deleted file]
heatmapcommand.cpp [deleted file]
heatmapcommand.h [deleted file]
heatmapsim.cpp [deleted file]
heatmapsim.h [deleted file]
heatmapsimcommand.cpp [deleted file]
heatmapsimcommand.h [deleted file]
heip.cpp [deleted file]
heip.h [deleted file]
hellinger.cpp [deleted file]
hellinger.h [deleted file]
helpcommand.cpp [deleted file]
helpcommand.h [deleted file]
homovacommand.cpp [deleted file]
homovacommand.h [deleted file]
ignoregaps.h [deleted file]
indicatorcommand.cpp [deleted file]
indicatorcommand.h [deleted file]
inputdata.cpp [deleted file]
inputdata.h [deleted file]
interv.f [deleted file]
intrv.f [deleted file]
invsimpson.cpp [deleted file]
invsimpson.h [deleted file]
jackknife.cpp [deleted file]
jackknife.h [deleted file]
kmer.cpp [deleted file]
kmer.hpp [deleted file]
kmerdb.cpp [deleted file]
kmerdb.hpp [deleted file]
knn.cpp [deleted file]
knn.h [deleted file]
libshuff.cpp [deleted file]
libshuff.h [deleted file]
libshuffcommand.cpp [deleted file]
libshuffcommand.h [deleted file]
linearalgebra.cpp [deleted file]
linearalgebra.h [deleted file]
listseqscommand.cpp [deleted file]
listseqscommand.h [deleted file]
listvector.cpp [deleted file]
listvector.hpp [deleted file]
logsd.cpp [deleted file]
logsd.h [deleted file]
makebiomcommand.cpp [deleted file]
makebiomcommand.h [deleted file]
makefastqcommand.cpp [deleted file]
makefastqcommand.h [deleted file]
makefile [deleted file]
makegroupcommand.cpp [deleted file]
makegroupcommand.h [deleted file]
maligner.cpp [deleted file]
maligner.h [deleted file]
manhattan.cpp [deleted file]
manhattan.h [deleted file]
mantelcommand.cpp [deleted file]
mantelcommand.h [deleted file]
matrixoutputcommand.cpp [deleted file]
matrixoutputcommand.h [deleted file]
memchi2.cpp [deleted file]
memchi2.h [deleted file]
memchord.cpp [deleted file]
memchord.h [deleted file]
memeuclidean.cpp [deleted file]
memeuclidean.h [deleted file]
mempearson.cpp [deleted file]
mempearson.h [deleted file]
mergefilecommand.cpp [deleted file]
mergefilecommand.h [deleted file]
mergegroupscommand.cpp [deleted file]
mergegroupscommand.h [deleted file]
metastatscommand.cpp [deleted file]
metastatscommand.h [deleted file]
mgclustercommand.cpp [deleted file]
mgclustercommand.h [deleted file]
mothur.cpp [deleted file]
mothur.h [deleted file]
mothurfisher.cpp [deleted file]
mothurfisher.h [deleted file]
mothurmetastats.cpp [deleted file]
mothurmetastats.h [deleted file]
mothurout.cpp [deleted file]
mothurout.h [deleted file]
myPerseus.cpp [deleted file]
myPerseus.h [deleted file]
myseqdist.cpp [deleted file]
myseqdist.h [deleted file]
nameassignment.cpp [deleted file]
nameassignment.hpp [deleted file]
nast.cpp [deleted file]
nast.hpp [deleted file]
nastreport.cpp [deleted file]
nastreport.hpp [deleted file]
needlemanoverlap.cpp [deleted file]
needlemanoverlap.hpp [deleted file]
nmdscommand.cpp [deleted file]
nmdscommand.h [deleted file]
noalign.cpp [deleted file]
noalign.hpp [deleted file]
nocommands.cpp [deleted file]
nocommands.h [deleted file]
normalizesharedcommand.cpp [deleted file]
normalizesharedcommand.h [deleted file]
npshannon.cpp [deleted file]
npshannon.h [deleted file]
nseqs.h [deleted file]
observable.h [deleted file]
odum.cpp [deleted file]
odum.h [deleted file]
onegapdist.h [deleted file]
onegapignore.h [deleted file]
optionparser.cpp [deleted file]
optionparser.h [deleted file]
ordervector.cpp [deleted file]
ordervector.hpp [deleted file]
otuassociationcommand.cpp [deleted file]
otuassociationcommand.h [deleted file]
otuhierarchycommand.cpp [deleted file]
otuhierarchycommand.h [deleted file]
overlap.cpp [deleted file]
overlap.hpp [deleted file]
pairwiseseqscommand.cpp [deleted file]
pairwiseseqscommand.h [deleted file]
parsefastaqcommand.cpp [deleted file]
parsefastaqcommand.h [deleted file]
parselistscommand.cpp [deleted file]
parselistscommand.h [deleted file]
parsimony.cpp [deleted file]
parsimony.h [deleted file]
parsimonycommand.cpp [deleted file]
parsimonycommand.h [deleted file]
pcacommand.cpp [deleted file]
pcacommand.h [deleted file]
pcoacommand.cpp [deleted file]
pcoacommand.h [deleted file]
pcrseqscommand.h [deleted file]
phylodiversitycommand.cpp [deleted file]
phylodiversitycommand.h [deleted file]
phylosummary.cpp [deleted file]
phylosummary.h [deleted file]
phylotree.cpp [deleted file]
phylotree.h [deleted file]
phylotypecommand.cpp [deleted file]
phylotypecommand.h [deleted file]
pintail.cpp [deleted file]
pintail.h [deleted file]
pipelinepdscommand.cpp [deleted file]
pipelinepdscommand.h [deleted file]
prcseqscommand.cpp [deleted file]
preclustercommand.cpp [deleted file]
preclustercommand.h [deleted file]
prng.cpp [deleted file]
prng.h [deleted file]
progress.cpp [deleted file]
progress.hpp [deleted file]
qstat.cpp [deleted file]
qstat.h [deleted file]
qualityscores.cpp [deleted file]
qualityscores.h [deleted file]
quitcommand.cpp [deleted file]
quitcommand.h [deleted file]
rabundvector.cpp [deleted file]
rabundvector.hpp [deleted file]
rarecalc.cpp [deleted file]
rarecalc.h [deleted file]
raredisplay.cpp [deleted file]
raredisplay.h [deleted file]
rarefact.cpp [deleted file]
rarefact.h [deleted file]
rarefactcommand.cpp [deleted file]
rarefactcommand.h [deleted file]
rarefactioncurvedata.h [deleted file]
rarefactsharedcommand.cpp [deleted file]
rarefactsharedcommand.h [deleted file]
readblast.cpp [deleted file]
readblast.h [deleted file]
readcluster.cpp [deleted file]
readcluster.h [deleted file]
readcolumn.cpp [deleted file]
readcolumn.h [deleted file]
readdistcommand.cpp [deleted file]
readdistcommand.h [deleted file]
readmatrix.hpp [deleted file]
readotucommand.cpp [deleted file]
readotucommand.h [deleted file]
readphylip.cpp [deleted file]
readphylip.h [deleted file]
readphylipvector.cpp [deleted file]
readphylipvector.h [deleted file]
readtree.cpp [deleted file]
readtree.h [deleted file]
readtreecommand.cpp [deleted file]
readtreecommand.h [deleted file]
refchimeratest.cpp [deleted file]
refchimeratest.h [deleted file]
referencedb.cpp [deleted file]
referencedb.h [deleted file]
removegroupscommand.cpp [deleted file]
removegroupscommand.h [deleted file]
removelineagecommand.cpp [deleted file]
removelineagecommand.h [deleted file]
removeotuscommand.cpp [deleted file]
removeotuscommand.h [deleted file]
removerarecommand.cpp [deleted file]
removerarecommand.h [deleted file]
removeseqscommand.cpp [deleted file]
removeseqscommand.h [deleted file]
reportfile.cpp [deleted file]
reportfile.h [deleted file]
reversecommand.cpp [deleted file]
reversecommand.h [deleted file]
sabundvector.cpp [deleted file]
sabundvector.hpp [deleted file]
screenseqscommand.cpp [deleted file]
screenseqscommand.h [deleted file]
secondarystructurecommand.cpp [deleted file]
secondarystructurecommand.h [deleted file]
sensspeccommand.cpp [deleted file]
sensspeccommand.h [deleted file]
seqerrorcommand.cpp [deleted file]
seqerrorcommand.h [deleted file]
seqnoise.cpp [deleted file]
seqnoise.h [deleted file]
seqsummarycommand.cpp [deleted file]
seqsummarycommand.h [deleted file]
sequence.cpp [deleted file]
sequence.hpp [deleted file]
sequencedb.cpp [deleted file]
sequencedb.h [deleted file]
sequenceparser.cpp [deleted file]
sequenceparser.h [deleted file]
setcurrentcommand.cpp [deleted file]
setcurrentcommand.h [deleted file]
setdircommand.cpp [deleted file]
setdircommand.h [deleted file]
setlogfilecommand.cpp [deleted file]
setlogfilecommand.h [deleted file]
sffinfocommand.cpp [deleted file]
sffinfocommand.h [deleted file]
sgram.f [deleted file]
shannon.cpp [deleted file]
shannon.h [deleted file]
shannoneven.cpp [deleted file]
shannoneven.h [deleted file]
sharedace.cpp [deleted file]
sharedace.h [deleted file]
sharedanderbergs.cpp [deleted file]
sharedanderbergs.h [deleted file]
sharedbraycurtis.cpp [deleted file]
sharedbraycurtis.h [deleted file]
sharedchao1.cpp [deleted file]
sharedchao1.h [deleted file]
sharedcommand.cpp [deleted file]
sharedcommand.h [deleted file]
sharedjabund.cpp [deleted file]
sharedjabund.h [deleted file]
sharedjackknife.cpp [deleted file]
sharedjackknife.h [deleted file]
sharedjclass.cpp [deleted file]
sharedjclass.h [deleted file]
sharedjest.cpp [deleted file]
sharedjest.h [deleted file]
sharedkstest.cpp [deleted file]
sharedkstest.h [deleted file]
sharedkulczynski.cpp [deleted file]
sharedkulczynski.h [deleted file]
sharedkulczynskicody.cpp [deleted file]
sharedkulczynskicody.h [deleted file]
sharedlennon.cpp [deleted file]
sharedlennon.h [deleted file]
sharedlistvector.cpp [deleted file]
sharedlistvector.h [deleted file]
sharedmarczewski.cpp [deleted file]
sharedmarczewski.h [deleted file]
sharedmorisitahorn.cpp [deleted file]
sharedmorisitahorn.h [deleted file]
sharednseqs.h [deleted file]
sharedochiai.cpp [deleted file]
sharedochiai.h [deleted file]
sharedordervector.cpp [deleted file]
sharedordervector.h [deleted file]
sharedrabundfloatvector.cpp [deleted file]
sharedrabundfloatvector.h [deleted file]
sharedrabundvector.cpp [deleted file]
sharedrabundvector.h [deleted file]
sharedsabundvector.cpp [deleted file]
sharedsabundvector.h [deleted file]
sharedsobs.cpp [deleted file]
sharedsobs.h [deleted file]
sharedsobscollectsummary.cpp [deleted file]
sharedsobscollectsummary.h [deleted file]
sharedsorabund.cpp [deleted file]
sharedsorabund.h [deleted file]
sharedsorclass.cpp [deleted file]
sharedsorclass.h [deleted file]
sharedsorest.cpp [deleted file]
sharedsorest.h [deleted file]
sharedthetan.cpp [deleted file]
sharedthetan.h [deleted file]
sharedthetayc.cpp [deleted file]
sharedthetayc.h [deleted file]
sharedutilities.cpp [deleted file]
sharedutilities.h [deleted file]
shen.cpp [deleted file]
shen.h [deleted file]
shhhercommand.cpp [deleted file]
shhhercommand.h [deleted file]
shhhseqscommand.cpp [deleted file]
shhhseqscommand.h [deleted file]
simpson.cpp [deleted file]
simpson.h [deleted file]
simpsoneven.cpp [deleted file]
simpsoneven.h [deleted file]
sinerp.f [deleted file]
singlelinkage.cpp [deleted file]
slayer.cpp [deleted file]
slayer.h [deleted file]
slibshuff.cpp [deleted file]
slibshuff.h [deleted file]
smithwilson.cpp [deleted file]
smithwilson.h [deleted file]
sobs.h [deleted file]
soergel.cpp [deleted file]
soergel.h [deleted file]
solow.cpp [deleted file]
solow.h [deleted file]
sortseqscommand.cpp [deleted file]
sortseqscommand.h [deleted file]
sparsematrix.cpp [deleted file]
sparsematrix.hpp [deleted file]
spearman.cpp [deleted file]
spearman.h [deleted file]
speciesprofile.cpp [deleted file]
speciesprofile.h [deleted file]
spline.cpp [deleted file]
spline.h [deleted file]
splitabundcommand.cpp [deleted file]
splitabundcommand.h [deleted file]
splitgroupscommand.cpp [deleted file]
splitgroupscommand.h [deleted file]
splitmatrix.cpp [deleted file]
splitmatrix.h [deleted file]
sslvrg.f [deleted file]
structchi2.cpp [deleted file]
structchi2.h [deleted file]
structchord.cpp [deleted file]
structchord.h [deleted file]
structeuclidean.cpp [deleted file]
structeuclidean.h [deleted file]
structkulczynski.cpp [deleted file]
structkulczynski.h [deleted file]
structpearson.cpp [deleted file]
structpearson.h [deleted file]
stxwx.f [deleted file]
subsample.cpp [deleted file]
subsample.h [deleted file]
subsamplecommand.cpp [deleted file]
subsamplecommand.h [deleted file]
suffixdb.cpp [deleted file]
suffixdb.hpp [deleted file]
suffixnodes.cpp [deleted file]
suffixnodes.hpp [deleted file]
suffixtree.cpp [deleted file]
suffixtree.hpp [deleted file]
summarycommand.cpp [deleted file]
summarycommand.h [deleted file]
summaryqualcommand.cpp [deleted file]
summaryqualcommand.h [deleted file]
summarysharedcommand.cpp [deleted file]
summarysharedcommand.h [deleted file]
summarytaxcommand.cpp [deleted file]
summarytaxcommand.h [deleted file]
systemcommand.cpp [deleted file]
systemcommand.h [deleted file]
taxonomyequalizer.cpp [deleted file]
taxonomyequalizer.h [deleted file]
tree.cpp [deleted file]
tree.h [deleted file]
treecalculator.h [deleted file]
treegroupscommand.cpp [deleted file]
treegroupscommand.h [deleted file]
treemap.cpp [deleted file]
treemap.h [deleted file]
treenode.cpp [deleted file]
treenode.h [deleted file]
treereader.cpp [deleted file]
treereader.h [deleted file]
trialSwap2.cpp [deleted file]
trialswap2.h [deleted file]
trimflowscommand.cpp [deleted file]
trimflowscommand.h [deleted file]
trimoligos.cpp [deleted file]
trimoligos.h [deleted file]
trimseqscommand.cpp [deleted file]
trimseqscommand.h [deleted file]
unifracunweightedcommand.cpp [deleted file]
unifracunweightedcommand.h [deleted file]
unifracweightedcommand.cpp [deleted file]
unifracweightedcommand.h [deleted file]
unweighted.cpp [deleted file]
unweighted.h [deleted file]
uvest.cpp [deleted file]
uvest.h [deleted file]
validcalculator.cpp [deleted file]
validcalculator.h [deleted file]
validparameter.cpp [deleted file]
validparameter.h [deleted file]
venn.cpp [deleted file]
venn.h [deleted file]
venncommand.cpp [deleted file]
venncommand.h [deleted file]
weighted.cpp [deleted file]
weighted.h [deleted file]
weightedlinkage.cpp [deleted file]
whittaker.cpp [deleted file]
whittaker.h [deleted file]

index 6e156df32f8d604dacdc37e9d350b6a6645f8a14..f62b9b46ff1631133bfe3ae1a1b6eb6946ebf335 100644 (file)
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
-               7E6BE10812F710D8007ADDBE /* refchimeratest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = refchimeratest.h; sourceTree = "<group>"; };
-               7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = refchimeratest.cpp; sourceTree = "<group>"; };
-               7E78911B135F3E8600E725D2 /* eachgapdistignorens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdistignorens.h; sourceTree = "<group>"; };
+               7E6BE10812F710D8007ADDBE /* refchimeratest.h */ = {isa = PBXFileReference; fileEncoding = 4; name = refchimeratest.h; path = source/refchimeratest.h; sourceTree = "<group>"; };
+               7E6BE10912F710D8007ADDBE /* refchimeratest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = refchimeratest.cpp; path = source/refchimeratest.cpp; sourceTree = "<group>"; };
+               7E78911B135F3E8600E725D2 /* eachgapdistignorens.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = eachgapdistignorens.h; path = source/eachgapdistignorens.h; sourceTree = "<group>"; };
                8DD76FB20486AB0100D96B5E /* Mothur */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Mothur; sourceTree = BUILT_PRODUCTS_DIR; };
-               A70332B512D3A13400761E33 /* makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = makefile; sourceTree = "<group>"; };
-               A713EBAA12DC7613000092AC /* readphylipvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylipvector.h; sourceTree = "<group>"; };
-               A713EBAB12DC7613000092AC /* readphylipvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readphylipvector.cpp; sourceTree = "<group>"; };
-               A713EBEB12DC7C5E000092AC /* nmdscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nmdscommand.h; sourceTree = "<group>"; };
-               A713EBEC12DC7C5E000092AC /* nmdscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nmdscommand.cpp; sourceTree = "<group>"; };
-               A71CB15E130B04A2001E7287 /* anosimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = anosimcommand.cpp; sourceTree = "<group>"; };
-               A71CB15F130B04A2001E7287 /* anosimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = anosimcommand.h; sourceTree = "<group>"; };
-               A71FE12A12EDF72400963CA7 /* mergegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mergegroupscommand.h; sourceTree = "<group>"; };
-               A71FE12B12EDF72400963CA7 /* mergegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mergegroupscommand.cpp; sourceTree = "<group>"; };
-               A721765513BB9F7D0014DAAE /* referencedb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = referencedb.h; sourceTree = "<group>"; };
-               A721765613BB9F7D0014DAAE /* referencedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = referencedb.cpp; sourceTree = "<group>"; };
-               A724D2B4153C8600000A826F /* makebiomcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makebiomcommand.h; sourceTree = "<group>"; };
-               A724D2B6153C8628000A826F /* makebiomcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makebiomcommand.cpp; sourceTree = "<group>"; };
-               A727864212E9E28C00F86ABA /* removerarecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removerarecommand.h; sourceTree = "<group>"; };
-               A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removerarecommand.cpp; sourceTree = "<group>"; };
-               A73DDBB813C4A0D1006AAE38 /* clearmemorycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearmemorycommand.h; sourceTree = "<group>"; };
-               A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearmemorycommand.cpp; sourceTree = "<group>"; };
-               A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurmetastats.h; sourceTree = "<group>"; };
-               A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurmetastats.cpp; sourceTree = "<group>"; };
-               A74A9A9D148E881E00AB5E3E /* spline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spline.h; sourceTree = "<group>"; };
-               A74A9A9E148E881E00AB5E3E /* spline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spline.cpp; sourceTree = "<group>"; };
-               A74D36B6137DAFAA00332B0C /* chimerauchimecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerauchimecommand.h; sourceTree = "<group>"; };
-               A74D36B7137DAFAA00332B0C /* chimerauchimecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimerauchimecommand.cpp; sourceTree = "<group>"; };
-               A754149514840CF7005850D1 /* summaryqualcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summaryqualcommand.h; sourceTree = "<group>"; };
-               A754149614840CF7005850D1 /* summaryqualcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summaryqualcommand.cpp; sourceTree = "<group>"; };
-               A75790571301749D00A30DAB /* homovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = homovacommand.h; sourceTree = "<group>"; };
-               A75790581301749D00A30DAB /* homovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = homovacommand.cpp; sourceTree = "<group>"; };
-               A76CDD7F1510F09A004C8458 /* pcrseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcrseqscommand.h; sourceTree = "<group>"; };
-               A76CDD811510F143004C8458 /* prcseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prcseqscommand.cpp; sourceTree = "<group>"; };
-               A7730EFD13967241007433A3 /* countseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = countseqscommand.h; sourceTree = "<group>"; };
-               A7730EFE13967241007433A3 /* countseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = countseqscommand.cpp; sourceTree = "<group>"; };
-               A774101214695AF60098E6AC /* shhhseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shhhseqscommand.h; sourceTree = "<group>"; };
-               A774101314695AF60098E6AC /* shhhseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shhhseqscommand.cpp; sourceTree = "<group>"; };
-               A774104614696F320098E6AC /* myseqdist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = myseqdist.cpp; sourceTree = "<group>"; };
-               A774104714696F320098E6AC /* myseqdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = myseqdist.h; sourceTree = "<group>"; };
-               A77410F414697C300098E6AC /* seqnoise.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = seqnoise.cpp; sourceTree = "<group>"; };
-               A77410F514697C300098E6AC /* seqnoise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seqnoise.h; sourceTree = "<group>"; };
-               A778FE69134CA6CA00C0BA33 /* getcommandinfocommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getcommandinfocommand.h; sourceTree = "<group>"; };
-               A778FE6A134CA6CA00C0BA33 /* getcommandinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcommandinfocommand.cpp; sourceTree = "<group>"; };
-               A77A221D139001B600B0BE70 /* deuniquetreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deuniquetreecommand.h; sourceTree = "<group>"; };
-               A77A221E139001B600B0BE70 /* deuniquetreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deuniquetreecommand.cpp; sourceTree = "<group>"; };
-               A77EBD2C1523707F00ED407C /* createdatabasecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = createdatabasecommand.h; sourceTree = "<group>"; };
-               A77EBD2E1523709100ED407C /* createdatabasecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = createdatabasecommand.cpp; sourceTree = "<group>"; };
-               A7876A25152A017C00A0AE86 /* subsample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = subsample.cpp; sourceTree = "<group>"; };
-               A7876A28152A018B00A0AE86 /* subsample.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = subsample.h; sourceTree = "<group>"; };
-               A79234D513C74BF6002B08E2 /* mothurfisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurfisher.h; sourceTree = "<group>"; };
-               A79234D613C74BF6002B08E2 /* mothurfisher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurfisher.cpp; sourceTree = "<group>"; };
-               A795840B13F13CD900F201D5 /* countgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = countgroupscommand.h; sourceTree = "<group>"; };
-               A795840C13F13CD900F201D5 /* countgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = countgroupscommand.cpp; sourceTree = "<group>"; };
-               A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makefastqcommand.h; sourceTree = "<group>"; };
-               A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makefastqcommand.cpp; sourceTree = "<group>"; };
-               A7A32DA914DC43B00001D2E5 /* sortseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sortseqscommand.cpp; sourceTree = "<group>"; };
-               A7A32DAC14DC43D10001D2E5 /* sortseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sortseqscommand.h; sourceTree = "<group>"; };
-               A7A3C8C714D041AD00B1BFBE /* otuassociationcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = otuassociationcommand.cpp; sourceTree = "<group>"; };
-               A7A3C8C814D041AD00B1BFBE /* otuassociationcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = otuassociationcommand.h; sourceTree = "<group>"; };
+               A70332B512D3A13400761E33 /* makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = makefile; path = source/makefile; sourceTree = "<group>"; };
+               A713EBAA12DC7613000092AC /* readphylipvector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readphylipvector.h; path = source/readphylipvector.h; sourceTree = "<group>"; };
+               A713EBAB12DC7613000092AC /* readphylipvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readphylipvector.cpp; path = source/readphylipvector.cpp; sourceTree = "<group>"; };
+               A713EBEB12DC7C5E000092AC /* nmdscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = nmdscommand.h; path = source/nmdscommand.h; sourceTree = "<group>"; };
+               A713EBEC12DC7C5E000092AC /* nmdscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nmdscommand.cpp; path = source/nmdscommand.cpp; sourceTree = "<group>"; };
+               A71CB15E130B04A2001E7287 /* anosimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = anosimcommand.cpp; path = source/anosimcommand.cpp; sourceTree = "<group>"; };
+               A71CB15F130B04A2001E7287 /* anosimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = anosimcommand.h; path = source/anosimcommand.h; sourceTree = "<group>"; };
+               A71FE12A12EDF72400963CA7 /* mergegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mergegroupscommand.h; path = source/mergegroupscommand.h; sourceTree = "<group>"; };
+               A71FE12B12EDF72400963CA7 /* mergegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mergegroupscommand.cpp; path = source/mergegroupscommand.cpp; sourceTree = "<group>"; };
+               A721765513BB9F7D0014DAAE /* referencedb.h */ = {isa = PBXFileReference; fileEncoding = 4; name = referencedb.h; path = source/referencedb.h; sourceTree = "<group>"; };
+               A721765613BB9F7D0014DAAE /* referencedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = referencedb.cpp; path = source/referencedb.cpp; sourceTree = "<group>"; };
+               A724D2B4153C8600000A826F /* makebiomcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = makebiomcommand.h; path = source/makebiomcommand.h; sourceTree = "<group>"; };
+               A724D2B6153C8628000A826F /* makebiomcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = makebiomcommand.cpp; path = source/makebiomcommand.cpp; sourceTree = "<group>"; };
+               A727864212E9E28C00F86ABA /* removerarecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = removerarecommand.h; path = source/removerarecommand.h; sourceTree = "<group>"; };
+               A727864312E9E28C00F86ABA /* removerarecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = removerarecommand.cpp; path = source/removerarecommand.cpp; sourceTree = "<group>"; };
+               A73DDBB813C4A0D1006AAE38 /* clearmemorycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clearmemorycommand.h; path = source/clearmemorycommand.h; sourceTree = "<group>"; };
+               A73DDBB913C4A0D1006AAE38 /* clearmemorycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clearmemorycommand.cpp; path = source/clearmemorycommand.cpp; sourceTree = "<group>"; };
+               A73DDC3613C4BF64006AAE38 /* mothurmetastats.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mothurmetastats.h; path = source/mothurmetastats.h; sourceTree = "<group>"; };
+               A73DDC3713C4BF64006AAE38 /* mothurmetastats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mothurmetastats.cpp; path = source/mothurmetastats.cpp; sourceTree = "<group>"; };
+               A74A9A9D148E881E00AB5E3E /* spline.h */ = {isa = PBXFileReference; fileEncoding = 4; name = spline.h; path = source/spline.h; sourceTree = "<group>"; };
+               A74A9A9E148E881E00AB5E3E /* spline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = spline.cpp; path = source/spline.cpp; sourceTree = "<group>"; };
+               A74D36B6137DAFAA00332B0C /* chimerauchimecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerauchimecommand.h; path = source/chimerauchimecommand.h; sourceTree = "<group>"; };
+               A74D36B7137DAFAA00332B0C /* chimerauchimecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerauchimecommand.cpp; path = source/chimerauchimecommand.cpp; sourceTree = "<group>"; };
+               A754149514840CF7005850D1 /* summaryqualcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = summaryqualcommand.h; path = source/summaryqualcommand.h; sourceTree = "<group>"; };
+               A754149614840CF7005850D1 /* summaryqualcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = summaryqualcommand.cpp; path = source/summaryqualcommand.cpp; sourceTree = "<group>"; };
+               A75790571301749D00A30DAB /* homovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = homovacommand.h; path = source/homovacommand.h; sourceTree = "<group>"; };
+               A75790581301749D00A30DAB /* homovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = homovacommand.cpp; path = source/homovacommand.cpp; sourceTree = "<group>"; };
+               A76CDD7F1510F09A004C8458 /* pcrseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pcrseqscommand.h; path = source/pcrseqscommand.h; sourceTree = "<group>"; };
+               A76CDD811510F143004C8458 /* prcseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = prcseqscommand.cpp; path = source/prcseqscommand.cpp; sourceTree = "<group>"; };
+               A7730EFD13967241007433A3 /* countseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = countseqscommand.h; path = source/countseqscommand.h; sourceTree = "<group>"; };
+               A7730EFE13967241007433A3 /* countseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = countseqscommand.cpp; path = source/countseqscommand.cpp; sourceTree = "<group>"; };
+               A774101214695AF60098E6AC /* shhhseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = shhhseqscommand.h; path = source/shhhseqscommand.h; sourceTree = "<group>"; };
+               A774101314695AF60098E6AC /* shhhseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = shhhseqscommand.cpp; path = source/shhhseqscommand.cpp; sourceTree = "<group>"; };
+               A774104614696F320098E6AC /* myseqdist.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = myseqdist.cpp; path = source/myseqdist.cpp; sourceTree = "<group>"; };
+               A774104714696F320098E6AC /* myseqdist.h */ = {isa = PBXFileReference; fileEncoding = 4; name = myseqdist.h; path = source/myseqdist.h; sourceTree = "<group>"; };
+               A77410F414697C300098E6AC /* seqnoise.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = seqnoise.cpp; path = source/seqnoise.cpp; sourceTree = "<group>"; };
+               A77410F514697C300098E6AC /* seqnoise.h */ = {isa = PBXFileReference; fileEncoding = 4; name = seqnoise.h; path = source/seqnoise.h; sourceTree = "<group>"; };
+               A778FE69134CA6CA00C0BA33 /* getcommandinfocommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getcommandinfocommand.h; path = source/getcommandinfocommand.h; sourceTree = "<group>"; };
+               A778FE6A134CA6CA00C0BA33 /* getcommandinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getcommandinfocommand.cpp; path = source/getcommandinfocommand.cpp; sourceTree = "<group>"; };
+               A77A221D139001B600B0BE70 /* deuniquetreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = deuniquetreecommand.h; path = source/deuniquetreecommand.h; sourceTree = "<group>"; };
+               A77A221E139001B600B0BE70 /* deuniquetreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = deuniquetreecommand.cpp; path = source/deuniquetreecommand.cpp; sourceTree = "<group>"; };
+               A77EBD2C1523707F00ED407C /* createdatabasecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = createdatabasecommand.h; path = source/createdatabasecommand.h; sourceTree = "<group>"; };
+               A77EBD2E1523709100ED407C /* createdatabasecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = createdatabasecommand.cpp; path = source/createdatabasecommand.cpp; sourceTree = "<group>"; };
+               A7876A25152A017C00A0AE86 /* subsample.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = subsample.cpp; path = source/subsample.cpp; sourceTree = "<group>"; };
+               A7876A28152A018B00A0AE86 /* subsample.h */ = {isa = PBXFileReference; fileEncoding = 4; name = subsample.h; path = source/subsample.h; sourceTree = "<group>"; };
+               A79234D513C74BF6002B08E2 /* mothurfisher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mothurfisher.h; path = source/mothurfisher.h; sourceTree = "<group>"; };
+               A79234D613C74BF6002B08E2 /* mothurfisher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mothurfisher.cpp; path = source/mothurfisher.cpp; sourceTree = "<group>"; };
+               A795840B13F13CD900F201D5 /* countgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = countgroupscommand.h; path = source/countgroupscommand.h; sourceTree = "<group>"; };
+               A795840C13F13CD900F201D5 /* countgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = countgroupscommand.cpp; path = source/countgroupscommand.cpp; sourceTree = "<group>"; };
+               A799F5B71309A3E000AEEFA0 /* makefastqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = makefastqcommand.h; path = source/makefastqcommand.h; sourceTree = "<group>"; };
+               A799F5B81309A3E000AEEFA0 /* makefastqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = makefastqcommand.cpp; path = source/makefastqcommand.cpp; sourceTree = "<group>"; };
+               A7A32DA914DC43B00001D2E5 /* sortseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sortseqscommand.cpp; path = source/sortseqscommand.cpp; sourceTree = "<group>"; };
+               A7A32DAC14DC43D10001D2E5 /* sortseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = sortseqscommand.h; path = source/sortseqscommand.h; sourceTree = "<group>"; };
+               A7A3C8C714D041AD00B1BFBE /* otuassociationcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = otuassociationcommand.cpp; path = source/otuassociationcommand.cpp; sourceTree = "<group>"; };
+               A7A3C8C814D041AD00B1BFBE /* otuassociationcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = otuassociationcommand.h; path = source/otuassociationcommand.h; sourceTree = "<group>"; };
                A7A61F1A130035C800E05B6B /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
-               A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = amovacommand.h; sourceTree = "<group>"; };
-               A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = amovacommand.cpp; sourceTree = "<group>"; };
-               A7AACFBA132FE008003D6C4D /* currentfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = currentfile.h; sourceTree = "<group>"; };
-               A7BF221214587886000AD524 /* myPerseus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = myPerseus.cpp; sourceTree = "<group>"; };
-               A7BF221314587886000AD524 /* myPerseus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = myPerseus.h; sourceTree = "<group>"; };
-               A7BF2230145879B2000AD524 /* chimeraperseuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraperseuscommand.h; sourceTree = "<group>"; };
-               A7BF2231145879B2000AD524 /* chimeraperseuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraperseuscommand.cpp; sourceTree = "<group>"; };
-               A7C3DC0914FE457500FE1924 /* cooccurrencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cooccurrencecommand.cpp; sourceTree = "<group>"; };
-               A7C3DC0A14FE457500FE1924 /* cooccurrencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cooccurrencecommand.h; sourceTree = "<group>"; };
-               A7C3DC0D14FE469500FE1924 /* trialSwap2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = trialSwap2.cpp; sourceTree = "<group>"; };
-               A7C3DC0E14FE469500FE1924 /* trialswap2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trialswap2.h; sourceTree = "<group>"; };
-               A7D755D71535F665009BF21A /* treereader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treereader.h; sourceTree = "<group>"; };
-               A7D755D91535F679009BF21A /* treereader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treereader.cpp; sourceTree = "<group>"; };
-               A7DAAFA3133A254E003956EB /* commandparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commandparameter.h; sourceTree = "<group>"; };
-               A7E9B64F12D37EC300DA6239 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ace.cpp; sourceTree = "<group>"; };
-               A7E9B65012D37EC300DA6239 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ace.h; sourceTree = "<group>"; };
-               A7E9B65112D37EC300DA6239 /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = aligncommand.cpp; sourceTree = "<group>"; };
-               A7E9B65212D37EC300DA6239 /* aligncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = aligncommand.h; sourceTree = "<group>"; };
-               A7E9B65312D37EC300DA6239 /* alignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignment.cpp; sourceTree = "<group>"; };
-               A7E9B65412D37EC300DA6239 /* alignment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alignment.hpp; sourceTree = "<group>"; };
-               A7E9B65512D37EC300DA6239 /* alignmentcell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignmentcell.cpp; sourceTree = "<group>"; };
-               A7E9B65612D37EC300DA6239 /* alignmentcell.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = alignmentcell.hpp; sourceTree = "<group>"; };
-               A7E9B65712D37EC300DA6239 /* alignmentdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = alignmentdb.cpp; sourceTree = "<group>"; };
-               A7E9B65812D37EC300DA6239 /* alignmentdb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alignmentdb.h; sourceTree = "<group>"; };
-               A7E9B65912D37EC300DA6239 /* averagelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = averagelinkage.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B65A12D37EC300DA6239 /* bayesian.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bayesian.cpp; sourceTree = "<group>"; };
-               A7E9B65B12D37EC300DA6239 /* bayesian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bayesian.h; sourceTree = "<group>"; };
-               A7E9B65C12D37EC300DA6239 /* bellerophon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bellerophon.cpp; sourceTree = "<group>"; };
-               A7E9B65D12D37EC300DA6239 /* bellerophon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bellerophon.h; sourceTree = "<group>"; };
-               A7E9B65E12D37EC300DA6239 /* bergerparker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bergerparker.cpp; sourceTree = "<group>"; };
-               A7E9B65F12D37EC300DA6239 /* bergerparker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bergerparker.h; sourceTree = "<group>"; };
-               A7E9B66012D37EC300DA6239 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = binsequencecommand.cpp; sourceTree = "<group>"; };
-               A7E9B66112D37EC300DA6239 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = binsequencecommand.h; sourceTree = "<group>"; };
-               A7E9B66212D37EC300DA6239 /* blastalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blastalign.cpp; sourceTree = "<group>"; };
-               A7E9B66312D37EC400DA6239 /* blastalign.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = blastalign.hpp; sourceTree = "<group>"; };
-               A7E9B66412D37EC400DA6239 /* blastdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = blastdb.cpp; sourceTree = "<group>"; };
-               A7E9B66512D37EC400DA6239 /* blastdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = blastdb.hpp; sourceTree = "<group>"; };
-               A7E9B66612D37EC400DA6239 /* boneh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = boneh.cpp; sourceTree = "<group>"; };
-               A7E9B66712D37EC400DA6239 /* boneh.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = boneh.h; sourceTree = "<group>"; };
-               A7E9B66812D37EC400DA6239 /* bootstrap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bootstrap.cpp; sourceTree = "<group>"; };
-               A7E9B66912D37EC400DA6239 /* bootstrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bootstrap.h; sourceTree = "<group>"; };
-               A7E9B66C12D37EC400DA6239 /* bstick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = bstick.cpp; sourceTree = "<group>"; };
-               A7E9B66D12D37EC400DA6239 /* bstick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bstick.h; sourceTree = "<group>"; };
-               A7E9B66E12D37EC400DA6239 /* calculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = calculator.cpp; sourceTree = "<group>"; };
-               A7E9B66F12D37EC400DA6239 /* calculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = calculator.h; sourceTree = "<group>"; };
-               A7E9B67012D37EC400DA6239 /* canberra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = canberra.cpp; sourceTree = "<group>"; };
-               A7E9B67112D37EC400DA6239 /* canberra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = canberra.h; sourceTree = "<group>"; };
-               A7E9B67212D37EC400DA6239 /* catchallcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catchallcommand.cpp; sourceTree = "<group>"; };
-               A7E9B67312D37EC400DA6239 /* catchallcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catchallcommand.h; sourceTree = "<group>"; };
-               A7E9B67412D37EC400DA6239 /* ccode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ccode.cpp; sourceTree = "<group>"; };
-               A7E9B67512D37EC400DA6239 /* ccode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccode.h; sourceTree = "<group>"; };
-               A7E9B67612D37EC400DA6239 /* chao1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chao1.cpp; sourceTree = "<group>"; };
-               A7E9B67712D37EC400DA6239 /* chao1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chao1.h; sourceTree = "<group>"; };
-               A7E9B67812D37EC400DA6239 /* chimera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimera.cpp; sourceTree = "<group>"; };
-               A7E9B67912D37EC400DA6239 /* chimera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimera.h; sourceTree = "<group>"; };
-               A7E9B67A12D37EC400DA6239 /* chimerabellerophoncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimerabellerophoncommand.cpp; sourceTree = "<group>"; };
-               A7E9B67B12D37EC400DA6239 /* chimerabellerophoncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerabellerophoncommand.h; sourceTree = "<group>"; };
-               A7E9B67C12D37EC400DA6239 /* chimeraccodecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraccodecommand.cpp; sourceTree = "<group>"; };
-               A7E9B67D12D37EC400DA6239 /* chimeraccodecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraccodecommand.h; sourceTree = "<group>"; };
-               A7E9B67E12D37EC400DA6239 /* chimeracheckcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeracheckcommand.cpp; sourceTree = "<group>"; };
-               A7E9B67F12D37EC400DA6239 /* chimeracheckcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeracheckcommand.h; sourceTree = "<group>"; };
-               A7E9B68012D37EC400DA6239 /* chimeracheckrdp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeracheckrdp.cpp; sourceTree = "<group>"; };
-               A7E9B68112D37EC400DA6239 /* chimeracheckrdp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeracheckrdp.h; sourceTree = "<group>"; };
-               A7E9B68212D37EC400DA6239 /* chimerapintailcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimerapintailcommand.cpp; sourceTree = "<group>"; };
-               A7E9B68312D37EC400DA6239 /* chimerapintailcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerapintailcommand.h; sourceTree = "<group>"; };
-               A7E9B68412D37EC400DA6239 /* chimerarealigner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimerarealigner.cpp; sourceTree = "<group>"; };
-               A7E9B68512D37EC400DA6239 /* chimerarealigner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimerarealigner.h; sourceTree = "<group>"; };
-               A7E9B68812D37EC400DA6239 /* chimeraslayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraslayer.cpp; sourceTree = "<group>"; };
-               A7E9B68912D37EC400DA6239 /* chimeraslayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraslayer.h; sourceTree = "<group>"; };
-               A7E9B68A12D37EC400DA6239 /* chimeraslayercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chimeraslayercommand.cpp; sourceTree = "<group>"; };
-               A7E9B68B12D37EC400DA6239 /* chimeraslayercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chimeraslayercommand.h; sourceTree = "<group>"; };
-               A7E9B68C12D37EC400DA6239 /* chopseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = chopseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B68D12D37EC400DA6239 /* chopseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = chopseqscommand.h; sourceTree = "<group>"; };
-               A7E9B68E12D37EC400DA6239 /* classify.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classify.cpp; sourceTree = "<group>"; };
-               A7E9B68F12D37EC400DA6239 /* classify.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classify.h; sourceTree = "<group>"; };
-               A7E9B69012D37EC400DA6239 /* classifyotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classifyotucommand.cpp; sourceTree = "<group>"; };
-               A7E9B69112D37EC400DA6239 /* classifyotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classifyotucommand.h; sourceTree = "<group>"; };
-               A7E9B69212D37EC400DA6239 /* classifyseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classifyseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B69312D37EC400DA6239 /* classifyseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classifyseqscommand.h; sourceTree = "<group>"; };
-               A7E9B69412D37EC400DA6239 /* clearcut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearcut.cpp; sourceTree = "<group>"; };
-               A7E9B69512D37EC400DA6239 /* clearcut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearcut.h; sourceTree = "<group>"; };
-               A7E9B69612D37EC400DA6239 /* clearcutcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clearcutcommand.cpp; sourceTree = "<group>"; };
-               A7E9B69712D37EC400DA6239 /* clearcutcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clearcutcommand.h; sourceTree = "<group>"; };
-               A7E9B69812D37EC400DA6239 /* cluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cluster.cpp; sourceTree = "<group>"; };
-               A7E9B69912D37EC400DA6239 /* cluster.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cluster.hpp; sourceTree = "<group>"; };
-               A7E9B69A12D37EC400DA6239 /* clusterclassic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clusterclassic.cpp; sourceTree = "<group>"; };
-               A7E9B69B12D37EC400DA6239 /* clusterclassic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clusterclassic.h; sourceTree = "<group>"; };
-               A7E9B69C12D37EC400DA6239 /* clustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clustercommand.cpp; sourceTree = "<group>"; };
-               A7E9B69D12D37EC400DA6239 /* clustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clustercommand.h; sourceTree = "<group>"; };
-               A7E9B69E12D37EC400DA6239 /* clusterdoturcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clusterdoturcommand.cpp; sourceTree = "<group>"; };
-               A7E9B69F12D37EC400DA6239 /* clusterdoturcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clusterdoturcommand.h; sourceTree = "<group>"; };
-               A7E9B6A012D37EC400DA6239 /* clusterfragmentscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clusterfragmentscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6A112D37EC400DA6239 /* clusterfragmentscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clusterfragmentscommand.h; sourceTree = "<group>"; };
-               A7E9B6A212D37EC400DA6239 /* clustersplitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = clustersplitcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6A312D37EC400DA6239 /* clustersplitcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clustersplitcommand.h; sourceTree = "<group>"; };
-               A7E9B6A412D37EC400DA6239 /* cmdargs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cmdargs.cpp; sourceTree = "<group>"; };
-               A7E9B6A512D37EC400DA6239 /* cmdargs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cmdargs.h; sourceTree = "<group>"; };
-               A7E9B6A612D37EC400DA6239 /* collect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = collect.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6A712D37EC400DA6239 /* collect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collect.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6A812D37EC400DA6239 /* collectcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = collectcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6A912D37EC400DA6239 /* collectcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectcommand.h; sourceTree = "<group>"; };
-               A7E9B6AA12D37EC400DA6239 /* collectdisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectdisplay.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6AB12D37EC400DA6239 /* collectorscurvedata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectorscurvedata.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6AC12D37EC400DA6239 /* collectsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = collectsharedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6AD12D37EC400DA6239 /* collectsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = collectsharedcommand.h; sourceTree = "<group>"; };
-               A7E9B6AE12D37EC400DA6239 /* command.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = command.hpp; sourceTree = "<group>"; };
-               A7E9B6AF12D37EC400DA6239 /* commandfactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commandfactory.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6B012D37EC400DA6239 /* commandfactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = commandfactory.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6B112D37EC400DA6239 /* commandoptionparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = commandoptionparser.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6B212D37EC400DA6239 /* commandoptionparser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = commandoptionparser.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6B312D37EC400DA6239 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
-               A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = completelinkage.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6B512D37EC400DA6239 /* consensus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = consensus.cpp; sourceTree = "<group>"; };
-               A7E9B6B612D37EC400DA6239 /* consensus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = consensus.h; sourceTree = "<group>"; };
-               A7E9B6B712D37EC400DA6239 /* consensusseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = consensusseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6B812D37EC400DA6239 /* consensusseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = consensusseqscommand.h; sourceTree = "<group>"; };
-               A7E9B6B912D37EC400DA6239 /* corraxescommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = corraxescommand.cpp; sourceTree = "<group>"; };
-               A7E9B6BA12D37EC400DA6239 /* corraxescommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = corraxescommand.h; sourceTree = "<group>"; };
-               A7E9B6BB12D37EC400DA6239 /* coverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = coverage.cpp; sourceTree = "<group>"; };
-               A7E9B6BC12D37EC400DA6239 /* coverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = coverage.h; sourceTree = "<group>"; };
-               A7E9B6BD12D37EC400DA6239 /* database.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = database.cpp; sourceTree = "<group>"; };
-               A7E9B6BE12D37EC400DA6239 /* database.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = database.hpp; sourceTree = "<group>"; };
-               A7E9B6BF12D37EC400DA6239 /* datavector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = datavector.hpp; sourceTree = "<group>"; };
-               A7E9B6C012D37EC400DA6239 /* dayhoff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dayhoff.h; sourceTree = "<group>"; };
-               A7E9B6C112D37EC400DA6239 /* decalc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = decalc.cpp; sourceTree = "<group>"; };
-               A7E9B6C212D37EC400DA6239 /* decalc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decalc.h; sourceTree = "<group>"; };
-               A7E9B6C312D37EC400DA6239 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deconvolutecommand.cpp; sourceTree = "<group>"; };
-               A7E9B6C412D37EC400DA6239 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deconvolutecommand.h; sourceTree = "<group>"; };
-               A7E9B6C512D37EC400DA6239 /* degapseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = degapseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6C612D37EC400DA6239 /* degapseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = degapseqscommand.h; sourceTree = "<group>"; };
-               A7E9B6C712D37EC400DA6239 /* deuniqueseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = deuniqueseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6C812D37EC400DA6239 /* deuniqueseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deuniqueseqscommand.h; sourceTree = "<group>"; };
-               A7E9B6C912D37EC400DA6239 /* display.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = display.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6CA12D37EC400DA6239 /* dist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dist.h; sourceTree = "<group>"; };
-               A7E9B6CB12D37EC400DA6239 /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancecommand.cpp; sourceTree = "<group>"; };
-               A7E9B6CC12D37EC400DA6239 /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distancecommand.h; sourceTree = "<group>"; };
-               A7E9B6CD12D37EC400DA6239 /* distancedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distancedb.cpp; sourceTree = "<group>"; };
-               A7E9B6CE12D37EC400DA6239 /* distancedb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = distancedb.hpp; sourceTree = "<group>"; };
-               A7E9B6CF12D37EC400DA6239 /* distclearcut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = distclearcut.cpp; sourceTree = "<group>"; };
-               A7E9B6D012D37EC400DA6239 /* distclearcut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = distclearcut.h; sourceTree = "<group>"; };
-               A7E9B6D112D37EC400DA6239 /* dlibshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dlibshuff.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6D212D37EC400DA6239 /* dlibshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dlibshuff.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6D312D37EC400DA6239 /* dmat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = dmat.cpp; sourceTree = "<group>"; };
-               A7E9B6D412D37EC400DA6239 /* dmat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dmat.h; sourceTree = "<group>"; };
-               A7E9B6D512D37EC400DA6239 /* eachgapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapdist.h; sourceTree = "<group>"; };
-               A7E9B6D612D37EC400DA6239 /* eachgapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eachgapignore.h; sourceTree = "<group>"; };
-               A7E9B6D712D37EC400DA6239 /* efron.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = efron.cpp; sourceTree = "<group>"; };
-               A7E9B6D812D37EC400DA6239 /* efron.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = efron.h; sourceTree = "<group>"; };
-               A7E9B6D912D37EC400DA6239 /* endiannessmacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = endiannessmacros.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6DA12D37EC400DA6239 /* engine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = engine.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6DB12D37EC400DA6239 /* engine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = engine.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6DC12D37EC400DA6239 /* fasta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fasta.cpp; sourceTree = "<group>"; };
-               A7E9B6DD12D37EC400DA6239 /* fasta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fasta.h; sourceTree = "<group>"; };
-               A7E9B6DE12D37EC400DA6239 /* fastamap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fastamap.cpp; sourceTree = "<group>"; };
-               A7E9B6DF12D37EC400DA6239 /* fastamap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fastamap.h; sourceTree = "<group>"; };
-               A7E9B6E012D37EC400DA6239 /* fileoutput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fileoutput.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B6E112D37EC400DA6239 /* fileoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fileoutput.h; sourceTree = SOURCE_ROOT; };
-               A7E9B6E212D37EC400DA6239 /* filters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filters.h; sourceTree = "<group>"; };
-               A7E9B6E312D37EC400DA6239 /* filterseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = filterseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6E412D37EC400DA6239 /* filterseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = filterseqscommand.h; sourceTree = "<group>"; };
-               A7E9B6E712D37EC400DA6239 /* flowdata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flowdata.cpp; sourceTree = "<group>"; };
-               A7E9B6E812D37EC400DA6239 /* flowdata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = flowdata.h; sourceTree = "<group>"; };
-               A7E9B6E912D37EC400DA6239 /* formatcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = formatcolumn.cpp; sourceTree = "<group>"; };
-               A7E9B6EA12D37EC400DA6239 /* formatcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = formatcolumn.h; sourceTree = "<group>"; };
-               A7E9B6EB12D37EC400DA6239 /* formatmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = formatmatrix.h; sourceTree = "<group>"; };
-               A7E9B6EC12D37EC400DA6239 /* formatphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = formatphylip.cpp; sourceTree = "<group>"; };
-               A7E9B6ED12D37EC400DA6239 /* formatphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = formatphylip.h; sourceTree = "<group>"; };
-               A7E9B6EE12D37EC400DA6239 /* fullmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = fullmatrix.cpp; sourceTree = "<group>"; };
-               A7E9B6EF12D37EC400DA6239 /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fullmatrix.h; sourceTree = "<group>"; };
-               A7E9B6F012D37EC400DA6239 /* geom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = geom.cpp; sourceTree = "<group>"; };
-               A7E9B6F112D37EC400DA6239 /* geom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = geom.h; sourceTree = "<group>"; };
-               A7E9B6F212D37EC400DA6239 /* getgroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getgroupcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6F312D37EC400DA6239 /* getgroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getgroupcommand.h; sourceTree = "<group>"; };
-               A7E9B6F412D37EC400DA6239 /* getgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getgroupscommand.cpp; sourceTree = "<group>"; };
-               A7E9B6F512D37EC400DA6239 /* getgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getgroupscommand.h; sourceTree = "<group>"; };
-               A7E9B6F612D37EC400DA6239 /* getlabelcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getlabelcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6F712D37EC400DA6239 /* getlabelcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getlabelcommand.h; sourceTree = "<group>"; };
-               A7E9B6F812D37EC400DA6239 /* getlineagecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getlineagecommand.cpp; sourceTree = "<group>"; };
-               A7E9B6F912D37EC400DA6239 /* getlineagecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getlineagecommand.h; sourceTree = "<group>"; };
-               A7E9B6FA12D37EC400DA6239 /* getlistcountcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getlistcountcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6FB12D37EC400DA6239 /* getlistcountcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getlistcountcommand.h; sourceTree = "<group>"; };
-               A7E9B6FC12D37EC400DA6239 /* getopt_long.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getopt_long.cpp; sourceTree = "<group>"; };
-               A7E9B6FD12D37EC400DA6239 /* getopt_long.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getopt_long.h; sourceTree = "<group>"; };
-               A7E9B6FE12D37EC400DA6239 /* getoturepcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getoturepcommand.cpp; sourceTree = "<group>"; };
-               A7E9B6FF12D37EC400DA6239 /* getoturepcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getoturepcommand.h; sourceTree = "<group>"; };
-               A7E9B70012D37EC400DA6239 /* getotuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getotuscommand.cpp; sourceTree = "<group>"; };
-               A7E9B70112D37EC400DA6239 /* getotuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getotuscommand.h; sourceTree = "<group>"; };
-               A7E9B70212D37EC400DA6239 /* getrabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getrabundcommand.cpp; sourceTree = "<group>"; };
-               A7E9B70312D37EC400DA6239 /* getrabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getrabundcommand.h; sourceTree = "<group>"; };
-               A7E9B70412D37EC400DA6239 /* getrelabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getrelabundcommand.cpp; sourceTree = "<group>"; };
-               A7E9B70512D37EC400DA6239 /* getrelabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getrelabundcommand.h; sourceTree = "<group>"; };
-               A7E9B70612D37EC400DA6239 /* getsabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getsabundcommand.cpp; sourceTree = "<group>"; };
-               A7E9B70712D37EC400DA6239 /* getsabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getsabundcommand.h; sourceTree = "<group>"; };
-               A7E9B70812D37EC400DA6239 /* getseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B70912D37EC400DA6239 /* getseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getseqscommand.h; sourceTree = "<group>"; };
-               A7E9B70A12D37EC400DA6239 /* getsharedotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getsharedotucommand.cpp; sourceTree = "<group>"; };
-               A7E9B70B12D37EC400DA6239 /* getsharedotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getsharedotucommand.h; sourceTree = "<group>"; };
-               A7E9B70E12D37EC400DA6239 /* goodscoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = goodscoverage.cpp; sourceTree = "<group>"; };
-               A7E9B70F12D37EC400DA6239 /* goodscoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = goodscoverage.h; sourceTree = "<group>"; };
-               A7E9B71012D37EC400DA6239 /* gotohoverlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gotohoverlap.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B71112D37EC400DA6239 /* gotohoverlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = gotohoverlap.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B71212D37EC400DA6239 /* gower.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gower.cpp; sourceTree = "<group>"; };
-               A7E9B71312D37EC400DA6239 /* gower.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gower.h; sourceTree = "<group>"; };
-               A7E9B71412D37EC400DA6239 /* groupmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = groupmap.cpp; sourceTree = "<group>"; };
-               A7E9B71512D37EC400DA6239 /* groupmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = groupmap.h; sourceTree = "<group>"; };
-               A7E9B71612D37EC400DA6239 /* hamming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hamming.cpp; sourceTree = "<group>"; };
-               A7E9B71712D37EC400DA6239 /* hamming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hamming.h; sourceTree = "<group>"; };
-               A7E9B71812D37EC400DA6239 /* hcluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hcluster.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B71912D37EC400DA6239 /* hcluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hcluster.h; sourceTree = SOURCE_ROOT; };
-               A7E9B71A12D37EC400DA6239 /* hclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hclustercommand.cpp; sourceTree = "<group>"; };
-               A7E9B71B12D37EC400DA6239 /* hclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hclustercommand.h; sourceTree = "<group>"; };
-               A7E9B71C12D37EC400DA6239 /* heatmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmap.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B71D12D37EC400DA6239 /* heatmap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmap.h; sourceTree = SOURCE_ROOT; };
-               A7E9B71E12D37EC400DA6239 /* heatmapcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapcommand.cpp; sourceTree = "<group>"; };
-               A7E9B71F12D37EC400DA6239 /* heatmapcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapcommand.h; sourceTree = "<group>"; };
-               A7E9B72012D37EC400DA6239 /* heatmapsim.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsim.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B72112D37EC400DA6239 /* heatmapsim.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsim.h; sourceTree = SOURCE_ROOT; };
-               A7E9B72212D37EC400DA6239 /* heatmapsimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heatmapsimcommand.cpp; sourceTree = "<group>"; };
-               A7E9B72312D37EC400DA6239 /* heatmapsimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heatmapsimcommand.h; sourceTree = "<group>"; };
-               A7E9B72412D37EC400DA6239 /* heip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = heip.cpp; sourceTree = "<group>"; };
-               A7E9B72512D37EC400DA6239 /* heip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = heip.h; sourceTree = "<group>"; };
-               A7E9B72612D37EC400DA6239 /* hellinger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = hellinger.cpp; sourceTree = "<group>"; };
-               A7E9B72712D37EC400DA6239 /* hellinger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hellinger.h; sourceTree = "<group>"; };
-               A7E9B72812D37EC400DA6239 /* helpcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = helpcommand.cpp; sourceTree = "<group>"; };
-               A7E9B72912D37EC400DA6239 /* helpcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = helpcommand.h; sourceTree = "<group>"; };
-               A7E9B72A12D37EC400DA6239 /* ignoregaps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ignoregaps.h; sourceTree = "<group>"; };
-               A7E9B72B12D37EC400DA6239 /* indicatorcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = indicatorcommand.cpp; sourceTree = "<group>"; };
-               A7E9B72C12D37EC400DA6239 /* indicatorcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = indicatorcommand.h; sourceTree = "<group>"; };
-               A7E9B72D12D37EC400DA6239 /* inputdata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = inputdata.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B72E12D37EC400DA6239 /* inputdata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = inputdata.h; sourceTree = SOURCE_ROOT; };
-               A7E9B72F12D37EC400DA6239 /* invsimpson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = invsimpson.cpp; sourceTree = "<group>"; };
-               A7E9B73012D37EC400DA6239 /* invsimpson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = invsimpson.h; sourceTree = "<group>"; };
-               A7E9B73112D37EC400DA6239 /* jackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jackknife.cpp; sourceTree = "<group>"; };
-               A7E9B73212D37EC400DA6239 /* jackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jackknife.h; sourceTree = "<group>"; };
-               A7E9B73312D37EC400DA6239 /* kmer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kmer.cpp; sourceTree = "<group>"; };
-               A7E9B73412D37EC400DA6239 /* kmer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kmer.hpp; sourceTree = "<group>"; };
-               A7E9B73512D37EC400DA6239 /* kmerdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kmerdb.cpp; sourceTree = "<group>"; };
-               A7E9B73612D37EC400DA6239 /* kmerdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = kmerdb.hpp; sourceTree = "<group>"; };
-               A7E9B73712D37EC400DA6239 /* knn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = knn.cpp; sourceTree = "<group>"; };
-               A7E9B73812D37EC400DA6239 /* knn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = knn.h; sourceTree = "<group>"; };
-               A7E9B73912D37EC400DA6239 /* libshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libshuff.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B73A12D37EC400DA6239 /* libshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuff.h; sourceTree = SOURCE_ROOT; };
-               A7E9B73B12D37EC400DA6239 /* libshuffcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libshuffcommand.cpp; sourceTree = "<group>"; };
-               A7E9B73C12D37EC400DA6239 /* libshuffcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libshuffcommand.h; sourceTree = "<group>"; };
-               A7E9B73D12D37EC400DA6239 /* listseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B73E12D37EC400DA6239 /* listseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = listseqscommand.h; sourceTree = "<group>"; };
-               A7E9B73F12D37EC400DA6239 /* listvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = listvector.cpp; sourceTree = "<group>"; };
-               A7E9B74012D37EC400DA6239 /* listvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = listvector.hpp; sourceTree = "<group>"; };
-               A7E9B74112D37EC400DA6239 /* logsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = logsd.cpp; sourceTree = "<group>"; };
-               A7E9B74212D37EC400DA6239 /* logsd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = logsd.h; sourceTree = "<group>"; };
-               A7E9B74312D37EC400DA6239 /* makegroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = makegroupcommand.cpp; sourceTree = "<group>"; };
-               A7E9B74412D37EC400DA6239 /* makegroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = makegroupcommand.h; sourceTree = "<group>"; };
-               A7E9B74512D37EC400DA6239 /* maligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = maligner.cpp; sourceTree = "<group>"; };
-               A7E9B74612D37EC400DA6239 /* maligner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = maligner.h; sourceTree = "<group>"; };
-               A7E9B74712D37EC400DA6239 /* manhattan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = manhattan.cpp; sourceTree = "<group>"; };
-               A7E9B74812D37EC400DA6239 /* manhattan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = manhattan.h; sourceTree = "<group>"; };
-               A7E9B74912D37EC400DA6239 /* matrixoutputcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = matrixoutputcommand.cpp; sourceTree = "<group>"; };
-               A7E9B74A12D37EC400DA6239 /* matrixoutputcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = matrixoutputcommand.h; sourceTree = "<group>"; };
-               A7E9B74B12D37EC400DA6239 /* memchi2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memchi2.cpp; sourceTree = "<group>"; };
-               A7E9B74C12D37EC400DA6239 /* memchi2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memchi2.h; sourceTree = "<group>"; };
-               A7E9B74D12D37EC400DA6239 /* memchord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memchord.cpp; sourceTree = "<group>"; };
-               A7E9B74E12D37EC400DA6239 /* memchord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memchord.h; sourceTree = "<group>"; };
-               A7E9B74F12D37EC400DA6239 /* memeuclidean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = memeuclidean.cpp; sourceTree = "<group>"; };
-               A7E9B75012D37EC400DA6239 /* memeuclidean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memeuclidean.h; sourceTree = "<group>"; };
-               A7E9B75112D37EC400DA6239 /* mempearson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mempearson.cpp; sourceTree = "<group>"; };
-               A7E9B75212D37EC400DA6239 /* mempearson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mempearson.h; sourceTree = "<group>"; };
-               A7E9B75312D37EC400DA6239 /* mergefilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mergefilecommand.cpp; sourceTree = "<group>"; };
-               A7E9B75412D37EC400DA6239 /* mergefilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mergefilecommand.h; sourceTree = "<group>"; };
-               A7E9B75712D37EC400DA6239 /* metastatscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = metastatscommand.cpp; sourceTree = "<group>"; };
-               A7E9B75812D37EC400DA6239 /* metastatscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = metastatscommand.h; sourceTree = "<group>"; };
-               A7E9B75912D37EC400DA6239 /* mgclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mgclustercommand.cpp; sourceTree = "<group>"; };
-               A7E9B75A12D37EC400DA6239 /* mgclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mgclustercommand.h; sourceTree = "<group>"; };
-               A7E9B75B12D37EC400DA6239 /* mothur.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothur.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B75C12D37EC400DA6239 /* mothur.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothur.h; sourceTree = SOURCE_ROOT; };
-               A7E9B75D12D37EC400DA6239 /* mothurout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mothurout.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B75E12D37EC400DA6239 /* mothurout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mothurout.h; sourceTree = SOURCE_ROOT; };
-               A7E9B75F12D37EC400DA6239 /* nameassignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nameassignment.cpp; sourceTree = "<group>"; };
-               A7E9B76012D37EC400DA6239 /* nameassignment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = nameassignment.hpp; sourceTree = "<group>"; };
-               A7E9B76112D37EC400DA6239 /* nast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nast.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76212D37EC400DA6239 /* nast.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = nast.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76312D37EC400DA6239 /* nastreport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nastreport.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76412D37EC400DA6239 /* nastreport.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = nastreport.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76512D37EC400DA6239 /* needlemanoverlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = needlemanoverlap.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76612D37EC400DA6239 /* needlemanoverlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = needlemanoverlap.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76712D37EC400DA6239 /* noalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = noalign.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76812D37EC400DA6239 /* noalign.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = noalign.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B76912D37EC400DA6239 /* nocommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = nocommands.cpp; sourceTree = "<group>"; };
-               A7E9B76A12D37EC400DA6239 /* nocommands.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nocommands.h; sourceTree = "<group>"; };
-               A7E9B76B12D37EC400DA6239 /* normalizesharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = normalizesharedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B76C12D37EC400DA6239 /* normalizesharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = normalizesharedcommand.h; sourceTree = "<group>"; };
-               A7E9B76D12D37EC400DA6239 /* npshannon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = npshannon.cpp; sourceTree = "<group>"; };
-               A7E9B76E12D37EC400DA6239 /* npshannon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = npshannon.h; sourceTree = "<group>"; };
-               A7E9B76F12D37EC400DA6239 /* nseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = nseqs.h; sourceTree = "<group>"; };
-               A7E9B77012D37EC400DA6239 /* observable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = observable.h; sourceTree = SOURCE_ROOT; };
-               A7E9B77112D37EC400DA6239 /* odum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = odum.cpp; sourceTree = "<group>"; };
-               A7E9B77212D37EC400DA6239 /* odum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = odum.h; sourceTree = "<group>"; };
-               A7E9B77312D37EC400DA6239 /* onegapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapdist.h; sourceTree = "<group>"; };
-               A7E9B77412D37EC400DA6239 /* onegapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = onegapignore.h; sourceTree = "<group>"; };
-               A7E9B77512D37EC400DA6239 /* optionparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = optionparser.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B77612D37EC400DA6239 /* optionparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = optionparser.h; sourceTree = SOURCE_ROOT; };
-               A7E9B77712D37EC400DA6239 /* ordervector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ordervector.cpp; sourceTree = "<group>"; };
-               A7E9B77812D37EC400DA6239 /* ordervector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ordervector.hpp; sourceTree = "<group>"; };
-               A7E9B77912D37EC400DA6239 /* otuhierarchycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = otuhierarchycommand.cpp; sourceTree = "<group>"; };
-               A7E9B77A12D37EC400DA6239 /* otuhierarchycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = otuhierarchycommand.h; sourceTree = "<group>"; };
-               A7E9B77B12D37EC400DA6239 /* overlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = overlap.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B77C12D37EC400DA6239 /* overlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = overlap.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B77D12D37EC400DA6239 /* pairwiseseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pairwiseseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B77E12D37EC400DA6239 /* pairwiseseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pairwiseseqscommand.h; sourceTree = "<group>"; };
-               A7E9B77F12D37EC400DA6239 /* parsefastaqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parsefastaqcommand.cpp; sourceTree = "<group>"; };
-               A7E9B78012D37EC400DA6239 /* parsefastaqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsefastaqcommand.h; sourceTree = "<group>"; };
-               A7E9B78112D37EC400DA6239 /* parselistscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parselistscommand.cpp; sourceTree = "<group>"; };
-               A7E9B78212D37EC400DA6239 /* parselistscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parselistscommand.h; sourceTree = "<group>"; };
-               A7E9B78312D37EC400DA6239 /* parsimony.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parsimony.cpp; sourceTree = "<group>"; };
-               A7E9B78412D37EC400DA6239 /* parsimony.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsimony.h; sourceTree = "<group>"; };
-               A7E9B78512D37EC400DA6239 /* parsimonycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = parsimonycommand.cpp; sourceTree = "<group>"; };
-               A7E9B78612D37EC400DA6239 /* parsimonycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = parsimonycommand.h; sourceTree = "<group>"; };
-               A7E9B78712D37EC400DA6239 /* pcoacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pcoacommand.cpp; sourceTree = "<group>"; };
-               A7E9B78812D37EC400DA6239 /* pcoacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcoacommand.h; sourceTree = "<group>"; };
-               A7E9B78B12D37EC400DA6239 /* phylodiversitycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylodiversitycommand.cpp; sourceTree = "<group>"; };
-               A7E9B78C12D37EC400DA6239 /* phylodiversitycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylodiversitycommand.h; sourceTree = "<group>"; };
-               A7E9B78D12D37EC400DA6239 /* phylosummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylosummary.cpp; sourceTree = "<group>"; };
-               A7E9B78E12D37EC400DA6239 /* phylosummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylosummary.h; sourceTree = "<group>"; };
-               A7E9B78F12D37EC400DA6239 /* phylotree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylotree.cpp; sourceTree = "<group>"; };
-               A7E9B79012D37EC400DA6239 /* phylotree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylotree.h; sourceTree = "<group>"; };
-               A7E9B79112D37EC400DA6239 /* phylotypecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = phylotypecommand.cpp; sourceTree = "<group>"; };
-               A7E9B79212D37EC400DA6239 /* phylotypecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = phylotypecommand.h; sourceTree = "<group>"; };
-               A7E9B79312D37EC400DA6239 /* pintail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pintail.cpp; sourceTree = "<group>"; };
-               A7E9B79412D37EC400DA6239 /* pintail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pintail.h; sourceTree = "<group>"; };
-               A7E9B79512D37EC400DA6239 /* pipelinepdscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pipelinepdscommand.cpp; sourceTree = "<group>"; };
-               A7E9B79612D37EC400DA6239 /* pipelinepdscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pipelinepdscommand.h; sourceTree = "<group>"; };
-               A7E9B79712D37EC400DA6239 /* preclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = preclustercommand.cpp; sourceTree = "<group>"; };
-               A7E9B79812D37EC400DA6239 /* preclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = preclustercommand.h; sourceTree = "<group>"; };
-               A7E9B79912D37EC400DA6239 /* prng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = prng.cpp; sourceTree = "<group>"; };
-               A7E9B79A12D37EC400DA6239 /* prng.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = prng.h; sourceTree = "<group>"; };
-               A7E9B79B12D37EC400DA6239 /* progress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = progress.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B79C12D37EC400DA6239 /* progress.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = progress.hpp; sourceTree = SOURCE_ROOT; };
-               A7E9B79D12D37EC400DA6239 /* qstat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = qstat.cpp; sourceTree = "<group>"; };
-               A7E9B79E12D37EC400DA6239 /* qstat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = qstat.h; sourceTree = "<group>"; };
-               A7E9B79F12D37EC400DA6239 /* qualityscores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = qualityscores.cpp; sourceTree = "<group>"; };
-               A7E9B7A012D37EC400DA6239 /* qualityscores.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = qualityscores.h; sourceTree = "<group>"; };
-               A7E9B7A112D37EC400DA6239 /* quitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = quitcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7A212D37EC400DA6239 /* quitcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = quitcommand.h; sourceTree = "<group>"; };
-               A7E9B7A312D37EC400DA6239 /* rabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rabundvector.cpp; sourceTree = "<group>"; };
-               A7E9B7A412D37EC400DA6239 /* rabundvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = rabundvector.hpp; sourceTree = "<group>"; };
-               A7E9B7A512D37EC400DA6239 /* rarecalc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rarecalc.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B7A612D37EC400DA6239 /* rarecalc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarecalc.h; sourceTree = SOURCE_ROOT; };
-               A7E9B7A712D37EC400DA6239 /* raredisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = raredisplay.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B7A812D37EC400DA6239 /* raredisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = raredisplay.h; sourceTree = SOURCE_ROOT; };
-               A7E9B7A912D37EC400DA6239 /* rarefact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rarefact.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B7AA12D37EC400DA6239 /* rarefact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefact.h; sourceTree = SOURCE_ROOT; };
-               A7E9B7AB12D37EC400DA6239 /* rarefactcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rarefactcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7AC12D37EC400DA6239 /* rarefactcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefactcommand.h; sourceTree = "<group>"; };
-               A7E9B7AD12D37EC400DA6239 /* rarefactioncurvedata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefactioncurvedata.h; sourceTree = SOURCE_ROOT; };
-               A7E9B7AE12D37EC400DA6239 /* rarefactsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rarefactsharedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7AF12D37EC400DA6239 /* rarefactsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarefactsharedcommand.h; sourceTree = "<group>"; };
-               A7E9B7B012D37EC400DA6239 /* readblast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readblast.cpp; sourceTree = "<group>"; };
-               A7E9B7B112D37EC400DA6239 /* readblast.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readblast.h; sourceTree = "<group>"; };
-               A7E9B7B212D37EC400DA6239 /* readcluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readcluster.cpp; sourceTree = "<group>"; };
-               A7E9B7B312D37EC400DA6239 /* readcluster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readcluster.h; sourceTree = "<group>"; };
-               A7E9B7B412D37EC400DA6239 /* readcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readcolumn.cpp; sourceTree = "<group>"; };
-               A7E9B7B512D37EC400DA6239 /* readcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readcolumn.h; sourceTree = "<group>"; };
-               A7E9B7B612D37EC400DA6239 /* readdistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readdistcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7B712D37EC400DA6239 /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readdistcommand.h; sourceTree = "<group>"; };
-               A7E9B7B812D37EC400DA6239 /* readmatrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = readmatrix.hpp; sourceTree = "<group>"; };
-               A7E9B7BB12D37EC400DA6239 /* readotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readotucommand.cpp; sourceTree = "<group>"; };
-               A7E9B7BC12D37EC400DA6239 /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readotucommand.h; sourceTree = "<group>"; };
-               A7E9B7BD12D37EC400DA6239 /* readphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readphylip.cpp; sourceTree = "<group>"; };
-               A7E9B7BE12D37EC400DA6239 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readphylip.h; sourceTree = "<group>"; };
-               A7E9B7BF12D37EC400DA6239 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtree.cpp; sourceTree = "<group>"; };
-               A7E9B7C012D37EC400DA6239 /* readtree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtree.h; sourceTree = "<group>"; };
-               A7E9B7C112D37EC400DA6239 /* readtreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtreecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7C212D37EC400DA6239 /* readtreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtreecommand.h; sourceTree = "<group>"; };
-               A7E9B7C312D37EC400DA6239 /* removegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removegroupscommand.cpp; sourceTree = "<group>"; };
-               A7E9B7C412D37EC400DA6239 /* removegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removegroupscommand.h; sourceTree = "<group>"; };
-               A7E9B7C512D37EC400DA6239 /* removelineagecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removelineagecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7C612D37EC400DA6239 /* removelineagecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removelineagecommand.h; sourceTree = "<group>"; };
-               A7E9B7C712D37EC400DA6239 /* removeotuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removeotuscommand.cpp; sourceTree = "<group>"; };
-               A7E9B7C812D37EC400DA6239 /* removeotuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removeotuscommand.h; sourceTree = "<group>"; };
-               A7E9B7C912D37EC400DA6239 /* removeseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = removeseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B7CA12D37EC400DA6239 /* removeseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = removeseqscommand.h; sourceTree = "<group>"; };
-               A7E9B7CB12D37EC400DA6239 /* reportfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reportfile.cpp; sourceTree = "<group>"; };
-               A7E9B7CC12D37EC400DA6239 /* reportfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reportfile.h; sourceTree = "<group>"; };
-               A7E9B7CD12D37EC400DA6239 /* reversecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = reversecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7CE12D37EC400DA6239 /* reversecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = reversecommand.h; sourceTree = "<group>"; };
-               A7E9B7CF12D37EC400DA6239 /* sabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sabundvector.cpp; sourceTree = "<group>"; };
-               A7E9B7D012D37EC400DA6239 /* sabundvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sabundvector.hpp; sourceTree = "<group>"; };
-               A7E9B7D112D37EC400DA6239 /* screenseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = screenseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B7D212D37EC400DA6239 /* screenseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = screenseqscommand.h; sourceTree = "<group>"; };
-               A7E9B7D312D37EC400DA6239 /* secondarystructurecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = secondarystructurecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7D412D37EC400DA6239 /* secondarystructurecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = secondarystructurecommand.h; sourceTree = "<group>"; };
-               A7E9B7D512D37EC400DA6239 /* sensspeccommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sensspeccommand.cpp; sourceTree = "<group>"; };
-               A7E9B7D612D37EC400DA6239 /* sensspeccommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sensspeccommand.h; sourceTree = "<group>"; };
-               A7E9B7D712D37EC400DA6239 /* seqerrorcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = seqerrorcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7D812D37EC400DA6239 /* seqerrorcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seqerrorcommand.h; sourceTree = "<group>"; };
-               A7E9B7D912D37EC400DA6239 /* seqsummarycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = seqsummarycommand.cpp; sourceTree = "<group>"; };
-               A7E9B7DA12D37EC400DA6239 /* seqsummarycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = seqsummarycommand.h; sourceTree = "<group>"; };
-               A7E9B7DB12D37EC400DA6239 /* sequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sequence.cpp; sourceTree = "<group>"; };
-               A7E9B7DC12D37EC400DA6239 /* sequence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sequence.hpp; sourceTree = "<group>"; };
-               A7E9B7DD12D37EC400DA6239 /* sequencedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sequencedb.cpp; sourceTree = "<group>"; };
-               A7E9B7DE12D37EC400DA6239 /* sequencedb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sequencedb.h; sourceTree = "<group>"; };
-               A7E9B7DF12D37EC400DA6239 /* setdircommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = setdircommand.cpp; sourceTree = "<group>"; };
-               A7E9B7E012D37EC400DA6239 /* setdircommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setdircommand.h; sourceTree = "<group>"; };
-               A7E9B7E112D37EC400DA6239 /* setlogfilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = setlogfilecommand.cpp; sourceTree = "<group>"; };
-               A7E9B7E212D37EC400DA6239 /* setlogfilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setlogfilecommand.h; sourceTree = "<group>"; };
-               A7E9B7E312D37EC400DA6239 /* sffinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sffinfocommand.cpp; sourceTree = "<group>"; };
-               A7E9B7E412D37EC400DA6239 /* sffinfocommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sffinfocommand.h; sourceTree = "<group>"; };
-               A7E9B7E512D37EC400DA6239 /* shannon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shannon.cpp; sourceTree = "<group>"; };
-               A7E9B7E612D37EC400DA6239 /* shannon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shannon.h; sourceTree = "<group>"; };
-               A7E9B7E712D37EC400DA6239 /* shannoneven.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shannoneven.cpp; sourceTree = "<group>"; };
-               A7E9B7E812D37EC400DA6239 /* shannoneven.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shannoneven.h; sourceTree = "<group>"; };
-               A7E9B7E912D37EC400DA6239 /* sharedace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedace.cpp; sourceTree = "<group>"; };
-               A7E9B7EA12D37EC400DA6239 /* sharedace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedace.h; sourceTree = "<group>"; };
-               A7E9B7EC12D37EC400DA6239 /* sharedanderbergs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedanderbergs.cpp; sourceTree = "<group>"; };
-               A7E9B7ED12D37EC400DA6239 /* sharedanderbergs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedanderbergs.h; sourceTree = "<group>"; };
-               A7E9B7EE12D37EC400DA6239 /* sharedbraycurtis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedbraycurtis.cpp; sourceTree = "<group>"; };
-               A7E9B7EF12D37EC400DA6239 /* sharedbraycurtis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedbraycurtis.h; sourceTree = "<group>"; };
-               A7E9B7F012D37EC400DA6239 /* sharedchao1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedchao1.cpp; sourceTree = "<group>"; };
-               A7E9B7F112D37EC400DA6239 /* sharedchao1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedchao1.h; sourceTree = "<group>"; };
-               A7E9B7F212D37EC400DA6239 /* sharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B7F312D37EC400DA6239 /* sharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedcommand.h; sourceTree = "<group>"; };
-               A7E9B7F412D37EC400DA6239 /* sharedjabund.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjabund.cpp; sourceTree = "<group>"; };
-               A7E9B7F512D37EC400DA6239 /* sharedjabund.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjabund.h; sourceTree = "<group>"; };
-               A7E9B7F612D37EC400DA6239 /* sharedjackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjackknife.cpp; sourceTree = "<group>"; };
-               A7E9B7F712D37EC400DA6239 /* sharedjackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjackknife.h; sourceTree = "<group>"; };
-               A7E9B7F812D37EC400DA6239 /* sharedjclass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjclass.cpp; sourceTree = "<group>"; };
-               A7E9B7F912D37EC400DA6239 /* sharedjclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjclass.h; sourceTree = "<group>"; };
-               A7E9B7FA12D37EC400DA6239 /* sharedjest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedjest.cpp; sourceTree = "<group>"; };
-               A7E9B7FB12D37EC400DA6239 /* sharedjest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedjest.h; sourceTree = "<group>"; };
-               A7E9B7FC12D37EC400DA6239 /* sharedkstest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedkstest.cpp; sourceTree = "<group>"; };
-               A7E9B7FD12D37EC400DA6239 /* sharedkstest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedkstest.h; sourceTree = "<group>"; };
-               A7E9B7FE12D37EC400DA6239 /* sharedkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedkulczynski.cpp; sourceTree = "<group>"; };
-               A7E9B7FF12D37EC400DA6239 /* sharedkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedkulczynski.h; sourceTree = "<group>"; };
-               A7E9B80012D37EC400DA6239 /* sharedkulczynskicody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedkulczynskicody.cpp; sourceTree = "<group>"; };
-               A7E9B80112D37EC400DA6239 /* sharedkulczynskicody.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedkulczynskicody.h; sourceTree = "<group>"; };
-               A7E9B80212D37EC400DA6239 /* sharedlennon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedlennon.cpp; sourceTree = "<group>"; };
-               A7E9B80312D37EC400DA6239 /* sharedlennon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedlennon.h; sourceTree = "<group>"; };
-               A7E9B80412D37EC400DA6239 /* sharedlistvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedlistvector.cpp; sourceTree = "<group>"; };
-               A7E9B80512D37EC400DA6239 /* sharedlistvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedlistvector.h; sourceTree = "<group>"; };
-               A7E9B80612D37EC400DA6239 /* sharedmarczewski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedmarczewski.cpp; sourceTree = "<group>"; };
-               A7E9B80712D37EC400DA6239 /* sharedmarczewski.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedmarczewski.h; sourceTree = "<group>"; };
-               A7E9B80812D37EC400DA6239 /* sharedmorisitahorn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedmorisitahorn.cpp; sourceTree = "<group>"; };
-               A7E9B80912D37EC400DA6239 /* sharedmorisitahorn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedmorisitahorn.h; sourceTree = "<group>"; };
-               A7E9B80A12D37EC400DA6239 /* sharednseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharednseqs.h; sourceTree = "<group>"; };
-               A7E9B80B12D37EC400DA6239 /* sharedochiai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedochiai.cpp; sourceTree = "<group>"; };
-               A7E9B80C12D37EC400DA6239 /* sharedochiai.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedochiai.h; sourceTree = "<group>"; };
-               A7E9B80D12D37EC400DA6239 /* sharedordervector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedordervector.cpp; sourceTree = "<group>"; };
-               A7E9B80E12D37EC400DA6239 /* sharedordervector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedordervector.h; sourceTree = "<group>"; };
-               A7E9B80F12D37EC400DA6239 /* sharedrabundfloatvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedrabundfloatvector.cpp; sourceTree = "<group>"; };
-               A7E9B81012D37EC400DA6239 /* sharedrabundfloatvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedrabundfloatvector.h; sourceTree = "<group>"; };
-               A7E9B81112D37EC400DA6239 /* sharedrabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedrabundvector.cpp; sourceTree = "<group>"; };
-               A7E9B81212D37EC400DA6239 /* sharedrabundvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedrabundvector.h; sourceTree = "<group>"; };
-               A7E9B81312D37EC400DA6239 /* sharedsabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsabundvector.cpp; sourceTree = "<group>"; };
-               A7E9B81412D37EC400DA6239 /* sharedsabundvector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsabundvector.h; sourceTree = "<group>"; };
-               A7E9B81512D37EC400DA6239 /* sharedsobs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsobs.cpp; sourceTree = "<group>"; };
-               A7E9B81612D37EC400DA6239 /* sharedsobs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsobs.h; sourceTree = "<group>"; };
-               A7E9B81712D37EC400DA6239 /* sharedsobscollectsummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsobscollectsummary.cpp; sourceTree = "<group>"; };
-               A7E9B81812D37EC400DA6239 /* sharedsobscollectsummary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsobscollectsummary.h; sourceTree = "<group>"; };
-               A7E9B81912D37EC400DA6239 /* sharedsorabund.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsorabund.cpp; sourceTree = "<group>"; };
-               A7E9B81A12D37EC400DA6239 /* sharedsorabund.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsorabund.h; sourceTree = "<group>"; };
-               A7E9B81B12D37EC400DA6239 /* sharedsorclass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsorclass.cpp; sourceTree = "<group>"; };
-               A7E9B81C12D37EC400DA6239 /* sharedsorclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsorclass.h; sourceTree = "<group>"; };
-               A7E9B81D12D37EC400DA6239 /* sharedsorest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedsorest.cpp; sourceTree = "<group>"; };
-               A7E9B81E12D37EC400DA6239 /* sharedsorest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedsorest.h; sourceTree = "<group>"; };
-               A7E9B81F12D37EC400DA6239 /* sharedthetan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedthetan.cpp; sourceTree = "<group>"; };
-               A7E9B82012D37EC400DA6239 /* sharedthetan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedthetan.h; sourceTree = "<group>"; };
-               A7E9B82112D37EC400DA6239 /* sharedthetayc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedthetayc.cpp; sourceTree = "<group>"; };
-               A7E9B82212D37EC400DA6239 /* sharedthetayc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedthetayc.h; sourceTree = "<group>"; };
-               A7E9B82312D37EC400DA6239 /* sharedutilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sharedutilities.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B82412D37EC400DA6239 /* sharedutilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sharedutilities.h; sourceTree = SOURCE_ROOT; };
-               A7E9B82512D37EC400DA6239 /* shen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shen.cpp; sourceTree = "<group>"; };
-               A7E9B82612D37EC400DA6239 /* shen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shen.h; sourceTree = "<group>"; };
-               A7E9B82712D37EC400DA6239 /* shhhercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shhhercommand.cpp; sourceTree = "<group>"; };
-               A7E9B82812D37EC400DA6239 /* shhhercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = shhhercommand.h; sourceTree = "<group>"; };
-               A7E9B82912D37EC400DA6239 /* simpson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simpson.cpp; sourceTree = "<group>"; };
-               A7E9B82A12D37EC400DA6239 /* simpson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simpson.h; sourceTree = "<group>"; };
-               A7E9B82B12D37EC400DA6239 /* simpsoneven.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simpsoneven.cpp; sourceTree = "<group>"; };
-               A7E9B82C12D37EC400DA6239 /* simpsoneven.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simpsoneven.h; sourceTree = "<group>"; };
-               A7E9B82D12D37EC400DA6239 /* singlelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = singlelinkage.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B82E12D37EC400DA6239 /* slayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slayer.cpp; sourceTree = "<group>"; };
-               A7E9B82F12D37EC400DA6239 /* slayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slayer.h; sourceTree = "<group>"; };
-               A7E9B83012D37EC400DA6239 /* slibshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = slibshuff.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B83112D37EC400DA6239 /* slibshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = slibshuff.h; sourceTree = SOURCE_ROOT; };
-               A7E9B83212D37EC400DA6239 /* smithwilson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = smithwilson.cpp; sourceTree = "<group>"; };
-               A7E9B83312D37EC400DA6239 /* smithwilson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = smithwilson.h; sourceTree = "<group>"; };
-               A7E9B83412D37EC400DA6239 /* sobs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sobs.h; sourceTree = "<group>"; };
-               A7E9B83512D37EC400DA6239 /* soergel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = soergel.cpp; sourceTree = "<group>"; };
-               A7E9B83612D37EC400DA6239 /* soergel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = soergel.h; sourceTree = "<group>"; };
-               A7E9B83712D37EC400DA6239 /* solow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = solow.cpp; sourceTree = "<group>"; };
-               A7E9B83812D37EC400DA6239 /* solow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = solow.h; sourceTree = "<group>"; };
-               A7E9B83912D37EC400DA6239 /* sparsematrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sparsematrix.cpp; sourceTree = "<group>"; };
-               A7E9B83A12D37EC400DA6239 /* sparsematrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = sparsematrix.hpp; sourceTree = "<group>"; };
-               A7E9B83B12D37EC400DA6239 /* spearman.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = spearman.cpp; sourceTree = "<group>"; };
-               A7E9B83C12D37EC400DA6239 /* spearman.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = spearman.h; sourceTree = "<group>"; };
-               A7E9B83D12D37EC400DA6239 /* speciesprofile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = speciesprofile.cpp; sourceTree = "<group>"; };
-               A7E9B83E12D37EC400DA6239 /* speciesprofile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = speciesprofile.h; sourceTree = "<group>"; };
-               A7E9B83F12D37EC400DA6239 /* splitabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = splitabundcommand.cpp; sourceTree = "<group>"; };
-               A7E9B84012D37EC400DA6239 /* splitabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitabundcommand.h; sourceTree = "<group>"; };
-               A7E9B84112D37EC400DA6239 /* splitgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = splitgroupscommand.cpp; sourceTree = "<group>"; };
-               A7E9B84212D37EC400DA6239 /* splitgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitgroupscommand.h; sourceTree = "<group>"; };
-               A7E9B84312D37EC400DA6239 /* splitmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = splitmatrix.cpp; sourceTree = "<group>"; };
-               A7E9B84412D37EC400DA6239 /* splitmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = splitmatrix.h; sourceTree = "<group>"; };
-               A7E9B84512D37EC400DA6239 /* structchi2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = structchi2.cpp; sourceTree = "<group>"; };
-               A7E9B84612D37EC400DA6239 /* structchi2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = structchi2.h; sourceTree = "<group>"; };
-               A7E9B84712D37EC400DA6239 /* structchord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = structchord.cpp; sourceTree = "<group>"; };
-               A7E9B84812D37EC400DA6239 /* structchord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = structchord.h; sourceTree = "<group>"; };
-               A7E9B84912D37EC400DA6239 /* structeuclidean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = structeuclidean.cpp; sourceTree = "<group>"; };
-               A7E9B84A12D37EC400DA6239 /* structeuclidean.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = structeuclidean.h; sourceTree = "<group>"; };
-               A7E9B84B12D37EC400DA6239 /* structkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = structkulczynski.cpp; sourceTree = "<group>"; };
-               A7E9B84C12D37EC400DA6239 /* structkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = structkulczynski.h; sourceTree = "<group>"; };
-               A7E9B84D12D37EC400DA6239 /* structpearson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = structpearson.cpp; sourceTree = "<group>"; };
-               A7E9B84E12D37EC400DA6239 /* structpearson.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = structpearson.h; sourceTree = "<group>"; };
-               A7E9B84F12D37EC400DA6239 /* subsamplecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = subsamplecommand.cpp; sourceTree = "<group>"; };
-               A7E9B85012D37EC400DA6239 /* subsamplecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = subsamplecommand.h; sourceTree = "<group>"; };
-               A7E9B85112D37EC400DA6239 /* suffixdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = suffixdb.cpp; sourceTree = "<group>"; };
-               A7E9B85212D37EC400DA6239 /* suffixdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = suffixdb.hpp; sourceTree = "<group>"; };
-               A7E9B85312D37EC400DA6239 /* suffixnodes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = suffixnodes.cpp; sourceTree = "<group>"; };
-               A7E9B85412D37EC400DA6239 /* suffixnodes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = suffixnodes.hpp; sourceTree = "<group>"; };
-               A7E9B85512D37EC400DA6239 /* suffixtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = suffixtree.cpp; sourceTree = "<group>"; };
-               A7E9B85612D37EC400DA6239 /* suffixtree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = suffixtree.hpp; sourceTree = "<group>"; };
-               A7E9B85712D37EC400DA6239 /* summarycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summarycommand.cpp; sourceTree = "<group>"; };
-               A7E9B85812D37EC400DA6239 /* summarycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarycommand.h; sourceTree = "<group>"; };
-               A7E9B85912D37EC400DA6239 /* summarysharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summarysharedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B85A12D37EC400DA6239 /* summarysharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarysharedcommand.h; sourceTree = "<group>"; };
-               A7E9B85B12D37EC400DA6239 /* systemcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = systemcommand.cpp; sourceTree = "<group>"; };
-               A7E9B85C12D37EC400DA6239 /* systemcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = systemcommand.h; sourceTree = "<group>"; };
-               A7E9B85D12D37EC400DA6239 /* taxonomyequalizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = taxonomyequalizer.cpp; sourceTree = "<group>"; };
-               A7E9B85E12D37EC400DA6239 /* taxonomyequalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = taxonomyequalizer.h; sourceTree = "<group>"; };
-               A7E9B85F12D37EC400DA6239 /* tree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = tree.cpp; sourceTree = "<group>"; };
-               A7E9B86012D37EC400DA6239 /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tree.h; sourceTree = "<group>"; };
-               A7E9B86112D37EC400DA6239 /* treecalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treecalculator.h; sourceTree = "<group>"; };
-               A7E9B86212D37EC400DA6239 /* treegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treegroupscommand.cpp; sourceTree = "<group>"; };
-               A7E9B86312D37EC400DA6239 /* treegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treegroupscommand.h; sourceTree = "<group>"; };
-               A7E9B86412D37EC400DA6239 /* treemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treemap.cpp; sourceTree = "<group>"; };
-               A7E9B86512D37EC400DA6239 /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treemap.h; sourceTree = "<group>"; };
-               A7E9B86612D37EC400DA6239 /* treenode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treenode.cpp; sourceTree = "<group>"; };
-               A7E9B86712D37EC400DA6239 /* treenode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = treenode.h; sourceTree = "<group>"; };
-               A7E9B86812D37EC400DA6239 /* trimflowscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = trimflowscommand.cpp; sourceTree = "<group>"; };
-               A7E9B86912D37EC400DA6239 /* trimflowscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trimflowscommand.h; sourceTree = "<group>"; };
-               A7E9B86A12D37EC400DA6239 /* trimseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = trimseqscommand.cpp; sourceTree = "<group>"; };
-               A7E9B86B12D37EC400DA6239 /* trimseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trimseqscommand.h; sourceTree = "<group>"; };
-               A7E9B86C12D37EC400DA6239 /* unifracunweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unifracunweightedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B86D12D37EC400DA6239 /* unifracunweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unifracunweightedcommand.h; sourceTree = "<group>"; };
-               A7E9B86E12D37EC400DA6239 /* unifracweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unifracweightedcommand.cpp; sourceTree = "<group>"; };
-               A7E9B86F12D37EC400DA6239 /* unifracweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unifracweightedcommand.h; sourceTree = "<group>"; };
-               A7E9B87012D37EC400DA6239 /* unweighted.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unweighted.cpp; sourceTree = "<group>"; };
-               A7E9B87112D37EC400DA6239 /* unweighted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unweighted.h; sourceTree = "<group>"; };
-               A7E9B87212D37EC400DA6239 /* uvest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = uvest.cpp; sourceTree = "<group>"; };
-               A7E9B87312D37EC400DA6239 /* uvest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = uvest.h; sourceTree = "<group>"; };
-               A7E9B87412D37EC400DA6239 /* validcalculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validcalculator.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B87512D37EC400DA6239 /* validcalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = validcalculator.h; sourceTree = SOURCE_ROOT; };
-               A7E9B87612D37EC400DA6239 /* validparameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = validparameter.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B87712D37EC400DA6239 /* validparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = validparameter.h; sourceTree = SOURCE_ROOT; };
-               A7E9B87812D37EC400DA6239 /* venn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = venn.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B87912D37EC400DA6239 /* venn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = venn.h; sourceTree = SOURCE_ROOT; };
-               A7E9B87A12D37EC400DA6239 /* venncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = venncommand.cpp; sourceTree = "<group>"; };
-               A7E9B87B12D37EC400DA6239 /* venncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = venncommand.h; sourceTree = "<group>"; };
-               A7E9B87C12D37EC400DA6239 /* weighted.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = weighted.cpp; sourceTree = "<group>"; };
-               A7E9B87D12D37EC400DA6239 /* weighted.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = weighted.h; sourceTree = "<group>"; };
-               A7E9B87E12D37EC400DA6239 /* weightedlinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = weightedlinkage.cpp; sourceTree = SOURCE_ROOT; };
-               A7E9B87F12D37EC400DA6239 /* whittaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = whittaker.cpp; sourceTree = "<group>"; };
-               A7E9B88012D37EC400DA6239 /* whittaker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = whittaker.h; sourceTree = "<group>"; };
-               A7EEB0F414F29BFD00344B83 /* classifytreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = classifytreecommand.cpp; sourceTree = "<group>"; };
-               A7EEB0F714F29C1B00344B83 /* classifytreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = classifytreecommand.h; sourceTree = "<group>"; };
-               A7F9F5CD141A5E500032F693 /* sequenceparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sequenceparser.h; sourceTree = "<group>"; };
-               A7F9F5CE141A5E500032F693 /* sequenceparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sequenceparser.cpp; sourceTree = "<group>"; };
-               A7FA10001302E096003860FE /* mantelcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mantelcommand.h; sourceTree = "<group>"; };
-               A7FA10011302E096003860FE /* mantelcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = mantelcommand.cpp; sourceTree = "<group>"; };
-               A7FA2ABC14A0E881007C09A6 /* bsplvb.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = bsplvb.f; sourceTree = "<group>"; };
-               A7FA2ABD14A0E881007C09A6 /* bsplvd.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = bsplvd.f; sourceTree = "<group>"; };
-               A7FA2ABE14A0E881007C09A6 /* bvalue.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = bvalue.f; sourceTree = "<group>"; };
-               A7FA2ABF14A0E881007C09A6 /* daxpy.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = daxpy.f; sourceTree = "<group>"; };
-               A7FA2AC014A0E881007C09A6 /* ddot.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = ddot.f; sourceTree = "<group>"; };
-               A7FA2AC114A0E881007C09A6 /* dpbfa.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = dpbfa.f; sourceTree = "<group>"; };
-               A7FA2AC214A0E881007C09A6 /* dpbsl.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = dpbsl.f; sourceTree = "<group>"; };
-               A7FA2AC314A0E881007C09A6 /* interv.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = interv.f; sourceTree = "<group>"; };
-               A7FA2AC414A0E881007C09A6 /* sgram.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = sgram.f; sourceTree = "<group>"; };
-               A7FA2AC514A0E881007C09A6 /* sinerp.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = sinerp.f; sourceTree = "<group>"; };
-               A7FA2AC614A0E881007C09A6 /* stxwx.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = stxwx.f; sourceTree = "<group>"; };
-               A7FA2B1514A0EBEA007C09A6 /* sslvrg.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = sslvrg.f; sourceTree = "<group>"; };
-               A7FA2B5A14A0F0C2007C09A6 /* intrv.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; path = intrv.f; sourceTree = "<group>"; };
-               A7FC480C12D788F20055BC5C /* linearalgebra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = linearalgebra.h; sourceTree = "<group>"; };
-               A7FC480D12D788F20055BC5C /* linearalgebra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = linearalgebra.cpp; sourceTree = "<group>"; };
-               A7FC486512D795D60055BC5C /* pcacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pcacommand.h; sourceTree = "<group>"; };
-               A7FC486612D795D60055BC5C /* pcacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = pcacommand.cpp; sourceTree = "<group>"; };
-               A7FE7C3E1330EA1000F7B327 /* getcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getcurrentcommand.h; sourceTree = "<group>"; };
-               A7FE7C3F1330EA1000F7B327 /* getcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = getcurrentcommand.cpp; sourceTree = "<group>"; };
-               A7FE7E6B13311EA400F7B327 /* setcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = setcurrentcommand.h; sourceTree = "<group>"; };
-               A7FE7E6C13311EA400F7B327 /* setcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = setcurrentcommand.cpp; sourceTree = "<group>"; };
-               A7FF19F0140FFDA500AD216D /* trimoligos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = trimoligos.h; sourceTree = "<group>"; };
-               A7FF19F1140FFDA500AD216D /* trimoligos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = trimoligos.cpp; sourceTree = "<group>"; };
-               A7FFB556142CA02C004884F2 /* summarytaxcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = summarytaxcommand.h; sourceTree = "<group>"; };
-               A7FFB557142CA02C004884F2 /* summarytaxcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = summarytaxcommand.cpp; sourceTree = "<group>"; };
+               A7A61F2B130062E000E05B6B /* amovacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = amovacommand.h; path = source/amovacommand.h; sourceTree = "<group>"; };
+               A7A61F2C130062E000E05B6B /* amovacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = amovacommand.cpp; path = source/amovacommand.cpp; sourceTree = "<group>"; };
+               A7AACFBA132FE008003D6C4D /* currentfile.h */ = {isa = PBXFileReference; fileEncoding = 4; name = currentfile.h; path = source/currentfile.h; sourceTree = "<group>"; };
+               A7BF221214587886000AD524 /* myPerseus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = myPerseus.cpp; path = source/myPerseus.cpp; sourceTree = "<group>"; };
+               A7BF221314587886000AD524 /* myPerseus.h */ = {isa = PBXFileReference; fileEncoding = 4; name = myPerseus.h; path = source/myPerseus.h; sourceTree = "<group>"; };
+               A7BF2230145879B2000AD524 /* chimeraperseuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraperseuscommand.h; path = source/chimeraperseuscommand.h; sourceTree = "<group>"; };
+               A7BF2231145879B2000AD524 /* chimeraperseuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraperseuscommand.cpp; path = source/chimeraperseuscommand.cpp; sourceTree = "<group>"; };
+               A7C3DC0914FE457500FE1924 /* cooccurrencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = cooccurrencecommand.cpp; path = source/cooccurrencecommand.cpp; sourceTree = "<group>"; };
+               A7C3DC0A14FE457500FE1924 /* cooccurrencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = cooccurrencecommand.h; path = source/cooccurrencecommand.h; sourceTree = "<group>"; };
+               A7C3DC0D14FE469500FE1924 /* trialSwap2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = trialSwap2.cpp; path = source/trialSwap2.cpp; sourceTree = "<group>"; };
+               A7C3DC0E14FE469500FE1924 /* trialswap2.h */ = {isa = PBXFileReference; fileEncoding = 4; name = trialswap2.h; path = source/trialswap2.h; sourceTree = "<group>"; };
+               A7D755D71535F665009BF21A /* treereader.h */ = {isa = PBXFileReference; fileEncoding = 4; name = treereader.h; path = source/treereader.h; sourceTree = "<group>"; };
+               A7D755D91535F679009BF21A /* treereader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = treereader.cpp; path = source/treereader.cpp; sourceTree = "<group>"; };
+               A7DAAFA3133A254E003956EB /* commandparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; name = commandparameter.h; path = source/commandparameter.h; sourceTree = "<group>"; };
+               A7E9B64F12D37EC300DA6239 /* ace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = ace.cpp; path = source/ace.cpp; sourceTree = "<group>"; };
+               A7E9B65012D37EC300DA6239 /* ace.h */ = {isa = PBXFileReference; fileEncoding = 4; name = ace.h; path = source/ace.h; sourceTree = "<group>"; };
+               A7E9B65112D37EC300DA6239 /* aligncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = aligncommand.cpp; path = source/aligncommand.cpp; sourceTree = "<group>"; };
+               A7E9B65212D37EC300DA6239 /* aligncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = aligncommand.h; path = source/aligncommand.h; sourceTree = "<group>"; };
+               A7E9B65312D37EC300DA6239 /* alignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = alignment.cpp; path = source/alignment.cpp; sourceTree = "<group>"; };
+               A7E9B65412D37EC300DA6239 /* alignment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = alignment.hpp; path = source/alignment.hpp; sourceTree = "<group>"; };
+               A7E9B65512D37EC300DA6239 /* alignmentcell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = alignmentcell.cpp; path = source/alignmentcell.cpp; sourceTree = "<group>"; };
+               A7E9B65612D37EC300DA6239 /* alignmentcell.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = alignmentcell.hpp; path = source/alignmentcell.hpp; sourceTree = "<group>"; };
+               A7E9B65712D37EC300DA6239 /* alignmentdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = alignmentdb.cpp; path = source/alignmentdb.cpp; sourceTree = "<group>"; };
+               A7E9B65812D37EC300DA6239 /* alignmentdb.h */ = {isa = PBXFileReference; fileEncoding = 4; name = alignmentdb.h; path = source/alignmentdb.h; sourceTree = "<group>"; };
+               A7E9B65912D37EC300DA6239 /* averagelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = averagelinkage.cpp; path = source/averagelinkage.cpp; sourceTree = "<group>"; };
+               A7E9B65A12D37EC300DA6239 /* bayesian.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bayesian.cpp; path = source/bayesian.cpp; sourceTree = "<group>"; };
+               A7E9B65B12D37EC300DA6239 /* bayesian.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bayesian.h; path = source/bayesian.h; sourceTree = "<group>"; };
+               A7E9B65C12D37EC300DA6239 /* bellerophon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bellerophon.cpp; path = source/bellerophon.cpp; sourceTree = "<group>"; };
+               A7E9B65D12D37EC300DA6239 /* bellerophon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bellerophon.h; path = source/bellerophon.h; sourceTree = "<group>"; };
+               A7E9B65E12D37EC300DA6239 /* bergerparker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = bergerparker.cpp; path = source/bergerparker.cpp; sourceTree = "<group>"; };
+               A7E9B65F12D37EC300DA6239 /* bergerparker.h */ = {isa = PBXFileReference; fileEncoding = 4; name = bergerparker.h; path = source/bergerparker.h; sourceTree = "<group>"; };
+               A7E9B66012D37EC300DA6239 /* binsequencecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = binsequencecommand.cpp; path = source/binsequencecommand.cpp; sourceTree = "<group>"; };
+               A7E9B66112D37EC300DA6239 /* binsequencecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = binsequencecommand.h; path = source/binsequencecommand.h; sourceTree = "<group>"; };
+               A7E9B66212D37EC300DA6239 /* blastalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = blastalign.cpp; path = source/blastalign.cpp; sourceTree = "<group>"; };
+               A7E9B66312D37EC400DA6239 /* blastalign.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = blastalign.hpp; path = source/blastalign.hpp; sourceTree = "<group>"; };
+               A7E9B66412D37EC400DA6239 /* blastdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = blastdb.cpp; path = source/blastdb.cpp; sourceTree = "<group>"; };
+               A7E9B66512D37EC400DA6239 /* blastdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = blastdb.hpp; path = source/blastdb.hpp; sourceTree = "<group>"; };
+               A7E9B66612D37EC400DA6239 /* boneh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = boneh.cpp; path = source/boneh.cpp; sourceTree = "<group>"; };
+               A7E9B66712D37EC400DA6239 /* boneh.h */ = {isa = PBXFileReference; fileEncoding = 4; name = boneh.h; path = source/boneh.h; sourceTree = "<group>"; };
+               A7E9B66812D37EC400DA6239 /* bootstrap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = bootstrap.cpp; path = source/bootstrap.cpp; sourceTree = "<group>"; };
+               A7E9B66912D37EC400DA6239 /* bootstrap.h */ = {isa = PBXFileReference; fileEncoding = 4; name = bootstrap.h; path = source/bootstrap.h; sourceTree = "<group>"; };
+               A7E9B66C12D37EC400DA6239 /* bstick.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = bstick.cpp; path = source/bstick.cpp; sourceTree = "<group>"; };
+               A7E9B66D12D37EC400DA6239 /* bstick.h */ = {isa = PBXFileReference; fileEncoding = 4; name = bstick.h; path = source/bstick.h; sourceTree = "<group>"; };
+               A7E9B66E12D37EC400DA6239 /* calculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = calculator.cpp; path = source/calculator.cpp; sourceTree = "<group>"; };
+               A7E9B66F12D37EC400DA6239 /* calculator.h */ = {isa = PBXFileReference; fileEncoding = 4; name = calculator.h; path = source/calculator.h; sourceTree = "<group>"; };
+               A7E9B67012D37EC400DA6239 /* canberra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = canberra.cpp; path = source/canberra.cpp; sourceTree = "<group>"; };
+               A7E9B67112D37EC400DA6239 /* canberra.h */ = {isa = PBXFileReference; fileEncoding = 4; name = canberra.h; path = source/canberra.h; sourceTree = "<group>"; };
+               A7E9B67212D37EC400DA6239 /* catchallcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = catchallcommand.cpp; path = source/catchallcommand.cpp; sourceTree = "<group>"; };
+               A7E9B67312D37EC400DA6239 /* catchallcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = catchallcommand.h; path = source/catchallcommand.h; sourceTree = "<group>"; };
+               A7E9B67412D37EC400DA6239 /* ccode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = ccode.cpp; path = source/ccode.cpp; sourceTree = "<group>"; };
+               A7E9B67512D37EC400DA6239 /* ccode.h */ = {isa = PBXFileReference; fileEncoding = 4; name = ccode.h; path = source/ccode.h; sourceTree = "<group>"; };
+               A7E9B67612D37EC400DA6239 /* chao1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chao1.cpp; path = source/chao1.cpp; sourceTree = "<group>"; };
+               A7E9B67712D37EC400DA6239 /* chao1.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chao1.h; path = source/chao1.h; sourceTree = "<group>"; };
+               A7E9B67812D37EC400DA6239 /* chimera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimera.cpp; path = source/chimera.cpp; sourceTree = "<group>"; };
+               A7E9B67912D37EC400DA6239 /* chimera.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimera.h; path = source/chimera.h; sourceTree = "<group>"; };
+               A7E9B67A12D37EC400DA6239 /* chimerabellerophoncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerabellerophoncommand.cpp; path = source/chimerabellerophoncommand.cpp; sourceTree = "<group>"; };
+               A7E9B67B12D37EC400DA6239 /* chimerabellerophoncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerabellerophoncommand.h; path = source/chimerabellerophoncommand.h; sourceTree = "<group>"; };
+               A7E9B67C12D37EC400DA6239 /* chimeraccodecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraccodecommand.cpp; path = source/chimeraccodecommand.cpp; sourceTree = "<group>"; };
+               A7E9B67D12D37EC400DA6239 /* chimeraccodecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraccodecommand.h; path = source/chimeraccodecommand.h; sourceTree = "<group>"; };
+               A7E9B67E12D37EC400DA6239 /* chimeracheckcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeracheckcommand.cpp; path = source/chimeracheckcommand.cpp; sourceTree = "<group>"; };
+               A7E9B67F12D37EC400DA6239 /* chimeracheckcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeracheckcommand.h; path = source/chimeracheckcommand.h; sourceTree = "<group>"; };
+               A7E9B68012D37EC400DA6239 /* chimeracheckrdp.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeracheckrdp.cpp; path = source/chimeracheckrdp.cpp; sourceTree = "<group>"; };
+               A7E9B68112D37EC400DA6239 /* chimeracheckrdp.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeracheckrdp.h; path = source/chimeracheckrdp.h; sourceTree = "<group>"; };
+               A7E9B68212D37EC400DA6239 /* chimerapintailcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerapintailcommand.cpp; path = source/chimerapintailcommand.cpp; sourceTree = "<group>"; };
+               A7E9B68312D37EC400DA6239 /* chimerapintailcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerapintailcommand.h; path = source/chimerapintailcommand.h; sourceTree = "<group>"; };
+               A7E9B68412D37EC400DA6239 /* chimerarealigner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerarealigner.cpp; path = source/chimerarealigner.cpp; sourceTree = "<group>"; };
+               A7E9B68512D37EC400DA6239 /* chimerarealigner.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimerarealigner.h; path = source/chimerarealigner.h; sourceTree = "<group>"; };
+               A7E9B68812D37EC400DA6239 /* chimeraslayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraslayer.cpp; path = source/chimeraslayer.cpp; sourceTree = "<group>"; };
+               A7E9B68912D37EC400DA6239 /* chimeraslayer.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraslayer.h; path = source/chimeraslayer.h; sourceTree = "<group>"; };
+               A7E9B68A12D37EC400DA6239 /* chimeraslayercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraslayercommand.cpp; path = source/chimeraslayercommand.cpp; sourceTree = "<group>"; };
+               A7E9B68B12D37EC400DA6239 /* chimeraslayercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chimeraslayercommand.h; path = source/chimeraslayercommand.h; sourceTree = "<group>"; };
+               A7E9B68C12D37EC400DA6239 /* chopseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = chopseqscommand.cpp; path = source/chopseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B68D12D37EC400DA6239 /* chopseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = chopseqscommand.h; path = source/chopseqscommand.h; sourceTree = "<group>"; };
+               A7E9B68E12D37EC400DA6239 /* classify.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = classify.cpp; path = source/classify.cpp; sourceTree = "<group>"; };
+               A7E9B68F12D37EC400DA6239 /* classify.h */ = {isa = PBXFileReference; fileEncoding = 4; name = classify.h; path = source/classify.h; sourceTree = "<group>"; };
+               A7E9B69012D37EC400DA6239 /* classifyotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = classifyotucommand.cpp; path = source/classifyotucommand.cpp; sourceTree = "<group>"; };
+               A7E9B69112D37EC400DA6239 /* classifyotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = classifyotucommand.h; path = source/classifyotucommand.h; sourceTree = "<group>"; };
+               A7E9B69212D37EC400DA6239 /* classifyseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = classifyseqscommand.cpp; path = source/classifyseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B69312D37EC400DA6239 /* classifyseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = classifyseqscommand.h; path = source/classifyseqscommand.h; sourceTree = "<group>"; };
+               A7E9B69412D37EC400DA6239 /* clearcut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = clearcut.cpp; path = source/clearcut.cpp; sourceTree = "<group>"; };
+               A7E9B69512D37EC400DA6239 /* clearcut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = clearcut.h; path = source/clearcut.h; sourceTree = "<group>"; };
+               A7E9B69612D37EC400DA6239 /* clearcutcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clearcutcommand.cpp; path = source/clearcutcommand.cpp; sourceTree = "<group>"; };
+               A7E9B69712D37EC400DA6239 /* clearcutcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clearcutcommand.h; path = source/clearcutcommand.h; sourceTree = "<group>"; };
+               A7E9B69812D37EC400DA6239 /* cluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = cluster.cpp; path = source/cluster.cpp; sourceTree = "<group>"; };
+               A7E9B69912D37EC400DA6239 /* cluster.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = cluster.hpp; path = source/cluster.hpp; sourceTree = "<group>"; };
+               A7E9B69A12D37EC400DA6239 /* clusterclassic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterclassic.cpp; path = source/clusterclassic.cpp; sourceTree = "<group>"; };
+               A7E9B69B12D37EC400DA6239 /* clusterclassic.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterclassic.h; path = source/clusterclassic.h; sourceTree = "<group>"; };
+               A7E9B69C12D37EC400DA6239 /* clustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clustercommand.cpp; path = source/clustercommand.cpp; sourceTree = "<group>"; };
+               A7E9B69D12D37EC400DA6239 /* clustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clustercommand.h; path = source/clustercommand.h; sourceTree = "<group>"; };
+               A7E9B69E12D37EC400DA6239 /* clusterdoturcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterdoturcommand.cpp; path = source/clusterdoturcommand.cpp; sourceTree = "<group>"; };
+               A7E9B69F12D37EC400DA6239 /* clusterdoturcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterdoturcommand.h; path = source/clusterdoturcommand.h; sourceTree = "<group>"; };
+               A7E9B6A012D37EC400DA6239 /* clusterfragmentscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterfragmentscommand.cpp; path = source/clusterfragmentscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6A112D37EC400DA6239 /* clusterfragmentscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clusterfragmentscommand.h; path = source/clusterfragmentscommand.h; sourceTree = "<group>"; };
+               A7E9B6A212D37EC400DA6239 /* clustersplitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = clustersplitcommand.cpp; path = source/clustersplitcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6A312D37EC400DA6239 /* clustersplitcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = clustersplitcommand.h; path = source/clustersplitcommand.h; sourceTree = "<group>"; };
+               A7E9B6A412D37EC400DA6239 /* cmdargs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = cmdargs.cpp; path = source/cmdargs.cpp; sourceTree = "<group>"; };
+               A7E9B6A512D37EC400DA6239 /* cmdargs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = cmdargs.h; path = source/cmdargs.h; sourceTree = "<group>"; };
+               A7E9B6A612D37EC400DA6239 /* collect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = collect.cpp; path = source/collect.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6A712D37EC400DA6239 /* collect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = collect.h; path = source/collect.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6A812D37EC400DA6239 /* collectcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = collectcommand.cpp; path = source/collectcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6A912D37EC400DA6239 /* collectcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = collectcommand.h; path = source/collectcommand.h; sourceTree = "<group>"; };
+               A7E9B6AA12D37EC400DA6239 /* collectdisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; name = collectdisplay.h; path = source/collectdisplay.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6AB12D37EC400DA6239 /* collectorscurvedata.h */ = {isa = PBXFileReference; fileEncoding = 4; name = collectorscurvedata.h; path = source/collectorscurvedata.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6AC12D37EC400DA6239 /* collectsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = collectsharedcommand.cpp; path = source/collectsharedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6AD12D37EC400DA6239 /* collectsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = collectsharedcommand.h; path = source/collectsharedcommand.h; sourceTree = "<group>"; };
+               A7E9B6AE12D37EC400DA6239 /* command.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = command.hpp; path = source/command.hpp; sourceTree = "<group>"; };
+               A7E9B6AF12D37EC400DA6239 /* commandfactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = commandfactory.cpp; path = source/commandfactory.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6B012D37EC400DA6239 /* commandfactory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = commandfactory.hpp; path = source/commandfactory.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6B112D37EC400DA6239 /* commandoptionparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = commandoptionparser.cpp; path = source/commandoptionparser.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6B212D37EC400DA6239 /* commandoptionparser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = commandoptionparser.hpp; path = source/commandoptionparser.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6B312D37EC400DA6239 /* common.h */ = {isa = PBXFileReference; fileEncoding = 4; name = common.h; path = source/common.h; sourceTree = "<group>"; };
+               A7E9B6B412D37EC400DA6239 /* completelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = completelinkage.cpp; path = source/completelinkage.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6B512D37EC400DA6239 /* consensus.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = consensus.cpp; path = source/consensus.cpp; sourceTree = "<group>"; };
+               A7E9B6B612D37EC400DA6239 /* consensus.h */ = {isa = PBXFileReference; fileEncoding = 4; name = consensus.h; path = source/consensus.h; sourceTree = "<group>"; };
+               A7E9B6B712D37EC400DA6239 /* consensusseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = consensusseqscommand.cpp; path = source/consensusseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6B812D37EC400DA6239 /* consensusseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = consensusseqscommand.h; path = source/consensusseqscommand.h; sourceTree = "<group>"; };
+               A7E9B6B912D37EC400DA6239 /* corraxescommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = corraxescommand.cpp; path = source/corraxescommand.cpp; sourceTree = "<group>"; };
+               A7E9B6BA12D37EC400DA6239 /* corraxescommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = corraxescommand.h; path = source/corraxescommand.h; sourceTree = "<group>"; };
+               A7E9B6BB12D37EC400DA6239 /* coverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = coverage.cpp; path = source/coverage.cpp; sourceTree = "<group>"; };
+               A7E9B6BC12D37EC400DA6239 /* coverage.h */ = {isa = PBXFileReference; fileEncoding = 4; name = coverage.h; path = source/coverage.h; sourceTree = "<group>"; };
+               A7E9B6BD12D37EC400DA6239 /* database.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = database.cpp; path = source/database.cpp; sourceTree = "<group>"; };
+               A7E9B6BE12D37EC400DA6239 /* database.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = database.hpp; path = source/database.hpp; sourceTree = "<group>"; };
+               A7E9B6BF12D37EC400DA6239 /* datavector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = datavector.hpp; path = source/datavector.hpp; sourceTree = "<group>"; };
+               A7E9B6C012D37EC400DA6239 /* dayhoff.h */ = {isa = PBXFileReference; fileEncoding = 4; name = dayhoff.h; path = source/dayhoff.h; sourceTree = "<group>"; };
+               A7E9B6C112D37EC400DA6239 /* decalc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = decalc.cpp; path = source/decalc.cpp; sourceTree = "<group>"; };
+               A7E9B6C212D37EC400DA6239 /* decalc.h */ = {isa = PBXFileReference; fileEncoding = 4; name = decalc.h; path = source/decalc.h; sourceTree = "<group>"; };
+               A7E9B6C312D37EC400DA6239 /* deconvolutecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = deconvolutecommand.cpp; path = source/deconvolutecommand.cpp; sourceTree = "<group>"; };
+               A7E9B6C412D37EC400DA6239 /* deconvolutecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = deconvolutecommand.h; path = source/deconvolutecommand.h; sourceTree = "<group>"; };
+               A7E9B6C512D37EC400DA6239 /* degapseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = degapseqscommand.cpp; path = source/degapseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6C612D37EC400DA6239 /* degapseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = degapseqscommand.h; path = source/degapseqscommand.h; sourceTree = "<group>"; };
+               A7E9B6C712D37EC400DA6239 /* deuniqueseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = deuniqueseqscommand.cpp; path = source/deuniqueseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6C812D37EC400DA6239 /* deuniqueseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = deuniqueseqscommand.h; path = source/deuniqueseqscommand.h; sourceTree = "<group>"; };
+               A7E9B6C912D37EC400DA6239 /* display.h */ = {isa = PBXFileReference; fileEncoding = 4; name = display.h; path = source/display.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6CA12D37EC400DA6239 /* dist.h */ = {isa = PBXFileReference; fileEncoding = 4; name = dist.h; path = source/dist.h; sourceTree = "<group>"; };
+               A7E9B6CB12D37EC400DA6239 /* distancecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = distancecommand.cpp; path = source/distancecommand.cpp; sourceTree = "<group>"; };
+               A7E9B6CC12D37EC400DA6239 /* distancecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = distancecommand.h; path = source/distancecommand.h; sourceTree = "<group>"; };
+               A7E9B6CD12D37EC400DA6239 /* distancedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = distancedb.cpp; path = source/distancedb.cpp; sourceTree = "<group>"; };
+               A7E9B6CE12D37EC400DA6239 /* distancedb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = distancedb.hpp; path = source/distancedb.hpp; sourceTree = "<group>"; };
+               A7E9B6CF12D37EC400DA6239 /* distclearcut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = distclearcut.cpp; path = source/distclearcut.cpp; sourceTree = "<group>"; };
+               A7E9B6D012D37EC400DA6239 /* distclearcut.h */ = {isa = PBXFileReference; fileEncoding = 4; name = distclearcut.h; path = source/distclearcut.h; sourceTree = "<group>"; };
+               A7E9B6D112D37EC400DA6239 /* dlibshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = dlibshuff.cpp; path = source/dlibshuff.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6D212D37EC400DA6239 /* dlibshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; name = dlibshuff.h; path = source/dlibshuff.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6D312D37EC400DA6239 /* dmat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = dmat.cpp; path = source/dmat.cpp; sourceTree = "<group>"; };
+               A7E9B6D412D37EC400DA6239 /* dmat.h */ = {isa = PBXFileReference; fileEncoding = 4; name = dmat.h; path = source/dmat.h; sourceTree = "<group>"; };
+               A7E9B6D512D37EC400DA6239 /* eachgapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; name = eachgapdist.h; path = source/eachgapdist.h; sourceTree = "<group>"; };
+               A7E9B6D612D37EC400DA6239 /* eachgapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; name = eachgapignore.h; path = source/eachgapignore.h; sourceTree = "<group>"; };
+               A7E9B6D712D37EC400DA6239 /* efron.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = efron.cpp; path = source/efron.cpp; sourceTree = "<group>"; };
+               A7E9B6D812D37EC400DA6239 /* efron.h */ = {isa = PBXFileReference; fileEncoding = 4; name = efron.h; path = source/efron.h; sourceTree = "<group>"; };
+               A7E9B6D912D37EC400DA6239 /* endiannessmacros.h */ = {isa = PBXFileReference; fileEncoding = 4; name = endiannessmacros.h; path = source/endiannessmacros.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6DA12D37EC400DA6239 /* engine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = engine.cpp; path = source/engine.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6DB12D37EC400DA6239 /* engine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = engine.hpp; path = source/engine.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6DC12D37EC400DA6239 /* fasta.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = fasta.cpp; path = source/fasta.cpp; sourceTree = "<group>"; };
+               A7E9B6DD12D37EC400DA6239 /* fasta.h */ = {isa = PBXFileReference; fileEncoding = 4; name = fasta.h; path = source/fasta.h; sourceTree = "<group>"; };
+               A7E9B6DE12D37EC400DA6239 /* fastamap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = fastamap.cpp; path = source/fastamap.cpp; sourceTree = "<group>"; };
+               A7E9B6DF12D37EC400DA6239 /* fastamap.h */ = {isa = PBXFileReference; fileEncoding = 4; name = fastamap.h; path = source/fastamap.h; sourceTree = "<group>"; };
+               A7E9B6E012D37EC400DA6239 /* fileoutput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = fileoutput.cpp; path = source/fileoutput.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B6E112D37EC400DA6239 /* fileoutput.h */ = {isa = PBXFileReference; fileEncoding = 4; name = fileoutput.h; path = source/fileoutput.h; sourceTree = SOURCE_ROOT; };
+               A7E9B6E212D37EC400DA6239 /* filters.h */ = {isa = PBXFileReference; fileEncoding = 4; name = filters.h; path = source/filters.h; sourceTree = "<group>"; };
+               A7E9B6E312D37EC400DA6239 /* filterseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = filterseqscommand.cpp; path = source/filterseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6E412D37EC400DA6239 /* filterseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = filterseqscommand.h; path = source/filterseqscommand.h; sourceTree = "<group>"; };
+               A7E9B6E712D37EC400DA6239 /* flowdata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = flowdata.cpp; path = source/flowdata.cpp; sourceTree = "<group>"; };
+               A7E9B6E812D37EC400DA6239 /* flowdata.h */ = {isa = PBXFileReference; fileEncoding = 4; name = flowdata.h; path = source/flowdata.h; sourceTree = "<group>"; };
+               A7E9B6E912D37EC400DA6239 /* formatcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = formatcolumn.cpp; path = source/formatcolumn.cpp; sourceTree = "<group>"; };
+               A7E9B6EA12D37EC400DA6239 /* formatcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = formatcolumn.h; path = source/formatcolumn.h; sourceTree = "<group>"; };
+               A7E9B6EB12D37EC400DA6239 /* formatmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; name = formatmatrix.h; path = source/formatmatrix.h; sourceTree = "<group>"; };
+               A7E9B6EC12D37EC400DA6239 /* formatphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = formatphylip.cpp; path = source/formatphylip.cpp; sourceTree = "<group>"; };
+               A7E9B6ED12D37EC400DA6239 /* formatphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; name = formatphylip.h; path = source/formatphylip.h; sourceTree = "<group>"; };
+               A7E9B6EE12D37EC400DA6239 /* fullmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = fullmatrix.cpp; path = source/fullmatrix.cpp; sourceTree = "<group>"; };
+               A7E9B6EF12D37EC400DA6239 /* fullmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; name = fullmatrix.h; path = source/fullmatrix.h; sourceTree = "<group>"; };
+               A7E9B6F012D37EC400DA6239 /* geom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = geom.cpp; path = source/geom.cpp; sourceTree = "<group>"; };
+               A7E9B6F112D37EC400DA6239 /* geom.h */ = {isa = PBXFileReference; fileEncoding = 4; name = geom.h; path = source/geom.h; sourceTree = "<group>"; };
+               A7E9B6F212D37EC400DA6239 /* getgroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getgroupcommand.cpp; path = source/getgroupcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6F312D37EC400DA6239 /* getgroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getgroupcommand.h; path = source/getgroupcommand.h; sourceTree = "<group>"; };
+               A7E9B6F412D37EC400DA6239 /* getgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getgroupscommand.cpp; path = source/getgroupscommand.cpp; sourceTree = "<group>"; };
+               A7E9B6F512D37EC400DA6239 /* getgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getgroupscommand.h; path = source/getgroupscommand.h; sourceTree = "<group>"; };
+               A7E9B6F612D37EC400DA6239 /* getlabelcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getlabelcommand.cpp; path = source/getlabelcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6F712D37EC400DA6239 /* getlabelcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getlabelcommand.h; path = source/getlabelcommand.h; sourceTree = "<group>"; };
+               A7E9B6F812D37EC400DA6239 /* getlineagecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getlineagecommand.cpp; path = source/getlineagecommand.cpp; sourceTree = "<group>"; };
+               A7E9B6F912D37EC400DA6239 /* getlineagecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getlineagecommand.h; path = source/getlineagecommand.h; sourceTree = "<group>"; };
+               A7E9B6FA12D37EC400DA6239 /* getlistcountcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getlistcountcommand.cpp; path = source/getlistcountcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6FB12D37EC400DA6239 /* getlistcountcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getlistcountcommand.h; path = source/getlistcountcommand.h; sourceTree = "<group>"; };
+               A7E9B6FC12D37EC400DA6239 /* getopt_long.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getopt_long.cpp; path = source/getopt_long.cpp; sourceTree = "<group>"; };
+               A7E9B6FD12D37EC400DA6239 /* getopt_long.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getopt_long.h; path = source/getopt_long.h; sourceTree = "<group>"; };
+               A7E9B6FE12D37EC400DA6239 /* getoturepcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getoturepcommand.cpp; path = source/getoturepcommand.cpp; sourceTree = "<group>"; };
+               A7E9B6FF12D37EC400DA6239 /* getoturepcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getoturepcommand.h; path = source/getoturepcommand.h; sourceTree = "<group>"; };
+               A7E9B70012D37EC400DA6239 /* getotuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getotuscommand.cpp; path = source/getotuscommand.cpp; sourceTree = "<group>"; };
+               A7E9B70112D37EC400DA6239 /* getotuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getotuscommand.h; path = source/getotuscommand.h; sourceTree = "<group>"; };
+               A7E9B70212D37EC400DA6239 /* getrabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getrabundcommand.cpp; path = source/getrabundcommand.cpp; sourceTree = "<group>"; };
+               A7E9B70312D37EC400DA6239 /* getrabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getrabundcommand.h; path = source/getrabundcommand.h; sourceTree = "<group>"; };
+               A7E9B70412D37EC400DA6239 /* getrelabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getrelabundcommand.cpp; path = source/getrelabundcommand.cpp; sourceTree = "<group>"; };
+               A7E9B70512D37EC400DA6239 /* getrelabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getrelabundcommand.h; path = source/getrelabundcommand.h; sourceTree = "<group>"; };
+               A7E9B70612D37EC400DA6239 /* getsabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getsabundcommand.cpp; path = source/getsabundcommand.cpp; sourceTree = "<group>"; };
+               A7E9B70712D37EC400DA6239 /* getsabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getsabundcommand.h; path = source/getsabundcommand.h; sourceTree = "<group>"; };
+               A7E9B70812D37EC400DA6239 /* getseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getseqscommand.cpp; path = source/getseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B70912D37EC400DA6239 /* getseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getseqscommand.h; path = source/getseqscommand.h; sourceTree = "<group>"; };
+               A7E9B70A12D37EC400DA6239 /* getsharedotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getsharedotucommand.cpp; path = source/getsharedotucommand.cpp; sourceTree = "<group>"; };
+               A7E9B70B12D37EC400DA6239 /* getsharedotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getsharedotucommand.h; path = source/getsharedotucommand.h; sourceTree = "<group>"; };
+               A7E9B70E12D37EC400DA6239 /* goodscoverage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = goodscoverage.cpp; path = source/goodscoverage.cpp; sourceTree = "<group>"; };
+               A7E9B70F12D37EC400DA6239 /* goodscoverage.h */ = {isa = PBXFileReference; fileEncoding = 4; name = goodscoverage.h; path = source/goodscoverage.h; sourceTree = "<group>"; };
+               A7E9B71012D37EC400DA6239 /* gotohoverlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = gotohoverlap.cpp; path = source/gotohoverlap.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B71112D37EC400DA6239 /* gotohoverlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = gotohoverlap.hpp; path = source/gotohoverlap.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B71212D37EC400DA6239 /* gower.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = gower.cpp; path = source/gower.cpp; sourceTree = "<group>"; };
+               A7E9B71312D37EC400DA6239 /* gower.h */ = {isa = PBXFileReference; fileEncoding = 4; name = gower.h; path = source/gower.h; sourceTree = "<group>"; };
+               A7E9B71412D37EC400DA6239 /* groupmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = groupmap.cpp; path = source/groupmap.cpp; sourceTree = "<group>"; };
+               A7E9B71512D37EC400DA6239 /* groupmap.h */ = {isa = PBXFileReference; fileEncoding = 4; name = groupmap.h; path = source/groupmap.h; sourceTree = "<group>"; };
+               A7E9B71612D37EC400DA6239 /* hamming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = hamming.cpp; path = source/hamming.cpp; sourceTree = "<group>"; };
+               A7E9B71712D37EC400DA6239 /* hamming.h */ = {isa = PBXFileReference; fileEncoding = 4; name = hamming.h; path = source/hamming.h; sourceTree = "<group>"; };
+               A7E9B71812D37EC400DA6239 /* hcluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = hcluster.cpp; path = source/hcluster.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B71912D37EC400DA6239 /* hcluster.h */ = {isa = PBXFileReference; fileEncoding = 4; name = hcluster.h; path = source/hcluster.h; sourceTree = SOURCE_ROOT; };
+               A7E9B71A12D37EC400DA6239 /* hclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = hclustercommand.cpp; path = source/hclustercommand.cpp; sourceTree = "<group>"; };
+               A7E9B71B12D37EC400DA6239 /* hclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = hclustercommand.h; path = source/hclustercommand.h; sourceTree = "<group>"; };
+               A7E9B71C12D37EC400DA6239 /* heatmap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmap.cpp; path = source/heatmap.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B71D12D37EC400DA6239 /* heatmap.h */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmap.h; path = source/heatmap.h; sourceTree = SOURCE_ROOT; };
+               A7E9B71E12D37EC400DA6239 /* heatmapcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapcommand.cpp; path = source/heatmapcommand.cpp; sourceTree = "<group>"; };
+               A7E9B71F12D37EC400DA6239 /* heatmapcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapcommand.h; path = source/heatmapcommand.h; sourceTree = "<group>"; };
+               A7E9B72012D37EC400DA6239 /* heatmapsim.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapsim.cpp; path = source/heatmapsim.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B72112D37EC400DA6239 /* heatmapsim.h */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapsim.h; path = source/heatmapsim.h; sourceTree = SOURCE_ROOT; };
+               A7E9B72212D37EC400DA6239 /* heatmapsimcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapsimcommand.cpp; path = source/heatmapsimcommand.cpp; sourceTree = "<group>"; };
+               A7E9B72312D37EC400DA6239 /* heatmapsimcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = heatmapsimcommand.h; path = source/heatmapsimcommand.h; sourceTree = "<group>"; };
+               A7E9B72412D37EC400DA6239 /* heip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = heip.cpp; path = source/heip.cpp; sourceTree = "<group>"; };
+               A7E9B72512D37EC400DA6239 /* heip.h */ = {isa = PBXFileReference; fileEncoding = 4; name = heip.h; path = source/heip.h; sourceTree = "<group>"; };
+               A7E9B72612D37EC400DA6239 /* hellinger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = hellinger.cpp; path = source/hellinger.cpp; sourceTree = "<group>"; };
+               A7E9B72712D37EC400DA6239 /* hellinger.h */ = {isa = PBXFileReference; fileEncoding = 4; name = hellinger.h; path = source/hellinger.h; sourceTree = "<group>"; };
+               A7E9B72812D37EC400DA6239 /* helpcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = helpcommand.cpp; path = source/helpcommand.cpp; sourceTree = "<group>"; };
+               A7E9B72912D37EC400DA6239 /* helpcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = helpcommand.h; path = source/helpcommand.h; sourceTree = "<group>"; };
+               A7E9B72A12D37EC400DA6239 /* ignoregaps.h */ = {isa = PBXFileReference; fileEncoding = 4; name = ignoregaps.h; path = source/ignoregaps.h; sourceTree = "<group>"; };
+               A7E9B72B12D37EC400DA6239 /* indicatorcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = indicatorcommand.cpp; path = source/indicatorcommand.cpp; sourceTree = "<group>"; };
+               A7E9B72C12D37EC400DA6239 /* indicatorcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = indicatorcommand.h; path = source/indicatorcommand.h; sourceTree = "<group>"; };
+               A7E9B72D12D37EC400DA6239 /* inputdata.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = inputdata.cpp; path = source/inputdata.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B72E12D37EC400DA6239 /* inputdata.h */ = {isa = PBXFileReference; fileEncoding = 4; name = inputdata.h; path = source/inputdata.h; sourceTree = SOURCE_ROOT; };
+               A7E9B72F12D37EC400DA6239 /* invsimpson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = invsimpson.cpp; path = source/invsimpson.cpp; sourceTree = "<group>"; };
+               A7E9B73012D37EC400DA6239 /* invsimpson.h */ = {isa = PBXFileReference; fileEncoding = 4; name = invsimpson.h; path = source/invsimpson.h; sourceTree = "<group>"; };
+               A7E9B73112D37EC400DA6239 /* jackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = jackknife.cpp; path = source/jackknife.cpp; sourceTree = "<group>"; };
+               A7E9B73212D37EC400DA6239 /* jackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; name = jackknife.h; path = source/jackknife.h; sourceTree = "<group>"; };
+               A7E9B73312D37EC400DA6239 /* kmer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = kmer.cpp; path = source/kmer.cpp; sourceTree = "<group>"; };
+               A7E9B73412D37EC400DA6239 /* kmer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = kmer.hpp; path = source/kmer.hpp; sourceTree = "<group>"; };
+               A7E9B73512D37EC400DA6239 /* kmerdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = kmerdb.cpp; path = source/kmerdb.cpp; sourceTree = "<group>"; };
+               A7E9B73612D37EC400DA6239 /* kmerdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = kmerdb.hpp; path = source/kmerdb.hpp; sourceTree = "<group>"; };
+               A7E9B73712D37EC400DA6239 /* knn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = knn.cpp; path = source/knn.cpp; sourceTree = "<group>"; };
+               A7E9B73812D37EC400DA6239 /* knn.h */ = {isa = PBXFileReference; fileEncoding = 4; name = knn.h; path = source/knn.h; sourceTree = "<group>"; };
+               A7E9B73912D37EC400DA6239 /* libshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = libshuff.cpp; path = source/libshuff.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B73A12D37EC400DA6239 /* libshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; name = libshuff.h; path = source/libshuff.h; sourceTree = SOURCE_ROOT; };
+               A7E9B73B12D37EC400DA6239 /* libshuffcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = libshuffcommand.cpp; path = source/libshuffcommand.cpp; sourceTree = "<group>"; };
+               A7E9B73C12D37EC400DA6239 /* libshuffcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = libshuffcommand.h; path = source/libshuffcommand.h; sourceTree = "<group>"; };
+               A7E9B73D12D37EC400DA6239 /* listseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = listseqscommand.cpp; path = source/listseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B73E12D37EC400DA6239 /* listseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = listseqscommand.h; path = source/listseqscommand.h; sourceTree = "<group>"; };
+               A7E9B73F12D37EC400DA6239 /* listvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = listvector.cpp; path = source/listvector.cpp; sourceTree = "<group>"; };
+               A7E9B74012D37EC400DA6239 /* listvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = listvector.hpp; path = source/listvector.hpp; sourceTree = "<group>"; };
+               A7E9B74112D37EC400DA6239 /* logsd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = logsd.cpp; path = source/logsd.cpp; sourceTree = "<group>"; };
+               A7E9B74212D37EC400DA6239 /* logsd.h */ = {isa = PBXFileReference; fileEncoding = 4; name = logsd.h; path = source/logsd.h; sourceTree = "<group>"; };
+               A7E9B74312D37EC400DA6239 /* makegroupcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = makegroupcommand.cpp; path = source/makegroupcommand.cpp; sourceTree = "<group>"; };
+               A7E9B74412D37EC400DA6239 /* makegroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = makegroupcommand.h; path = source/makegroupcommand.h; sourceTree = "<group>"; };
+               A7E9B74512D37EC400DA6239 /* maligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = maligner.cpp; path = source/maligner.cpp; sourceTree = "<group>"; };
+               A7E9B74612D37EC400DA6239 /* maligner.h */ = {isa = PBXFileReference; fileEncoding = 4; name = maligner.h; path = source/maligner.h; sourceTree = "<group>"; };
+               A7E9B74712D37EC400DA6239 /* manhattan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = manhattan.cpp; path = source/manhattan.cpp; sourceTree = "<group>"; };
+               A7E9B74812D37EC400DA6239 /* manhattan.h */ = {isa = PBXFileReference; fileEncoding = 4; name = manhattan.h; path = source/manhattan.h; sourceTree = "<group>"; };
+               A7E9B74912D37EC400DA6239 /* matrixoutputcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = matrixoutputcommand.cpp; path = source/matrixoutputcommand.cpp; sourceTree = "<group>"; };
+               A7E9B74A12D37EC400DA6239 /* matrixoutputcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = matrixoutputcommand.h; path = source/matrixoutputcommand.h; sourceTree = "<group>"; };
+               A7E9B74B12D37EC400DA6239 /* memchi2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = memchi2.cpp; path = source/memchi2.cpp; sourceTree = "<group>"; };
+               A7E9B74C12D37EC400DA6239 /* memchi2.h */ = {isa = PBXFileReference; fileEncoding = 4; name = memchi2.h; path = source/memchi2.h; sourceTree = "<group>"; };
+               A7E9B74D12D37EC400DA6239 /* memchord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = memchord.cpp; path = source/memchord.cpp; sourceTree = "<group>"; };
+               A7E9B74E12D37EC400DA6239 /* memchord.h */ = {isa = PBXFileReference; fileEncoding = 4; name = memchord.h; path = source/memchord.h; sourceTree = "<group>"; };
+               A7E9B74F12D37EC400DA6239 /* memeuclidean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = memeuclidean.cpp; path = source/memeuclidean.cpp; sourceTree = "<group>"; };
+               A7E9B75012D37EC400DA6239 /* memeuclidean.h */ = {isa = PBXFileReference; fileEncoding = 4; name = memeuclidean.h; path = source/memeuclidean.h; sourceTree = "<group>"; };
+               A7E9B75112D37EC400DA6239 /* mempearson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mempearson.cpp; path = source/mempearson.cpp; sourceTree = "<group>"; };
+               A7E9B75212D37EC400DA6239 /* mempearson.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mempearson.h; path = source/mempearson.h; sourceTree = "<group>"; };
+               A7E9B75312D37EC400DA6239 /* mergefilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mergefilecommand.cpp; path = source/mergefilecommand.cpp; sourceTree = "<group>"; };
+               A7E9B75412D37EC400DA6239 /* mergefilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mergefilecommand.h; path = source/mergefilecommand.h; sourceTree = "<group>"; };
+               A7E9B75712D37EC400DA6239 /* metastatscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = metastatscommand.cpp; path = source/metastatscommand.cpp; sourceTree = "<group>"; };
+               A7E9B75812D37EC400DA6239 /* metastatscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = metastatscommand.h; path = source/metastatscommand.h; sourceTree = "<group>"; };
+               A7E9B75912D37EC400DA6239 /* mgclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mgclustercommand.cpp; path = source/mgclustercommand.cpp; sourceTree = "<group>"; };
+               A7E9B75A12D37EC400DA6239 /* mgclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mgclustercommand.h; path = source/mgclustercommand.h; sourceTree = "<group>"; };
+               A7E9B75B12D37EC400DA6239 /* mothur.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mothur.cpp; path = source/mothur.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B75C12D37EC400DA6239 /* mothur.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mothur.h; path = source/mothur.h; sourceTree = SOURCE_ROOT; };
+               A7E9B75D12D37EC400DA6239 /* mothurout.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mothurout.cpp; path = source/mothurout.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B75E12D37EC400DA6239 /* mothurout.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mothurout.h; path = source/mothurout.h; sourceTree = SOURCE_ROOT; };
+               A7E9B75F12D37EC400DA6239 /* nameassignment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nameassignment.cpp; path = source/nameassignment.cpp; sourceTree = "<group>"; };
+               A7E9B76012D37EC400DA6239 /* nameassignment.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nameassignment.hpp; path = source/nameassignment.hpp; sourceTree = "<group>"; };
+               A7E9B76112D37EC400DA6239 /* nast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nast.cpp; path = source/nast.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76212D37EC400DA6239 /* nast.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nast.hpp; path = source/nast.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76312D37EC400DA6239 /* nastreport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nastreport.cpp; path = source/nastreport.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76412D37EC400DA6239 /* nastreport.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nastreport.hpp; path = source/nastreport.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76512D37EC400DA6239 /* needlemanoverlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = needlemanoverlap.cpp; path = source/needlemanoverlap.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76612D37EC400DA6239 /* needlemanoverlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = needlemanoverlap.hpp; path = source/needlemanoverlap.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76712D37EC400DA6239 /* noalign.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = noalign.cpp; path = source/noalign.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76812D37EC400DA6239 /* noalign.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = noalign.hpp; path = source/noalign.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B76912D37EC400DA6239 /* nocommands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = nocommands.cpp; path = source/nocommands.cpp; sourceTree = "<group>"; };
+               A7E9B76A12D37EC400DA6239 /* nocommands.h */ = {isa = PBXFileReference; fileEncoding = 4; name = nocommands.h; path = source/nocommands.h; sourceTree = "<group>"; };
+               A7E9B76B12D37EC400DA6239 /* normalizesharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = normalizesharedcommand.cpp; path = source/normalizesharedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B76C12D37EC400DA6239 /* normalizesharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = normalizesharedcommand.h; path = source/normalizesharedcommand.h; sourceTree = "<group>"; };
+               A7E9B76D12D37EC400DA6239 /* npshannon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = npshannon.cpp; path = source/npshannon.cpp; sourceTree = "<group>"; };
+               A7E9B76E12D37EC400DA6239 /* npshannon.h */ = {isa = PBXFileReference; fileEncoding = 4; name = npshannon.h; path = source/npshannon.h; sourceTree = "<group>"; };
+               A7E9B76F12D37EC400DA6239 /* nseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = nseqs.h; path = source/nseqs.h; sourceTree = "<group>"; };
+               A7E9B77012D37EC400DA6239 /* observable.h */ = {isa = PBXFileReference; fileEncoding = 4; name = observable.h; path = source/observable.h; sourceTree = SOURCE_ROOT; };
+               A7E9B77112D37EC400DA6239 /* odum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = odum.cpp; path = source/odum.cpp; sourceTree = "<group>"; };
+               A7E9B77212D37EC400DA6239 /* odum.h */ = {isa = PBXFileReference; fileEncoding = 4; name = odum.h; path = source/odum.h; sourceTree = "<group>"; };
+               A7E9B77312D37EC400DA6239 /* onegapdist.h */ = {isa = PBXFileReference; fileEncoding = 4; name = onegapdist.h; path = source/onegapdist.h; sourceTree = "<group>"; };
+               A7E9B77412D37EC400DA6239 /* onegapignore.h */ = {isa = PBXFileReference; fileEncoding = 4; name = onegapignore.h; path = source/onegapignore.h; sourceTree = "<group>"; };
+               A7E9B77512D37EC400DA6239 /* optionparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = optionparser.cpp; path = source/optionparser.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B77612D37EC400DA6239 /* optionparser.h */ = {isa = PBXFileReference; fileEncoding = 4; name = optionparser.h; path = source/optionparser.h; sourceTree = SOURCE_ROOT; };
+               A7E9B77712D37EC400DA6239 /* ordervector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = ordervector.cpp; path = source/ordervector.cpp; sourceTree = "<group>"; };
+               A7E9B77812D37EC400DA6239 /* ordervector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = ordervector.hpp; path = source/ordervector.hpp; sourceTree = "<group>"; };
+               A7E9B77912D37EC400DA6239 /* otuhierarchycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = otuhierarchycommand.cpp; path = source/otuhierarchycommand.cpp; sourceTree = "<group>"; };
+               A7E9B77A12D37EC400DA6239 /* otuhierarchycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = otuhierarchycommand.h; path = source/otuhierarchycommand.h; sourceTree = "<group>"; };
+               A7E9B77B12D37EC400DA6239 /* overlap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = overlap.cpp; path = source/overlap.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B77C12D37EC400DA6239 /* overlap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = overlap.hpp; path = source/overlap.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B77D12D37EC400DA6239 /* pairwiseseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = pairwiseseqscommand.cpp; path = source/pairwiseseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B77E12D37EC400DA6239 /* pairwiseseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pairwiseseqscommand.h; path = source/pairwiseseqscommand.h; sourceTree = "<group>"; };
+               A7E9B77F12D37EC400DA6239 /* parsefastaqcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = parsefastaqcommand.cpp; path = source/parsefastaqcommand.cpp; sourceTree = "<group>"; };
+               A7E9B78012D37EC400DA6239 /* parsefastaqcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = parsefastaqcommand.h; path = source/parsefastaqcommand.h; sourceTree = "<group>"; };
+               A7E9B78112D37EC400DA6239 /* parselistscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = parselistscommand.cpp; path = source/parselistscommand.cpp; sourceTree = "<group>"; };
+               A7E9B78212D37EC400DA6239 /* parselistscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = parselistscommand.h; path = source/parselistscommand.h; sourceTree = "<group>"; };
+               A7E9B78312D37EC400DA6239 /* parsimony.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = parsimony.cpp; path = source/parsimony.cpp; sourceTree = "<group>"; };
+               A7E9B78412D37EC400DA6239 /* parsimony.h */ = {isa = PBXFileReference; fileEncoding = 4; name = parsimony.h; path = source/parsimony.h; sourceTree = "<group>"; };
+               A7E9B78512D37EC400DA6239 /* parsimonycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = parsimonycommand.cpp; path = source/parsimonycommand.cpp; sourceTree = "<group>"; };
+               A7E9B78612D37EC400DA6239 /* parsimonycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = parsimonycommand.h; path = source/parsimonycommand.h; sourceTree = "<group>"; };
+               A7E9B78712D37EC400DA6239 /* pcoacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = pcoacommand.cpp; path = source/pcoacommand.cpp; sourceTree = "<group>"; };
+               A7E9B78812D37EC400DA6239 /* pcoacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pcoacommand.h; path = source/pcoacommand.h; sourceTree = "<group>"; };
+               A7E9B78B12D37EC400DA6239 /* phylodiversitycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = phylodiversitycommand.cpp; path = source/phylodiversitycommand.cpp; sourceTree = "<group>"; };
+               A7E9B78C12D37EC400DA6239 /* phylodiversitycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = phylodiversitycommand.h; path = source/phylodiversitycommand.h; sourceTree = "<group>"; };
+               A7E9B78D12D37EC400DA6239 /* phylosummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = phylosummary.cpp; path = source/phylosummary.cpp; sourceTree = "<group>"; };
+               A7E9B78E12D37EC400DA6239 /* phylosummary.h */ = {isa = PBXFileReference; fileEncoding = 4; name = phylosummary.h; path = source/phylosummary.h; sourceTree = "<group>"; };
+               A7E9B78F12D37EC400DA6239 /* phylotree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = phylotree.cpp; path = source/phylotree.cpp; sourceTree = "<group>"; };
+               A7E9B79012D37EC400DA6239 /* phylotree.h */ = {isa = PBXFileReference; fileEncoding = 4; name = phylotree.h; path = source/phylotree.h; sourceTree = "<group>"; };
+               A7E9B79112D37EC400DA6239 /* phylotypecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = phylotypecommand.cpp; path = source/phylotypecommand.cpp; sourceTree = "<group>"; };
+               A7E9B79212D37EC400DA6239 /* phylotypecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = phylotypecommand.h; path = source/phylotypecommand.h; sourceTree = "<group>"; };
+               A7E9B79312D37EC400DA6239 /* pintail.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = pintail.cpp; path = source/pintail.cpp; sourceTree = "<group>"; };
+               A7E9B79412D37EC400DA6239 /* pintail.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pintail.h; path = source/pintail.h; sourceTree = "<group>"; };
+               A7E9B79512D37EC400DA6239 /* pipelinepdscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = pipelinepdscommand.cpp; path = source/pipelinepdscommand.cpp; sourceTree = "<group>"; };
+               A7E9B79612D37EC400DA6239 /* pipelinepdscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pipelinepdscommand.h; path = source/pipelinepdscommand.h; sourceTree = "<group>"; };
+               A7E9B79712D37EC400DA6239 /* preclustercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = preclustercommand.cpp; path = source/preclustercommand.cpp; sourceTree = "<group>"; };
+               A7E9B79812D37EC400DA6239 /* preclustercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = preclustercommand.h; path = source/preclustercommand.h; sourceTree = "<group>"; };
+               A7E9B79912D37EC400DA6239 /* prng.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = prng.cpp; path = source/prng.cpp; sourceTree = "<group>"; };
+               A7E9B79A12D37EC400DA6239 /* prng.h */ = {isa = PBXFileReference; fileEncoding = 4; name = prng.h; path = source/prng.h; sourceTree = "<group>"; };
+               A7E9B79B12D37EC400DA6239 /* progress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = progress.cpp; path = source/progress.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B79C12D37EC400DA6239 /* progress.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = progress.hpp; path = source/progress.hpp; sourceTree = SOURCE_ROOT; };
+               A7E9B79D12D37EC400DA6239 /* qstat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = qstat.cpp; path = source/qstat.cpp; sourceTree = "<group>"; };
+               A7E9B79E12D37EC400DA6239 /* qstat.h */ = {isa = PBXFileReference; fileEncoding = 4; name = qstat.h; path = source/qstat.h; sourceTree = "<group>"; };
+               A7E9B79F12D37EC400DA6239 /* qualityscores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = qualityscores.cpp; path = source/qualityscores.cpp; sourceTree = "<group>"; };
+               A7E9B7A012D37EC400DA6239 /* qualityscores.h */ = {isa = PBXFileReference; fileEncoding = 4; name = qualityscores.h; path = source/qualityscores.h; sourceTree = "<group>"; };
+               A7E9B7A112D37EC400DA6239 /* quitcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = quitcommand.cpp; path = source/quitcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7A212D37EC400DA6239 /* quitcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = quitcommand.h; path = source/quitcommand.h; sourceTree = "<group>"; };
+               A7E9B7A312D37EC400DA6239 /* rabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rabundvector.cpp; path = source/rabundvector.cpp; sourceTree = "<group>"; };
+               A7E9B7A412D37EC400DA6239 /* rabundvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rabundvector.hpp; path = source/rabundvector.hpp; sourceTree = "<group>"; };
+               A7E9B7A512D37EC400DA6239 /* rarecalc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rarecalc.cpp; path = source/rarecalc.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B7A612D37EC400DA6239 /* rarecalc.h */ = {isa = PBXFileReference; fileEncoding = 4; name = rarecalc.h; path = source/rarecalc.h; sourceTree = SOURCE_ROOT; };
+               A7E9B7A712D37EC400DA6239 /* raredisplay.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = raredisplay.cpp; path = source/raredisplay.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B7A812D37EC400DA6239 /* raredisplay.h */ = {isa = PBXFileReference; fileEncoding = 4; name = raredisplay.h; path = source/raredisplay.h; sourceTree = SOURCE_ROOT; };
+               A7E9B7A912D37EC400DA6239 /* rarefact.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefact.cpp; path = source/rarefact.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B7AA12D37EC400DA6239 /* rarefact.h */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefact.h; path = source/rarefact.h; sourceTree = SOURCE_ROOT; };
+               A7E9B7AB12D37EC400DA6239 /* rarefactcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefactcommand.cpp; path = source/rarefactcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7AC12D37EC400DA6239 /* rarefactcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefactcommand.h; path = source/rarefactcommand.h; sourceTree = "<group>"; };
+               A7E9B7AD12D37EC400DA6239 /* rarefactioncurvedata.h */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefactioncurvedata.h; path = source/rarefactioncurvedata.h; sourceTree = SOURCE_ROOT; };
+               A7E9B7AE12D37EC400DA6239 /* rarefactsharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefactsharedcommand.cpp; path = source/rarefactsharedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7AF12D37EC400DA6239 /* rarefactsharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = rarefactsharedcommand.h; path = source/rarefactsharedcommand.h; sourceTree = "<group>"; };
+               A7E9B7B012D37EC400DA6239 /* readblast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readblast.cpp; path = source/readblast.cpp; sourceTree = "<group>"; };
+               A7E9B7B112D37EC400DA6239 /* readblast.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readblast.h; path = source/readblast.h; sourceTree = "<group>"; };
+               A7E9B7B212D37EC400DA6239 /* readcluster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readcluster.cpp; path = source/readcluster.cpp; sourceTree = "<group>"; };
+               A7E9B7B312D37EC400DA6239 /* readcluster.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readcluster.h; path = source/readcluster.h; sourceTree = "<group>"; };
+               A7E9B7B412D37EC400DA6239 /* readcolumn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readcolumn.cpp; path = source/readcolumn.cpp; sourceTree = "<group>"; };
+               A7E9B7B512D37EC400DA6239 /* readcolumn.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readcolumn.h; path = source/readcolumn.h; sourceTree = "<group>"; };
+               A7E9B7B612D37EC400DA6239 /* readdistcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readdistcommand.cpp; path = source/readdistcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7B712D37EC400DA6239 /* readdistcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readdistcommand.h; path = source/readdistcommand.h; sourceTree = "<group>"; };
+               A7E9B7B812D37EC400DA6239 /* readmatrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readmatrix.hpp; path = source/readmatrix.hpp; sourceTree = "<group>"; };
+               A7E9B7BB12D37EC400DA6239 /* readotucommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readotucommand.cpp; path = source/readotucommand.cpp; sourceTree = "<group>"; };
+               A7E9B7BC12D37EC400DA6239 /* readotucommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readotucommand.h; path = source/readotucommand.h; sourceTree = "<group>"; };
+               A7E9B7BD12D37EC400DA6239 /* readphylip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readphylip.cpp; path = source/readphylip.cpp; sourceTree = "<group>"; };
+               A7E9B7BE12D37EC400DA6239 /* readphylip.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readphylip.h; path = source/readphylip.h; sourceTree = "<group>"; };
+               A7E9B7BF12D37EC400DA6239 /* readtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readtree.cpp; path = source/readtree.cpp; sourceTree = "<group>"; };
+               A7E9B7C012D37EC400DA6239 /* readtree.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readtree.h; path = source/readtree.h; sourceTree = "<group>"; };
+               A7E9B7C112D37EC400DA6239 /* readtreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = readtreecommand.cpp; path = source/readtreecommand.cpp; sourceTree = "<group>"; };
+               A7E9B7C212D37EC400DA6239 /* readtreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = readtreecommand.h; path = source/readtreecommand.h; sourceTree = "<group>"; };
+               A7E9B7C312D37EC400DA6239 /* removegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = removegroupscommand.cpp; path = source/removegroupscommand.cpp; sourceTree = "<group>"; };
+               A7E9B7C412D37EC400DA6239 /* removegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = removegroupscommand.h; path = source/removegroupscommand.h; sourceTree = "<group>"; };
+               A7E9B7C512D37EC400DA6239 /* removelineagecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = removelineagecommand.cpp; path = source/removelineagecommand.cpp; sourceTree = "<group>"; };
+               A7E9B7C612D37EC400DA6239 /* removelineagecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = removelineagecommand.h; path = source/removelineagecommand.h; sourceTree = "<group>"; };
+               A7E9B7C712D37EC400DA6239 /* removeotuscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = removeotuscommand.cpp; path = source/removeotuscommand.cpp; sourceTree = "<group>"; };
+               A7E9B7C812D37EC400DA6239 /* removeotuscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = removeotuscommand.h; path = source/removeotuscommand.h; sourceTree = "<group>"; };
+               A7E9B7C912D37EC400DA6239 /* removeseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = removeseqscommand.cpp; path = source/removeseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B7CA12D37EC400DA6239 /* removeseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = removeseqscommand.h; path = source/removeseqscommand.h; sourceTree = "<group>"; };
+               A7E9B7CB12D37EC400DA6239 /* reportfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = reportfile.cpp; path = source/reportfile.cpp; sourceTree = "<group>"; };
+               A7E9B7CC12D37EC400DA6239 /* reportfile.h */ = {isa = PBXFileReference; fileEncoding = 4; name = reportfile.h; path = source/reportfile.h; sourceTree = "<group>"; };
+               A7E9B7CD12D37EC400DA6239 /* reversecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = reversecommand.cpp; path = source/reversecommand.cpp; sourceTree = "<group>"; };
+               A7E9B7CE12D37EC400DA6239 /* reversecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = reversecommand.h; path = source/reversecommand.h; sourceTree = "<group>"; };
+               A7E9B7CF12D37EC400DA6239 /* sabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sabundvector.cpp; path = source/sabundvector.cpp; sourceTree = "<group>"; };
+               A7E9B7D012D37EC400DA6239 /* sabundvector.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sabundvector.hpp; path = source/sabundvector.hpp; sourceTree = "<group>"; };
+               A7E9B7D112D37EC400DA6239 /* screenseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = screenseqscommand.cpp; path = source/screenseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B7D212D37EC400DA6239 /* screenseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = screenseqscommand.h; path = source/screenseqscommand.h; sourceTree = "<group>"; };
+               A7E9B7D312D37EC400DA6239 /* secondarystructurecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = secondarystructurecommand.cpp; path = source/secondarystructurecommand.cpp; sourceTree = "<group>"; };
+               A7E9B7D412D37EC400DA6239 /* secondarystructurecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = secondarystructurecommand.h; path = source/secondarystructurecommand.h; sourceTree = "<group>"; };
+               A7E9B7D512D37EC400DA6239 /* sensspeccommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sensspeccommand.cpp; path = source/sensspeccommand.cpp; sourceTree = "<group>"; };
+               A7E9B7D612D37EC400DA6239 /* sensspeccommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sensspeccommand.h; path = source/sensspeccommand.h; sourceTree = "<group>"; };
+               A7E9B7D712D37EC400DA6239 /* seqerrorcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = seqerrorcommand.cpp; path = source/seqerrorcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7D812D37EC400DA6239 /* seqerrorcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = seqerrorcommand.h; path = source/seqerrorcommand.h; sourceTree = "<group>"; };
+               A7E9B7D912D37EC400DA6239 /* seqsummarycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = seqsummarycommand.cpp; path = source/seqsummarycommand.cpp; sourceTree = "<group>"; };
+               A7E9B7DA12D37EC400DA6239 /* seqsummarycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = seqsummarycommand.h; path = source/seqsummarycommand.h; sourceTree = "<group>"; };
+               A7E9B7DB12D37EC400DA6239 /* sequence.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sequence.cpp; path = source/sequence.cpp; sourceTree = "<group>"; };
+               A7E9B7DC12D37EC400DA6239 /* sequence.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sequence.hpp; path = source/sequence.hpp; sourceTree = "<group>"; };
+               A7E9B7DD12D37EC400DA6239 /* sequencedb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sequencedb.cpp; path = source/sequencedb.cpp; sourceTree = "<group>"; };
+               A7E9B7DE12D37EC400DA6239 /* sequencedb.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sequencedb.h; path = source/sequencedb.h; sourceTree = "<group>"; };
+               A7E9B7DF12D37EC400DA6239 /* setdircommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = setdircommand.cpp; path = source/setdircommand.cpp; sourceTree = "<group>"; };
+               A7E9B7E012D37EC400DA6239 /* setdircommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = setdircommand.h; path = source/setdircommand.h; sourceTree = "<group>"; };
+               A7E9B7E112D37EC400DA6239 /* setlogfilecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = setlogfilecommand.cpp; path = source/setlogfilecommand.cpp; sourceTree = "<group>"; };
+               A7E9B7E212D37EC400DA6239 /* setlogfilecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = setlogfilecommand.h; path = source/setlogfilecommand.h; sourceTree = "<group>"; };
+               A7E9B7E312D37EC400DA6239 /* sffinfocommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sffinfocommand.cpp; path = source/sffinfocommand.cpp; sourceTree = "<group>"; };
+               A7E9B7E412D37EC400DA6239 /* sffinfocommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sffinfocommand.h; path = source/sffinfocommand.h; sourceTree = "<group>"; };
+               A7E9B7E512D37EC400DA6239 /* shannon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = shannon.cpp; path = source/shannon.cpp; sourceTree = "<group>"; };
+               A7E9B7E612D37EC400DA6239 /* shannon.h */ = {isa = PBXFileReference; fileEncoding = 4; name = shannon.h; path = source/shannon.h; sourceTree = "<group>"; };
+               A7E9B7E712D37EC400DA6239 /* shannoneven.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = shannoneven.cpp; path = source/shannoneven.cpp; sourceTree = "<group>"; };
+               A7E9B7E812D37EC400DA6239 /* shannoneven.h */ = {isa = PBXFileReference; fileEncoding = 4; name = shannoneven.h; path = source/shannoneven.h; sourceTree = "<group>"; };
+               A7E9B7E912D37EC400DA6239 /* sharedace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedace.cpp; path = source/sharedace.cpp; sourceTree = "<group>"; };
+               A7E9B7EA12D37EC400DA6239 /* sharedace.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedace.h; path = source/sharedace.h; sourceTree = "<group>"; };
+               A7E9B7EC12D37EC400DA6239 /* sharedanderbergs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedanderbergs.cpp; path = source/sharedanderbergs.cpp; sourceTree = "<group>"; };
+               A7E9B7ED12D37EC400DA6239 /* sharedanderbergs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedanderbergs.h; path = source/sharedanderbergs.h; sourceTree = "<group>"; };
+               A7E9B7EE12D37EC400DA6239 /* sharedbraycurtis.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedbraycurtis.cpp; path = source/sharedbraycurtis.cpp; sourceTree = "<group>"; };
+               A7E9B7EF12D37EC400DA6239 /* sharedbraycurtis.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedbraycurtis.h; path = source/sharedbraycurtis.h; sourceTree = "<group>"; };
+               A7E9B7F012D37EC400DA6239 /* sharedchao1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedchao1.cpp; path = source/sharedchao1.cpp; sourceTree = "<group>"; };
+               A7E9B7F112D37EC400DA6239 /* sharedchao1.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedchao1.h; path = source/sharedchao1.h; sourceTree = "<group>"; };
+               A7E9B7F212D37EC400DA6239 /* sharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedcommand.cpp; path = source/sharedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B7F312D37EC400DA6239 /* sharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedcommand.h; path = source/sharedcommand.h; sourceTree = "<group>"; };
+               A7E9B7F412D37EC400DA6239 /* sharedjabund.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjabund.cpp; path = source/sharedjabund.cpp; sourceTree = "<group>"; };
+               A7E9B7F512D37EC400DA6239 /* sharedjabund.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjabund.h; path = source/sharedjabund.h; sourceTree = "<group>"; };
+               A7E9B7F612D37EC400DA6239 /* sharedjackknife.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjackknife.cpp; path = source/sharedjackknife.cpp; sourceTree = "<group>"; };
+               A7E9B7F712D37EC400DA6239 /* sharedjackknife.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjackknife.h; path = source/sharedjackknife.h; sourceTree = "<group>"; };
+               A7E9B7F812D37EC400DA6239 /* sharedjclass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjclass.cpp; path = source/sharedjclass.cpp; sourceTree = "<group>"; };
+               A7E9B7F912D37EC400DA6239 /* sharedjclass.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjclass.h; path = source/sharedjclass.h; sourceTree = "<group>"; };
+               A7E9B7FA12D37EC400DA6239 /* sharedjest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjest.cpp; path = source/sharedjest.cpp; sourceTree = "<group>"; };
+               A7E9B7FB12D37EC400DA6239 /* sharedjest.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedjest.h; path = source/sharedjest.h; sourceTree = "<group>"; };
+               A7E9B7FC12D37EC400DA6239 /* sharedkstest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkstest.cpp; path = source/sharedkstest.cpp; sourceTree = "<group>"; };
+               A7E9B7FD12D37EC400DA6239 /* sharedkstest.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkstest.h; path = source/sharedkstest.h; sourceTree = "<group>"; };
+               A7E9B7FE12D37EC400DA6239 /* sharedkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkulczynski.cpp; path = source/sharedkulczynski.cpp; sourceTree = "<group>"; };
+               A7E9B7FF12D37EC400DA6239 /* sharedkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkulczynski.h; path = source/sharedkulczynski.h; sourceTree = "<group>"; };
+               A7E9B80012D37EC400DA6239 /* sharedkulczynskicody.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkulczynskicody.cpp; path = source/sharedkulczynskicody.cpp; sourceTree = "<group>"; };
+               A7E9B80112D37EC400DA6239 /* sharedkulczynskicody.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedkulczynskicody.h; path = source/sharedkulczynskicody.h; sourceTree = "<group>"; };
+               A7E9B80212D37EC400DA6239 /* sharedlennon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedlennon.cpp; path = source/sharedlennon.cpp; sourceTree = "<group>"; };
+               A7E9B80312D37EC400DA6239 /* sharedlennon.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedlennon.h; path = source/sharedlennon.h; sourceTree = "<group>"; };
+               A7E9B80412D37EC400DA6239 /* sharedlistvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedlistvector.cpp; path = source/sharedlistvector.cpp; sourceTree = "<group>"; };
+               A7E9B80512D37EC400DA6239 /* sharedlistvector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedlistvector.h; path = source/sharedlistvector.h; sourceTree = "<group>"; };
+               A7E9B80612D37EC400DA6239 /* sharedmarczewski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedmarczewski.cpp; path = source/sharedmarczewski.cpp; sourceTree = "<group>"; };
+               A7E9B80712D37EC400DA6239 /* sharedmarczewski.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedmarczewski.h; path = source/sharedmarczewski.h; sourceTree = "<group>"; };
+               A7E9B80812D37EC400DA6239 /* sharedmorisitahorn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedmorisitahorn.cpp; path = source/sharedmorisitahorn.cpp; sourceTree = "<group>"; };
+               A7E9B80912D37EC400DA6239 /* sharedmorisitahorn.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedmorisitahorn.h; path = source/sharedmorisitahorn.h; sourceTree = "<group>"; };
+               A7E9B80A12D37EC400DA6239 /* sharednseqs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharednseqs.h; path = source/sharednseqs.h; sourceTree = "<group>"; };
+               A7E9B80B12D37EC400DA6239 /* sharedochiai.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedochiai.cpp; path = source/sharedochiai.cpp; sourceTree = "<group>"; };
+               A7E9B80C12D37EC400DA6239 /* sharedochiai.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedochiai.h; path = source/sharedochiai.h; sourceTree = "<group>"; };
+               A7E9B80D12D37EC400DA6239 /* sharedordervector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedordervector.cpp; path = source/sharedordervector.cpp; sourceTree = "<group>"; };
+               A7E9B80E12D37EC400DA6239 /* sharedordervector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedordervector.h; path = source/sharedordervector.h; sourceTree = "<group>"; };
+               A7E9B80F12D37EC400DA6239 /* sharedrabundfloatvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedrabundfloatvector.cpp; path = source/sharedrabundfloatvector.cpp; sourceTree = "<group>"; };
+               A7E9B81012D37EC400DA6239 /* sharedrabundfloatvector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedrabundfloatvector.h; path = source/sharedrabundfloatvector.h; sourceTree = "<group>"; };
+               A7E9B81112D37EC400DA6239 /* sharedrabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedrabundvector.cpp; path = source/sharedrabundvector.cpp; sourceTree = "<group>"; };
+               A7E9B81212D37EC400DA6239 /* sharedrabundvector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedrabundvector.h; path = source/sharedrabundvector.h; sourceTree = "<group>"; };
+               A7E9B81312D37EC400DA6239 /* sharedsabundvector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsabundvector.cpp; path = source/sharedsabundvector.cpp; sourceTree = "<group>"; };
+               A7E9B81412D37EC400DA6239 /* sharedsabundvector.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsabundvector.h; path = source/sharedsabundvector.h; sourceTree = "<group>"; };
+               A7E9B81512D37EC400DA6239 /* sharedsobs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsobs.cpp; path = source/sharedsobs.cpp; sourceTree = "<group>"; };
+               A7E9B81612D37EC400DA6239 /* sharedsobs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsobs.h; path = source/sharedsobs.h; sourceTree = "<group>"; };
+               A7E9B81712D37EC400DA6239 /* sharedsobscollectsummary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsobscollectsummary.cpp; path = source/sharedsobscollectsummary.cpp; sourceTree = "<group>"; };
+               A7E9B81812D37EC400DA6239 /* sharedsobscollectsummary.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsobscollectsummary.h; path = source/sharedsobscollectsummary.h; sourceTree = "<group>"; };
+               A7E9B81912D37EC400DA6239 /* sharedsorabund.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorabund.cpp; path = source/sharedsorabund.cpp; sourceTree = "<group>"; };
+               A7E9B81A12D37EC400DA6239 /* sharedsorabund.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorabund.h; path = source/sharedsorabund.h; sourceTree = "<group>"; };
+               A7E9B81B12D37EC400DA6239 /* sharedsorclass.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorclass.cpp; path = source/sharedsorclass.cpp; sourceTree = "<group>"; };
+               A7E9B81C12D37EC400DA6239 /* sharedsorclass.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorclass.h; path = source/sharedsorclass.h; sourceTree = "<group>"; };
+               A7E9B81D12D37EC400DA6239 /* sharedsorest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorest.cpp; path = source/sharedsorest.cpp; sourceTree = "<group>"; };
+               A7E9B81E12D37EC400DA6239 /* sharedsorest.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedsorest.h; path = source/sharedsorest.h; sourceTree = "<group>"; };
+               A7E9B81F12D37EC400DA6239 /* sharedthetan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedthetan.cpp; path = source/sharedthetan.cpp; sourceTree = "<group>"; };
+               A7E9B82012D37EC400DA6239 /* sharedthetan.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedthetan.h; path = source/sharedthetan.h; sourceTree = "<group>"; };
+               A7E9B82112D37EC400DA6239 /* sharedthetayc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedthetayc.cpp; path = source/sharedthetayc.cpp; sourceTree = "<group>"; };
+               A7E9B82212D37EC400DA6239 /* sharedthetayc.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedthetayc.h; path = source/sharedthetayc.h; sourceTree = "<group>"; };
+               A7E9B82312D37EC400DA6239 /* sharedutilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = sharedutilities.cpp; path = source/sharedutilities.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B82412D37EC400DA6239 /* sharedutilities.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sharedutilities.h; path = source/sharedutilities.h; sourceTree = SOURCE_ROOT; };
+               A7E9B82512D37EC400DA6239 /* shen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = shen.cpp; path = source/shen.cpp; sourceTree = "<group>"; };
+               A7E9B82612D37EC400DA6239 /* shen.h */ = {isa = PBXFileReference; fileEncoding = 4; name = shen.h; path = source/shen.h; sourceTree = "<group>"; };
+               A7E9B82712D37EC400DA6239 /* shhhercommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = shhhercommand.cpp; path = source/shhhercommand.cpp; sourceTree = "<group>"; };
+               A7E9B82812D37EC400DA6239 /* shhhercommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = shhhercommand.h; path = source/shhhercommand.h; sourceTree = "<group>"; };
+               A7E9B82912D37EC400DA6239 /* simpson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = simpson.cpp; path = source/simpson.cpp; sourceTree = "<group>"; };
+               A7E9B82A12D37EC400DA6239 /* simpson.h */ = {isa = PBXFileReference; fileEncoding = 4; name = simpson.h; path = source/simpson.h; sourceTree = "<group>"; };
+               A7E9B82B12D37EC400DA6239 /* simpsoneven.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = simpsoneven.cpp; path = source/simpsoneven.cpp; sourceTree = "<group>"; };
+               A7E9B82C12D37EC400DA6239 /* simpsoneven.h */ = {isa = PBXFileReference; fileEncoding = 4; name = simpsoneven.h; path = source/simpsoneven.h; sourceTree = "<group>"; };
+               A7E9B82D12D37EC400DA6239 /* singlelinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = singlelinkage.cpp; path = source/singlelinkage.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B82E12D37EC400DA6239 /* slayer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = slayer.cpp; path = source/slayer.cpp; sourceTree = "<group>"; };
+               A7E9B82F12D37EC400DA6239 /* slayer.h */ = {isa = PBXFileReference; fileEncoding = 4; name = slayer.h; path = source/slayer.h; sourceTree = "<group>"; };
+               A7E9B83012D37EC400DA6239 /* slibshuff.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = slibshuff.cpp; path = source/slibshuff.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B83112D37EC400DA6239 /* slibshuff.h */ = {isa = PBXFileReference; fileEncoding = 4; name = slibshuff.h; path = source/slibshuff.h; sourceTree = SOURCE_ROOT; };
+               A7E9B83212D37EC400DA6239 /* smithwilson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = smithwilson.cpp; path = source/smithwilson.cpp; sourceTree = "<group>"; };
+               A7E9B83312D37EC400DA6239 /* smithwilson.h */ = {isa = PBXFileReference; fileEncoding = 4; name = smithwilson.h; path = source/smithwilson.h; sourceTree = "<group>"; };
+               A7E9B83412D37EC400DA6239 /* sobs.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sobs.h; path = source/sobs.h; sourceTree = "<group>"; };
+               A7E9B83512D37EC400DA6239 /* soergel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = soergel.cpp; path = source/soergel.cpp; sourceTree = "<group>"; };
+               A7E9B83612D37EC400DA6239 /* soergel.h */ = {isa = PBXFileReference; fileEncoding = 4; name = soergel.h; path = source/soergel.h; sourceTree = "<group>"; };
+               A7E9B83712D37EC400DA6239 /* solow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = solow.cpp; path = source/solow.cpp; sourceTree = "<group>"; };
+               A7E9B83812D37EC400DA6239 /* solow.h */ = {isa = PBXFileReference; fileEncoding = 4; name = solow.h; path = source/solow.h; sourceTree = "<group>"; };
+               A7E9B83912D37EC400DA6239 /* sparsematrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sparsematrix.cpp; path = source/sparsematrix.cpp; sourceTree = "<group>"; };
+               A7E9B83A12D37EC400DA6239 /* sparsematrix.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sparsematrix.hpp; path = source/sparsematrix.hpp; sourceTree = "<group>"; };
+               A7E9B83B12D37EC400DA6239 /* spearman.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = spearman.cpp; path = source/spearman.cpp; sourceTree = "<group>"; };
+               A7E9B83C12D37EC400DA6239 /* spearman.h */ = {isa = PBXFileReference; fileEncoding = 4; name = spearman.h; path = source/spearman.h; sourceTree = "<group>"; };
+               A7E9B83D12D37EC400DA6239 /* speciesprofile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = speciesprofile.cpp; path = source/speciesprofile.cpp; sourceTree = "<group>"; };
+               A7E9B83E12D37EC400DA6239 /* speciesprofile.h */ = {isa = PBXFileReference; fileEncoding = 4; name = speciesprofile.h; path = source/speciesprofile.h; sourceTree = "<group>"; };
+               A7E9B83F12D37EC400DA6239 /* splitabundcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = splitabundcommand.cpp; path = source/splitabundcommand.cpp; sourceTree = "<group>"; };
+               A7E9B84012D37EC400DA6239 /* splitabundcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = splitabundcommand.h; path = source/splitabundcommand.h; sourceTree = "<group>"; };
+               A7E9B84112D37EC400DA6239 /* splitgroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = splitgroupscommand.cpp; path = source/splitgroupscommand.cpp; sourceTree = "<group>"; };
+               A7E9B84212D37EC400DA6239 /* splitgroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = splitgroupscommand.h; path = source/splitgroupscommand.h; sourceTree = "<group>"; };
+               A7E9B84312D37EC400DA6239 /* splitmatrix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = splitmatrix.cpp; path = source/splitmatrix.cpp; sourceTree = "<group>"; };
+               A7E9B84412D37EC400DA6239 /* splitmatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; name = splitmatrix.h; path = source/splitmatrix.h; sourceTree = "<group>"; };
+               A7E9B84512D37EC400DA6239 /* structchi2.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = structchi2.cpp; path = source/structchi2.cpp; sourceTree = "<group>"; };
+               A7E9B84612D37EC400DA6239 /* structchi2.h */ = {isa = PBXFileReference; fileEncoding = 4; name = structchi2.h; path = source/structchi2.h; sourceTree = "<group>"; };
+               A7E9B84712D37EC400DA6239 /* structchord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = structchord.cpp; path = source/structchord.cpp; sourceTree = "<group>"; };
+               A7E9B84812D37EC400DA6239 /* structchord.h */ = {isa = PBXFileReference; fileEncoding = 4; name = structchord.h; path = source/structchord.h; sourceTree = "<group>"; };
+               A7E9B84912D37EC400DA6239 /* structeuclidean.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = structeuclidean.cpp; path = source/structeuclidean.cpp; sourceTree = "<group>"; };
+               A7E9B84A12D37EC400DA6239 /* structeuclidean.h */ = {isa = PBXFileReference; fileEncoding = 4; name = structeuclidean.h; path = source/structeuclidean.h; sourceTree = "<group>"; };
+               A7E9B84B12D37EC400DA6239 /* structkulczynski.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = structkulczynski.cpp; path = source/structkulczynski.cpp; sourceTree = "<group>"; };
+               A7E9B84C12D37EC400DA6239 /* structkulczynski.h */ = {isa = PBXFileReference; fileEncoding = 4; name = structkulczynski.h; path = source/structkulczynski.h; sourceTree = "<group>"; };
+               A7E9B84D12D37EC400DA6239 /* structpearson.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = structpearson.cpp; path = source/structpearson.cpp; sourceTree = "<group>"; };
+               A7E9B84E12D37EC400DA6239 /* structpearson.h */ = {isa = PBXFileReference; fileEncoding = 4; name = structpearson.h; path = source/structpearson.h; sourceTree = "<group>"; };
+               A7E9B84F12D37EC400DA6239 /* subsamplecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = subsamplecommand.cpp; path = source/subsamplecommand.cpp; sourceTree = "<group>"; };
+               A7E9B85012D37EC400DA6239 /* subsamplecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = subsamplecommand.h; path = source/subsamplecommand.h; sourceTree = "<group>"; };
+               A7E9B85112D37EC400DA6239 /* suffixdb.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixdb.cpp; path = source/suffixdb.cpp; sourceTree = "<group>"; };
+               A7E9B85212D37EC400DA6239 /* suffixdb.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixdb.hpp; path = source/suffixdb.hpp; sourceTree = "<group>"; };
+               A7E9B85312D37EC400DA6239 /* suffixnodes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixnodes.cpp; path = source/suffixnodes.cpp; sourceTree = "<group>"; };
+               A7E9B85412D37EC400DA6239 /* suffixnodes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixnodes.hpp; path = source/suffixnodes.hpp; sourceTree = "<group>"; };
+               A7E9B85512D37EC400DA6239 /* suffixtree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixtree.cpp; path = source/suffixtree.cpp; sourceTree = "<group>"; };
+               A7E9B85612D37EC400DA6239 /* suffixtree.hpp */ = {isa = PBXFileReference; fileEncoding = 4; name = suffixtree.hpp; path = source/suffixtree.hpp; sourceTree = "<group>"; };
+               A7E9B85712D37EC400DA6239 /* summarycommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = summarycommand.cpp; path = source/summarycommand.cpp; sourceTree = "<group>"; };
+               A7E9B85812D37EC400DA6239 /* summarycommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = summarycommand.h; path = source/summarycommand.h; sourceTree = "<group>"; };
+               A7E9B85912D37EC400DA6239 /* summarysharedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = summarysharedcommand.cpp; path = source/summarysharedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B85A12D37EC400DA6239 /* summarysharedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = summarysharedcommand.h; path = source/summarysharedcommand.h; sourceTree = "<group>"; };
+               A7E9B85B12D37EC400DA6239 /* systemcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = systemcommand.cpp; path = source/systemcommand.cpp; sourceTree = "<group>"; };
+               A7E9B85C12D37EC400DA6239 /* systemcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = systemcommand.h; path = source/systemcommand.h; sourceTree = "<group>"; };
+               A7E9B85D12D37EC400DA6239 /* taxonomyequalizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = taxonomyequalizer.cpp; path = source/taxonomyequalizer.cpp; sourceTree = "<group>"; };
+               A7E9B85E12D37EC400DA6239 /* taxonomyequalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; name = taxonomyequalizer.h; path = source/taxonomyequalizer.h; sourceTree = "<group>"; };
+               A7E9B85F12D37EC400DA6239 /* tree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = tree.cpp; path = source/tree.cpp; sourceTree = "<group>"; };
+               A7E9B86012D37EC400DA6239 /* tree.h */ = {isa = PBXFileReference; fileEncoding = 4; name = tree.h; path = source/tree.h; sourceTree = "<group>"; };
+               A7E9B86112D37EC400DA6239 /* treecalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; name = treecalculator.h; path = source/treecalculator.h; sourceTree = "<group>"; };
+               A7E9B86212D37EC400DA6239 /* treegroupscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = treegroupscommand.cpp; path = source/treegroupscommand.cpp; sourceTree = "<group>"; };
+               A7E9B86312D37EC400DA6239 /* treegroupscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = treegroupscommand.h; path = source/treegroupscommand.h; sourceTree = "<group>"; };
+               A7E9B86412D37EC400DA6239 /* treemap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = treemap.cpp; path = source/treemap.cpp; sourceTree = "<group>"; };
+               A7E9B86512D37EC400DA6239 /* treemap.h */ = {isa = PBXFileReference; fileEncoding = 4; name = treemap.h; path = source/treemap.h; sourceTree = "<group>"; };
+               A7E9B86612D37EC400DA6239 /* treenode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = treenode.cpp; path = source/treenode.cpp; sourceTree = "<group>"; };
+               A7E9B86712D37EC400DA6239 /* treenode.h */ = {isa = PBXFileReference; fileEncoding = 4; name = treenode.h; path = source/treenode.h; sourceTree = "<group>"; };
+               A7E9B86812D37EC400DA6239 /* trimflowscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = trimflowscommand.cpp; path = source/trimflowscommand.cpp; sourceTree = "<group>"; };
+               A7E9B86912D37EC400DA6239 /* trimflowscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = trimflowscommand.h; path = source/trimflowscommand.h; sourceTree = "<group>"; };
+               A7E9B86A12D37EC400DA6239 /* trimseqscommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = trimseqscommand.cpp; path = source/trimseqscommand.cpp; sourceTree = "<group>"; };
+               A7E9B86B12D37EC400DA6239 /* trimseqscommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = trimseqscommand.h; path = source/trimseqscommand.h; sourceTree = "<group>"; };
+               A7E9B86C12D37EC400DA6239 /* unifracunweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = unifracunweightedcommand.cpp; path = source/unifracunweightedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B86D12D37EC400DA6239 /* unifracunweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = unifracunweightedcommand.h; path = source/unifracunweightedcommand.h; sourceTree = "<group>"; };
+               A7E9B86E12D37EC400DA6239 /* unifracweightedcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = unifracweightedcommand.cpp; path = source/unifracweightedcommand.cpp; sourceTree = "<group>"; };
+               A7E9B86F12D37EC400DA6239 /* unifracweightedcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = unifracweightedcommand.h; path = source/unifracweightedcommand.h; sourceTree = "<group>"; };
+               A7E9B87012D37EC400DA6239 /* unweighted.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = unweighted.cpp; path = source/unweighted.cpp; sourceTree = "<group>"; };
+               A7E9B87112D37EC400DA6239 /* unweighted.h */ = {isa = PBXFileReference; fileEncoding = 4; name = unweighted.h; path = source/unweighted.h; sourceTree = "<group>"; };
+               A7E9B87212D37EC400DA6239 /* uvest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = uvest.cpp; path = source/uvest.cpp; sourceTree = "<group>"; };
+               A7E9B87312D37EC400DA6239 /* uvest.h */ = {isa = PBXFileReference; fileEncoding = 4; name = uvest.h; path = source/uvest.h; sourceTree = "<group>"; };
+               A7E9B87412D37EC400DA6239 /* validcalculator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = validcalculator.cpp; path = source/validcalculator.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B87512D37EC400DA6239 /* validcalculator.h */ = {isa = PBXFileReference; fileEncoding = 4; name = validcalculator.h; path = source/validcalculator.h; sourceTree = SOURCE_ROOT; };
+               A7E9B87612D37EC400DA6239 /* validparameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = validparameter.cpp; path = source/validparameter.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B87712D37EC400DA6239 /* validparameter.h */ = {isa = PBXFileReference; fileEncoding = 4; name = validparameter.h; path = source/validparameter.h; sourceTree = SOURCE_ROOT; };
+               A7E9B87812D37EC400DA6239 /* venn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = venn.cpp; path = source/venn.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B87912D37EC400DA6239 /* venn.h */ = {isa = PBXFileReference; fileEncoding = 4; name = venn.h; path = source/venn.h; sourceTree = SOURCE_ROOT; };
+               A7E9B87A12D37EC400DA6239 /* venncommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = venncommand.cpp; path = source/venncommand.cpp; sourceTree = "<group>"; };
+               A7E9B87B12D37EC400DA6239 /* venncommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = venncommand.h; path = source/venncommand.h; sourceTree = "<group>"; };
+               A7E9B87C12D37EC400DA6239 /* weighted.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = weighted.cpp; path = source/weighted.cpp; sourceTree = "<group>"; };
+               A7E9B87D12D37EC400DA6239 /* weighted.h */ = {isa = PBXFileReference; fileEncoding = 4; name = weighted.h; path = source/weighted.h; sourceTree = "<group>"; };
+               A7E9B87E12D37EC400DA6239 /* weightedlinkage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = weightedlinkage.cpp; path = source/weightedlinkage.cpp; sourceTree = SOURCE_ROOT; };
+               A7E9B87F12D37EC400DA6239 /* whittaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = whittaker.cpp; path = source/whittaker.cpp; sourceTree = "<group>"; };
+               A7E9B88012D37EC400DA6239 /* whittaker.h */ = {isa = PBXFileReference; fileEncoding = 4; name = whittaker.h; path = source/whittaker.h; sourceTree = "<group>"; };
+               A7EEB0F414F29BFD00344B83 /* classifytreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = classifytreecommand.cpp; path = source/classifytreecommand.cpp; sourceTree = "<group>"; };
+               A7EEB0F714F29C1B00344B83 /* classifytreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = classifytreecommand.h; path = source/classifytreecommand.h; sourceTree = "<group>"; };
+               A7F9F5CD141A5E500032F693 /* sequenceparser.h */ = {isa = PBXFileReference; fileEncoding = 4; name = sequenceparser.h; path = source/sequenceparser.h; sourceTree = "<group>"; };
+               A7F9F5CE141A5E500032F693 /* sequenceparser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = sequenceparser.cpp; path = source/sequenceparser.cpp; sourceTree = "<group>"; };
+               A7FA10001302E096003860FE /* mantelcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = mantelcommand.h; path = source/mantelcommand.h; sourceTree = "<group>"; };
+               A7FA10011302E096003860FE /* mantelcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = mantelcommand.cpp; path = source/mantelcommand.cpp; sourceTree = "<group>"; };
+               A7FA2ABC14A0E881007C09A6 /* bsplvb.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = bsplvb.f; path = source/bsplvb.f; sourceTree = "<group>"; };
+               A7FA2ABD14A0E881007C09A6 /* bsplvd.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = bsplvd.f; path = source/bsplvd.f; sourceTree = "<group>"; };
+               A7FA2ABE14A0E881007C09A6 /* bvalue.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = bvalue.f; path = source/bvalue.f; sourceTree = "<group>"; };
+               A7FA2ABF14A0E881007C09A6 /* daxpy.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = daxpy.f; path = source/daxpy.f; sourceTree = "<group>"; };
+               A7FA2AC014A0E881007C09A6 /* ddot.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = ddot.f; path = source/ddot.f; sourceTree = "<group>"; };
+               A7FA2AC114A0E881007C09A6 /* dpbfa.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = dpbfa.f; path = source/dpbfa.f; sourceTree = "<group>"; };
+               A7FA2AC214A0E881007C09A6 /* dpbsl.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = dpbsl.f; path = source/dpbsl.f; sourceTree = "<group>"; };
+               A7FA2AC314A0E881007C09A6 /* interv.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = interv.f; path = source/interv.f; sourceTree = "<group>"; };
+               A7FA2AC414A0E881007C09A6 /* sgram.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = sgram.f; path = source/sgram.f; sourceTree = "<group>"; };
+               A7FA2AC514A0E881007C09A6 /* sinerp.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = sinerp.f; path = source/sinerp.f; sourceTree = "<group>"; };
+               A7FA2AC614A0E881007C09A6 /* stxwx.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = stxwx.f; path = source/stxwx.f; sourceTree = "<group>"; };
+               A7FA2B1514A0EBEA007C09A6 /* sslvrg.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = sslvrg.f; path = source/sslvrg.f; sourceTree = "<group>"; };
+               A7FA2B5A14A0F0C2007C09A6 /* intrv.f */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.fortran; name = intrv.f; path = source/intrv.f; sourceTree = "<group>"; };
+               A7FC480C12D788F20055BC5C /* linearalgebra.h */ = {isa = PBXFileReference; fileEncoding = 4; name = linearalgebra.h; path = source/linearalgebra.h; sourceTree = "<group>"; };
+               A7FC480D12D788F20055BC5C /* linearalgebra.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = linearalgebra.cpp; path = source/linearalgebra.cpp; sourceTree = "<group>"; };
+               A7FC486512D795D60055BC5C /* pcacommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = pcacommand.h; path = source/pcacommand.h; sourceTree = "<group>"; };
+               A7FC486612D795D60055BC5C /* pcacommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = pcacommand.cpp; path = source/pcacommand.cpp; sourceTree = "<group>"; };
+               A7FE7C3E1330EA1000F7B327 /* getcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = getcurrentcommand.h; path = source/getcurrentcommand.h; sourceTree = "<group>"; };
+               A7FE7C3F1330EA1000F7B327 /* getcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = getcurrentcommand.cpp; path = source/getcurrentcommand.cpp; sourceTree = "<group>"; };
+               A7FE7E6B13311EA400F7B327 /* setcurrentcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = setcurrentcommand.h; path = source/setcurrentcommand.h; sourceTree = "<group>"; };
+               A7FE7E6C13311EA400F7B327 /* setcurrentcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = setcurrentcommand.cpp; path = source/setcurrentcommand.cpp; sourceTree = "<group>"; };
+               A7FF19F0140FFDA500AD216D /* trimoligos.h */ = {isa = PBXFileReference; fileEncoding = 4; name = trimoligos.h; path = source/trimoligos.h; sourceTree = "<group>"; };
+               A7FF19F1140FFDA500AD216D /* trimoligos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = trimoligos.cpp; path = source/trimoligos.cpp; sourceTree = "<group>"; };
+               A7FFB556142CA02C004884F2 /* summarytaxcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; name = summarytaxcommand.h; path = source/summarytaxcommand.h; sourceTree = "<group>"; };
+               A7FFB557142CA02C004884F2 /* summarytaxcommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; name = summarytaxcommand.cpp; path = source/summarytaxcommand.cpp; sourceTree = "<group>"; };
                C6A0FF2C0290799A04C91782 /* mothur.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = mothur.1; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
diff --git a/ace.cpp b/ace.cpp
deleted file mode 100644 (file)
index 92c023f..0000000
--- a/ace.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- *  ace.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "ace.h"
-
-/***********************************************************************/
-
-EstOutput Ace::getValues(SAbundVector* rank) {
-       try {
-               data.resize(3,0);
-               double ace, acelci, acehci;
-       
-               double nrare = 0;
-               double srare = 0;
-               double sabund = 0;
-       
-               double Cace, term1, gamace;
-               double numsum = 0;
-       
-               double maxRank = (double)rank->getMaxRank();
-       
-               for(int i=1;i<=maxRank;i++){
-                       if(i<=abund){
-                               srare += rank->get(i);
-                               nrare += i*rank->get(i);
-                               numsum += (i-1)*i*rank->get(i);
-                       }
-                       else if(i>abund)        {sabund += rank->get(i);}
-               }
-               double sobs = srare + sabund;
-       
-               if (nrare == 0){ Cace = 0.0000; }
-               else { Cace = 1.0000 -(double)rank->get(1)/(double)nrare; }
-       
-               double denom = Cace * (double)(nrare * (nrare-1));
-       
-               if(denom <= 0.0){       term1=0.0000;   } else {        term1 = (double)(srare * numsum)/(double)denom - 1.0;   }
-               if(term1 >= 0.0){       gamace = term1; } else {        gamace = 0.0;                                                                                   }
-               
-               if(gamace >= 0.64){
-                       gamace = gamace * (1 + (nrare * (1 - Cace) * numsum) / denom);
-                       if(gamace<0){                   gamace = 0;                     }
-               }
-       
-               if(Cace == 0.0){
-                       ace = 0.00;}//ace
-               else{
-                       ace = (double)sabund+((double)srare+(double)rank->get(1)*gamace)/Cace;//ace
-               }
-       
-               /*              
-               The following code was obtained from Anne Chao for calculating the SE for her ACE estimator                     
-               My modification was to reset the frequencies so that a singleton is found in rank[1] insted
-               of in rank[0], etc.
-               
-               I have also added the forumlae to calculate the 95% confidence intervals.
-               */
-       
-               double j,D_s=0,nn=0,ww=0;
-               int Max_Index=rank->getMaxRank()+1;
-               double pp, temp1, temp2;
-               vector<double> Part_N_Part_F(Max_Index+1,0.0);
-    
-               for (j=1; j<Max_Index; j++) if(j<=abund) D_s += rank->get(j);
-               for (j=1; j<Max_Index; j++){
-                       if(j<=abund){
-                               nn += rank->get(j) * j;
-                               ww += rank->get(j) * j * ( j - 1);
-                       }
-               }
-               double C_hat = 1.-rank->get(1)/double(nn);
-               double Gamma = ( D_s * ww) / ( C_hat * nn * ( nn - 1.)) - 1.; 
-               temp1 = double(nn - rank->get(1));
-               temp2 = double(nn - 1.); 
-       
-               if ( Gamma > 0.){
-                       Part_N_Part_F[1] =  ( D_s + nn) * ( 1. + rank->get(1) * ww / temp1 / temp2) / temp1 + nn * D_s * ww * ( temp1 - 1.) /
-                       ( temp1 * temp1 * temp2 * temp2) - ( nn + rank->get(1)) / temp1;
-                       for ( j=2; j<=Max_Index; j++){
-                               if(j<=abund){
-                                       Part_N_Part_F[j] = ( nn * temp1 - j * rank->get(1) * D_s) / temp1 / temp1 * ( 1. + rank->get(1) * ww / temp1 / temp2)
-                                       + j * rank->get(1) * D_s * nn * ( ( j - 1.) * temp1 * temp2 - ww * ( temp1 + temp2))
-                                       / temp1 / temp1 / temp1 / temp2 / temp2 + j * rank->get(1) * rank->get(1) / temp1 / temp1;
-                               }
-                       }
-               }
-               else{
-                       Part_N_Part_F[1] = ( nn + D_s ) / temp1;
-                       for ( j=2; j<=Max_Index; j++){
-                               if(j<=abund){
-                                       Part_N_Part_F[j-1] = ( nn * temp1 - j * rank->get(1) * D_s ) / temp1 / temp1;
-                               }
-                       }
-               }
-               if(Max_Index>abund){
-                       for ( j=abund+1; j<=Max_Index; j++){                            
-                               Part_N_Part_F[j-1] = 1.;        
-                       }
-               } 
-               for ( temp1=0., temp2=0., j=0; j<Max_Index; j++) {
-                       pp = Part_N_Part_F[j];
-                       temp1 += pp * rank->get(j);
-                       temp2 += pp * pp * rank->get(j);
-               }
-       
-               double se = temp2 - temp1 * temp1 / ace;
-       
-               if(toString(se) == "nan"){
-                       acelci = ace;
-                       acehci = ace;
-               }       
-               else if(ace==0.000){
-                       acelci = ace;
-                       acehci = ace;
-               }
-               else if(ace==sobs){
-                       double ci = 1.96*pow(se,0.5);
-                       acelci = ace-ci;                                        //ace lci
-                       acehci = ace+ci;                                        //ace hci
-               }else{
-                       double denom = pow(ace-sobs,2);
-                       double c = exp(1.96*pow((log(1+se/denom)),0.5));
-                       acelci = sobs+(ace-sobs)/c;                     //ace lci 
-                       acehci = sobs+(ace-sobs)*c;                     //ace hci
-               }
-               
-               data[0] = ace;
-               data[1] = acelci;
-               data[2] = acehci;       
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ace", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/ace.h b/ace.h
deleted file mode 100644 (file)
index ce56b76..0000000
--- a/ace.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef ACE_H
-#define ACE_H
-
-/*
- *  ace.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Ace estimator on a single group. 
-It is a child of the calculator class. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Ace : public Calculator  {
-       
-public:
-       Ace(int n) : abund(n), Calculator("ace", 3, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Ace"; }
-private:
-       int abund;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/aligncommand.cpp b/aligncommand.cpp
deleted file mode 100644 (file)
index 8215de3..0000000
+++ /dev/null
@@ -1,1041 +0,0 @@
-/*
- *  aligncommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/15/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- *     This version of nast does everything I think that the greengenes nast server does and then some.  I have added the 
- *     feature of allowing users to define their database, kmer size for searching, alignment penalty values and alignment 
- *     method.  This latter feature is perhaps most significant.  nastPlus enables a user to use either a Needleman-Wunsch 
- *     (non-affine gap penalty) or Gotoh (affine gap penalty) pairwise alignment algorithm.  This is significant because it
- *     allows for a global alignment and not the local alignment provided by bLAst.  Furthermore, it has the potential to
- *     provide a better alignment because of the banding method employed by blast (I'm not sure about this).
- *
- */
-
-#include "aligncommand.h"
-#include "referencedb.h"
-
-//**********************************************************************************************************************
-vector<string> AlignCommand::setParameters(){  
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pcandidate("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pcandidate);
-               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix", "kmer", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pksize("ksize", "Number", "", "8", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "",false,false); parameters.push_back(palign);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               CommandParameter pthreshold("threshold", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string AlignCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "The align.seqs command reads a file containing sequences and creates an alignment file and a report file.";
-               helpString += "The align.seqs command parameters are reference, fasta, search, ksize, align, match, mismatch, gapopen, gapextend and processors.";
-               helpString += "The reference and fasta parameters are required. You may leave fasta blank if you have a valid fasta file. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta.";
-               helpString += "The search parameter allows you to specify the method to find most similar template.  Your options are: suffix, kmer and blast. The default is kmer.";
-               helpString += "The align parameter allows you to specify the alignment method to use.  Your options are: gotoh, needleman, blast and noalign. The default is needleman.";
-               helpString += "The ksize parameter allows you to specify the kmer size for finding most similar template to candidate.  The default is 8.";
-               helpString += "The match parameter allows you to specify the bonus for having the same base. The default is 1.0.";
-               helpString += "The mistmatch parameter allows you to specify the penalty for having different bases.  The default is -1.0.";
-               helpString += "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.";
-               helpString += "The gapextend parameter allows you to specify the penalty for extending a gap in an alignment.  The default is -1.0.";
-               helpString += "The flip parameter is used to specify whether or not you want mothur to try the reverse complement if a sequence falls below the threshold.  The default is false.";
-               helpString += "The threshold is used to specify a cutoff at which an alignment is deemed 'bad' and the reverse complement may be tried. The default threshold is 0.50, meaning 50% of the bases are removed in the alignment.";
-               helpString += "If the flip parameter is set to true the reverse complement of the sequence is aligned and the better alignment is reported.";
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The default for the threshold parameter is 0.50, meaning at least 50% of the bases must remain or the sequence is reported as potentially reversed.";
-               helpString += "The align.seqs command should be in the following format:";
-               helpString += "align.seqs(reference=yourTemplateFile, fasta=yourCandidateFile, align=yourAlignmentMethod, search=yourSearchmethod, ksize=yourKmerSize, match=yourMatchBonus, mismatch=yourMismatchpenalty, gapopen=yourGapopenPenalty, gapextend=yourGapExtendPenalty)";
-               helpString += "Example align.seqs(candidate=candidate.fasta, template=core.filtered, align=kmer, search=gotoh, ksize=8, match=2.0, mismatch=3.0, gapopen=-2.0, gapextend=-1.0)";
-               helpString += "Note: No spaces between parameter labels (i.e. candidate), '=' and parameters (i.e.yourFastaFile).";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AlignCommand::AlignCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "AlignCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AlignCommand::AlignCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;  
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true;}
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter("align.seqs");
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-
-                               it = parameters.find("reference");
-
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                       }
-
-                       candidateFileName = validParameter.validFile(parameters, "fasta", false);
-                       if (candidateFileName == "not found") { 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { candidateFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the candidate parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(candidateFileName, candidateFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < candidateFileNames.size(); i++) {
-                                       //candidateFileNames[i] = m->getFullPathName(candidateFileNames[i]);
-                                       
-                                       bool ignore = false;
-                                       if (candidateFileNames[i] == "current") { 
-                                               candidateFileNames[i] = m->getFastaFile(); 
-                                               if (candidateFileNames[i] != "") {  m->mothurOut("Using " + candidateFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       candidateFileNames.erase(candidateFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(candidateFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       candidateFileNames[i] = inputDir + candidateFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               ableToOpen = m->openInputFile(candidateFileNames[i], in, "noerror");
-                                               in.close();     
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(candidateFileNames[i]);
-                                                               m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               candidateFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try output location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]);
-                                                               m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               candidateFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                                                               
-
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + candidateFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       candidateFileNames.erase(candidateFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(candidateFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (candidateFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "ksize", false);            if (temp == "not found"){       temp = "8";                             }
-                       m->mothurConvert(temp, kmerSize); 
-                       
-                       temp = validParameter.validFile(parameters, "match", false);            if (temp == "not found"){       temp = "1.0";                   }
-                       m->mothurConvert(temp, match);  
-                       
-                       temp = validParameter.validFile(parameters, "mismatch", false);         if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, misMatch);  
-                       
-                       temp = validParameter.validFile(parameters, "gapopen", false);          if (temp == "not found"){       temp = "-2.0";                  }
-                       m->mothurConvert(temp, gapOpen);  
-                       
-                       temp = validParameter.validFile(parameters, "gapextend", false);        if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, gapExtend); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       temp = validParameter.validFile(parameters, "flip", false);                     if (temp == "not found"){       temp = "f";                             }
-                       flip = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       templateFileName = validParameter.validFile(parameters, "reference", true);
-                       if (templateFileName == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templateFileName = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required for the align.seqs command."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (templateFileName == "not open") { abort = true; }     
-                       else {  if (save) {     rdb->setSavedReference(templateFileName);       }       }
-                       
-                       temp = validParameter.validFile(parameters, "threshold", false);        if (temp == "not found"){       temp = "0.50";                  }
-                       m->mothurConvert(temp, threshold); 
-                       
-                       search = validParameter.validFile(parameters, "search", false);         if (search == "not found"){     search = "kmer";                }
-                       if ((search != "suffix") && (search != "kmer") && (search != "blast")) { m->mothurOut("invalid search option: choices are kmer, suffix or blast."); m->mothurOutEndLine(); abort=true; }
-                       
-                       align = validParameter.validFile(parameters, "align", false);           if (align == "not found"){      align = "needleman";    }
-                       if ((align != "needleman") && (align != "gotoh") && (align != "blast") && (align != "noalign")) { m->mothurOut("invalid align option: choices are needleman, gotoh, blast or noalign."); m->mothurOutEndLine(); abort=true; }
-
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "AlignCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AlignCommand::~AlignCommand(){ 
-
-       if (abort == false) {
-               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-               delete templateDB;
-       }
-}
-//**********************************************************************************************************************
-
-int AlignCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, rand());
-               
-               for (int s = 0; s < candidateFileNames.size(); s++) {
-                       if (m->control_pressed) { outputTypes.clear(); return 0; }
-                       
-                       m->mothurOut("Aligning sequences from " + candidateFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       if (outputDir == "") {  outputDir += m->hasPath(candidateFileNames[s]); }
-                       string alignFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "align";
-                       string reportFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "align.report";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(candidateFileNames[s])) + "flip.accnos";
-                       bool hasAccnos = true;
-                       
-                       int numFastaSeqs = 0;
-                       for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                       int start = time(NULL);
-               
-#ifdef USE_MPI 
-                               int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                               MPIWroteAccnos = false;
-                       
-                               MPI_Status status; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-
-                               MPI_File inMPI;
-                               MPI_File outMPIAlign;
-                               MPI_File outMPIReport;
-                               MPI_File outMPIAccnos;
-                               
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                               
-                               char outAlignFilename[1024];
-                               strcpy(outAlignFilename, alignFileName.c_str());
-                               
-                               char outReportFilename[1024];
-                               strcpy(outReportFilename, reportFileName.c_str());
-                               
-                               char outAccnosFilename[1024];
-                               strcpy(outAccnosFilename, accnosFileName.c_str());
-                               
-                               char inFileName[1024];
-                               strcpy(inFileName, candidateFileNames[s].c_str());
-                               
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outAlignFilename, outMode, MPI_INFO_NULL, &outMPIAlign);
-                               MPI_File_open(MPI_COMM_WORLD, outReportFilename, outMode, MPI_INFO_NULL, &outMPIReport);
-                               MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-                               
-                               if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
-                               
-                               if (pid == 0) { //you are the root process 
-                                       
-                                       MPIPos = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numFastaSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numFastaSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-                                       
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIAlign, outMPIReport, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
-
-                                       for (int i = 1; i < processors; i++) {
-                                               bool tempResult;
-                                               MPI_Recv(&tempResult, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                               if (tempResult != 0) { MPIWroteAccnos = true; }
-                                       }
-                               }else{ //you are a child process
-                                       MPI_Recv(&numFastaSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numFastaSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numFastaSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-                                       
-                                       
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIAlign, outMPIReport, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIAlign);  MPI_File_close(&outMPIReport);  MPI_File_close(&outMPIAccnos); outputTypes.clear(); return 0; }
-
-                                       MPI_Send(&MPIWroteAccnos, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); 
-                               }
-                               
-                               //close files 
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPIAlign);
-                               MPI_File_close(&outMPIReport);
-                               MPI_File_close(&outMPIAccnos);
-                               
-                               //delete accnos file if blank
-                               if (pid == 0) {
-                                       //delete accnos file if its blank else report to user
-                                       if (MPIWroteAccnos) { 
-                                               m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
-                                               if (!flip) {
-                                                       m->mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well."); 
-                                               }else{  m->mothurOut(" If the reverse compliment proved to be better it was reported.");  }
-                                               m->mothurOutEndLine();
-                                       }else { 
-                                               //MPI_Info info;
-                                               //MPI_File_delete(outAccnosFilename, info);
-                                               hasAccnos = false;      
-                                               m->mothurRemove(accnosFileName); 
-                                       }
-                               }
-                               
-#else
-
-                       vector<unsigned long long> positions; 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       positions = m->divideFile(candidateFileNames[s], processors);
-                       for (int i = 0; i < (positions.size()-1); i++) {        lines.push_back(new linePair(positions[i], positions[(i+1)]));  }
-               #else
-                       if (processors == 1) {
-                               lines.push_back(new linePair(0, 1000));
-                       }else {
-                               positions = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs); 
-                               if (positions.size() < processors) { processors = positions.size(); }
-                
-                               //figure out how many sequences you have to process
-                               int numSeqsPerProcessor = numFastaSeqs / processors;
-                               for (int i = 0; i < processors; i++) {
-                                       int startIndex =  i * numSeqsPerProcessor;
-                                       if(i == (processors - 1)){      numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                                       lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
-                               }
-                       }
-               #endif
-                       
-                       if(processors == 1){
-                               numFastaSeqs = driver(lines[0], alignFileName, reportFileName, accnosFileName, candidateFileNames[s]);
-                       }else{
-                               numFastaSeqs = createProcesses(alignFileName, reportFileName, accnosFileName, candidateFileNames[s]); 
-                       }
-                               
-                       if (m->control_pressed) { m->mothurRemove(accnosFileName); m->mothurRemove(alignFileName); m->mothurRemove(reportFileName); outputTypes.clear();  return 0; }
-                       
-                       //delete accnos file if its blank else report to user
-                       if (m->isBlank(accnosFileName)) {  m->mothurRemove(accnosFileName);  hasAccnos = false; }
-                       else { 
-                               m->mothurOut("Some of you sequences generated alignments that eliminated too many bases, a list is provided in " + accnosFileName + ".");
-                               if (!flip) {
-                                       m->mothurOut(" If you set the flip parameter to true mothur will try aligning the reverse compliment as well."); 
-                               }else{  m->mothurOut(" If the reverse compliment proved to be better it was reported.");  }
-                               m->mothurOutEndLine();
-                       }
-
-#endif         
-
-
-               #ifdef USE_MPI
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-
-                       outputNames.push_back(alignFileName); outputTypes["fasta"].push_back(alignFileName);
-                       outputNames.push_back(reportFileName); outputTypes["alignreport"].push_back(reportFileName);
-                       if (hasAccnos)  {       outputNames.push_back(accnosFileName);  outputTypes["accnos"].push_back(accnosFileName);  }
-                       
-               #ifdef USE_MPI
-                       }
-               #endif
-
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to align " + toString(numFastaSeqs) + " sequences.");
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine();
-               }
-               
-               //set align file as new current fastafile
-               string currentFasta = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { currentFasta = (itTypes->second)[0]; m->setFastaFile(currentFasta); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int AlignCommand::driver(linePair* filePos, string alignFName, string reportFName, string accnosFName, string filename){
-       try {
-               ofstream alignmentFile;
-               m->openOutputFile(alignFName, alignmentFile);
-               
-               ofstream accnosFile;
-               m->openOutputFile(accnosFName, accnosFile);
-               
-               NastReport report(reportFName);
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-               
-               //moved this into driver to avoid deep copies in windows paralellized version
-               Alignment* alignment;
-               int longestBase = templateDB->getLongestBase();
-               if(align == "gotoh")                    {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-       
-               while (!done) {
-                       
-                       if (m->control_pressed) {  break; }
-                       
-                       Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
-                       report.setCandidate(candidateSeq);
-
-                       int origNumBases = candidateSeq->getNumBases();
-                       string originalUnaligned = candidateSeq->getUnaligned();
-                       int numBasesNeeded = origNumBases * threshold;
-       
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               if (candidateSeq->getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(candidateSeq->getUnaligned().length()+1);
-                               }
-                                                               
-                               Sequence temp = templateDB->findClosestSequence(candidateSeq);
-                               Sequence* templateSeq = &temp;
-                               
-                               float searchScore = templateDB->getSearchScore();
-                                                               
-                               Nast* nast = new Nast(alignment, candidateSeq, templateSeq);
-               
-                               Sequence* copy;
-                               
-                               Nast* nast2;
-                               bool needToDeleteCopy = false;  //this is needed in case you have you enter the ifs below
-                                                                                               //since nast does not make a copy of hte sequence passed, and it is used by the reporter below
-                                                                                               //you can't delete the copy sequence til after you report, but you may choose not to create it in the first place
-                                                                                               //so this bool tells you if you need to delete it
-                                                                                               
-                               //if there is a possibility that this sequence should be reversed
-                               if (candidateSeq->getNumBases() < numBasesNeeded) {
-                                       
-                                       string wasBetter =  "";
-                                       //if the user wants you to try the reverse
-                                       if (flip) {
-                               
-                                               //get reverse compliment
-                                               copy = new Sequence(candidateSeq->getName(), originalUnaligned);
-                                               copy->reverseComplement();
-                                               
-                                               //rerun alignment
-                                               Sequence temp2 = templateDB->findClosestSequence(copy);
-                                               Sequence* templateSeq2 = &temp2;
-                                               
-                                               searchScore = templateDB->getSearchScore();
-                                               
-                                               nast2 = new Nast(alignment, copy, templateSeq2);
-                       
-                                               //check if any better
-                                               if (copy->getNumBases() > candidateSeq->getNumBases()) {
-                                                       candidateSeq->setAligned(copy->getAligned());  //use reverse compliments alignment since its better
-                                                       templateSeq = templateSeq2; 
-                                                       delete nast;
-                                                       nast = nast2;
-                                                       needToDeleteCopy = true;
-                                                       wasBetter = "\treverse complement produced a better alignment, so mothur used the reverse complement.";
-                                               }else{  
-                                                       wasBetter = "\treverse complement did NOT produce a better alignment so it was not used, please check sequence.";
-                                                       delete nast2;
-                                                       delete copy;    
-                                               }
-                                       }
-                                       
-                                       //create accnos file with names
-                                       accnosFile << candidateSeq->getName() << wasBetter << endl;
-                               }
-                               
-                               report.setTemplate(templateSeq);
-                               report.setSearchParameters(search, searchScore);
-                               report.setAlignmentParameters(align, alignment);
-                               report.setNastParameters(*nast);
-       
-                               alignmentFile << '>' << candidateSeq->getName() << '\n' << candidateSeq->getAligned() << endl;
-                               
-                               report.print();
-                               delete nast;
-                               if (needToDeleteCopy) {   delete copy;   }
-                               
-                               count++;
-                       }
-                       delete candidateSeq;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-                       
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               
-               delete alignment;
-               alignmentFile.close();
-               inFASTA.close();
-               accnosFile.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& alignFile, MPI_File& reportFile, MPI_File& accnosFile, vector<unsigned long long>& MPIPos){
-       try {
-               string outputString = "";
-               MPI_Status statusReport; 
-               MPI_Status statusAlign; 
-               MPI_Status statusAccnos; 
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-       
-               NastReport report;
-               
-               if (pid == 0) {
-                       outputString = report.getHeaders();
-                       int length = outputString.length();
-            
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-               
-                       MPI_File_write_shared(reportFile, buf, length, MPI_CHAR, &statusReport);
-
-            delete buf;
-               }
-               
-               Alignment* alignment;
-               int longestBase = templateDB->getLongestBase();
-               if(align == "gotoh")                    {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-               
-               
-               for(int i=0;i<num;i++){
-               
-                       if (m->control_pressed) { delete alignment; return 0; }
-
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-
-                       char* buf4 = new char[length];
-                       //memcpy(buf4, outputString.c_str(), length);
-
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-
-                       delete buf4;
-
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-       
-                       istringstream iss (tempBuf,istringstream::in);
-
-                       Sequence* candidateSeq = new Sequence(iss);  
-                       report.setCandidate(candidateSeq);
-
-                       int origNumBases = candidateSeq->getNumBases();
-                       string originalUnaligned = candidateSeq->getUnaligned();
-                       int numBasesNeeded = origNumBases * threshold;
-       
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               if (candidateSeq->getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(candidateSeq->getUnaligned().length()+1);
-                               }
-                                                               
-                               Sequence temp = templateDB->findClosestSequence(candidateSeq);
-                               Sequence* templateSeq = &temp;
-                               
-                               float searchScore = templateDB->getSearchScore();
-                                                               
-                               Nast* nast = new Nast(alignment, candidateSeq, templateSeq);
-                               Sequence* copy;
-                               
-                               Nast* nast2;
-                               bool needToDeleteCopy = false;  //this is needed in case you have you enter the ifs below
-                                                                                               //since nast does not make a copy of hte sequence passed, and it is used by the reporter below
-                                                                                               //you can't delete the copy sequence til after you report, but you may choose not to create it in the first place
-                                                                                               //so this bool tells you if you need to delete it
-                                                                                               
-                               //if there is a possibility that this sequence should be reversed
-                               if (candidateSeq->getNumBases() < numBasesNeeded) {
-                                       
-                                       string wasBetter = "";
-                                       //if the user wants you to try the reverse
-                                       if (flip) {
-                                               //get reverse compliment
-                                               copy = new Sequence(candidateSeq->getName(), originalUnaligned);
-                                               copy->reverseComplement();
-                                               
-                                               //rerun alignment
-                                               Sequence temp2 = templateDB->findClosestSequence(copy);
-                                               Sequence* templateSeq2 = &temp2;
-                                               
-                                               searchScore = templateDB->getSearchScore();
-                                               
-                                               nast2 = new Nast(alignment, copy, templateSeq2);
-                       
-                                               //check if any better
-                                               if (copy->getNumBases() > candidateSeq->getNumBases()) {
-                                                       candidateSeq->setAligned(copy->getAligned());  //use reverse compliments alignment since its better
-                                                       templateSeq = templateSeq2; 
-                                                       delete nast;
-                                                       nast = nast2;
-                                                       needToDeleteCopy = true;
-                                                       wasBetter = "\treverse complement produced a better alignment, so mothur used the reverse complement.";
-                                               }else{  
-                                                       wasBetter = "\treverse complement did NOT produce a better alignment, please check sequence.";
-                                                       delete nast2;
-                                                       delete copy;    
-                                               }
-                                       }
-                                       
-                                       //create accnos file with names
-                                       outputString = candidateSeq->getName() + wasBetter + "\n";
-                                       
-                                       //send results to parent
-                                       int length = outputString.length();
-
-                                       char* buf = new char[length];
-                                       memcpy(buf, outputString.c_str(), length);
-                               
-                                       MPI_File_write_shared(accnosFile, buf, length, MPI_CHAR, &statusAccnos);
-                                       delete buf;
-                                       MPIWroteAccnos = true;
-                               }
-                               
-                               report.setTemplate(templateSeq);
-                               report.setSearchParameters(search, searchScore);
-                               report.setAlignmentParameters(align, alignment);
-                               report.setNastParameters(*nast);
-       
-                               outputString =  ">" + candidateSeq->getName() + "\n" + candidateSeq->getAligned() + "\n";
-                               
-                               //send results to parent
-                               int length = outputString.length();
-                               char* buf2 = new char[length];
-                               memcpy(buf2, outputString.c_str(), length);
-                               
-                               MPI_File_write_shared(alignFile, buf2, length, MPI_CHAR, &statusAlign);
-                               
-                               delete buf2;
-
-                               outputString = report.getReport();
-                               
-                               //send results to parent
-                               length = outputString.length();
-                               char* buf3 = new char[length];
-                               memcpy(buf3, outputString.c_str(), length);
-                               
-                               MPI_File_write_shared(reportFile, buf3, length, MPI_CHAR, &statusReport);
-                               
-                               delete buf3;
-                               delete nast;
-                               if (needToDeleteCopy) {   delete copy;   }
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((i+1) % 100 == 0){   cout << (toString(i+1)) << endl;                }
-               }
-               //report progress
-               if((num) % 100 != 0){   cout << (toString(num)) << endl;                }
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-
-int AlignCommand::createProcesses(string alignFileName, string reportFileName, string accnosFName, string filename) {
-       try {
-               int num = 0;
-               processIDS.resize(0);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], alignFileName + toString(getpid()) + ".temp", reportFileName + toString(getpid()) + ".temp", accnosFName + toString(getpid()) + ".temp", filename);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = alignFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driver(lines[0], alignFileName, reportFileName, accnosFName, filename);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               vector<string> nonBlankAccnosFiles;
-               if (!(m->isBlank(accnosFName))) { nonBlankAccnosFiles.push_back(accnosFName); }
-               else { m->mothurRemove(accnosFName); } //remove so other files can be renamed to it
-                       
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  alignFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-                       
-                       appendAlignFiles((alignFileName + toString(processIDS[i]) + ".temp"), alignFileName);
-                       m->mothurRemove((alignFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       appendReportFiles((reportFileName + toString(processIDS[i]) + ".temp"), reportFileName);
-                       m->mothurRemove((reportFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       if (!(m->isBlank(accnosFName + toString(processIDS[i]) + ".temp"))) {
-                               nonBlankAccnosFiles.push_back(accnosFName + toString(processIDS[i]) + ".temp");
-                       }else { m->mothurRemove((accnosFName + toString(processIDS[i]) + ".temp"));  }
-                       
-               }
-               
-               //append accnos files
-               if (nonBlankAccnosFiles.size() != 0) { 
-                       rename(nonBlankAccnosFiles[0].c_str(), accnosFName.c_str());
-                       
-                       for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
-                               appendAlignFiles(nonBlankAccnosFiles[h], accnosFName);
-                               m->mothurRemove(nonBlankAccnosFiles[h]);
-                       }
-               }else { //recreate the accnosfile if needed
-                       ofstream out;
-                       m->openOutputFile(accnosFName, out);
-                       out.close();
-               }
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the alignData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<alignData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       //copy templateDb
-                       //AlignmentDB* tempDB = new AlignmentDB(*templateDB);
-                       
-                       // Allocate memory for thread data.
-                       string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; }
-                       
-                       alignData* tempalign = new alignData(templateFileName, (alignFileName + extension), (reportFileName + extension), (accnosFName + extension), filename, align, search, kmerSize, m, lines[i]->start, lines[i]->end, flip, match, misMatch, gapOpen, gapExtend, threshold, i);
-                       pDataArray.push_back(tempalign);
-                       processIDS.push_back(i);
-                               
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MyAlignThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-               //need to check for line ending error
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-               inFASTA.seekg(lines[processors-1]->start-1);
-               char c = inFASTA.peek();
-               
-               if (c != '>') { //we need to move back
-                       lines[processors-1]->start--; 
-               }
-               
-               //using the main process as a worker saves time and memory
-               //do my part - do last piece because windows is looking for eof
-               num = driver(lines[processors-1], (alignFileName + toString(processors-1) + ".temp"), (reportFileName + toString(processors-1) + ".temp"), (accnosFName + toString(processors-1) + ".temp"), filename);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-               vector<string> nonBlankAccnosFiles;
-               if (!(m->isBlank(accnosFName))) { nonBlankAccnosFiles.push_back(accnosFName); }
-               else { m->mothurRemove(accnosFName); } //remove so other files can be renamed to it
-               
-               for (int i = 1; i < processors; i++) {
-                       appendAlignFiles((alignFileName + toString(i) + ".temp"), alignFileName);
-                       m->mothurRemove((alignFileName + toString(i) + ".temp"));
-                       
-                       appendReportFiles((reportFileName + toString(i) + ".temp"), reportFileName);
-                       m->mothurRemove((reportFileName + toString(i) + ".temp"));
-                       
-                       if (!(m->isBlank(accnosFName + toString(i) + ".temp"))) {
-                               nonBlankAccnosFiles.push_back(accnosFName + toString(i) + ".temp");
-                       }else { m->mothurRemove((accnosFName + toString(i) + ".temp"));  }
-               }
-               
-               //append accnos files
-               if (nonBlankAccnosFiles.size() != 0) { 
-                       rename(nonBlankAccnosFiles[0].c_str(), accnosFName.c_str());
-                       
-                       for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
-                               appendAlignFiles(nonBlankAccnosFiles[h], accnosFName);
-                               m->mothurRemove(nonBlankAccnosFiles[h]);
-                       }
-               }else { //recreate the accnosfile if needed
-                       ofstream out;
-                       m->openOutputFile(accnosFName, out);
-                       out.close();
-               }       
-#endif 
-               
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void AlignCommand::appendAlignFiles(string temp, string filename) {
-       try{
-               
-               ofstream output;
-               ifstream input;
-               m->openOutputFileAppend(filename, output);
-               m->openInputFile(temp, input);
-               
-               while(char c = input.get()){
-                       if(input.eof())         {       break;                  }
-                       else                            {       output << c;    }
-               }
-               
-               input.close();
-               output.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "appendAlignFiles");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-void AlignCommand::appendReportFiles(string temp, string filename) {
-       try{
-               
-               ofstream output;
-               ifstream input;
-               m->openOutputFileAppend(filename, output);
-               m->openInputFile(temp, input);
-
-               while (!input.eof())    {       char c = input.get(); if (c == 10 || c == 13){  break;  }       } // get header line
-                               
-               while(char c = input.get()){
-                       if(input.eof())         {       break;                  }
-                       else                            {       output << c;    }
-               }
-               
-               input.close();
-               output.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "appendReportFiles");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/aligncommand.h b/aligncommand.h
deleted file mode 100644 (file)
index 5da7a1f..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-#ifndef ALIGNCOMMAND_H
-#define ALIGNCOMMAND_H
-//test
-/*
- *  aligncommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/15/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "database.hpp"
-#include "alignment.hpp"
-#include "alignmentdb.h"
-#include "sequence.hpp"
-
-#include "gotohoverlap.hpp"
-#include "needlemanoverlap.hpp"
-#include "blastalign.hpp"
-#include "noalign.hpp"
-
-#include "nast.hpp"
-#include "nastreport.hpp"
-
-//test
-class AlignCommand : public Command {
-       
-public:
-       AlignCommand(string);   
-       AlignCommand();
-       ~AlignCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "align.seqs";                  }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "DeSantis TZ, Jr., Hugenholtz P, Keller K, Brodie EL, Larsen N, Piceno YM, Phan R, Andersen GL (2006). NAST: a multiple sequence alignment server for comparative analysis of 16S rRNA genes. Nucleic Acids Res 34: W394-9.\nSchloss PD (2009). A high-throughput DNA sequence aligner for microbial ecology studies. PLoS ONE 4: e8230.\nSchloss PD (2010). The effects of alignment quality, distance calculation method, sequence filtering, and region on the analysis of 16S rRNA gene-based studies. PLoS Comput Biol 6: e1000844.\nhttp://www.mothur.org/wiki/Align.seqs http://www.mothur.org/wiki/Align.seqs"; }
-       string getDescription()         { return "align sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-       bool MPIWroteAccnos;
-       
-       AlignmentDB* templateDB;
-       
-       int driver(linePair*, string, string, string, string);
-       int createProcesses(string, string, string, string);
-       void appendAlignFiles(string, string); 
-       void appendReportFiles(string, string);
-       
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&);
-       #endif
-       
-       string candidateFileName, templateFileName, distanceFileName, search, align, outputDir;
-       float match, misMatch, gapOpen, gapExtend, threshold;
-       int processors, kmerSize;
-       vector<string> candidateFileNames;
-       vector<string> outputNames;
-       
-       bool abort, flip, calledHelp, save;
-
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct alignData {
-       string templateFileName;
-       string alignFName; 
-       string reportFName; 
-       string accnosFName;
-       string filename;
-       string align;
-       string search;
-       bool flip;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       //AlignmentDB* templateDB;
-       float match, misMatch, gapOpen, gapExtend, threshold;
-       int count, kmerSize, threadID;
-       
-       alignData(){}
-       alignData(string te, string a, string r, string ac, string f, string al, string se, int ks, MothurOut* mout, unsigned long long st, unsigned long long en, bool fl, float ma, float misMa, float gapO, float gapE, float thr, int tid) {
-               templateFileName = te;
-               alignFName = a;
-               reportFName = r;
-               accnosFName = ac;
-               filename = f;
-               flip = fl;
-               m = mout;
-               start = st;
-               end = en;
-               //templateDB = tdb;
-               match = ma; 
-               misMatch = misMa;
-               gapOpen = gapO; 
-               gapExtend = gapE; 
-               threshold = thr;
-               align = al;
-               search = se;
-               count = 0;
-               kmerSize = ks;
-               threadID = tid;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyAlignThreadFunction(LPVOID lpParam){ 
-       alignData* pDataArray;
-       pDataArray = (alignData*)lpParam;
-       
-       try {
-               ofstream alignmentFile;
-               pDataArray->m->openOutputFile(pDataArray->alignFName, alignmentFile);
-               
-               ofstream accnosFile;
-               pDataArray->m->openOutputFile(pDataArray->accnosFName, accnosFile);
-               
-               NastReport report(pDataArray->reportFName);
-               
-               ifstream inFASTA;
-               pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
-               
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       inFASTA.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               
-               AlignmentDB* templateDB = new AlignmentDB(pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->threadID);
-               
-               //moved this into driver to avoid deep copies in windows paralellized version
-               Alignment* alignment;
-               int longestBase = templateDB->getLongestBase();
-               if(pDataArray->align == "gotoh")                        {       alignment = new GotohOverlap(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, longestBase);                 }
-               else if(pDataArray->align == "needleman")       {       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, longestBase);                            }
-               else if(pDataArray->align == "blast")           {       alignment = new BlastAlignment(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch);            }
-               else if(pDataArray->align == "noalign")         {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       pDataArray->m->mothurOut(pDataArray->align + " is not a valid alignment option. I will run the command using needleman.");
-                       pDataArray->m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, longestBase);
-               }
-               
-               int count = 0;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) {  break; }
-                       
-                       Sequence* candidateSeq = new Sequence(inFASTA);  pDataArray->m->gobble(inFASTA);
-                       report.setCandidate(candidateSeq);
-                       
-                       int origNumBases = candidateSeq->getNumBases();
-                       string originalUnaligned = candidateSeq->getUnaligned();
-                       int numBasesNeeded = origNumBases * pDataArray->threshold;
-                       
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               if (candidateSeq->getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(candidateSeq->getUnaligned().length()+1);
-                               }
-                               
-                               Sequence temp = templateDB->findClosestSequence(candidateSeq);
-                               Sequence* templateSeq = &temp;
-                               
-                               float searchScore = templateDB->getSearchScore();
-                               
-                               Nast* nast = new Nast(alignment, candidateSeq, templateSeq);
-                               
-                               Sequence* copy;
-                               
-                               Nast* nast2;
-                               bool needToDeleteCopy = false;  //this is needed in case you have you enter the ifs below
-                               //since nast does not make a copy of hte sequence passed, and it is used by the reporter below
-                               //you can't delete the copy sequence til after you report, but you may choose not to create it in the first place
-                               //so this bool tells you if you need to delete it
-                               
-                               //if there is a possibility that this sequence should be reversed
-                               if (candidateSeq->getNumBases() < numBasesNeeded) {
-                                       
-                                       string wasBetter =  "";
-                                       //if the user wants you to try the reverse
-                                       if (pDataArray->flip) {
-                                               
-                                               //get reverse compliment
-                                               copy = new Sequence(candidateSeq->getName(), originalUnaligned);
-                                               copy->reverseComplement();
-                                               
-                                               //rerun alignment
-                                               Sequence temp2 = templateDB->findClosestSequence(copy);
-                                               Sequence* templateSeq2 = &temp2;
-                                               
-                                               searchScore = templateDB->getSearchScore();
-                                               
-                                               nast2 = new Nast(alignment, copy, templateSeq2);
-                                               
-                                               //check if any better
-                                               if (copy->getNumBases() > candidateSeq->getNumBases()) {
-                                                       candidateSeq->setAligned(copy->getAligned());  //use reverse compliments alignment since its better
-                                                       templateSeq = templateSeq2; 
-                                                       delete nast;
-                                                       nast = nast2;
-                                                       needToDeleteCopy = true;
-                                                       wasBetter = "\treverse complement produced a better alignment, so mothur used the reverse complement.";
-                                               }else{  
-                                                       wasBetter = "\treverse complement did NOT produce a better alignment so it was not used, please check sequence.";
-                                                       delete nast2;
-                                                       delete copy;    
-                                               }
-                                       }
-                                       
-                                       //create accnos file with names
-                                       accnosFile << candidateSeq->getName() << wasBetter << endl;
-                               }
-                               
-                               report.setTemplate(templateSeq);
-                               report.setSearchParameters(pDataArray->search, searchScore);
-                               report.setAlignmentParameters(pDataArray->align, alignment);
-                               report.setNastParameters(*nast);
-                               
-                               alignmentFile << '>' << candidateSeq->getName() << '\n' << candidateSeq->getAligned() << endl;
-                               
-                               report.print();
-                               delete nast;
-                               if (needToDeleteCopy) {   delete copy;   }
-                               
-                               count++;
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((count) % 100 == 0){ pDataArray->m->mothurOut(toString(count)); pDataArray->m->mothurOutEndLine();           }
-                       
-               }
-               //report progress
-               if((count) % 100 != 0){ pDataArray->m->mothurOut(toString(count)); pDataArray->m->mothurOutEndLine();           }
-               
-               delete alignment;
-               delete templateDB;
-               alignmentFile.close();
-               inFASTA.close();
-               accnosFile.close();
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "AlignCommand", "MyAlignThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-
-#endif
diff --git a/alignment.cpp b/alignment.cpp
deleted file mode 100644 (file)
index 235216e..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- *  alignment.cpp
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *  This is a class for an abstract datatype for classes that implement various types of alignment     algorithms.
- *     As of 12/18/08 these included alignments based on blastn, needleman-wunsch, and the     Gotoh algorithms
- *  
- */
-
-#include "alignmentcell.hpp"
-#include "alignment.hpp"
-
-
-/**************************************************************************************************/
-
-Alignment::Alignment() {       /*      do nothing      */      }
-
-/**************************************************************************************************/
-
-Alignment::Alignment(int A) : nCols(A), nRows(A) {
-       try {
-               m = MothurOut::getInstance();
-               alignment.resize(nRows);                        //      For the Gotoh and Needleman-Wunsch we initialize the dynamic programming
-               for(int i=0;i<nRows;i++){                       //      matrix by initializing a matrix that is A x A.  By default we will set A
-                       alignment[i].resize(nCols);             //      at 2000 for 16S rRNA gene sequences
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Alignment", "Alignment");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Alignment::resize(int A) {
-       try {
-               nCols = A;
-               nRows = A;
-
-               alignment.resize(nRows);                        
-               for(int i=0;i<nRows;i++){                       
-                       alignment[i].resize(nCols);             
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Alignment", "resize");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void Alignment::traceBack(){                   //      This traceback routine is used by the dynamic programming algorithms
-       try {   
-                                                                       //      to fill the values of seqAaln and seqBaln
-               seqAaln = "";
-               seqBaln = "";
-               int row = lB-1;
-               int column = lA-1;
-               //      seqAstart = 1;
-               //      seqAend = column;
-               
-               AlignmentCell currentCell = alignment[row][column];     //      Start the traceback from the bottom-right corner of the
-               //      matrix
-               
-               if(currentCell.prevCell == 'x'){        seqAaln = seqBaln = "NOALIGNMENT";              }//If there's an 'x' in the bottom-
-               else{                                                                                           //      right corner bail out because it means nothing got aligned
-                       while(currentCell.prevCell != 'x'){                             //      while the previous cell isn't an 'x', keep going...
-                               
-                               if(currentCell.prevCell == 'u'){                        //      if the pointer to the previous cell is 'u', go up in the
-                                       seqAaln = '-' + seqAaln;                                //      matrix.  this indicates that we need to insert a gap in
-                                       seqBaln = seqB[row] + seqBaln;                  //      seqA and a base in seqB
-                                       currentCell = alignment[--row][column];
-                               }
-                               else if(currentCell.prevCell == 'l'){           //      if the pointer to the previous cell is 'l', go to the left
-                                       seqBaln = '-' + seqBaln;                                //      in the matrix.  this indicates that we need to insert a gap
-                                       seqAaln = seqA[column] + seqAaln;               //      in seqB and a base in seqA
-                                       currentCell = alignment[row][--column];
-                               }
-                               else{
-                                       seqAaln = seqA[column] + seqAaln;               //      otherwise we need to go diagonally up and to the left,
-                                       seqBaln = seqB[row] + seqBaln;                  //      here we add a base to both alignments
-                                       currentCell = alignment[--row][--column];
-                               }
-                       }
-               }
-               
-               pairwiseLength = seqAaln.length();
-               seqAstart = 1;  seqAend = 0;
-               seqBstart = 1;  seqBend = 0;
-               
-               for(int i=0;i<seqAaln.length();i++){
-                       if(seqAaln[i] != '-' && seqBaln[i] == '-')              {       seqAstart++;    }
-                       else if(seqAaln[i] == '-' && seqBaln[i] != '-') {       seqBstart++;    }
-                       else                                                                                    {       break;                  }
-               }
-               
-               pairwiseLength -= (seqAstart + seqBstart - 2);
-               
-               for(int i=seqAaln.length()-1; i>=0;i--){
-                       if(seqAaln[i] != '-' && seqBaln[i] == '-')              {       seqAend++;              }
-                       else if(seqAaln[i] == '-' && seqBaln[i] != '-') {       seqBend++;              }
-                       else                                                                                    {       break;                  }
-               }
-               pairwiseLength -= (seqAend + seqBend);
-               
-               seqAend = seqA.length() - seqAend - 1;
-               seqBend = seqB.length() - seqBend - 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Alignment", "traceBack");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-Alignment::~Alignment(){
-       try {
-               for (int i = 0; i < alignment.size(); i++) {
-                       for (int j = (alignment[i].size()-1); j >= 0; j--) {  alignment[i].pop_back();  }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Alignment", "~Alignment");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string Alignment::getSeqAAln(){
-       return seqAaln;                                                                         //      this is called to get the alignment of seqA
-}
-
-/**************************************************************************************************/
-
-string Alignment::getSeqBAln(){
-       return seqBaln;                                                                         //      this is called to get the alignment of seqB                                                     
-}
-
-/**************************************************************************************************/
-
-int Alignment::getCandidateStartPos(){
-       return seqAstart;                                                                       //      this is called to report the quality of the alignment
-}
-
-/**************************************************************************************************/
-
-int Alignment::getCandidateEndPos(){
-       return seqAend;                                                                         //      this is called to report the quality of the alignment
-}
-
-/**************************************************************************************************/
-
-int Alignment::getTemplateStartPos(){
-       return seqBstart;                                                                       //      this is called to report the quality of the alignment
-}
-
-/**************************************************************************************************/
-
-int Alignment::getTemplateEndPos(){
-       return seqBend;                                                                         //      this is called to report the quality of the alignment
-}
-
-/**************************************************************************************************/
-
-int Alignment::getPairwiseLength(){
-       return pairwiseLength;                                                          //      this is the pairwise alignment length
-}
-
-/**************************************************************************************************/
-
-//int Alignment::getLongestTemplateGap(){
-//
-//     int length = seqBaln.length();
-//     int longGap = 0;
-//     int gapLength = 0;
-//     
-//     int start = seqAstart;
-//     if(seqAstart < seqBstart){      start = seqBstart;      }
-//     for(int i=seqAstart;i<length;i++){
-//             if(seqBaln[i] == '-'){
-//                     gapLength++;
-//             }
-//             else{
-//                     if(gapLength > 0){
-//                             if(gapLength > longGap){        longGap = gapLength;    }
-//                     }
-//                     gapLength = 0;
-//             }
-//     }
-//     return longGap;
-//}
-
-/**************************************************************************************************/
diff --git a/alignment.hpp b/alignment.hpp
deleted file mode 100644 (file)
index 7a943fd..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef DPALIGNMENT_H
-#define DPALIGNMENT_H
-
-/*
- *  dpalignment.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *  This is a class for an abstract datatype for classes that implement various types of alignment     algorithms.
- *     As of 12/18/08 these included alignments based on blastn, needleman-wunsch, and the     Gotoh algorithms
- * 
- */
-
-#include "mothur.h"
-#include "alignmentcell.hpp"
-
-/**************************************************************************************************/
-
-class Alignment {
-       
-public:
-       Alignment(int);
-       Alignment();
-       virtual ~Alignment();
-       virtual void align(string, string) = 0;
-       
-       
-//     float getAlignmentScore();
-       string getSeqAAln();
-       string getSeqBAln();
-       int getCandidateStartPos();
-       int getCandidateEndPos();
-       int getTemplateStartPos();
-       int getTemplateEndPos();
-       
-       int getPairwiseLength();
-       void resize(int);
-       int getnRows() { return nRows; }
-//     int getLongestTemplateGap();
-
-protected:
-       void traceBack();
-       string seqA, seqAaln;
-       string seqB, seqBaln;
-       int seqAstart, seqAend;
-       int seqBstart, seqBend;
-       int pairwiseLength;
-       int nRows, nCols, lA, lB;
-       vector<vector<AlignmentCell> > alignment;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/alignmentcell.cpp b/alignmentcell.cpp
deleted file mode 100644 (file)
index 72bcb31..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- *  alignmentcell.cpp
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is pretty basic.  Each AlignmentCell object contains a pointer to the previous cell and different values
- *     used to calcualte the alignment.  Initially everything is set to zero and all pointers are set to 'x'
- *  
- */
-
-#include "alignmentcell.hpp"
-
-//********************************************************************************************************************
-
-AlignmentCell::AlignmentCell() : prevCell('x'), cValue(0.0000), dValue(0.0000), iValue(0.0000) {}
-
-//********************************************************************************************************************
diff --git a/alignmentcell.hpp b/alignmentcell.hpp
deleted file mode 100644 (file)
index 569198f..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef ALIGNMENTCELL_H
-#define ALIGNMENTCELL_H
-
-/*
- *  alignmentcell.hpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is pretty basic.  Each AlignmentCell object contains a pointer to the previous cell and different values
- *     used to calcualte the alignment.  Initially everything is set to zero and all pointers are set to 'x'
- *  
- */
-#include "mothurout.h"
-//********************************************************************************************************************
-
-class AlignmentCell {
-       
-public:
-       AlignmentCell();
-       char prevCell;
-       float cValue;
-       float dValue;
-       float iValue;
-};
-
-//********************************************************************************************************************
-
-#endif
diff --git a/alignmentdb.cpp b/alignmentdb.cpp
deleted file mode 100644 (file)
index f59c5db..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- *  alignmentdb.cpp
- *  Mothur
- *
- *  Created by westcott on 11/4/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "alignmentdb.h"
-#include "kmerdb.hpp"
-#include "suffixdb.hpp"
-#include "blastdb.hpp"
-#include "referencedb.h"
-
-/**************************************************************************************************/
-AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int tid){          //      This assumes that the template database is in fasta format, may 
-       try {                                                                                   //      need to alter this in the future?
-               m = MothurOut::getInstance();
-               longest = 0;
-               method = s;
-               bool needToGenerate = true;
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               bool silent = false;
-               threadID = tid;
-               
-               if (fastaFileName == "saved-silent") {
-                       fastaFileName = "saved"; silent = true;
-               }
-               
-               if (fastaFileName == "saved") {
-                       int start = time(NULL);
-                       
-                       if (!silent) { m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + " that are saved in memory."); m->mothurOutEndLine(); }
-
-                       for (int i = 0; i < rdb->referenceSeqs.size(); i++) {
-                               templateSequences.push_back(rdb->referenceSeqs[i]);
-                               //save longest base
-                               if (rdb->referenceSeqs[i].getUnaligned().length() >= longest)  { longest = (rdb->referenceSeqs[i].getUnaligned().length()+1); }
-                       }
-                       fastaFileName = rdb->getSavedReference();
-                       
-                       numSeqs = templateSequences.size();
-                       if (!silent) { m->mothurOut("It took " + toString(time(NULL) - start) + " to load " + toString(rdb->referenceSeqs.size()) + " sequences.");m->mothurOutEndLine();  }
-
-               }else {
-                       int start = time(NULL);
-                       m->mothurOutEndLine();
-                       m->mothurOut("Reading in the " + fastaFileName + " template sequences...\t");   cout.flush();
-                       
-                       #ifdef USE_MPI  
-                               int pid, processors;
-                               vector<unsigned long long> positions;
-                       
-                               MPI_Status status; 
-                               MPI_File inMPI;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               int tag = 2001;
-               
-                               char inFileName[1024];
-                               strcpy(inFileName, fastaFileName.c_str());
-               
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               
-                               if (pid == 0) {
-                                       positions = m->setFilePosFasta(fastaFileName, numSeqs); //fills MPIPos, returns numSeqs
-
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&positions[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                               }else{
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       positions.resize(numSeqs+1);
-                                       MPI_Recv(&positions[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                               }
-                       
-                               //read file 
-                               for(int i=0;i<numSeqs;i++){
-                                       
-                                       if (m->control_pressed) {  templateSequences.clear(); break;  }
-                                       
-                                       //read next sequence
-                                       int length = positions[i+1] - positions[i];
-                                       char* buf4 = new char[length];
-                               
-                                       MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
-                       
-                                       string tempBuf = buf4;
-                                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                                       delete buf4;
-
-                                       istringstream iss (tempBuf,istringstream::in);
-                       
-                                       Sequence temp(iss);  
-                                       if (temp.getName() != "") {
-                                               templateSequences.push_back(temp);
-                                               
-                                               if (rdb->save) { rdb->referenceSeqs.push_back(temp); }
-                                               
-                                               //save longest base
-                                               if (temp.getUnaligned().length() >= longest)  { longest = temp.getUnaligned().length()+1; }
-                                       }
-                               }
-                               
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               
-                               MPI_File_close(&inMPI);
-                       
-               #else
-                       ifstream fastaFile;
-                       m->openInputFile(fastaFileName, fastaFile);
-
-                       while (!fastaFile.eof()) {
-                               Sequence temp(fastaFile);  m->gobble(fastaFile);
-                               
-                               if (m->control_pressed) {  templateSequences.clear(); break;  }
-                               
-                               if (temp.getName() != "") {
-                                       templateSequences.push_back(temp);
-                                       
-                                       if (rdb->save) { rdb->referenceSeqs.push_back(temp); }
-                                       
-                                       //save longest base
-                                       if (temp.getUnaligned().length() >= longest)  { longest = (temp.getUnaligned().length()+1); }
-                               }
-                       }
-                       fastaFile.close();
-               #endif
-               
-                       numSeqs = templateSequences.size();
-                       //all of this is elsewhere already!
-                       
-                       m->mothurOut("DONE.");
-                       m->mothurOutEndLine();  cout.flush();
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " to read  " + toString(templateSequences.size()) + " sequences."); m->mothurOutEndLine();  
-
-               }
-               
-               
-               //in case you delete the seqs and then ask for them
-               emptySequence = Sequence();
-               emptySequence.setName("no_match");
-               emptySequence.setUnaligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
-               emptySequence.setAligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
-               
-               
-               string kmerDBName;
-               if(method == "kmer")                    {       
-                       search = new KmerDB(fastaFileName, kmerSize);                   
-                       
-                       #ifdef USE_MPI
-                       #else
-                               kmerDBName = fastaFileName.substr(0,fastaFileName.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               
-                               if(kmerFileTest){       
-                                       bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
-                                       if (GoodFile) {  needToGenerate = false;        }
-                               }
-                       #endif
-               }
-               else if(method == "suffix")             {       search = new SuffixDB(numSeqs);                                                         }
-               else if(method == "blast")              {       search = new BlastDB(fastaFileName.substr(0,fastaFileName.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID);     }
-               else {
-                       method = "kmer";
-                       m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
-                       m->mothurOutEndLine();
-                       search = new KmerDB(fastaFileName, 8);
-               }
-               
-               if (!(m->control_pressed)) {
-                       if (needToGenerate) {
-                               //add sequences to search 
-                               for (int i = 0; i < templateSequences.size(); i++) {
-                                       search->addSequence(templateSequences[i]);
-                                       
-                                       if (m->control_pressed) {  templateSequences.clear(); break;  }
-                               }
-                               
-                               if (m->control_pressed) {  templateSequences.clear();  }
-                               
-                               search->generateDB();
-                               
-                       }else if ((method == "kmer") && (!needToGenerate)) {
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               search->readKmerDB(kmerFileTest);       
-                       }
-               
-                       search->setNumSeqs(numSeqs);
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignmentDB", "AlignmentDB");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-AlignmentDB::AlignmentDB(string s){             
-       try {                                                                                   
-               m = MothurOut::getInstance();
-               method = s;
-               
-               if(method == "suffix")          {       search = new SuffixDB();        }
-               else if(method == "blast")      {       search = new BlastDB("", 0);            }
-               else                                            {       search = new KmerDB();          }
-
-                               
-               //in case you delete the seqs and then ask for them
-               emptySequence = Sequence();
-               emptySequence.setName("no_match");
-               emptySequence.setUnaligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
-               emptySequence.setAligned("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignmentDB", "AlignmentDB");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-AlignmentDB::~AlignmentDB() {  delete search;  }
-/**************************************************************************************************/
-Sequence AlignmentDB::findClosestSequence(Sequence* seq) {
-       try{
-       
-               vector<int> spot = search->findClosestSequences(seq, 1);
-       
-               if (spot.size() != 0)   {               return templateSequences[spot[0]];      }
-               else                                    {               return emptySequence;                           }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignmentDB", "findClosestSequence");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
-
-
-
-
diff --git a/alignmentdb.h b/alignmentdb.h
deleted file mode 100644 (file)
index 537af8d..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef ALIGNMENTDB_H
-#define ALIGNMENTDB_H
-
-/*
- *  alignmentdb.h
- *  Mothur
- *
- *  Created by westcott on 11/4/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sequence.hpp"
-#include "database.hpp"
-
-/**************************************************************************************************/
-
-class AlignmentDB {
-
-public:
-
-       AlignmentDB(string, string, int, float, float, float, float, int);  //reads fastafile passed in and stores sequences
-       AlignmentDB(string);
-       ~AlignmentDB();
-       
-       Sequence findClosestSequence(Sequence*);
-       float getSearchScore()  {  return search->getSearchScore();  }
-       int getLongestBase()    {  return longest;  }
-       
-private:
-       int numSeqs, longest, threadID;
-       string method;
-       
-       Database* search;
-       vector<Sequence> templateSequences;
-       Sequence emptySequence;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
-
diff --git a/amovacommand.cpp b/amovacommand.cpp
deleted file mode 100644 (file)
index 3ec14bf..0000000
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- *  amovacommand.cpp
- *  mothur
- *
- *  Created by westcott on 2/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "amovacommand.h"
-#include "readphylipvector.h"
-#include "groupmap.h"
-
-
-//**********************************************************************************************************************
-vector<string> AmovaCommand::setParameters(){  
-       try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string AmovaCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "Referenced: Anderson MJ (2001). A new method for non-parametric multivariate analysis of variance. Austral Ecol 26: 32-46.";
-               helpString += "The amova command outputs a .amova file.";
-               helpString += "The amova command parameters are phylip, iters, and alpha.  The phylip and design parameters are required, unless you have valid current files.";
-               helpString += "The design parameter allows you to assign your samples to groups when you are running amova. It is required.";
-               helpString += "The design file looks like the group file.  It is a 2 column tab delimited file, where the first column is the sample name and the second column is the group the sample belongs to.";
-               helpString += "The iters parameter allows you to set number of randomization for the P value.  The default is 1000.";
-               helpString += "The amova command should be in the following format: amova(phylip=file.dist, design=file.design).";
-               helpString += "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e. 1000).";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AmovaCommand::AmovaCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["amova"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "AmovaCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AmovaCommand::AmovaCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["amova"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       phylipFileName = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipFileName == "not open") { phylipFileName = ""; abort = true; }
-                       else if (phylipFileName == "not found") { 
-                               //if there is a current phylip file, use it
-                               phylipFileName = m->getPhylipFile(); 
-                               if (phylipFileName != "") { m->mothurOut("Using " + phylipFileName + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setPhylipFile(phylipFileName); }
-                       
-                       //check for required parameters
-                       designFileName = validParameter.validFile(parameters, "design", true);
-                       if (designFileName == "not open") { designFileName = ""; abort = true; }
-                       else if (designFileName == "not found") {
-                               //if there is a current design file, use it
-                               designFileName = m->getDesignFile(); 
-                               if (designFileName != "") { m->mothurOut("Using " + designFileName + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current design file and the design parameter is required."); m->mothurOutEndLine(); abort = true; }                           
-                       }else { m->setDesignFile(designFileName); }     
-
-                       string temp = validParameter.validFile(parameters, "iters", false);
-                       if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "alpha", false);
-                       if (temp == "not found") { temp = "0.05"; }
-                       m->mothurConvert(temp, experimentwiseAlpha); 
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "AmovaCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int AmovaCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read design file
-               designMap = new GroupMap(designFileName);
-               designMap->readDesignMap();
-
-               if (outputDir == "") { outputDir = m->hasPath(phylipFileName); }
-                                               
-               //read in distance matrix and square it
-               ReadPhylipVector readMatrix(phylipFileName);
-               vector<string> sampleNames = readMatrix.read(distanceMatrix);
-               
-               for(int i=0;i<distanceMatrix.size();i++){
-                       for(int j=0;j<i;j++){
-                               distanceMatrix[i][j] *= distanceMatrix[i][j];   
-                       }
-               }
-               
-               //link designMap to rows/columns in distance matrix
-               map<string, vector<int> > origGroupSampleMap;
-               for(int i=0;i<sampleNames.size();i++){
-                       string group = designMap->getGroup(sampleNames[i]);
-                       
-                       if (group == "not found") {
-                               m->mothurOut("[ERROR]: " + sampleNames[i] + " is not in your design file, please correct."); m->mothurOutEndLine(); m->control_pressed = true;
-                       }else { origGroupSampleMap[group].push_back(i); }
-                       
-               }
-               int numGroups = origGroupSampleMap.size();
-               
-               if (m->control_pressed) { delete designMap; return 0; }
-               
-               //create a new filename
-               ofstream AMOVAFile;
-               string AMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "amova";                         
-               m->openOutputFile(AMOVAFileName, AMOVAFile);
-               outputNames.push_back(AMOVAFileName); outputTypes["amova"].push_back(AMOVAFileName);
-               
-               double fullANOVAPValue = runAMOVA(AMOVAFile, origGroupSampleMap, experimentwiseAlpha);
-               if(fullANOVAPValue <= experimentwiseAlpha && numGroups > 2){
-                       
-                       int numCombos = numGroups * (numGroups-1) / 2;
-                       double pairwiseAlpha = experimentwiseAlpha / (double) numCombos;
-                       
-                       map<string, vector<int> >::iterator itA;
-                       map<string, vector<int> >::iterator itB;
-                       
-                       for(itA=origGroupSampleMap.begin();itA!=origGroupSampleMap.end();itA++){
-                               itB = itA;itB++;
-                               for(itB;itB!=origGroupSampleMap.end();itB++){
-                                       
-                                       map<string, vector<int> > pairwiseGroupSampleMap;
-                                       pairwiseGroupSampleMap[itA->first] = itA->second;
-                                       pairwiseGroupSampleMap[itB->first] = itB->second;
-                                       
-                                       runAMOVA(AMOVAFile, pairwiseGroupSampleMap, pairwiseAlpha);
-                               }                       
-                       }
-                       m->mothurOut("Experiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-                       m->mothurOut("Pair-wise error rate (Bonferroni): " + toString(pairwiseAlpha) + '\n');
-               }
-               else{
-                       m->mothurOut("Experiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-               }
-               m->mothurOut("If you have borderline P-values, you should try increasing the number of iterations\n");
-               AMOVAFile.close();
-               
-               delete designMap;
-        
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double AmovaCommand::runAMOVA(ofstream& AMOVAFile, map<string, vector<int> > groupSampleMap, double alpha) {
-       try {
-               map<string, vector<int> >::iterator it;
-
-               int numGroups = groupSampleMap.size();
-               int totalNumSamples = 0;
-
-               for(it = groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       totalNumSamples += it->second.size();                   
-               }
-
-               double ssTotalOrig = calcSSTotal(groupSampleMap);
-               double ssWithinOrig = calcSSWithin(groupSampleMap);
-               double ssAmongOrig = ssTotalOrig - ssWithinOrig;
-               
-               double counter = 0;
-               for(int i=0;i<iters;i++){
-                       map<string, vector<int> > randomizedGroup = getRandomizedGroups(groupSampleMap);
-                       double ssWithinRand = calcSSWithin(randomizedGroup);
-                       if(ssWithinRand < ssWithinOrig){        counter++;      }
-               }
-               
-               double pValue = (double)counter / (double) iters;
-               string pString = "";
-               if(pValue < 1/(double)iters){   pString = '<' + toString(1/(double)iters);      }
-               else                                            {       pString = toString(pValue);                                     }
-               
-               
-               //print anova table
-               it = groupSampleMap.begin();
-               AMOVAFile << it->first;
-               m->mothurOut(it->first);
-               it++;
-               for(it;it!=groupSampleMap.end();it++){
-                       AMOVAFile << '-' << it->first;
-                       m->mothurOut('-' + it->first);
-               }
-               
-               AMOVAFile << "\tAmong\tWithin\tTotal" << endl;
-               m->mothurOut("\tAmong\tWithin\tTotal\n");
-               
-               AMOVAFile << "SS\t" << ssAmongOrig << '\t' << ssWithinOrig << '\t' << ssTotalOrig << endl;
-               m->mothurOut("SS\t" + toString(ssAmongOrig) + '\t' + toString(ssWithinOrig) + '\t' + toString(ssTotalOrig) + '\n');
-               
-               int dfAmong = numGroups - 1;                            double MSAmong = ssAmongOrig / (double) dfAmong;
-               int dfWithin = totalNumSamples - numGroups;     double MSWithin = ssWithinOrig / (double) dfWithin;
-               int dfTotal = totalNumSamples - 1;                      double Fs = MSAmong / MSWithin;
-               
-               AMOVAFile << "df\t" << dfAmong << '\t' << dfWithin << '\t' << dfTotal << endl;
-               m->mothurOut("df\t" + toString(dfAmong) + '\t' + toString(dfWithin) + '\t' + toString(dfTotal) + '\n');
-
-               AMOVAFile << "MS\t" << MSAmong << '\t' << MSWithin << endl << endl;
-               m->mothurOut("MS\t" + toString(MSAmong) + '\t' + toString(MSWithin) + "\n\n");
-
-               AMOVAFile << "Fs:\t" << Fs << endl;
-               m->mothurOut("Fs:\t" + toString(Fs) + '\n');
-               
-               AMOVAFile << "p-value: " << pString;
-               m->mothurOut("p-value: " + pString);
-
-               if(pValue < alpha){
-                       AMOVAFile << "*";
-                       m->mothurOut("*");
-               }
-               AMOVAFile << endl << endl;
-               m->mothurOutEndLine();m->mothurOutEndLine();
-
-               return pValue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "runAMOVA");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-map<string, vector<int> > AmovaCommand::getRandomizedGroups(map<string, vector<int> > origMapping){
-       try{
-               vector<int> sampleIndices;
-               vector<int> samplesPerGroup;
-               
-               map<string, vector<int> >::iterator it;
-               for(it=origMapping.begin();it!=origMapping.end();it++){
-                       vector<int> indices = it->second;
-                       samplesPerGroup.push_back(indices.size());
-                       sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
-               }
-               
-               random_shuffle(sampleIndices.begin(), sampleIndices.end());
-               
-               int index = 0;
-               map<string, vector<int> > randomizedGroups = origMapping;
-               for(it=randomizedGroups.begin();it!=randomizedGroups.end();it++){
-                       for(int i=0;i<it->second.size();i++){
-                               it->second[i] = sampleIndices[index++];                         
-                       }
-               }
-
-               return randomizedGroups;                
-       }
-       catch (exception& e) {
-               m->errorOut(e, "AmovaCommand", "getRandomizedGroups");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double AmovaCommand::calcSSTotal(map<string, vector<int> >& groupSampleMap) {
-       try {
-               
-               vector<int> indices;
-               map<string, vector<int> >::iterator it;
-               for(it=groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       indices.insert(indices.end(), it->second.begin(), it->second.end());                    
-               }
-               sort(indices.begin(), indices.end());
-                       
-               int numIndices =indices.size();
-               double ssTotal = 0.0;
-               
-               for(int i=1;i<numIndices;i++){
-                       int row = indices[i];
-                       
-                       for(int j=0;j<i;j++){
-                               ssTotal += distanceMatrix[row][indices[j]];
-                       }
-               }
-               ssTotal /= numIndices;
-                       
-               return ssTotal;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "calcSSTotal");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double AmovaCommand::calcSSWithin(map<string, vector<int> >& groupSampleMap) {
-       try {
-
-               double ssWithin = 0.0;
-               
-               map<string, vector<int> >::iterator it;
-               for(it=groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       
-                       double withinGroup = 0;
-                       
-                       vector<int> samples = it->second;
-                       
-                       for(int i=0;i<samples.size();i++){
-                               int row = samples[i];
-
-                               for(int j=0;j<samples.size();j++){
-                                       int col = samples[j];
-
-                                       if(col < row){
-                                               withinGroup += distanceMatrix[row][col];
-                                       }
-                                       
-                               }
-                       }
-
-                       ssWithin += withinGroup / samples.size();
-               }
-
-               return ssWithin;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AmovaCommand", "calcSSWithin");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/amovacommand.h b/amovacommand.h
deleted file mode 100644 (file)
index 50dc81a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef AMOVACOMMAND_H
-#define AMOVACOMMAND_H
-
-/*
- *  amovacommand.h
- *  mothur
- *
- *  Created by westcott on 2/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-class GroupMap;
-
-class AmovaCommand : public Command {
-       
-public:
-       AmovaCommand(string);
-       AmovaCommand();
-       ~AmovaCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "amova";                                       }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Anderson MJ (2001). A new method for non-parametric multivariate analysis of variance. Austral Ecol 26: 32-46.\nhttp://www.mothur.org/wiki/Amova"; }
-       string getDescription()         { return "analysis of molecular variance"; }
-       
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       double runAMOVA(ofstream&, map<string, vector<int> >, double);
-       double calcSSWithin(map<string, vector<int> >&);
-       double calcSSTotal(map<string, vector<int> >&);
-       map<string, vector<int> > getRandomizedGroups(map<string, vector<int> >);
-
-       bool abort;
-       vector<string> outputNames;
-
-       string outputDir, inputDir, designFileName, phylipFileName;
-       GroupMap* designMap;
-       vector< vector<double> > distanceMatrix;
-       int iters;
-       double experimentwiseAlpha;
-};
-
-#endif
-
diff --git a/anosimcommand.cpp b/anosimcommand.cpp
deleted file mode 100644 (file)
index 1b6afe3..0000000
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- *  anosimcommand.cpp
- *  mothur
- *
- *  Created by westcott on 2/14/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "anosimcommand.h"
-#include "inputdata.h"
-#include "readphylipvector.h"
-
-//**********************************************************************************************************************
-vector<string> AnosimCommand::setParameters(){ 
-       try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string AnosimCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "Referenced: Clarke, K. R. (1993). Non-parametric multivariate analysis of changes in community structure.   _Australian Journal of Ecology_ 18, 117-143.\n";
-               helpString += "The anosim command outputs a .anosim file. \n";
-               helpString += "The anosim command parameters are phylip, iters, and alpha.  The phylip and design parameters are required, unless you have valid current files.\n";
-               helpString += "The design parameter allows you to assign your samples to groups when you are running anosim. It is required. \n";
-               helpString += "The design file looks like the group file.  It is a 2 column tab delimited file, where the first column is the sample name and the second column is the group the sample belongs to.\n";
-               helpString += "The iters parameter allows you to set number of randomization for the P value.  The default is 1000. \n";
-               helpString += "The anosim command should be in the following format: anosim(phylip=file.dist, design=file.design).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e. 1000).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-AnosimCommand::AnosimCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["anosim"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "AnosimCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-AnosimCommand::AnosimCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["anosim"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       phylipFileName = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipFileName == "not open") { phylipFileName = ""; abort = true; }
-                       else if (phylipFileName == "not found") { 
-                               //if there is a current phylip file, use it
-                               phylipFileName = m->getPhylipFile(); 
-                               if (phylipFileName != "") { m->mothurOut("Using " + phylipFileName + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                               
-                       }else { m->setPhylipFile(phylipFileName); }     
-                       
-                       //check for required parameters
-                       designFileName = validParameter.validFile(parameters, "design", true);
-                       if (designFileName == "not open") { designFileName = ""; abort = true; }
-                       else if (designFileName == "not found") {
-                               //if there is a current design file, use it
-                               designFileName = m->getDesignFile(); 
-                               if (designFileName != "") { m->mothurOut("Using " + designFileName + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current design file and the design parameter is required."); m->mothurOutEndLine(); abort = true; }                                                           
-                       }else { m->setDesignFile(designFileName); }     
-                       
-                       string temp = validParameter.validFile(parameters, "iters", false);
-                       if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "alpha", false);
-                       if (temp == "not found") { temp = "0.05"; }
-                       m->mothurConvert(temp, experimentwiseAlpha); 
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "AnosimCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int AnosimCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read design file
-               designMap = new GroupMap(designFileName);
-               designMap->readDesignMap();
-               
-               if (outputDir == "") { outputDir = m->hasPath(phylipFileName); }
-               
-               //read in distance matrix and square it
-               ReadPhylipVector readMatrix(phylipFileName);
-               vector<string> sampleNames = readMatrix.read(distanceMatrix);
-               
-               for(int i=0;i<distanceMatrix.size();i++){
-                       for(int j=0;j<i;j++){
-                               distanceMatrix[i][j] *= distanceMatrix[i][j];   
-                       }
-               }
-               
-               //link designMap to rows/columns in distance matrix
-               map<string, vector<int> > origGroupSampleMap;
-               for(int i=0;i<sampleNames.size();i++){
-                       string group = designMap->getGroup(sampleNames[i]);
-                       
-                       if (group == "not found") {
-                               m->mothurOut("[ERROR]: " + sampleNames[i] + " is not in your design file, please correct."); m->mothurOutEndLine(); m->control_pressed = true;
-                       }else { origGroupSampleMap[group].push_back(i); }
-               }
-               int numGroups = origGroupSampleMap.size();
-               
-               if (m->control_pressed) { delete designMap; return 0; }
-               
-               //create a new filename
-               ofstream ANOSIMFile;
-               string ANOSIMFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "anosim";                               
-               m->openOutputFile(ANOSIMFileName, ANOSIMFile);
-               outputNames.push_back(ANOSIMFileName); outputTypes["anosim"].push_back(ANOSIMFileName);
-               m->mothurOut("\ncomparison\tR-value\tP-value\n");
-               ANOSIMFile << "comparison\tR-value\tP-value\n";
-               
-               
-               double fullANOSIMPValue = runANOSIM(ANOSIMFile, distanceMatrix, origGroupSampleMap, experimentwiseAlpha);
-               
-               
-               if(fullANOSIMPValue <= experimentwiseAlpha && numGroups > 2){
-
-                       int numCombos = numGroups * (numGroups-1) / 2;
-                       double pairwiseAlpha = experimentwiseAlpha / (double) numCombos;
-
-                       for(map<string, vector<int> >::iterator itA=origGroupSampleMap.begin();itA!=origGroupSampleMap.end();itA++){
-                               map<string, vector<int> >::iterator itB = itA;
-                               itB++;
-                               for(itB;itB!=origGroupSampleMap.end();itB++){
-                                       
-                                       map<string, vector<int> > subGroupSampleMap;
-                                       
-                                       subGroupSampleMap[itA->first] = itA->second;    string groupA = itA->first;
-                                       subGroupSampleMap[itB->first] = itB->second;    string groupB = itB->first;
-                       
-                                       vector<int> subIndices;
-                                       for(map<string, vector<int> >::iterator it=subGroupSampleMap.begin();it!=subGroupSampleMap.end();it++){
-                                               subIndices.insert(subIndices.end(), it->second.begin(), it->second.end());
-                                       }
-                                       int subNumSamples = subIndices.size();
-
-                                       sort(subIndices.begin(), subIndices.end());             
-                                       
-                                       vector<vector<double> > subDistMatrix(distanceMatrix.size());
-                                       for(int i=0;i<distanceMatrix.size();i++){
-                                               subDistMatrix[i].assign(distanceMatrix.size(), -1);
-                                       }
-
-                                       for(int i=0;i<subNumSamples;i++){
-                                               for(int j=0;j<i;j++){
-                                                       subDistMatrix[subIndices[i]][subIndices[j]] = distanceMatrix[subIndices[i]][subIndices[j]];
-                                               }
-                                       }
-
-                                       runANOSIM(ANOSIMFile, subDistMatrix, subGroupSampleMap, pairwiseAlpha);
-
-                               }
-                       }
-                       
-                       m->mothurOut("\nExperiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-                       m->mothurOut("Pair-wise error rate (Bonferroni): " + toString(pairwiseAlpha) + '\n');
-               }
-               else{
-                       m->mothurOut("\nExperiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-               }
-               m->mothurOut("If you have borderline P-values, you should try increasing the number of iterations\n");
-               ANOSIMFile.close();
-               
-                       
-               delete designMap;
-                               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-double AnosimCommand::runANOSIM(ofstream& ANOSIMFile, vector<vector<double> > dMatrix, map<string, vector<int> > groupSampleMap, double alpha) {
-       try {
-
-               
-               vector<vector<double> > rankMatrix = convertToRanks(dMatrix);
-               double RValue = calcR(rankMatrix, groupSampleMap);
-               
-               int pCount = 0;
-               for(int i=0;i<iters;i++){
-                       map<string, vector<int> > randGroupSampleMap = getRandomizedGroups(groupSampleMap);
-                       double RValueRand = calcR(rankMatrix, randGroupSampleMap);
-                       if(RValue <= RValueRand){       pCount++;       }
-               }
-
-               double pValue = (double)pCount / (double) iters;
-               string pString = "";
-               if(pValue < 1/(double)iters){   pString = '<' + toString(1/(double)iters);      }
-               else                                            {       pString = toString(pValue);                                     }
-               
-               
-               map<string, vector<int> >::iterator it=groupSampleMap.begin();
-               m->mothurOut(it->first);
-               ANOSIMFile << it->first;
-               it++;
-               for(it;it!=groupSampleMap.end();it++){
-                       m->mothurOut('-' + it->first);
-                       ANOSIMFile << '-' << it->first;
-               
-               }
-               m->mothurOut('\t' + toString(RValue) + '\t' + pString);
-               ANOSIMFile << '\t' << RValue << '\t' << pString;
-
-               if(pValue < alpha){
-                       ANOSIMFile << "*";
-                       m->mothurOut("*");
-               }
-               ANOSIMFile << endl;
-               m->mothurOutEndLine();
-               
-               return pValue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "calcAnisom");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double AnosimCommand::calcR(vector<vector<double> > rankMatrix, map<string, vector<int> > groupSampleMap){
-       try {
-
-               int numSamples = 0;
-               for(map<string, vector<int> >::iterator it=groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       numSamples += it->second.size();
-               }
-               
-               
-               double within = 0.0;
-               int numWithinComps = 0;         
-               
-               for(map<string, vector<int> >::iterator it=groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       vector<int> indices = it->second;
-                       for(int i=0;i<indices.size();i++){
-                               for(int j=0;j<i;j++){
-                                       if(indices[i] > indices[j])     {       within += rankMatrix[indices[i]][indices[j]];   }
-                                       else                                            {       within += rankMatrix[indices[j]][indices[i]];   }
-                                       numWithinComps++;
-                               }
-                       }
-               }
-               
-               within /= (float) numWithinComps;
-               
-               double between = 0.0;
-               int numBetweenComps = 0;
-
-               map<string, vector<int> >::iterator itB;
-               
-               for(map<string, vector<int> >::iterator itA=groupSampleMap.begin();itA!=groupSampleMap.end();itA++){
-
-                       for(int i=0;i<itA->second.size();i++){
-                               int A = itA->second[i];
-                               map<string, vector<int> >::iterator itB = itA;
-                               itB++;
-                               for(itB;itB!=groupSampleMap.end();itB++){
-                                       for(int j=0;j<itB->second.size();j++){
-                                               int B = itB->second[j];
-                                               if(A>B) {       between += rankMatrix[A][B];    }
-                                               else    {       between += rankMatrix[B][A];    }
-                                               numBetweenComps++;
-                                       }                                       
-                               }
-                               
-                       }
-               }
-               
-               
-               between /= (float) numBetweenComps;
-               
-               double Rvalue = (between - within)/(numSamples * (numSamples-1) / 4.0);
-                               
-               return Rvalue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "calcWithinBetween");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-vector<vector<double> > AnosimCommand::convertToRanks(vector<vector<double> > dist) {
-       try {
-               vector<seqDist> cells;
-               vector<vector<double> > ranks = dist;
-               
-               for (int i = 0; i < dist.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               if(dist[i][j] != -1){
-                                       seqDist member(i, j, dist[i][j]);
-                                       cells.push_back(member);
-                               }
-                       }
-               }
-               
-               
-               //sort distances
-               sort(cells.begin(), cells.end(), compareSequenceDistance);      
-
-               //find ranks of distances
-               int index = 0;
-               int indexSum = 0;
-               for(int i=0;i<cells.size()-1;i++){
-
-                       index = i;
-                       indexSum = i + 1;
-                       while(dist[cells[index].seq1][cells[index].seq2] == dist[cells[index+1].seq1][cells[index+1].seq2]){
-                               index++;                                
-                               indexSum += index + 1;
-                       }
-                       
-                       if(index == i){
-                               ranks[cells[i].seq1][cells[i].seq2] = i+1;
-                       }
-                       else{
-                               double aveIndex = (double)indexSum / (double)(index - i + 1);
-                               for(int j=i;j<=index;j++){
-                                       ranks[cells[j].seq1][cells[j].seq2] = aveIndex;
-                               }                                       
-                               i = index;
-                       }
-               }
-               
-               if(indexSum == cells.size() - 1){
-                       ranks[cells[cells.size()-1].seq1][cells[cells.size()-1].seq2] = indexSum + 1;
-               }
-
-               return ranks;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AnosimCommand", "convertToRanks");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-map<string, vector<int> > AnosimCommand::getRandomizedGroups(map<string, vector<int> > origMapping){
-       try{
-               vector<int> sampleIndices;
-               vector<int> samplesPerGroup;
-               
-               map<string, vector<int> >::iterator it;
-               for(it=origMapping.begin();it!=origMapping.end();it++){
-                       vector<int> indices = it->second;
-                       samplesPerGroup.push_back(indices.size());
-                       sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
-               }
-               
-               random_shuffle(sampleIndices.begin(), sampleIndices.end());
-               
-               int index = 0;
-               map<string, vector<int> > randomizedGroups = origMapping;
-               for(it=randomizedGroups.begin();it!=randomizedGroups.end();it++){
-                       for(int i=0;i<it->second.size();i++){
-                               it->second[i] = sampleIndices[index++];                         
-                       }
-               }
-               
-               return randomizedGroups;                
-       }
-       catch (exception& e) {
-               m->errorOut(e, "AnosimCommand", "randomizeGroups");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
diff --git a/anosimcommand.h b/anosimcommand.h
deleted file mode 100644 (file)
index 4b65070..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef ANOSIMCOMMAND_H
-#define ANOSIMCOMMAND_H
-
-/*
- *  anosimcommand.h
- *  mothur
- *
- *  Created by westcott on 2/14/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-class GroupMap;
-
-class AnosimCommand : public Command {
-       
-public:
-       AnosimCommand(string);
-       AnosimCommand();
-       ~AnosimCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "anosim";                                      }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Clarke, K. R. (1993). Non-parametric multivariate analysis of changes in community structure. _Australian Journal of Ecology_ 18, 117-143.\nhttp://www.mothur.org/wiki/Anosim"; }
-       string getDescription()         { return "analysis of similarity"; }
-       
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       bool abort;
-       GroupMap* designMap;
-       string outputDir, inputDir, designFileName, phylipFileName;
-       
-       vector<vector<double> > convertToRanks(vector<vector<double> >);
-       double calcR(vector<vector<double> >, map<string, vector<int> >);
-       map<string, vector<int> > getRandomizedGroups(map<string, vector<int> >);
-       double runANOSIM(ofstream&, vector<vector<double> >, map<string, vector<int> >, double);
-       
-       vector< vector<double> > distanceMatrix;
-       vector<string> outputNames;
-       int iters;
-       double experimentwiseAlpha;
-       vector< vector<string> > namesOfGroupCombos;
-       
-       
-};
-
-#endif
-
-
-
diff --git a/averagelinkage.cpp b/averagelinkage.cpp
deleted file mode 100644 (file)
index c430c88..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef AVERAGE_H
-#define AVERAGE_H
-
-//test
-#include "mothur.h"
-#include "cluster.hpp"
-#include "rabundvector.hpp"
-#include "sparsematrix.hpp"
-
-/* This class implements the average UPGMA, average neighbor clustering algorithm */
-
-/***********************************************************************/
-
-AverageLinkage::AverageLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
-       Cluster(rav, lv, dm, c, s)
-{
-       saveRow = -1;
-       saveCol = -1;
-}
-
-
-/***********************************************************************/
-//This function returns the tag of the method.
-string AverageLinkage::getTag() {
-       return("an");
-}
-
-
-/***********************************************************************/
-//This function updates the distance based on the average linkage method.
-bool AverageLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
-       try {
-               if ((saveRow != smallRow) || (saveCol != smallCol)) {
-                       rowBin = rabund->get(smallRow);
-                       colBin = rabund->get(smallCol);
-                       totalBin = rowBin + colBin;
-                       saveRow = smallRow;
-                       saveCol = smallCol;
-               }
-               
-               colCell->dist = (colBin * colCell->dist + rowBin * rowCell->dist) / totalBin;
-               
-               return(true);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AverageLinkage", "updateDistance");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-/***********************************************************************/
-
-#endif
diff --git a/bayesian.cpp b/bayesian.cpp
deleted file mode 100644 (file)
index 1dc3833..0000000
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- *  bayesian.cpp
- *  Mothur
- *
- *  Created by westcott on 11/3/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "bayesian.h"
-#include "kmer.hpp"
-#include "phylosummary.h"
-#include "referencedb.h"
-/**************************************************************************************************/
-Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i, int tid, bool f) : 
-Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
-       try {
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               threadID = tid;
-               flip = f;
-               string baseName = tempFile;
-                       
-               if (baseName == "saved") { baseName = rdb->getSavedReference(); }
-               
-               string baseTName = tfile;
-               if (baseTName == "saved") { baseTName = rdb->getSavedTaxonomy(); }
-               
-               /************calculate the probablity that each word will be in a specific taxonomy*************/
-               string tfileroot = m->getFullPathName(baseTName.substr(0,baseTName.find_last_of(".")+1));
-               string tempfileroot = m->getRootName(m->getSimpleName(baseName));
-               string phyloTreeName = tfileroot + "tree.train";
-               string phyloTreeSumName = tfileroot + "tree.sum";
-               string probFileName = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.prob";
-               string probFileName2 = tfileroot + tempfileroot + char('0'+ kmerSize) + "mer.numNonZero";
-               
-               ofstream out;
-               ofstream out2;
-               
-               ifstream phyloTreeTest(phyloTreeName.c_str());
-               ifstream probFileTest2(probFileName2.c_str());
-               ifstream probFileTest(probFileName.c_str());
-               ifstream probFileTest3(phyloTreeSumName.c_str());
-               
-               int start = time(NULL);
-               
-               //if they are there make sure they were created after this release date
-               bool FilesGood = false;
-               if(probFileTest && probFileTest2 && phyloTreeTest && probFileTest3){
-                       FilesGood = checkReleaseDate(probFileTest, probFileTest2, phyloTreeTest, probFileTest3);
-               }
-               
-               //if you want to save, but you dont need to calculate then just read
-               if (rdb->save && probFileTest && probFileTest2 && phyloTreeTest && probFileTest3 && FilesGood && (tempFile != "saved")) {  
-                       ifstream saveIn;
-                       m->openInputFile(tempFile, saveIn);
-                       
-                       while (!saveIn.eof()) {
-                               Sequence temp(saveIn);
-                               m->gobble(saveIn);
-                               
-                               rdb->referenceSeqs.push_back(temp); 
-                       }
-                       saveIn.close();                 
-               }
-               
-               if(probFileTest && probFileTest2 && phyloTreeTest && probFileTest3 && FilesGood){       
-                       if (tempFile == "saved") { m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + " that are saved in memory.");     m->mothurOutEndLine(); }
-                       
-                       m->mothurOut("Reading template taxonomy...     "); cout.flush();
-                       
-                       phyloTree = new PhyloTree(phyloTreeTest, phyloTreeName);
-                       
-                       m->mothurOut("DONE."); m->mothurOutEndLine();
-                       
-                       genusNodes = phyloTree->getGenusNodes(); 
-                       genusTotals = phyloTree->getGenusTotals();
-                       
-                       if (tfile == "saved") { 
-                               m->mothurOutEndLine();  m->mothurOut("Using probabilties from " + rdb->getSavedTaxonomy() + " that are saved in memory...    ");        cout.flush();; 
-                               wordGenusProb = rdb->wordGenusProb;
-                               WordPairDiffArr = rdb->WordPairDiffArr;
-                       }else {
-                               m->mothurOut("Reading template probabilities...     "); cout.flush();
-                               readProbFile(probFileTest, probFileTest2, probFileName, probFileName2);
-                       }       
-                       
-                       //save probabilities
-                       if (rdb->save) { rdb->wordGenusProb = wordGenusProb; rdb->WordPairDiffArr = WordPairDiffArr; }
-               }else{
-               
-                       //create search database and names vector
-                       generateDatabaseAndNames(tfile, tempFile, method, ksize, 0.0, 0.0, 0.0, 0.0);
-                       
-                       //prevents errors caused by creating shortcut files if you had an error in the sanity check.
-                       if (m->control_pressed) {  m->mothurRemove(phyloTreeName);  m->mothurRemove(probFileName); m->mothurRemove(probFileName2); }
-                       else{ 
-                               genusNodes = phyloTree->getGenusNodes(); 
-                               genusTotals = phyloTree->getGenusTotals();
-                               
-                               m->mothurOut("Calculating template taxonomy tree...     "); cout.flush();
-                               
-                               phyloTree->printTreeNodes(phyloTreeName);
-                                                       
-                               m->mothurOut("DONE."); m->mothurOutEndLine();
-                               
-                               m->mothurOut("Calculating template probabilities...     "); cout.flush();
-                               
-                               numKmers = database->getMaxKmer() + 1;
-                       
-                               //initialze probabilities
-                               wordGenusProb.resize(numKmers);
-                               WordPairDiffArr.resize(numKmers);
-                       
-                               for (int j = 0; j < wordGenusProb.size(); j++) {        wordGenusProb[j].resize(genusNodes.size());             }
-                    ofstream out;
-                               ofstream out2;
-                               
-                               #ifdef USE_MPI
-                                       int pid;
-                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-                                       if (pid == 0) {  
-                               #endif
-
-                               
-                               m->openOutputFile(probFileName, out);
-                               
-                               //output mothur version
-                               out << "#" << m->getVersion() << endl;
-                               
-                               out << numKmers << endl;
-                               
-                               m->openOutputFile(probFileName2, out2);
-                               
-                               //output mothur version
-                               out2 << "#" << m->getVersion() << endl;
-                               
-                               #ifdef USE_MPI
-                                       }
-                               #endif
-
-                               
-                               //for each word
-                               for (int i = 0; i < numKmers; i++) {
-                                       if (m->control_pressed) {  break; }
-                                       
-                                       #ifdef USE_MPI
-                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-                                               if (pid == 0) {  
-                                       #endif
-
-                                       out << i << '\t';
-                                       
-                                       #ifdef USE_MPI
-                                               }
-                                       #endif
-                                       
-                                       vector<int> seqsWithWordi = database->getSequencesWithKmer(i);
-                                       
-                                       map<int, int> count;
-                                       for (int k = 0; k < genusNodes.size(); k++) {  count[genusNodes[k]] = 0;  }                     
-                                                       
-                                       //for each sequence with that word
-                                       for (int j = 0; j < seqsWithWordi.size(); j++) {
-                                               int temp = phyloTree->getIndex(names[seqsWithWordi[j]]);
-                                               count[temp]++;  //increment count of seq in this genus who have this word
-                                       }
-                                       
-                                       //probabilityInTemplate = (# of seqs with that word in template + 0.50) / (total number of seqs in template + 1);
-                                       float probabilityInTemplate = (seqsWithWordi.size() + 0.50) / (float) (names.size() + 1);
-                                       diffPair tempProb(log(probabilityInTemplate), 0.0);
-                                       WordPairDiffArr[i] = tempProb;
-                                               
-                                       int numNotZero = 0;
-                                       for (int k = 0; k < genusNodes.size(); k++) {
-                                               //probabilityInThisTaxonomy = (# of seqs with that word in this taxonomy + probabilityInTemplate) / (total number of seqs in this taxonomy + 1);
-                                               
-                                               
-                                               wordGenusProb[i][k] = log((count[genusNodes[k]] + probabilityInTemplate) / (float) (genusTotals[k] + 1));  
-                                                                       
-                                               if (count[genusNodes[k]] != 0) { 
-                                                       #ifdef USE_MPI
-                                                               int pid;
-                                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                                               
-                                                               if (pid == 0) {  
-                                                       #endif
-
-                                                       out << k << '\t' << wordGenusProb[i][k] << '\t' ; 
-                                                       
-                                                       #ifdef USE_MPI
-                                                               }
-                                                       #endif
-
-                                                       numNotZero++;  
-                                               }
-                                       }
-                                       
-                                       #ifdef USE_MPI
-                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               
-                                               if (pid == 0) {  
-                                       #endif
-                                       
-                                       out << endl;
-                                       out2 << probabilityInTemplate << '\t' << numNotZero << '\t' << log(probabilityInTemplate) << endl;
-                                       
-                                       #ifdef USE_MPI
-                                               }
-                                       #endif
-                               }
-                               
-                               #ifdef USE_MPI
-                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               
-                                       if (pid == 0) {  
-                               #endif
-                               
-                               out.close();
-                               out2.close();
-                               
-                               #ifdef USE_MPI
-                                       }
-                               #endif
-                               
-                               //read in new phylotree with less info. - its faster
-                               ifstream phyloTreeTest(phyloTreeName.c_str());
-                               delete phyloTree;
-                               
-                               phyloTree = new PhyloTree(phyloTreeTest, phyloTreeName);
-                
-                               //save probabilities
-                               if (rdb->save) { rdb->wordGenusProb = wordGenusProb; rdb->WordPairDiffArr = WordPairDiffArr; }
-                       }
-               }
-               
-               generateWordPairDiffArr();
-               
-               //save probabilities
-               if (rdb->save) { rdb->wordGenusProb = wordGenusProb; rdb->WordPairDiffArr = WordPairDiffArr; }
-               
-               m->mothurOut("DONE."); m->mothurOutEndLine();
-               m->mothurOut("It took " + toString(time(NULL) - start) + " seconds get probabilities. "); m->mothurOutEndLine();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "Bayesian");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-Bayesian::~Bayesian() {
-       try {
-               
-                delete phyloTree; 
-                if (database != NULL) {  delete database; }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "~Bayesian");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-string Bayesian::getTaxonomy(Sequence* seq) {
-       try {
-               string tax = "";
-               Kmer kmer(kmerSize);
-               flipped = false;
-               
-               //get words contained in query
-               //getKmerString returns a string where the index in the string is hte kmer number 
-               //and the character at that index can be converted to be the number of times that kmer was seen
-               string queryKmerString = kmer.getKmerString(seq->getUnaligned()); 
-               
-               vector<int> queryKmers;
-               for (int i = 0; i < queryKmerString.length()-1; i++) {  // the -1 is to ignore any kmer with an N in it
-                       if (queryKmerString[i] != '!') { //this kmer is in the query
-                               queryKmers.push_back(i);
-                       }
-               }
-               
-               //if user wants to test reverse compliment and its reversed use that instead
-               if (flip) {     
-                       if (isReversed(queryKmers)) { 
-                               flipped = true;
-                               seq->reverseComplement(); 
-                               queryKmerString = kmer.getKmerString(seq->getUnaligned()); 
-                               queryKmers.clear();
-                               for (int i = 0; i < queryKmerString.length()-1; i++) {  // the -1 is to ignore any kmer with an N in it
-                                       if (queryKmerString[i] != '!') { //this kmer is in the query
-                                               queryKmers.push_back(i);
-                                       }
-                               }
-                       }  
-               }
-               
-               if (queryKmers.size() == 0) {  m->mothurOut(seq->getName() + "is bad."); m->mothurOutEndLine(); simpleTax = "unknown;";  return "unknown;"; }
-               
-               
-               int index = getMostProbableTaxonomy(queryKmers);
-               
-               if (m->control_pressed) { return tax; }
-                                       
-               //bootstrap - to set confidenceScore
-               int numToSelect = queryKmers.size() / 8;
-       
-               tax = bootstrapResults(queryKmers, index, numToSelect);
-               
-               return tax;     
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "getTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
-       try {
-                               
-               map<int, int> confidenceScores; 
-               
-               //initialize confidences to 0 
-               int seqIndex = tax;
-               TaxNode seq = phyloTree->get(tax);
-               confidenceScores[tax] = 0;
-               
-               while (seq.level != 0) { //while you are not at the root
-                       seqIndex = seq.parent;
-                       confidenceScores[seqIndex] = 0;
-                       seq = phyloTree->get(seq.parent);
-               }
-                               
-               map<int, int>::iterator itBoot;
-               map<int, int>::iterator itBoot2;
-               map<int, int>::iterator itConvert;
-                       
-               for (int i = 0; i < iters; i++) {
-                       if (m->control_pressed) { return "control"; }
-                       
-                       vector<int> temp;
-                       for (int j = 0; j < numToSelect; j++) {
-                               int index = int(rand() % kmers.size());
-                               
-                               //add word to temp
-                               temp.push_back(kmers[index]);
-                       }
-                       
-                       //get taxonomy
-                       int newTax = getMostProbableTaxonomy(temp);
-                       //int newTax = 1;
-                       TaxNode taxonomyTemp = phyloTree->get(newTax);
-                       
-                       //add to confidence results
-                       while (taxonomyTemp.level != 0) { //while you are not at the root
-                               itBoot2 = confidenceScores.find(newTax); //is this a classification we already have a count on
-                               
-                               if (itBoot2 != confidenceScores.end()) { //this is a classification we need a confidence for
-                                       (itBoot2->second)++;
-                               }
-                               
-                               newTax = taxonomyTemp.parent;
-                               taxonomyTemp = phyloTree->get(newTax);
-                       }
-       
-               }
-               
-               string confidenceTax = "";
-               simpleTax = "";
-               
-               int seqTaxIndex = tax;
-               TaxNode seqTax = phyloTree->get(tax);
-               
-               while (seqTax.level != 0) { //while you are not at the root
-                                       
-                               itBoot2 = confidenceScores.find(seqTaxIndex); //is this a classification we already have a count on
-                               
-                               int confidence = 0;
-                               if (itBoot2 != confidenceScores.end()) { //already in confidence scores
-                                       confidence = itBoot2->second;
-                               }
-                               
-                               if (((confidence/(float)iters) * 100) >= confidenceThreshold) {
-                                       confidenceTax = seqTax.name + "(" + toString(((confidence/(float)iters) * 100)) + ");" + confidenceTax;
-                                       simpleTax = seqTax.name + ";" + simpleTax;
-                               }
-                               
-                               seqTaxIndex = seqTax.parent;
-                               seqTax = phyloTree->get(seqTax.parent);
-               }
-               
-               if (confidenceTax == "") { confidenceTax = "unknown;"; simpleTax = "unknown;";  }
-       
-               return confidenceTax;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "bootstrapResults");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Bayesian::getMostProbableTaxonomy(vector<int> queryKmer) {
-       try {
-               int indexofGenus = 0;
-               
-               double maxProbability = -1000000.0;
-               //find taxonomy with highest probability that this sequence is from it
-               
-               
-//             cout << genusNodes.size() << endl;
-               
-               
-               for (int k = 0; k < genusNodes.size(); k++) {
-                       //for each taxonomy calc its probability
-                       
-                       double prob = 0.0000;
-                       for (int i = 0; i < queryKmer.size(); i++) {
-                               prob += wordGenusProb[queryKmer[i]][k];
-                       }
-                       
-//                     cout << phyloTree->get(genusNodes[k]).name << '\t' << prob << endl;
-
-                       //is this the taxonomy with the greatest probability?
-                       if (prob > maxProbability) { 
-                               indexofGenus = genusNodes[k];
-                               maxProbability = prob;
-                       }
-               }
-               
-                       
-               return indexofGenus;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "getMostProbableTaxonomy");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-//if it is more probable that the reverse compliment kmers are in the template, then we assume the sequence is reversed.
-bool Bayesian::isReversed(vector<int>& queryKmers){
-       try{
-               bool reversed = false;
-               float prob = 0;
-               float reverseProb = 0;
-                
-        for (int i = 0; i < queryKmers.size(); i++){
-            int kmer = queryKmers[i];
-            if (kmer >= 0){
-                prob += WordPairDiffArr[kmer].prob;
-                               reverseProb += WordPairDiffArr[kmer].reverseProb;
-            }
-        }
-               
-        if (reverseProb > prob){ reversed = true; }
-       
-               return reversed;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "isReversed");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-int Bayesian::generateWordPairDiffArr(){
-       try{
-               Kmer kmer(kmerSize);
-               for (int i = 0; i < WordPairDiffArr.size(); i++) {
-                       int reversedWord = kmer.getReverseKmerNumber(i);
-                       WordPairDiffArr[i].reverseProb = WordPairDiffArr[reversedWord].prob;
-               }
-               
-               return 0;
-       }catch(exception& e) {
-               m->errorOut(e, "Bayesian", "generateWordPairDiffArr");
-               exit(1);
-       }
-}
-/*************************************************************************************************
-map<string, int> Bayesian::parseTaxMap(string newTax) {
-       try{
-       
-               map<string, int> parsed;
-               
-               newTax = newTax.substr(0, newTax.length()-1);  //get rid of last ';'
-       
-               //parse taxonomy
-               string individual;
-               while (newTax.find_first_of(';') != -1) {
-                       individual = newTax.substr(0,newTax.find_first_of(';'));
-                       newTax = newTax.substr(newTax.find_first_of(';')+1, newTax.length());
-                       parsed[individual] = 1;
-               }
-               
-               //get last one
-               parsed[newTax] = 1;
-
-               return parsed;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "parseTax");
-               exit(1);
-       }
-}
-**************************************************************************************************/
-void Bayesian::readProbFile(ifstream& in, ifstream& inNum, string inName, string inNumName) {
-       try{
-               
-               #ifdef USE_MPI
-                       
-                       int pid, num, num2, processors;
-                       vector<unsigned long long> positions;
-                       vector<unsigned long long> positions2;
-                       
-                       MPI_Status status; 
-                       MPI_File inMPI;
-                       MPI_File inMPI2;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                       MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                       int tag = 2001;
-
-                       char inFileName[1024];
-                       strcpy(inFileName, inNumName.c_str());
-                       
-                       char inFileName2[1024];
-                       strcpy(inFileName2, inName.c_str());
-
-                       MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                       MPI_File_open(MPI_COMM_WORLD, inFileName2, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI2);  //comm, filename, mode, info, filepointer
-
-                       if (pid == 0) {
-                               positions = m->setFilePosEachLine(inNumName, num);
-                               positions2 = m->setFilePosEachLine(inName, num2);
-                               
-                               for(int i = 1; i < processors; i++) { 
-                                       MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&positions[0], (num+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       
-                                       MPI_Send(&num2, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&positions2[0], (num2+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                               }
-
-                       }else{
-                               MPI_Recv(&num, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               positions.resize(num+1);
-                               MPI_Recv(&positions[0], (num+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                               MPI_Recv(&num2, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               positions2.resize(num2+1);
-                               MPI_Recv(&positions2[0], (num2+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                       }
-                       
-                       //read version
-                       int length = positions2[1] - positions2[0];
-                       char* buf5 = new char[length];
-
-                       MPI_File_read_at(inMPI2, positions2[0], buf5, length, MPI_CHAR, &status);
-                       delete buf5;
-
-                       //read numKmers
-                       length = positions2[2] - positions2[1];
-                       char* buf = new char[length];
-
-                       MPI_File_read_at(inMPI2, positions2[1], buf, length, MPI_CHAR, &status);
-
-                       string tempBuf = buf;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                       delete buf;
-
-                       istringstream iss (tempBuf,istringstream::in);
-                       iss >> numKmers;  
-                       
-                       //initialze probabilities
-                       wordGenusProb.resize(numKmers);
-                       
-                       for (int j = 0; j < wordGenusProb.size(); j++) {        wordGenusProb[j].resize(genusNodes.size());             }
-                       
-                       int kmer, name;  
-                       vector<int> numbers; numbers.resize(numKmers);
-                       float prob;
-                       vector<float> zeroCountProb; zeroCountProb.resize(numKmers);
-                       WordPairDiffArr.resize(numKmers);
-                       
-                       //read version
-                       length = positions[1] - positions[0];
-                       char* buf6 = new char[length];
-
-                       MPI_File_read_at(inMPI2, positions[0], buf6, length, MPI_CHAR, &status);
-                       delete buf6;
-                       
-                       //read file 
-                       for(int i=1;i<num;i++){
-                               //read next sequence
-                               length = positions[i+1] - positions[i];
-                               char* buf4 = new char[length];
-
-                               MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
-
-                               tempBuf = buf4;
-                               if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                               delete buf4;
-
-                               istringstream iss (tempBuf,istringstream::in);
-                               float probTemp;
-                               iss >> zeroCountProb[i] >> numbers[i] >> probTemp; 
-                               WordPairDiffArr[i].prob = probTemp;
-
-                       }
-                       
-                       MPI_File_close(&inMPI);
-                       
-                       for(int i=2;i<num2;i++){
-                               //read next sequence
-                               length = positions2[i+1] - positions2[i];
-                               char* buf4 = new char[length];
-
-                               MPI_File_read_at(inMPI2, positions2[i], buf4, length, MPI_CHAR, &status);
-
-                               tempBuf = buf4;
-                               if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                               delete buf4;
-
-                               istringstream iss (tempBuf,istringstream::in);
-                               
-                               iss >> kmer;
-                               
-                               //set them all to zero value
-                               for (int i = 0; i < genusNodes.size(); i++) {
-                                       wordGenusProb[kmer][i] = log(zeroCountProb[kmer] / (float) (genusTotals[i]+1));
-                               }
-                               
-                               //get probs for nonzero values
-                               for (int i = 0; i < numbers[kmer]; i++) {
-                                       iss >> name >> prob;
-                                       wordGenusProb[kmer][name] = prob;
-                               }
-                               
-                       }
-                       MPI_File_close(&inMPI2);
-                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               #else
-                       //read version
-                       string line = m->getline(in); m->gobble(in);
-                       
-                       in >> numKmers; m->gobble(in);
-                       //cout << threadID << '\t' << line << '\t' << numKmers << &in << '\t' << &inNum << '\t' << genusNodes.size() << endl;
-                       //initialze probabilities
-                       wordGenusProb.resize(numKmers);
-                       
-                       for (int j = 0; j < wordGenusProb.size(); j++) {        wordGenusProb[j].resize(genusNodes.size());             }
-                       
-                       int kmer, name, count;  count = 0;
-                       vector<int> num; num.resize(numKmers);
-                       float prob;
-                       vector<float> zeroCountProb; zeroCountProb.resize(numKmers);    
-                       WordPairDiffArr.resize(numKmers);
-                       
-                       //read version
-                       string line2 = m->getline(inNum); m->gobble(inNum);
-                       float probTemp;
-               //cout << threadID << '\t' << line2 << '\t' << this << endl;    
-                       while (inNum) {
-                               inNum >> zeroCountProb[count] >> num[count] >> probTemp; 
-                               WordPairDiffArr[count].prob = probTemp;
-                               count++;
-                               m->gobble(inNum);
-                               //cout << threadID << '\t' << count << endl;
-                       }
-                       inNum.close();
-               //cout << threadID << '\t' << "here1 " << &wordGenusProb << '\t' << &num << endl; //
-               //cout << threadID << '\t' << &genusTotals << '\t' << endl; 
-               //cout << threadID << '\t' << genusNodes.size() << endl;
-                       while(in) {
-                               in >> kmer;
-                       //cout << threadID << '\t' << kmer << endl;
-                               //set them all to zero value
-                               for (int i = 0; i < genusNodes.size(); i++) {
-                                       wordGenusProb[kmer][i] = log(zeroCountProb[kmer] / (float) (genusTotals[i]+1));
-                               }
-                       //cout << threadID << '\t' << num[kmer] << "here" << endl;      
-                               //get probs for nonzero values
-                               for (int i = 0; i < num[kmer]; i++) {
-                                       in >> name >> prob;
-                                       wordGenusProb[kmer][name] = prob;
-                               }
-                               
-                               m->gobble(in);
-                       }
-                       in.close();
-               //cout << threadID << '\t' << "here" << endl;   
-               #endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "readProbFile");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-bool Bayesian::checkReleaseDate(ifstream& file1, ifstream& file2, ifstream& file3, ifstream& file4) {
-       try {
-               
-               bool good = true;
-               
-               vector<string> lines;
-               lines.push_back(m->getline(file1));  
-               lines.push_back(m->getline(file2)); 
-               lines.push_back(m->getline(file3)); 
-               lines.push_back(m->getline(file4)); 
-
-               //before we added this check
-               if ((lines[0][0] != '#') || (lines[1][0] != '#') || (lines[2][0] != '#') || (lines[3][0] != '#')) {  good = false;  }
-               else {
-                       //rip off #
-                       for (int i = 0; i < lines.size(); i++) { lines[i] = lines[i].substr(1);  }
-                       
-                       //get mothurs current version
-                       string version = m->getVersion();
-                       
-                       vector<string> versionVector;
-                       m->splitAtChar(version, versionVector, '.');
-                       
-                       //check each files version
-                       for (int i = 0; i < lines.size(); i++) { 
-                               vector<string> linesVector;
-                               m->splitAtChar(lines[i], linesVector, '.');
-                       
-                               if (versionVector.size() != linesVector.size()) { good = false; break; }
-                               else {
-                                       for (int j = 0; j < versionVector.size(); j++) {
-                                               int num1, num2;
-                                               convert(versionVector[j], num1);
-                                               convert(linesVector[j], num2);
-                                               
-                                               //if mothurs version is newer than this files version, then we want to remake it
-                                               if (num1 > num2) {  good = false; break;  }
-                                       }
-                               }
-                               
-                               if (!good) { break; }
-                       }
-               }
-               
-               if (!good) {  file1.close(); file2.close(); file3.close(); file4.close();  }
-               else { file1.seekg(0);  file2.seekg(0);  file3.seekg(0);  file4.seekg(0);  }
-               
-               return good;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bayesian", "checkReleaseDate");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
-
-
-
-
diff --git a/bayesian.h b/bayesian.h
deleted file mode 100644 (file)
index 7c88433..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef BAYESIAN_H
-#define BAYESIAN_H
-
-/*
- *  bayesian.h
- *  Mothur
- *
- *  Created by westcott on 11/3/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "classify.h"
-
-/**************************************************************************************************/
-
-class Bayesian : public Classify {
-       
-public:
-       Bayesian(string, string, string, int, int, int, int, bool);
-       ~Bayesian();
-       
-       string getTaxonomy(Sequence*);
-       
-private:
-       vector< vector<float> > wordGenusProb;  //vector of maps from genus to probability
-                                                                               //wordGenusProb[0][392] = probability that a sequence within genus that's index in the tree is 392 would contain kmer 0;
-       
-       vector<int> genusTotals;
-       vector<int> genusNodes;  //indexes in phyloTree where genus' are located
-       
-       vector<diffPair> WordPairDiffArr; 
-       
-       int kmerSize, numKmers, confidenceThreshold, iters;
-       
-       string bootstrapResults(vector<int>, int, int);
-       int getMostProbableTaxonomy(vector<int>);
-       void readProbFile(ifstream&, ifstream&, string, string);
-       bool checkReleaseDate(ifstream&, ifstream&, ifstream&, ifstream&);
-       bool isReversed(vector<int>&);
-       vector<int> createWordIndexArr(Sequence*);
-       int generateWordPairDiffArr();
-       
-};
-
-/**************************************************************************************************/
-
-#endif
-
diff --git a/bellerophon.cpp b/bellerophon.cpp
deleted file mode 100644 (file)
index 833cfb9..0000000
+++ /dev/null
@@ -1,791 +0,0 @@
-/*
- *  bellerophon.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "bellerophon.h"
-#include "eachgapdist.h"
-#include "ignoregaps.h"
-#include "onegapdist.h"
-
-
-/***************************************************************************************************************/
-
-Bellerophon::Bellerophon(string name, bool filterSeqs,  bool c, int win, int inc, int p, string o) : Chimera() {
-       try {
-               fastafile = name;
-               correction = c;
-               outputDir = o;
-               window = win;
-               increment = inc;
-               processors = p;
-               
-               //read in sequences
-               seqs = readSeqs(fastafile);
-               numSeqs = seqs.size();
-               if (numSeqs == 0) { m->mothurOut("Error in reading you sequences."); m->mothurOutEndLine(); exit(1); }
-       
-               //do soft filter
-               if (filterSeqs)  {
-                       createFilter(seqs, 0.5);
-                       for (int i = 0; i < seqs.size(); i++) {  runFilter(seqs[i]);  }
-               }
-               
-               distCalculator = new eachGapDist();
-               
-               //set default window to 25% of sequence length
-               string seq0 = seqs[0]->getAligned();
-               if (window == 0) { window = seq0.length() / 4;  }
-               else if (window > (seq0.length() / 2)) {  
-                       m->mothurOut("Your sequence length is = " + toString(seq0.length()) + ". You have selected a window size greater than the length of half your aligned sequence. I will run it with a window size of " + toString((seq0.length() / 2))); m->mothurOutEndLine();
-                       window = (seq0.length() / 2);
-               }
-               
-               if (increment > (seqs[0]->getAlignLength() - (2*window))) { 
-                       if (increment != 10) {
-                       
-                               m->mothurOut("You have selected a increment that is too large. I will use the default."); m->mothurOutEndLine();
-                               increment = 10;
-                               if (increment > (seqs[0]->getAlignLength() - (2*window))) {  increment = 0;  }
-                               
-                       }else{ increment = 0; }
-               }
-               
-               if (increment == 0) { iters = 1; }
-               else { iters = ((seqs[0]->getAlignLength() - (2*window)) / increment); }
-               
-               //initialize pref
-               pref.resize(iters);
-               for (int i = 0; i < iters; i++) { 
-                       Preference temp;
-                       for (int j = 0; j < numSeqs; j++) {  
-                               pref[i].push_back(temp); 
-                       }
-               } 
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "Bellerophon");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-int Bellerophon::print(ostream& out, ostream& outAcc, string s) {
-       try {
-               int above1 = 0;
-               
-               //sorted "best" preference scores for all seqs
-               vector<Preference> best = getBestPref();
-               
-               if (m->control_pressed) { return numSeqs; }
-               
-               out << "Name\tScore\tLeft\tRight\t" << endl;
-               //output prefenence structure to .chimeras file
-               for (int i = 0; i < best.size(); i++) {
-                       
-                       if (m->control_pressed) {  return numSeqs; }
-                       
-                       out << best[i].name << '\t' << setprecision(3) << best[i].score << '\t' << best[i].leftParent << '\t' << best[i].rightParent << endl;
-                       
-                       //calc # of seqs with preference above 1.0
-                       if (best[i].score > 1.0) { 
-                               above1++; 
-                               outAcc << best[i].name << endl;
-                               m->mothurOut(best[i].name + " is a suspected chimera at breakpoint " + toString(best[i].midpoint)); m->mothurOutEndLine();
-                               m->mothurOut("It's score is " + toString(best[i].score) + " with suspected left parent " + best[i].leftParent + " and right parent " + best[i].rightParent); m->mothurOutEndLine();
-                       }
-               }
-               
-               //output results to screen
-               m->mothurOutEndLine();
-               m->mothurOut("Sequence with preference score above 1.0: " + toString(above1)); m->mothurOutEndLine();
-               int spot;
-               spot = best.size()-1;
-               m->mothurOut("Minimum:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = best.size() * 0.975;
-               m->mothurOut("2.5%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = best.size() * 0.75;
-               m->mothurOut("25%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = best.size() * 0.50;
-               m->mothurOut("Median: \t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = best.size() * 0.25;
-               m->mothurOut("75%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = best.size() * 0.025;
-               m->mothurOut("97.5%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               spot = 0;
-               m->mothurOut("Maximum:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-               
-               return numSeqs;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "print");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-//***************************************************************************************************************
-int Bellerophon::print(MPI_File& out, MPI_File& outAcc, string s) {
-       try {
-       
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               if (pid == 0) {
-                       string outString = "";
-                                               
-                       //sorted "best" preference scores for all seqs
-                       vector<Preference> best = getBestPref();
-                       
-                       int above1 = 0;
-                       int ninetyfive = best.size() * 0.05;
-                       float cutoffScore = best[ninetyfive].score;
-
-                       if (m->control_pressed) { return numSeqs; }
-                       
-                       outString = "Name\tScore\tLeft\tRight\n";
-                       MPI_Status status;
-                       int olength = outString.length();
-                       char* buf5 = new char[olength];
-                       memcpy(buf5, outString.c_str(), olength);
-                                       
-                       MPI_File_write_shared(out, buf5, olength, MPI_CHAR, &status);
-                       
-                       delete buf5;
-
-                       //output prefenence structure to .chimeras file
-                       for (int i = 0; i < best.size(); i++) {
-                               
-                               if (m->control_pressed) {  return numSeqs; }
-                               
-                               outString = best[i].name + "\t" +  toString(best[i].score) + "\t" + best[i].leftParent + "\t" + best[i].rightParent + "\n";
-                       
-                               MPI_Status status;
-                               int length = outString.length();
-                               char* buf2 = new char[length];
-                               memcpy(buf2, outString.c_str(), length);
-                                       
-                               MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status);
-                               
-                               delete buf2;
-                               
-                               //calc # of seqs with preference above 95%tile
-                               if (best[i].score >= cutoffScore) { 
-                                       above1++; 
-                                       string outAccString = "";
-                                        outAccString += best[i].name + "\n";
-                                       
-                                       MPI_Status statusAcc;
-                                       length = outAccString.length();
-                                       char* buf = new char[length];
-                                       memcpy(buf, outAccString.c_str(), length);
-                                       
-                                       MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc);
-                                       
-                                       delete buf;
-
-                                       cout << best[i].name << " is a suspected chimera at breakpoint " << toString(best[i].midpoint) << endl;
-                                       cout << "It's score is " << toString(best[i].score) << " with suspected left parent " << best[i].leftParent << " and right parent " << best[i].rightParent << endl;
-                               }
-                       }
-                       
-                       //output results to screen
-                       m->mothurOutEndLine();
-                       m->mothurOut("Sequence with preference score above " + toString(cutoffScore) +  ": " + toString(above1)); m->mothurOutEndLine();
-                       int spot;
-                       spot = best.size()-1;
-                       m->mothurOut("Minimum:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = best.size() * 0.975;
-                       m->mothurOut("2.5%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = best.size() * 0.75;
-                       m->mothurOut("25%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = best.size() * 0.50;
-                       m->mothurOut("Median: \t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = best.size() * 0.25;
-                       m->mothurOut("75%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = best.size() * 0.025;
-                       m->mothurOut("97.5%-tile:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       spot = 0;
-                       m->mothurOut("Maximum:\t" + toString(best[spot].score)); m->mothurOutEndLine();
-                       
-               }
-               
-               return numSeqs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "print");
-               exit(1);
-       }
-}
-#endif
-//********************************************************************************************************************
-//sorts highest score to lowest
-inline bool comparePref(Preference left, Preference right){
-       return (left.score > right.score);      
-}
-//***************************************************************************************************************
-int Bellerophon::getChimeras() {
-       try {
-               
-               //create breaking points
-               vector<int> midpoints;   midpoints.resize(iters, window);
-               for (int i = 1; i < iters; i++) {  midpoints[i] = midpoints[i-1] + increment;  }
-       
-       #ifdef USE_MPI
-               int pid, numSeqsPerProcessor; 
-       
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-               
-               numSeqsPerProcessor = iters / processors;
-               
-               //each process hits this only once
-               unsigned long long startPos = pid * numSeqsPerProcessor;
-               if(pid == processors - 1){
-                               numSeqsPerProcessor = iters - pid * numSeqsPerProcessor;
-               }
-               lines.push_back(linePair(startPos, numSeqsPerProcessor));
-               
-               //fill pref with scores
-               driverChimeras(midpoints, lines[0]);
-               
-               if (m->control_pressed) { return 0; }
-                               
-               //each process must send its parts back to pid 0
-               if (pid == 0) {
-                       
-                       //receive results 
-                       for (int j = 1; j < processors; j++) {
-                               
-                               vector<string>  MPIBestSend; 
-                               for (int i = 0; i < numSeqs; i++) {
-                               
-                                       if (m->control_pressed) { return 0; }
-
-                                       MPI_Status status;
-                                       //receive string
-                                       int length;
-                                       MPI_Recv(&length, 1, MPI_INT, j, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       char* buf = new char[length];
-                                       MPI_Recv(&buf[0], length, MPI_CHAR, j, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       string temp = buf;
-                                       if (temp.length() > length) { temp = temp.substr(0, length); }
-                                       delete buf;
-
-                                       MPIBestSend.push_back(temp);
-                               }
-                               
-                               fillPref(j, MPIBestSend);
-                               
-                               if (m->control_pressed) { return 0; }
-                       }
-
-               }else {
-                       //takes best window for each sequence and turns Preference to string that can be parsed by pid 0.
-                       //played with this a bit, but it may be better to try user-defined datatypes with set string lengths??
-                       vector<string> MPIBestSend = getBestWindow(lines[0]);
-                       pref.clear();
-                               
-                       //send your result to parent
-                       for (int i = 0; i < numSeqs; i++) {
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               int bestLength = MPIBestSend[i].length();
-                               char* buf = new char[bestLength];
-                               memcpy(buf, MPIBestSend[i].c_str(), bestLength);
-                               
-                               MPI_Send(&bestLength, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               MPI_Send(buf, bestLength, MPI_CHAR, 0, 2001, MPI_COMM_WORLD);
-                               delete buf;
-                       }
-                       
-                       MPIBestSend.clear();
-               }
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-       #else
-       
-               //divide breakpoints between processors
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(processors == 1){ 
-                               lines.push_back(linePair(0, iters));    
-                               
-                               //fill pref with scores
-                               driverChimeras(midpoints, lines[0]);
-       
-                       }else{
-                       
-                               int numSeqsPerProcessor = iters / processors;
-                               
-                               for (int i = 0; i < processors; i++) {
-                                       unsigned long long startPos = i * numSeqsPerProcessor;
-                                       if(i == processors - 1){
-                                               numSeqsPerProcessor = iters - i * numSeqsPerProcessor;
-                                       }
-                                       lines.push_back(linePair(startPos, numSeqsPerProcessor));
-                               }
-                               
-                               createProcesses(midpoints);
-                       }
-               #else
-                       lines.push_back(linePair(0, iters));    
-                       
-                       ///fill pref with scores
-                       driverChimeras(midpoints, lines[0]);
-               #endif
-       
-       #endif
-       
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "getChimeras");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int Bellerophon::createProcesses(vector<int> mid) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 0;
-               int exitCommand = 1;
-               vector<int> processIDS;
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               exitCommand = driverChimeras(mid, lines[process]);
-                               string tempOut = outputDir + toString(getpid()) + ".temp";
-                               writePrefs(tempOut, lines[process]);
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //get info that other processes created
-               for (int i = 0; i < processIDS.size(); i++) {
-                       string tempIn = outputDir + toString(processIDS[i]) + ".temp";
-                       readPrefs(tempIn);
-               }
-               
-               return exitCommand;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCommand", "createProcesses");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int Bellerophon::driverChimeras(vector<int> midpoints, linePair line) {
-       try {
-               
-               for (int h = line.start; h < (line.start + line.num); h++) {
-                       count = h;
-                       int midpoint = midpoints[h];
-               
-                       //initialize pref[count]                
-                       for (int i = 0; i < numSeqs; i++ ) { 
-                               pref[count][i].name = seqs[i]->getName();
-                               pref[count][i].midpoint = midpoint;  
-                       }
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //create 2 vectors of sequences, 1 for left side and one for right side
-                       vector<Sequence> left;  vector<Sequence> right;
-                       
-                       for (int i = 0; i < seqs.size(); i++) {
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               //cout << "midpoint = " << midpoint << "\twindow = " << window << endl;
-                               //cout << "whole = " << seqs[i]->getAligned().length() << endl;
-                               //save left side
-                               string seqLeft = seqs[i]->getAligned().substr(midpoint-window, window);
-                               Sequence tempLeft;
-                               tempLeft.setName(seqs[i]->getName());
-                               tempLeft.setAligned(seqLeft);
-                               left.push_back(tempLeft);
-                               //cout << "left = " << tempLeft.getAligned().length() << endl;                  
-                               //save right side
-                               string seqRight = seqs[i]->getAligned().substr(midpoint, window);
-                               Sequence tempRight;
-                               tempRight.setName(seqs[i]->getName());
-                               tempRight.setAligned(seqRight);
-                               right.push_back(tempRight);
-                               //cout << "right = " << seqRight.length() << endl;      
-                       }
-                       
-                       //this should be parallelized
-                       //perference = sum of (| distance of my left to sequence j's left - distance of my right to sequence j's right | )
-                       //create a matrix containing the distance from left to left and right to right
-                       //calculate distances
-                       SparseMatrix* SparseLeft = new SparseMatrix();
-                       SparseMatrix* SparseRight = new SparseMatrix();
-                       
-                       createSparseMatrix(0, left.size(), SparseLeft, left);
-                       
-                       if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
-                       
-                       createSparseMatrix(0, right.size(), SparseRight, right);
-                       
-                       if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
-                       
-                       left.clear(); right.clear();
-                       vector<SeqMap> distMapRight;
-                       vector<SeqMap> distMapLeft;
-                       
-                       // Create a data structure to quickly access the distance information.
-                       //this is from thallingers reimplementation on get.oturep
-                       // It consists of a vector of distance maps, where each map contains
-                       // all distances of a certain sequence. Vector and maps are accessed
-                       // via the index of a sequence in the distance matrix
-                       distMapRight = vector<SeqMap>(numSeqs); 
-                       distMapLeft = vector<SeqMap>(numSeqs); 
-                       //cout << "left" << endl << endl;
-                       for (MatData currentCell = SparseLeft->begin(); currentCell != SparseLeft->end(); currentCell++) {
-                               distMapLeft[currentCell->row][currentCell->column] = currentCell->dist;
-                               if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
-                               //cout << " i = " << currentCell->row << " j = " << currentCell->column << " dist = " << currentCell->dist << endl;
-                       }
-                       //cout << "right" << endl << endl;
-                       for (MatData currentCell = SparseRight->begin(); currentCell != SparseRight->end(); currentCell++) {
-                               distMapRight[currentCell->row][currentCell->column] = currentCell->dist;
-                               if (m->control_pressed) { delete SparseLeft; delete SparseRight; return 0; }
-                               //cout << " i = " << currentCell->row << " j = " << currentCell->column << " dist = " << currentCell->dist << endl;
-                       }
-                       
-                       delete SparseLeft;
-                       delete SparseRight;
-                       
-                       //fill preference structure
-                       generatePreferences(distMapLeft, distMapRight, midpoint);
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //report progress
-                       if((h+1) % 10 == 0){    cout << "Processing sliding window: " << toString(h+1) <<  "\n";  m->mothurOutJustToLog("Processing sliding window: " + toString(h+1) + "\n") ;         }
-                       
-               }
-               
-               //report progress
-               if((line.start + line.num) % 10 != 0){  cout << "Processing sliding window: " << toString(line.start + line.num) <<  "\n";  m->mothurOutJustToLog("Processing sliding window: " + toString(line.start + line.num) + "\n") ;             }
-
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "driverChimeras");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************/
-int Bellerophon::createSparseMatrix(int startSeq, int endSeq, SparseMatrix* sparse, vector<Sequence> s){
-       try {
-
-               for(int i=startSeq; i<endSeq; i++){
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { return 0; }
-                       
-                               distCalculator->calcDist(s[i], s[j]);
-                               float dist = distCalculator->getDist();
-                       
-                               PCell temp(i, j, dist);
-                               sparse->addCell(temp);
-                               
-                       }
-               }
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "createSparseMatrix");
-               exit(1);
-       }
-}
-/***************************************************************************************************************/
-int Bellerophon::generatePreferences(vector<SeqMap> left, vector<SeqMap> right, int mid){
-       try {
-               
-               SeqMap::iterator itR;
-               SeqMap::iterator itL;
-               
-               for (int i = 0; i < left.size(); i++) {
-                       
-                       SeqMap currentLeft = left[i];    //example i = 3;   currentLeft is a map of 0 to the distance of sequence 3 to sequence 0,
-                                                                                               //                                                                              1 to the distance of sequence 3 to sequence 1,
-                                                                                               //                                                                              2 to the distance of sequence 3 to sequence 2.
-                       SeqMap currentRight = right[i];         // same as left but with distances on the right side.
-                       
-                       for (int j = 0; j < i; j++) {
-                       
-                               if (m->control_pressed) {  return 0; }
-                               
-                               itL = currentLeft.find(j);
-                               itR = currentRight.find(j);
-//cout << " i = " << i << " j = " << j << " distLeft = " << itL->second << endl;
-//cout << " i = " << i << " j = " << j << " distright = " << itR->second << endl;
-                               
-                               //if you can find this entry update the preferences
-                               if ((itL != currentLeft.end()) && (itR != currentRight.end())) {
-                               
-                                       if (!correction) {
-                                               pref[count][i].score += abs((itL->second - itR->second));
-                                               pref[count][j].score += abs((itL->second - itR->second));
-//cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
-//cout << "abs = " << abs((itL->second - itR->second)) << endl;
-//cout << i << " score = " << pref[i].score[1] << endl;
-//cout << j << " score = " << pref[j].score[1] << endl;
-                                       }else {
-                                               pref[count][i].score += abs((sqrt(itL->second) - sqrt(itR->second)));
-                                               pref[count][j].score += abs((sqrt(itL->second) - sqrt(itR->second)));
-//cout << "left " << i << " " << j << " = " << itL->second << " right " << i << " " << j << " = " << itR->second << endl;
-//cout << "abs = " << abs((sqrt(itL->second) - sqrt(itR->second))) << endl;
-//cout << i << " score = " << pref[i].score[1] << endl;
-//cout << j << " score = " << pref[j].score[1] << endl;
-                                       }
-//cout << "pref[" << i << "].closestLeft[1] = "        <<      pref[i].closestLeft[1] << " parent = " << pref[i].leftParent[1] << endl;                        
-                                       //are you the closest left sequence
-                                       if (itL->second < pref[count][i].closestLeft) {  
-
-                                               pref[count][i].closestLeft = itL->second;
-                                               pref[count][i].leftParent = seqs[j]->getName();
-//cout << "updating closest left to " << pref[i].leftParent[1] << endl;
-                                       }
-//cout << "pref[" << j << "].closestLeft[1] = "        <<      pref[j].closestLeft[1] << " parent = " << pref[j].leftParent[1] << endl;        
-                                       if (itL->second < pref[count][j].closestLeft) { 
-                                               pref[count][j].closestLeft = itL->second;
-                                               pref[count][j].leftParent = seqs[i]->getName();
-//cout << "updating closest left to " << pref[j].leftParent[1] << endl;
-                                       }
-                                       
-                                       //are you the closest right sequence
-                                       if (itR->second < pref[count][i].closestRight) {   
-                                               pref[count][i].closestRight = itR->second;
-                                               pref[count][i].rightParent = seqs[j]->getName();
-                                       }
-                                       if (itR->second < pref[count][j].closestRight) {   
-                                               pref[count][j].closestRight = itR->second;
-                                               pref[count][j].rightParent = seqs[i]->getName();
-                                       }
-                                       
-                               }
-                       }
-               
-               }
-               
-                               
-               return 1;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "generatePreferences");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<Preference> Bellerophon::getBestPref() {
-       try {
-               
-               vector<Preference> best;
-               
-               //for each sequence
-               for (int i = 0; i < numSeqs; i++) {
-                       
-                       //set best pref score to first one
-                       Preference temp = pref[0][i];
-                       
-                       if (m->control_pressed) { return best;  }
-                       
-                       //for each window
-                       for (int j = 1; j < pref.size(); j++) {
-                               
-                               //is this a better score
-                               if (pref[j][i].score > temp.score) {    temp = pref[j][i];              }
-                       }
-                       
-                       best.push_back(temp);
-               }
-               
-               //rank preference score to eachother
-               float dme = 0.0;
-               float expectedPercent = 1 / (float) (best.size());
-               
-               for (int i = 0; i < best.size(); i++) {  dme += best[i].score;  }
-       
-               for (int i = 0; i < best.size(); i++) {
-
-                       if (m->control_pressed) { return best; }
-                       
-                       //gives the actual percentage of the dme this seq adds
-                       best[i].score = best[i].score / dme;
-                       
-                       //how much higher or lower is this than expected
-                       best[i].score = best[i].score / expectedPercent;
-               
-               }
-               
-               //sort Preferences highest to lowest
-               sort(best.begin(), best.end(), comparePref);
-
-               return best;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "getBestPref");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Bellerophon::writePrefs(string file, linePair tempLine) {
-       try {
-       
-               ofstream outTemp;
-               m->openOutputFile(file, outTemp);
-               
-               //lets you know what part of the pref matrix you are writing
-               outTemp << tempLine.start << '\t' << tempLine.num << endl;
-               
-               for (int i = tempLine.start; i < (tempLine.start + tempLine.num); i++) {
-                       
-                       for (int j = 0; j < numSeqs; j++) {
-                               
-                               if (m->control_pressed) { outTemp.close(); m->mothurRemove(file); return 0; }
-                               
-                               outTemp << pref[i][j].name << '\t' << pref[i][j].leftParent << '\t' << pref[i][j].rightParent << '\t';
-                               outTemp << pref[i][j].score << '\t' << pref[i][j].closestLeft << '\t' << pref[i][j].closestRight << '\t' << pref[i][j].midpoint <<  endl;
-                       }
-               }
-               
-               outTemp.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "writePrefs");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Bellerophon::readPrefs(string file) {
-       try {
-       
-               ifstream inTemp;
-               m->openInputFile(file, inTemp);
-               
-               int start, num;
-               
-               //lets you know what part of the pref matrix you are writing
-               inTemp >> start >> num;  m->gobble(inTemp);
-               
-               for (int i = start; i < num; i++) {
-                       
-                       for (int j = 0; j < numSeqs; j++) {
-                               
-                               if (m->control_pressed) { inTemp.close(); m->mothurRemove(file); return 0; }
-                       
-                               inTemp >> pref[i][j].name >> pref[i][j].leftParent >> pref[i][j].rightParent;
-                               inTemp >> pref[i][j].score >> pref[i][j].closestLeft >> pref[i][j].closestRight >> pref[i][j].midpoint;
-                               m->gobble(inTemp);
-                       }
-               }
-               
-               inTemp.close();
-               
-               m->mothurRemove(file);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "writePrefs");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<string> Bellerophon::getBestWindow(linePair line) {
-       try {
-       
-               vector<string> best;
-                       
-               //for each sequence
-               for (int i = 0; i < numSeqs; i++) {
-                       
-                       //set best pref score to first one
-                       Preference temp = pref[line.start][i];
-                       
-                       if (m->control_pressed) { return best;  }
-                       
-                       //for each window
-                       for (int j = (line.start+1); j < (line.start+line.num); j++) {
-                               
-                               //is this a better score
-                               if (pref[j][i].score > temp.score) {    temp = pref[j][i];              }
-                       }
-                       
-                       string tempString = temp.name + '\t' + temp.leftParent + '\t' + temp.rightParent + '\t' + toString(temp.score);
-                       best.push_back(tempString);
-               }
-
-               return best;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "getBestWindow");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Bellerophon::fillPref(int process, vector<string>& best) {
-       try {
-               //figure out where you start so you can put the best scores there
-               int numSeqsPerProcessor = iters / processors;
-               int start = process * numSeqsPerProcessor;
-               
-               for (int i = 0; i < best.size(); i++) {
-               
-                       if (m->control_pressed) { return 0;  }
-                       
-                       istringstream iss (best[i],istringstream::in);
-                       
-                       string tempScore;
-                       iss >> pref[start][i].name >> pref[start][i].leftParent >> pref[start][i].rightParent >> tempScore;
-                       convert(tempScore, pref[start][i].score); 
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bellerophon", "fillPref");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
diff --git a/bellerophon.h b/bellerophon.h
deleted file mode 100644 (file)
index 36555bf..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef BELLEROPHON_H
-#define BELLEROPHON_H
-
-/*
- *  bellerophon.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "chimera.h"
-#include "sparsematrix.hpp"
-#include "sequence.hpp"
-#include "dist.h"
-
-typedef list<PCell>::iterator MatData;
-typedef map<int, float> SeqMap;  //maps sequence to all distance for that seqeunce
-
-/***********************************************************/
-
-class Bellerophon : public Chimera {
-       
-       public:
-               Bellerophon(string, bool, bool, int, int, int, string); //fastafile, filter, correction, window, increment, processors, outputDir);     
-               ~Bellerophon() { delete distCalculator; for (int i = 0; i < seqs.size(); i++) { delete seqs[i];  }  seqs.clear(); }
-               
-               int getChimeras();
-               int print(ostream&, ostream&, string);
-               
-               #ifdef USE_MPI
-               int print(MPI_File&, MPI_File&, string);
-               #endif
-               
-       private:
-               struct linePair {
-                       unsigned long long start;
-                       int num;
-                       linePair(unsigned long long i, int j) : start(i), num(j) {}
-               };
-               
-               vector<linePair> lines;
-       
-               Dist* distCalculator;
-               vector<Sequence*> seqs;
-               vector< vector<Preference> > pref; //pref[0] = preference scores for all seqs in window 0.
-               string fastafile;
-               int iters, count, window, increment, numSeqs, processors; //iters = number of windows
-               bool correction;
-               
-               int generatePreferences(vector<SeqMap>, vector<SeqMap>, int);
-               int createSparseMatrix(int, int, SparseMatrix*, vector<Sequence>);
-               vector<Preference> getBestPref();
-               int driverChimeras(vector<int>, linePair);
-               int createProcesses(vector<int>);
-               int writePrefs(string, linePair);
-               int readPrefs(string);
-               vector<string> getBestWindow(linePair line);
-               int fillPref(int, vector<string>&);
-};
-
-/***********************************************************/
-
-#endif
-
diff --git a/bergerparker.cpp b/bergerparker.cpp
deleted file mode 100644 (file)
index d00403c..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  ssbp.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "bergerparker.h"
-
-/***************************************************************/
-
-EstOutput BergerParker::getValues(SAbundVector* rank){
-       try {
-               data.resize(1,0);
-               //Berger-Parker index
-               double BP = (double)rank->getMaxRank() / (double)rank->getNumSeqs();
-               
-               data[0] = BP;
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BergerParker", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/bergerparker.h b/bergerparker.h
deleted file mode 100644 (file)
index 6ce6221..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BERGERPARKER_H
-#define BERGERPARKER_H
-/*
- *  bergerparker.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/*This class implements the SSBP estimator on single group. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class BergerParker : public Calculator  {
-       
-public:
-       BergerParker() : Calculator("bergerparker", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Bergerparker"; }
-
-private:
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/binsequencecommand.cpp b/binsequencecommand.cpp
deleted file mode 100644 (file)
index 2117daf..0000000
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
- *  binsequencecommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/3/09.
- *  Copyright 2009 Schloss Lab UMASS Amhers. All rights reserved.
- *
- */
-
-#include "binsequencecommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> BinSeqCommand::setParameters(){ 
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string BinSeqCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The bin.seqs command parameters are list, fasta, name, label and group.  The fasta and list are required, unless you have a valid current list and fasta file.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n";
-               helpString += "The bin.seqs command should be in the following format: bin.seqs(fasta=yourFastaFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n";
-               helpString += "Example bin.seqs(fasta=amazon.fasta, group=amazon.groups, name=amazon.names).\n";
-               helpString += "The default value for label is all lines in your inputfile.\n";
-               helpString += "The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name.\n";
-               helpString += "If you provide a groupfile, then it also appends the sequences group to the name.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-BinSeqCommand::BinSeqCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "BinSeqCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-BinSeqCommand::BinSeqCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               labels.clear();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 //if there is a current phylip file, use it
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fasta file and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (fastafile == "not open") { abort = true; }     
-                       else { m->setFastaFile(fastafile); }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found") {                  
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listfile == "not open") { listfile = ""; abort = true; }       
-                       else { m->setListFile(listfile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(listfile); //if user entered a file with a path then preserve it        
-                       }
-                       
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       namesfile = validParameter.validFile(parameters, "name", true);
-                       if (namesfile == "not open") { namesfile = ""; abort = true; }  
-                       else if (namesfile == "not found") { namesfile = ""; }
-                       else {  m->setNameFile(namesfile); }
-
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       if (namesfile == ""){
-                               vector<string> files; files.push_back(fastafile); 
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "BinSeqCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-BinSeqCommand::~BinSeqCommand(){}
-//**********************************************************************************************************************
-
-int BinSeqCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-       
-               int error = 0;
-               
-               fasta = new FastaMap();
-               if (groupfile != "") {
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-               }
-               
-               //read fastafile
-               fasta->readFastaFile(fastafile);
-               
-               //if user gave a namesfile then use it
-               if (namesfile != "") {
-                       readNamesFile();
-               }
-               
-               input = new InputData(listfile, "list");
-               list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               if (m->control_pressed) {  delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-                               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);                } delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; } 
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){
-                               
-                               error = process(list);  
-                               if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);                } delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; } 
-                                                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list;
-                               list = input->getListVector(lastLabel);
-                               
-                               error = process(list);  
-                               if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);                } delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; }
-                                                                                                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();                   
-                       
-                       delete list;
-                       list = input->getListVector();
-               }
-               
-               if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);                } delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; } 
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {             delete list;    }
-                       list = input->getListVector(lastLabel);
-                               
-                       error = process(list);  
-                       if (error == 1) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);                } delete input;  delete fasta; if (groupfile != "") {  delete groupMap;   } return 0; }
-                       
-                       delete list;  
-               }
-               
-               delete input;  
-               delete fasta; 
-               if (groupfile != "") {  delete groupMap;   } 
-               
-               if(m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);                }  return 0; }  
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-void BinSeqCommand::readNamesFile() {
-       try {
-               vector<string> dupNames;
-               m->openInputFile(namesfile, inNames);
-               
-               string name, names, sequence;
-       
-               while(inNames){
-                       inNames >> name;                        //read from first column  A
-                       inNames >> names;               //read from second column  A,B,C,D
-                       
-                       dupNames.clear();
-                       
-                       //parse names into vector
-                       m->splitAtComma(names, dupNames);
-                       
-                       //store names in fasta map
-                       sequence = fasta->getSequence(name);
-                       for (int i = 0; i < dupNames.size(); i++) {
-                               fasta->push_back(dupNames[i], sequence);
-                       }
-               
-                       m->gobble(inNames);
-               }
-               inNames.close();
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "readNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//return 1 if error, 0 otherwise
-int BinSeqCommand::process(ListVector* list) {
-       try {
-                               string binnames, name, sequence;
-                               
-                               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".fasta";
-                               m->openOutputFile(outputFileName, out);
-                               
-                               //save to output list of output file names
-                               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
-
-                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                               
-                               //for each bin in the list vector
-                               for (int i = 0; i < list->size(); i++) {
-                                       
-                                       if (m->control_pressed) {  return 1; }
-                                       
-                                       binnames = list->get(i);
-                                       while (binnames.find_first_of(',') != -1) { 
-                                               name = binnames.substr(0,binnames.find_first_of(','));
-                                               binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                               
-                                               //do work for that name
-                                               sequence = fasta->getSequence(name);
-                                               if (sequence != "not found") {
-                                                       //if you don't have groups
-                                                       if (groupfile == "") {
-                                                               name = name + "\t" + toString(i+1);
-                                                               out << ">" << name << endl;
-                                                               out << sequence << endl;
-                                                       }else {//if you do have groups
-                                                               string group = groupMap->getGroup(name);
-                                                               if (group == "not found") {  
-                                                                       m->mothurOut(name + " is missing from your group file. Please correct. ");  m->mothurOutEndLine();
-                                                                       return 1;
-                                                               }else{
-                                                                       name = name + "\t" + group + "\t" + toString(i+1);
-                                                                       out << ">" << name << endl;
-                                                                       out << sequence << endl;
-                                                               }
-                                                       }
-                                               }else { 
-                                                       m->mothurOut(name + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
-                                                       return 1;
-                                               }
-                                               
-                                       }
-                                       
-                                       //get last name
-                                       sequence = fasta->getSequence(binnames);
-                                       if (sequence != "not found") {
-                                               //if you don't have groups
-                                               if (groupfile == "") {
-                                                       binnames = binnames + "\t" + toString(i+1);
-                                                       out << ">" << binnames << endl;
-                                                       out << sequence << endl;
-                                               }else {//if you do have groups
-                                                       string group = groupMap->getGroup(binnames);
-                                                       if (group == "not found") {  
-                                                               m->mothurOut(binnames + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
-                                                               return 1;
-                                                       }else{
-                                                               binnames = binnames + "\t" + group + "\t" + toString(i+1);
-                                                               out << ">" << binnames << endl;
-                                                               out << sequence << endl;
-                                                       }
-                                               }
-                                       }else { 
-                                               m->mothurOut(binnames + " is missing from your fasta or name file. Please correct. "); m->mothurOutEndLine();
-                                               return 1;
-                                       }
-                               }
-                                       
-                               out.close();
-                               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BinSeqCommand", "process");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/binsequencecommand.h b/binsequencecommand.h
deleted file mode 100644 (file)
index 365fb3c..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef BINSEQCOMMAND_H
-#define BINSEQCOMMAND_H
-/*
- *  binsequencecommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/3/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* The bin.seqs command outputs a .fasta file for each distance you specify appending the OTU number to each name. */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "listvector.hpp"
-#include "fastamap.h"
-#include "groupmap.h"
-
-class BinSeqCommand : public Command {
-       
-public:
-       BinSeqCommand(string);  
-       BinSeqCommand();
-       ~BinSeqCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "bin.seqs";                    }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Bin.seqs"; }
-       string getDescription()         { return "maps sequences to otus"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-       
-private:
-       
-       ListVector* list;
-       InputData* input;
-       FastaMap* fasta;
-       GroupMap* groupMap;
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string filename, fastafile, listfile, namesfile, groupfile, label, outputDir;
-       ofstream out;
-       ifstream in, inNames;
-       vector<string> outputNames;
-       
-       void readNamesFile();
-       int process(ListVector*);
-};
-
-#endif
diff --git a/blastalign.cpp b/blastalign.cpp
deleted file mode 100644 (file)
index bb7192a..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- *  blastalign.cpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is a basic alignment method that gets the blast program to do the heavy lifting.  In the future, we should
- *     probably incorporate NCBI's library so that we don't have to call on a user-supplied executable.  This is a child
- *     of the Alignment class, which requires a constructor and align method.
- *
- */
-
-
-#include "alignment.hpp"
-#include "blastalign.hpp"
-
-
-//**************************************************************************************************/
-
-BlastAlignment::BlastAlignment(float go, float ge, float ma, float mm) : 
-                       match(ma),                              //      This is the score to award for two nucleotides matching (match >= 0)
-                       mismatch(mm)                    //      This is the penalty to assess for a mismatch (mismatch <= 0)
-{
-       path = m->argv;
-       path = path.substr(0, (path.find_last_of('m')));
-       
-       gapOpen = abs(go);                              //      This is the penalty to assess for opening a gap (gapOpen >= 0)
-       gapExtend = abs(ge);                            //      This is the penalty to assess for extending a gap (gapExtend >= 0)
-               
-       int randNumber = rand();
-       candidateFileName = toString(randNumber) + ".candidate";
-       templateFileName = toString(randNumber) + ".template";
-       blastFileName = toString(randNumber) + ".pairwise";
-}
-
-//**************************************************************************************************/
-
-BlastAlignment::~BlastAlignment(){             //      The desctructor should clean up by removing the temporary 
-       m->mothurRemove(candidateFileName);     //      files used to run bl2seq
-       m->mothurRemove(templateFileName);
-       m->mothurRemove(blastFileName);
-}
-
-//**************************************************************************************************/
-
-void BlastAlignment::align(string seqA, string seqB){  //Use blastn to align the two sequences
-
-       ofstream candidateFile(candidateFileName.c_str());      //      Write the sequence to be aligned to a temporary candidate seq file
-       candidateFile << ">candidate" << endl << seqA << endl;
-       candidateFile.close();
-       
-       ofstream templateFile(templateFileName.c_str());        //      Write the unaligned template sequence to a temporary candidate seq file
-       templateFile << ">template" << endl << seqB << endl;
-       templateFile.close();
-       
-       //      The blastCommand assumes that we have DNA sequences (blastn) and that they are fairly similar (-e 0.001) and
-       //      that we don't want to apply any kind of complexity filtering (-F F)
-       string blastCommand = path + "blast/bin/bl2seq -p blastn -i " + candidateFileName + " -j " + templateFileName + " -e 0.0001 -F F -o " + blastFileName + " -W 11";
-       blastCommand += " -r " + toString(match) + " -q " + toString(mismatch);
-       blastCommand += " -G " + toString(gapOpen) + " -E " + toString(gapExtend);
-       
-       system(blastCommand.c_str());   //      Here we assume that "bl2seq" is in the users path or in the same folder as
-                                                                       //      this executable
-       setPairwiseSeqs();
-}
-
-/**************************************************************************************************/
-
-void BlastAlignment::setPairwiseSeqs(){        //      This method call assigns the blast generated alignment
-                                                                                                                       //      to the pairwise entry in the Sequence class for the 
-                                                                                                                       //      candidate and template Sequence objects
-       ifstream blastFile;
-       m->openInputFile(blastFileName, blastFile);
-       
-       seqAaln = "";
-       seqBaln = "";
-       
-       int candidateLength, templateLength;
-       char d;
-       
-       string candidateName, templateName;
-       
-       while((d=blastFile.get()) != '='){}
-       blastFile >> candidateName;                                     //      Get the candidate sequence name from flatfile
-       
-       while((d=blastFile.get()) != '('){}
-       blastFile >> candidateLength;                           //      Get the candidate sequence length from flatfile
-       
-       while((d=blastFile.get())){
-               if(d == '>'){
-                       blastFile >> templateName;                      //      Get the template sequence name from flatfile
-                       break;
-               }
-               else if(d == '*'){                                                                      //      We go here if there is no significant match
-                       
-                       seqAstart = 0;
-                       seqBstart = 0;
-                       seqAend = 0;
-                       seqBend = 0;
-                       pairwiseLength = 0;
-                       
-//                     string dummy;
-//                     while(dummy != "query:"){       m->mothurOut(dummy, ""); m->mothurOutEndLine(); blastFile >> dummy;     }
-//                     blastFile >> seqBend;
-//                     m->mothurOut(toString(seqBend), ""); m->mothurOutEndLine();
-//                     for(int i=0;i<seqBend;i++){
-//                             seqAaln += 'Z';
-//                             seqBaln += 'X';
-//                     }
-//                     pairwiseLength = 0;
-                       return;
-               }
-       }
-       
-       while((d=blastFile.get()) != '='){}
-       blastFile >> templateLength;                            //      Get the template sequence length from flatfile
-               
-       while((d=blastFile.get()) != 'Q'){}                     //      Suck up everything else until we get to the start of the alignment
-       int queryStart, sbjctStart, queryEnd, sbjctEnd;
-       string queryLabel, sbjctLabel, query, sbjct;
-
-       blastFile >> queryLabel;        queryLabel = 'Q' + queryLabel;
-
-       
-       while(queryLabel == "Query:"){
-               blastFile >> queryStart >> query >> queryEnd;
-               
-               while((d=blastFile.get()) != 'S'){};
-               
-               blastFile >> sbjctLabel >> sbjctStart >> sbjct >> sbjctEnd;
-               
-               if(seqAaln == ""){
-                       seqAstart = queryStart;
-                       seqBstart = sbjctStart;
-               }
-
-               seqAaln += query;                                       //      concatenate each line of the sequence to what we already have
-               seqBaln += sbjct;                                       //      for the query and template (subject) sequence
-               
-               blastFile >> queryLabel;
-       }
-       seqAend = queryEnd;
-       seqBend = sbjctEnd;
-       pairwiseLength = seqAaln.length();
-
-       for(int i=1;i<seqBstart;i++){                           //      Since the alignments don't always start at (1, 1), we need to pad
-               seqAaln = 'Z' + seqAaln;                                //      the sequences so that they start at the same point
-               seqBaln = 'X' + seqBaln;
-       }
-       
-       for(int i=seqBend+1;i<=templateLength;i++){     //      since the sequences don't necessarily end at the same point, we
-               seqAaln += 'Z';                                                 //      again need ot pad the sequences so that they extend to the length
-               seqBaln += 'X';                                                 //      of the template sequence
-       }
-       blastFile.close();
-}
-
-//**************************************************************************************************/
diff --git a/blastalign.hpp b/blastalign.hpp
deleted file mode 100644 (file)
index 31688bd..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef BlastAlignment_H
-#define BlastAlignment_H
-
-
-/*
- *  blastalign.hpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is a basic alignment method that gets the blast program to do the heavy lifting.  In the future, we should
- *     probably incorporate NCBI's library so that we don't have to call on a user-supplied executable.  This is a child
- *     of the Alignment class, which requires a constructor and align method.
- *
- */
-#include "mothur.h"
-
-
-class BlastAlignment : public Alignment {
-
-public:
-       BlastAlignment(float, float, float, float);
-       ~BlastAlignment();
-       void align(string, string);
-       void setMatrix(int){};
-       
-private:
-
-       string candidateFileName;
-       string templateFileName;
-       string blastFileName;
-       string path;
-
-       void setPairwiseSeqs();
-       float match;
-       float mismatch;
-       float gapOpen;
-       float gapExtend;
-};
-
-#endif
-
-
-
diff --git a/blastdb.cpp b/blastdb.cpp
deleted file mode 100644 (file)
index 2eced7e..0000000
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- *  blastdb.cpp
- *  
- *
- *  Created by Pat Schloss on 12/22/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "database.hpp"
-#include "sequence.hpp"
-#include "blastdb.hpp"
-
-/**************************************************************************************************/
-
-BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b, int tid) : Database(), 
-gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
-       try {
-               count = 0;
-               path = b;
-               threadID = tid;
-
-               int randNumber = rand();
-               //int randNumber = 12345;
-               string pid = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               pid += getpid();        
-#else
-               pid += toString(threadID);      
-#endif
-               
-               
-               dbFileName = tag + pid + toString(randNumber) + ".template.unaligned.fasta";
-               queryFileName = tag + pid + toString(randNumber) + ".candidate.unaligned.fasta";
-               blastFileName = tag + pid + toString(randNumber) + ".blast";
-               
-               //make sure blast exists in the write place
-               if (path == "") {
-                       path = m->argv;
-                       string tempPath = path;
-                       for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); }
-                       path = path.substr(0, (tempPath.find_last_of('m')));
-                       
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       path += "blast/bin/";   
-#else
-                       path += "blast\\bin\\";
-#endif                 
-               }
-               
-               
-               string formatdbCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               formatdbCommand = path + "formatdb";    //      format the database, -o option gives us the ability
-#else
-               formatdbCommand = path + "formatdb.exe";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in;
-               formatdbCommand = m->getFullPathName(formatdbCommand);
-               int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               string blastCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               blastCommand = path + "blastall";       //      format the database, -o option gives us the ability
-#else
-               blastCommand = path + "blastall.exe";
-               //wrap entire string in ""
-               //blastCommand = "\"" + blastCommand + "\"";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in2;
-               blastCommand = m->getFullPathName(blastCommand);
-               ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               
-               string megablastCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               megablastCommand = path + "megablast";  //      format the database, -o option gives us the ability
-#else
-               megablastCommand = path + "megablast.exe";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in3;
-               megablastCommand = m->getFullPathName(megablastCommand);
-               ableToOpen = m->openInputFile(megablastCommand, in3, "no error"); in3.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " +  megablastCommand + " file does not exist. mothur requires megablast.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "BlastDB");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-BlastDB::BlastDB(string b, int tid) : Database() {
-       try {
-               count = 0;
-               
-               path = b;
-               threadID = tid;
-               
-               //make sure blast exists in the write place
-               if (path == "") {
-                       path = m->argv;
-                       string tempPath = path;
-                       for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); }
-                       path = path.substr(0, (tempPath.find_last_of('m')));
-                       
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       path += "blast/bin/";   
-#else
-                       path += "blast\\bin\\";
-#endif                 
-               }
-               
-               int randNumber = rand();
-               string pid = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               pid += getpid();        
-#else
-               pid += toString(threadID);      
-#endif
-               
-               dbFileName = pid + toString(randNumber) + ".template.unaligned.fasta";
-               queryFileName = pid + toString(randNumber) + ".candidate.unaligned.fasta";
-               blastFileName = pid + toString(randNumber) + ".blast";
-               
-               string formatdbCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               formatdbCommand = path + "formatdb";    //      format the database, -o option gives us the ability
-#else
-               formatdbCommand = path + "formatdb.exe";
-               //wrap entire string in ""
-               //formatdbCommand = "\"" + formatdbCommand + "\"";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in;
-               formatdbCommand = m->getFullPathName(formatdbCommand);
-               int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " +  formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               string blastCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               blastCommand = path + "blastall";       //      format the database, -o option gives us the ability
-#else
-               blastCommand = path + "blastall.exe";
-               //wrap entire string in ""
-               //blastCommand = "\"" + blastCommand + "\"";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in2;
-               blastCommand = m->getFullPathName(blastCommand);
-               ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               
-               string megablastCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               megablastCommand = path + "megablast";  //      format the database, -o option gives us the ability
-#else
-               megablastCommand = path + "megablast.exe";
-               //wrap entire string in ""
-               //megablastCommand = "\"" + megablastCommand + "\"";
-#endif
-               
-               //test to make sure formatdb exists
-               ifstream in3;
-               megablastCommand = m->getFullPathName(megablastCommand);
-               ableToOpen = m->openInputFile(megablastCommand, in3, "no error"); in3.close();
-               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + megablastCommand + " file does not exist. mothur requires megablast.exe."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "BlastDB");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-BlastDB::~BlastDB(){
-       try{
-               m->mothurRemove(queryFileName);                         //      let's clean stuff up and remove the temp files
-               m->mothurRemove(dbFileName);                                    //      let's clean stuff up and remove the temp files
-               m->mothurRemove((dbFileName+".nsq"));                                   //      let's clean stuff up and remove the temp files
-               m->mothurRemove((dbFileName+".nsi"));                                   //      let's clean stuff up and remove the temp files
-               m->mothurRemove((dbFileName+".nsd"));                                   //      let's clean stuff up and remove the temp files
-               m->mothurRemove((dbFileName+".nin"));                                   //      let's clean stuff up and remove the temp files
-               m->mothurRemove((dbFileName+".nhr"));                                   //      let's clean stuff up and remove the temp files
-               m->mothurRemove(blastFileName.c_str());                         //      let's clean stuff up and remove the temp files
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "~BlastDB");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-//assumes you have added all the template sequences using the addSequence function and run generateDB.
-vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
-       try{
-               vector<int> topMatches;
-               
-               ofstream queryFile;
-               int randNumber = rand();
-               string pid = scrubName(seq->getName());
-               
-               m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
-               queryFile << '>' << seq->getName() << endl;
-               queryFile << seq->getUnaligned() << endl;
-               queryFile.close();
-
-                               
-               //      the goal here is to quickly survey the database to find the closest match.  To do this we are using the default
-               //      wordsize used in megablast.  I'm sure we're sacrificing accuracy for speed, but anyother way would take way too
-               //      long.  With this setting, it seems comparable in speed to the suffix tree approach.
-               
-               string blastCommand;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-                       blastCommand = path + "blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
-                       blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
-               #else
-                       blastCommand =  "\"" + path + "blastall\" -p blastn -d " + "\"" + dbFileName + "\"" + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n);
-                       blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
-                       //wrap entire string in ""
-                       blastCommand = "\"" + blastCommand + "\"";
-               #endif
-               
-               system(blastCommand.c_str());
-               
-               ifstream m8FileHandle;
-               m->openInputFile(blastFileName+pid+toString(randNumber), m8FileHandle, "no error");
-               
-               string dummy;
-               int templateAccession;
-               m->gobble(m8FileHandle);
-               
-               while(!m8FileHandle.eof()){
-                       m8FileHandle >> dummy >> templateAccession >> searchScore;
-                       
-                       //get rest of junk in line
-                       while (!m8FileHandle.eof())     {       char c = m8FileHandle.get(); if (c == 10 || c == 13){   break;  }       } 
-                       
-                       m->gobble(m8FileHandle);
-                       topMatches.push_back(templateAccession);
-               }
-               m8FileHandle.close();
-               m->mothurRemove((queryFileName+pid+toString(randNumber)));
-               m->mothurRemove((blastFileName+pid+toString(randNumber)));
-
-               return topMatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "findClosestSequences");
-               exit(1);
-       }
-
-}
-/**************************************************************************************************/
-//assumes you have added all the template sequences using the addSequence function and run generateDB.
-vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) {
-       try{
-               vector<int> topMatches;
-               float numBases, mismatch, gap, startQuery, endQuery, startRef, endRef, score;
-               Scores.clear();
-               
-               ofstream queryFile;
-               int randNumber = rand();
-               string pid = scrubName(seq->getName());
-               
-               m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
-               queryFile << '>' << seq->getName() << endl;
-               queryFile << seq->getUnaligned() << endl;
-               queryFile.close();
-//             cout << seq->getUnaligned() << endl;
-               //      the goal here is to quickly survey the database to find the closest match.  To do this we are using the default
-               //      wordsize used in megablast.  I'm sure we're sacrificing accuracy for speed, but anyother way would take way too
-               //      long.  With this setting, it seems comparable in speed to the suffix tree approach.
-//7000004128189528left 0       100             66      0       0       1       66      61      126     1e-31    131    
-               string blastCommand;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       blastCommand = path + "megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
-                       blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
-               #else
-               //blastCommand = path + "blast\\bin\\megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
-               //blastCommand += (" -i " + (queryFileName+toString(randNumber)) + " -o " + blastFileName+toString(randNumber));
-
-                       blastCommand =  "\"" + path + "megablast\" -e 1e-10 -d " + "\"" + dbFileName + "\"" + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn
-                       blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber));
-                       //wrap entire string in ""
-                       blastCommand = "\"" + blastCommand + "\"";
-
-               #endif
-               system(blastCommand.c_str());
-
-               ifstream m8FileHandle;
-               m->openInputFile(blastFileName+pid+toString(randNumber), m8FileHandle, "no error");
-       
-               string dummy, eScore;
-               int templateAccession;
-               m->gobble(m8FileHandle);
-               
-               while(!m8FileHandle.eof()){
-                       m8FileHandle >> dummy >> templateAccession >> searchScore >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
-//                     cout << dummy << '\t' << templateAccession << '\t' << searchScore << '\t' << numBases << '\t' << mismatch << '\t' << gap << '\t' << startQuery << '\t' << endQuery << '\t' << startRef << '\t' << endRef << '\t' << eScore << '\t' << score << endl; 
-                       
-                       //get rest of junk in line
-                       //while (!m8FileHandle.eof())   {       char c = m8FileHandle.get(); if (c == 10 || c == 13){   break;  }else{ cout << c; }     } //
-                               //cout << endl;
-                       m->gobble(m8FileHandle);
-                       if (searchScore >= minPerID) { 
-                               topMatches.push_back(templateAccession);
-                               Scores.push_back(searchScore);
-                       }
-//cout << templateAccession << endl;
-               }
-               m8FileHandle.close();
-               m->mothurRemove((queryFileName+pid+toString(randNumber)));
-               m->mothurRemove((blastFileName+pid+toString(randNumber)));
-//cout << "\n" ;               
-               return topMatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "findClosestMegaBlast");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void BlastDB::addSequence(Sequence seq) {
-       try {
-       
-               ofstream unalignedFastaFile;
-               m->openOutputFileAppend(dbFileName, unalignedFastaFile);                                
-       
-               //      generating a fasta file with unaligned template
-               unalignedFastaFile << '>' << count << endl;                                     //      sequences, which will be input to formatdb
-               unalignedFastaFile << seq.getUnaligned() << endl;
-               unalignedFastaFile.close();
-       
-               count++;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "addSequence");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void BlastDB::generateDB() {
-       try {
-       
-               //m->mothurOut("Generating the temporary BLAST database...\t"); cout.flush();
-                       
-               string formatdbCommand;
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       formatdbCommand = path + "formatdb -p F -o T -i " + dbFileName; //      format the database, -o option gives us the ability
-               #else
-                       //formatdbCommand = path + "blast\\bin\\formatdb -p F -o T -i " + dbFileName;   //      format the database, -o option gives us the ability
-
-                       formatdbCommand = "\"" + path + "formatdb\" -p F -o T -i " + "\"" +  dbFileName + "\"";
-                       //wrap entire string in ""
-                       formatdbCommand = "\"" + formatdbCommand + "\"";
-               #endif
-               //cout << formatdbCommand << endl;
-               system(formatdbCommand.c_str());                                                                //      to get the right sequence names, i think. -p F
-                                                                                                                                       //      option tells formatdb that seqs are DNA, not prot
-               //m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine(); cout.flush();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "generateDB");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string BlastDB::scrubName(string seqName) {
-       try {
-               
-               string cleanName = "";
-               
-               for (int i = 0; i < seqName.length(); i++) {
-                       if (isalnum(seqName[i])) { cleanName += seqName[i]; }
-                       else { cleanName += "_";  }
-               }
-               
-               return cleanName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BlastDB", "scrubName");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-/**************************************************************************************************/
-
diff --git a/blastdb.hpp b/blastdb.hpp
deleted file mode 100644 (file)
index 50a8379..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef BLASTDB_HPP
-#define BLASTDB_HPP
-
-
-/*
- *  blastdb.hpp
- *  
- *
- *  Created by Pat Schloss on 12/22/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-class BlastDB : public Database {
-
-public:
-       BlastDB(string, float, float, float, float, string, int);
-       BlastDB(string, int);
-       ~BlastDB();
-       
-       void generateDB();
-       void addSequence(Sequence);
-       vector<int> findClosestSequences(Sequence*, int);
-       vector<int> findClosestMegaBlast(Sequence*, int, int);
-       
-private:
-       
-       string scrubName(string);
-       
-       string dbFileName;
-       string queryFileName;
-       string blastFileName;
-       string path;
-       
-       int count, threadID;
-       float gapOpen;
-       float gapExtend;
-       float match;
-       float misMatch;
-       
-};
-
-#endif
diff --git a/boneh.cpp b/boneh.cpp
deleted file mode 100644 (file)
index b4ce2ba..0000000
--- a/boneh.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *  boneh.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "boneh.h"
-#include <math.h>
-
-/***********************************************************************/
-
-//This solves for the value of 'v' using a binary search.
-double Boneh::getV(double f1, double n, double rs) {
-
-       if(rs == 0)
-               return 0;
-       
-       double accuracy = .0001;
-       double v = 100000.0;
-       double step = v/2;
-       double ls = v * (1 - pow((1 - f1/(n*v)), n));
-       
-       while(abs(ls - rs) > accuracy) {
-               if(ls > rs)     {       v -= step;      }
-               else            {       v += step;      }
-               
-               ls = v * (1 - pow((1 - f1/(n * v)), n));
-               step /= 2;
-       }
-
-       return v;
-}
-       
-/***********************************************************************/      
-EstOutput Boneh::getValues(SAbundVector* sabund){
-
-       try {
-               data.resize(1,0);
-               
-
-               bool valid = false;
-               double sum = 0;
-               double n = (double)sabund->getNumSeqs();
-               if(f==0){       f=n;    }
-               
-               double f1 = (double)sabund->get(1);
-               
-               for(int i = 1; i < sabund->size(); i++){
-                       sum += (double)sabund->get(i) * exp(-i);
-               }
-
-               if(sabund->get(1) > sum)
-                       valid = true;
-               
-               sum = 0;
-               if(valid) {
-                       for(int j = 1; j < sabund->size(); j++){
-                               sum += sabund->get(j) * pow((1 - (double)j / n), n);
-                       }
-                       
-                       double v = getV(f1, n, sum);
-                       
-                       sum = 0;
-                       for(int j = 1; j < sabund->size(); j++) {
-                               for (int i = 0; i < sabund->get(j); i++) {
-                                       sum += pow(1 - j / n, n) * (1 - pow(1 - j / n, f));
-                               }
-                       }
-                       sum +=  v * pow(1 - f1/(n*v), n) * (1 - pow(1 - f1/(n*v), f));
-               }
-
-               data[0] = sum;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Boneh", "getValues");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
diff --git a/boneh.h b/boneh.h
deleted file mode 100644 (file)
index d16ffa7..0000000
--- a/boneh.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef BONEH_H
-#define BONEH_H
-
-/*
- *  boneh.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the boneh calculator on single group. 
- It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Boneh : public Calculator  {
-       
-public: 
-       Boneh(int size) : f(size), Calculator("boneh", 1, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Boneh"; }
-private:
-       double getV(double, double, double);
-       int f;
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/bootstrap.cpp b/bootstrap.cpp
deleted file mode 100644 (file)
index ce261ce..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  bootstrap.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "bootstrap.h"
-
-/***********************************************************************/
-
-EstOutput Bootstrap::getValues(SAbundVector* rank){
-       try {
-               //vector<double> bootData(3,0);
-               data.resize(1,0);
-               double maxRank = (double)rank->getMaxRank();
-               double sampled = rank->getNumSeqs();
-               double sobs = rank->getNumBins();
-
-               double boot = (double)sobs;
-
-               for(int i=1;i<=maxRank;i++){
-                       boot += (double)rank->get(i)*pow((1.0-(double)i/(double)sampled),sampled);
-               }
-               
-               data[0] = boot;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-       
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Bootstrap", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/bootstrap.h b/bootstrap.h
deleted file mode 100644 (file)
index 962780a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef BOOTSTRAP_H
-#define BOOTSTRAP_H
-/*
- *  bootstrap.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Bootstrap estimator on single group. 
-It is a child of the calculator class. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-
-class Bootstrap : public Calculator  {
-       
-public:
-       Bootstrap() : Calculator("bootstrap", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Bootstrap"; }
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/bsplvb.f b/bsplvb.f
deleted file mode 100644 (file)
index 64ca95b..0000000
--- a/bsplvb.f
+++ /dev/null
@@ -1,102 +0,0 @@
-      subroutine bsplvb ( t, lent,jhigh, index, x, left, biatx )
-c      implicit none
-c     -------------
-
-calculates the value of all possibly nonzero b-splines at  x  of order
-c
-c               jout  =  dmax( jhigh , (j+1)*(index-1) )
-c
-c  with knot sequence  t .
-c
-c******  i n p u t  ******
-c  t.....knot sequence, of length  left + jout  , assumed to be nonde-
-c        creasing.
-c    a s s u m p t i o n  :  t(left)  <  t(left + 1)
-c    d i v i s i o n  b y  z e r o  will result if  t(left) = t(left+1)
-c
-c  jhigh,
-c  index.....integers which determine the order  jout = max(jhigh,
-c        (j+1)*(index-1))  of the b-splines whose values at  x  are to
-c        be returned.  index  is used to avoid recalculations when seve-
-c        ral columns of the triangular array of b-spline values are nee-
-c        ded (e.g., in  bvalue  or in  bsplvd ). precisely,
-c                     if  index = 1 ,
-c        the calculation starts from scratch and the entire triangular
-c        array of b-spline values of orders 1,2,...,jhigh  is generated
-c        order by order , i.e., column by column .
-c                     if  index = 2 ,
-c        only the b-spline values of order  j+1, j+2, ..., jout  are ge-
-c        nerated, the assumption being that  biatx , j , deltal , deltar
-c        are, on entry, as they were on exit at the previous call.
-c           in particular, if  jhigh = 0, then  jout = j+1, i.e., just
-c        the next column of b-spline values is generated.
-c
-c  w a r n i n g . . .  the restriction   jout <= jmax (= 20)  is
-c        imposed arbitrarily by the dimension statement for  deltal and
-c        deltar  below, but is  n o w h e r e  c h e c k e d  for .
-c
-c  x.....the point at which the b-splines are to be evaluated.
-c  left.....an integer chosen (usually) so that
-c                  t(left) <= x <= t(left+1)  .
-c
-c******  o u t p u t  ******
-c  biatx.....array of length  jout , with  biatx(i)  containing the val-
-c        ue at  x  of the polynomial of order  jout  which agrees with
-c        the b-spline  b(left-jout+i,jout,t)  on the interval (t(left),
-c        t(left+1)) .
-c
-c******  m e t h o d  ******
-c  the recurrence relation
-c
-c                       x - t(i)               t(i+j+1) - x
-c     b(i,j+1)(x)  =  ----------- b(i,j)(x) + --------------- b(i+1,j)(x)
-c                     t(i+j)-t(i)             t(i+j+1)-t(i+1)
-c
-c  is used (repeatedly) to generate the
-c  (j+1)-vector  b(left-j,j+1)(x),...,b(left,j+1)(x)
-c  from the j-vector  b(left-j+1,j)(x),...,b(left,j)(x),
-c  storing the new values in  biatx  over the old.  the facts that
-c            b(i,1) = 1         if  t(i) <= x < t(i+1)
-c  and that
-c            b(i,j)(x) = 0  unless  t(i) <= x < t(i+j)
-c  are used. the particular organization of the calculations follows
-c  algorithm (8)  in chapter x of the text.
-c
-
-C Arguments
-      integer lent, jhigh, index, left
-      double precision t(lent),x, biatx(jhigh)
-c     dimension     t(left+jout), biatx(jout)
-c     -----------------------------------
-c current fortran standard makes it impossible to specify the length of
-c  t  and of  biatx  precisely without the introduction of otherwise
-c  superfluous additional arguments.
-
-C Local Variables
-      integer jmax
-      parameter(jmax = 20)
-      integer i,j,jp1
-      double precision deltal(jmax), deltar(jmax),saved,term
-
-      save j,deltal,deltar
-      data j/1/
-c
-                                        go to (10,20), index
-   10 j = 1
-      biatx(1) = 1d0
-      if (j .ge. jhigh)                 go to 99
-c
-   20    jp1 = j + 1
-         deltar(j) = t(left+j) - x
-         deltal(j) = x - t(left+1-j)
-         saved = 0d0
-         do 26 i=1,j
-            term = biatx(i)/(deltar(i) + deltal(jp1-i))
-            biatx(i) = saved + deltar(i)*term
-   26       saved = deltal(jp1-i)*term
-         biatx(jp1) = saved
-         j = jp1
-         if (j .lt. jhigh)              go to 20
-c
-   99                                   return
-      end
diff --git a/bsplvd.f b/bsplvd.f
deleted file mode 100644 (file)
index 47a5586..0000000
--- a/bsplvd.f
+++ /dev/null
@@ -1,118 +0,0 @@
-      subroutine bsplvd ( t, lent, k, x, left, a, dbiatx, nderiv )
-c     --------   ------
-c      implicit none
-
-C calculates value and deriv.s of all b-splines which do not vanish at x
-C calls bsplvb
-c
-c******  i n p u t  ******
-c  t     the knot array, of length left+k (at least)
-c  k     the order of the b-splines to be evaluated
-c  x     the point at which these values are sought
-c  left  an integer indicating the left endpoint of the interval of
-c        interest. the  k  b-splines whose support contains the interval
-c               (t(left), t(left+1))
-c        are to be considered.
-c  a s s u m p t i o n  - - -  it is assumed that
-c               t(left) < t(left+1)
-c        division by zero will result otherwise (in  b s p l v b ).
-c        also, the output is as advertised only if
-c               t(left) <= x <= t(left+1) .
-c  nderiv   an integer indicating that values of b-splines and their
-c        derivatives up to but not including the  nderiv-th  are asked
-c        for. ( nderiv  is replaced internally by the integer in (1,k)
-c        closest to it.)
-c
-c******  w o r k   a r e a  ******
-c  a     an array of order (k,k), to contain b-coeff.s of the derivat-
-c        ives of a certain order of the  k  b-splines of interest.
-c
-c******  o u t p u t  ******
-c  dbiatx   an array of order (k,nderiv). its entry  (i,m)  contains
-c        value of  (m-1)st  derivative of  (left-k+i)-th  b-spline of
-c        order  k  for knot sequence  t , i=m,...,k; m=1,...,nderiv.
-c
-c******  m e t h o d  ******
-c  values at  x  of all the relevant b-splines of order k,k-1,...,
-c  k+1-nderiv  are generated via  bsplvb  and stored temporarily
-c  in  dbiatx .  then, the b-coeffs of the required derivatives of the
-c  b-splines of interest are generated by differencing, each from the
-c  preceding one of lower order, and combined with the values of b-
-c  splines of corresponding order in  dbiatx  to produce the desired
-c  values.
-
-C Args
-      integer lent,k,left,nderiv
-      double precision t(lent),x, dbiatx(k,nderiv), a(k,k)
-C Locals
-      double precision factor,fkp1mm,sum
-      integer i,ideriv,il,j,jlow,jp1mid, kp1,kp1mm,ldummy,m,mhigh
-
-      mhigh = max0(min0(nderiv,k),1)
-c     mhigh is usually equal to nderiv.
-      kp1 = k+1
-      call bsplvb(t,lent,kp1-mhigh,1,x,left,dbiatx)
-      if (mhigh .eq. 1)                 go to 99
-c     the first column of  dbiatx  always contains the b-spline values
-c     for the current order. these are stored in column k+1-current
-c     order  before  bsplvb  is called to put values for the next
-c     higher order on top of it.
-      ideriv = mhigh
-      do 15 m=2,mhigh
-         jp1mid = 1
-         do 11 j=ideriv,k
-            dbiatx(j,ideriv) = dbiatx(jp1mid,1)
-   11       jp1mid = jp1mid + 1
-         ideriv = ideriv - 1
-         call bsplvb(t,lent,kp1-ideriv,2,x,left,dbiatx)
-   15    continue
-c
-c     at this point,  b(left-k+i, k+1-j)(x) is in  dbiatx(i,j) for
-c     i=j,...,k and j=1,...,mhigh ('=' nderiv). in particular, the
-c     first column of  dbiatx  is already in final form. to obtain cor-
-c     responding derivatives of b-splines in subsequent columns, gene-
-c     rate their b-repr. by differencing, then evaluate at  x.
-c
-      jlow = 1
-      do 20 i=1,k
-         do 19 j=jlow,k
-   19       a(j,i) = 0d0
-         jlow = i
-   20    a(i,i) = 1d0
-c     at this point, a(.,j) contains the b-coeffs for the j-th of the
-c     k  b-splines of interest here.
-c
-      do 40 m=2,mhigh
-         kp1mm = kp1 - m
-         fkp1mm = dble(kp1mm)
-         il = left
-         i = k
-c
-c        for j=1,...,k, construct b-coeffs of  (m-1)st  derivative of
-c        b-splines from those for preceding derivative by differencing
-c        and store again in  a(.,j) . the fact that  a(i,j) = 0  for
-c        i < j  is used.sed.
-         do 25 ldummy=1,kp1mm
-            factor = fkp1mm/(t(il+kp1mm) - t(il))
-c           the assumption that t(left) < t(left+1) makes denominator
-c           in  factor  nonzero.
-            do 24 j=1,i
-   24          a(i,j) = (a(i,j) - a(i-1,j))*factor
-            il = il - 1
-   25       i = i - 1
-c
-c        for i=1,...,k, combine b-coeffs a(.,i) with b-spline values
-c        stored in dbiatx(.,m) to get value of  (m-1)st  derivative of
-c        i-th b-spline (of interest here) at  x , and store in
-c        dbiatx(i,m). storage of this value over the value of a b-spline
-c        of order m there is safe since the remaining b-spline derivat-
-c        ive of the same order do not use this value due to the fact
-c        that  a(j,i) = 0  for j < i .
-         do 40 i=1,k
-            sum = 0.d0
-            jlow = max0(i,m)
-            do 35 j=jlow,k
-   35          sum = a(j,i)*dbiatx(j,m) + sum
-   40       dbiatx(i,m) = sum
-   99 return
-      end
diff --git a/bstick.cpp b/bstick.cpp
deleted file mode 100644 (file)
index 67507a9..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *  bstick.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "bstick.h"
-
-
-/***********************************************************************/
-double BStick::invSum(int index, double numSpec)
-{
-       double sum = 0;
-       for(int i = index; i <= numSpec; i++)
-               sum += 1/(double)i;
-       return sum;
-}
-/***********************************************************************/
-RAbundVector BStick::getRAbundVector(SAbundVector* rank){
-               vector <int> rData;
-               int mr = 1;
-               int nb = 0;
-               int ns = 0;
-               
-               for(int i = rank->size()-1; i > 0; i--) {
-                       double cur = rank->get(i);
-                       if(mr == 1 && cur > 0)
-                               mr = i;
-                       nb += cur;
-                       ns += i*cur;
-                       for(int j = 0; j < cur; j++)
-                               rData.push_back(i);
-               }
-               
-               RAbundVector rav = RAbundVector(rData, mr, nb, ns);
-               rav.setLabel(rank->getLabel());
-               return rav;
-}
-
-/***************************************************************************/
-
-/***************************************************************************/
-EstOutput BStick::getValues(SAbundVector* rank){
-       try {
-               data.resize(3,0);
-               rdata = getRAbundVector(rank);
-               double numInd = (double)rdata.getNumSeqs();
-               double numSpec = (double)rdata.getNumBins();
-               
-               double sumExp = 0;
-               double sumObs = 0;
-               double maxDiff = 0;
-
-               for(int i = 0; i < rdata.size(); i++) {
-                       sumObs += rdata.get(i);
-                       sumExp += numInd/numSpec*invSum(i+1,numSpec);
-                       double diff = fabs(sumObs-sumExp);
-                       if(diff > maxDiff)
-                               maxDiff = diff;
-               }
-               
-
-               data[0] = maxDiff/numInd;
-               data[1] = 0.886/sqrt(rdata.size());
-               data[2] = 1.031/sqrt(rdata.size());
-
-               /*m->mothurOut(critVal); m->mothurOutEndLine();
-               m->mothurOut("If D-Statistic is less than the critical value then the data fits the Broken Stick model w/ 95% confidence.\n");*/
-               
-
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BStick", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
diff --git a/bstick.h b/bstick.h
deleted file mode 100644 (file)
index 11f4b8c..0000000
--- a/bstick.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef BSTICK_H
-#define BSTICK_H
-/*
- *  bstick.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/*This class implements the BStick estimator on single group. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class BStick : public Calculator  {
-       
-public:
-       BStick() : Calculator("bstick", 3, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Bstick"; }
-private:
-       double invSum(int, double);
-       RAbundVector getRAbundVector(SAbundVector*);
-       RAbundVector rdata;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/bvalue.f b/bvalue.f
deleted file mode 100644 (file)
index 3201c18..0000000
--- a/bvalue.f
+++ /dev/null
@@ -1,135 +0,0 @@
-      real function bvalue ( t, bcoef, n, k, x, jderiv )
-c  from  * a practical guide to splines *  by c. de boor    
-calls  interv
-c
-calculates value at  x  of  jderiv-th derivative of spline from b-repr.
-c  the spline is taken to be continuous from the right, EXCEPT at the
-c  rightmost knot, where it is taken to be continuous from the left.
-c
-c******  i n p u t ******
-c  t, bcoef, n, k......forms the b-representation of the spline  f  to
-c        be evaluated. specifically,
-c  t.....knot sequence, of length  n+k, assumed nondecreasing.
-c  bcoef.....b-coefficient sequence, of length  n .
-c  n.....length of  bcoef  and dimension of spline(k,t),
-c        a s s u m e d  positive .
-c  k.....order of the spline .
-c
-c  w a r n i n g . . .   the restriction  k .le. kmax (=20)  is imposed
-c        arbitrarily by the dimension statement for  aj, dl, dr  below,
-c        but is  n o w h e r e  c h e c k e d  for.
-c
-c  x.....the point at which to evaluate .
-c  jderiv.....integer giving the order of the derivative to be evaluated
-c        a s s u m e d  to be zero or positive.
-c
-c******  o u t p u t  ******
-c  bvalue.....the value of the (jderiv)-th derivative of  f  at  x .
-c
-c******  m e t h o d  ******
-c     The nontrivial knot interval  (t(i),t(i+1))  containing  x  is lo-
-c  cated with the aid of  interv . The  k  b-coeffs of  f  relevant for
-c  this interval are then obtained from  bcoef (or taken to be zero if
-c  not explicitly available) and are then differenced  jderiv  times to
-c  obtain the b-coeffs of  (d**jderiv)f  relevant for that interval.
-c  Precisely, with  j = jderiv, we have from x.(12) of the text that
-c
-c     (d**j)f  =  sum ( bcoef(.,j)*b(.,k-j,t) )
-c
-c  where
-c                   / bcoef(.),                     ,  j .eq. 0
-c                   /
-c    bcoef(.,j)  =  / bcoef(.,j-1) - bcoef(.-1,j-1)
-c                   / ----------------------------- ,  j .gt. 0
-c                   /    (t(.+k-j) - t(.))/(k-j)
-c
-c     Then, we use repeatedly the fact that
-c
-c    sum ( a(.)*b(.,m,t)(x) )  =  sum ( a(.,x)*b(.,m-1,t)(x) )
-c  with
-c                 (x - t(.))*a(.) + (t(.+m-1) - x)*a(.-1)
-c    a(.,x)  =    ---------------------------------------
-c                 (x - t(.))      + (t(.+m-1) - x)
-c
-c  to write  (d**j)f(x)  eventually as a linear combination of b-splines
-c  of order  1 , and the coefficient for  b(i,1,t)(x)  must then be the
-c  desired number  (d**j)f(x). (see x.(17)-(19) of text).
-c
-      integer jderiv,k,n,   i,ilo,imk,j,jc,jcmin,jcmax,jj,kmax,kmj,km1
-     *                     ,mflag,nmi,jdrvp1
-      parameter (kmax = 20)
-      real bcoef(n),t(n+k),x,   aj(kmax),dl(kmax),dr(kmax),fkmj
-      bvalue = 0.
-      if (jderiv .ge. k)                go to 99
-c
-c  *** Find  i   s.t.   1 .le. i .lt. n+k   and   t(i) .lt. t(i+1)   and
-c      t(i) .le. x .lt. t(i+1) . If no such i can be found,  x  lies
-c      outside the support of  the spline  f , hence  bvalue = 0.
-c      (The asymmetry in this choice of  i  makes  f  rightcontinuous, except
-c      at  t(n+k) where it is leftcontinuous.)
-      call interv ( t, n+k, x, i, mflag )
-      if (mflag .ne. 0)                 go to 99
-c  *** if k = 1 (and jderiv = 0), bvalue = bcoef(i).
-      km1 = k - 1
-      if (km1 .gt. 0)                   go to 1
-      bvalue = bcoef(i)
-                                        go to 99
-c
-c  *** store the k b-spline coefficients relevant for the knot interval
-c     (t(i),t(i+1)) in aj(1),...,aj(k) and compute dl(j) = x - t(i+1-j),
-c     dr(j) = t(i+j) - x, j=1,...,k-1 . set any of the aj not obtainable
-c     from input to zero. set any t.s not obtainable equal to t(1) or
-c     to t(n+k) appropriately.
-    1 jcmin = 1
-      imk = i - k
-      if (imk .ge. 0)                   go to 8
-      jcmin = 1 - imk
-      do 5 j=1,i
-    5    dl(j) = x - t(i+1-j)
-      do 6 j=i,km1
-         aj(k-j) = 0.
-    6    dl(j) = dl(i)
-                                        go to 10
-    8 do 9 j=1,km1
-    9    dl(j) = x - t(i+1-j)
-c
-   10 jcmax = k
-      nmi = n - i
-      if (nmi .ge. 0)                   go to 18
-      jcmax = k + nmi
-      do 15 j=1,jcmax
-   15    dr(j) = t(i+j) - x
-      do 16 j=jcmax,km1
-         aj(j+1) = 0.
-   16    dr(j) = dr(jcmax)
-                                        go to 20
-   18 do 19 j=1,km1
-   19    dr(j) = t(i+j) - x
-c
-   20 do 21 jc=jcmin,jcmax
-   21    aj(jc) = bcoef(imk + jc)
-c
-c               *** difference the coefficients  jderiv  times.
-      if (jderiv .eq. 0)                go to 30
-      do 23 j=1,jderiv
-         kmj = k-j
-         fkmj = float(kmj)
-         ilo = kmj
-         do 23 jj=1,kmj
-            aj(jj) = ((aj(jj+1) - aj(jj))/(dl(ilo) + dr(jj)))*fkmj
-   23       ilo = ilo - 1
-c
-c  *** compute value at  x  in (t(i),t(i+1)) of jderiv-th derivative,
-c     given its relevant b-spline coeffs in aj(1),...,aj(k-jderiv).
-   30 if (jderiv .eq. km1)              go to 39
-      jdrvp1 = jderiv + 1     
-      do 33 j=jdrvp1,km1
-         kmj = k-j
-         ilo = kmj
-         do 33 jj=1,kmj
-            aj(jj) = (aj(jj+1)*dl(ilo) + aj(jj)*dr(jj))/(dl(ilo)+dr(jj))
-   33       ilo = ilo - 1
-   39 bvalue = aj(1)
-c
-   99                                   return
-      end
diff --git a/calculator.cpp b/calculator.cpp
deleted file mode 100644 (file)
index 3aa6a57..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *  calculator.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-int VecCalc::sumElements(vector<int> vec){
-               return sumElements(vec,0);
-}
-/***********************************************************************/
-int VecCalc::sumElements(vector<int> vec, int index){
-       
-               int sum = 0;
-               for(int i = index; i < vec.size(); i++)
-                       sum += vec.at(i);
-               return sum;
-       
-}
-
-/***********************************************************************/
-double VecCalc::sumElements(vector<double> vec){
-               double sum = 0;
-               for(int i = 0; i < vec.size(); i++)
-                       sum += vec.at(i);
-               return sum;
-       
-}
-/***********************************************************************/
-double VecCalc::sumElements(vector<double> vec, int index){
-       
-               double sum = 0;
-               for(int i = index; i < vec.size(); i++)
-                       sum += vec.at(i);
-               return sum;
-       
-}
-/***********************************************************************/
-int VecCalc::numNZ(vector<int> vec){
-       
-               int numNZ = 0;
-               for(int i = 0; i < vec.size(); i++)
-                       if(vec.at(i) != 0)
-                               numNZ++;
-               return numNZ;
-       
-}
-/***********************************************************************/
-double VecCalc::numNZ(vector<double> vec){
-       
-               double numNZ = 0;
-               for(int i = 0; i < vec.size(); i++)
-                       if(vec.at(i) != 0)
-                               numNZ++;
-               return numNZ;
-       }
-/***********************************************************************/
-double TDTable::getConfLimit(int row, int col) //Rows are the degrees of freedom
-{                         
-               //Found on http://www.vgtu.lt/leidiniai/elektroniniai/Probability.pdf/Table%203.pdf
-
-               //Confidence Level        .90    .95     .975     .99    .995     .999    .9995
-               double values[30][7] = {{3.078, 6.314,  12.706, 31.821, 63.656, 318.289, 636.578},
-                                                       {1.886, 2.920,  4.303,  6.965,  9.925,  22.328, 31.600},
-                                                           {1.638,     2.353,  3.182,  4.541,  5.841,  10.214, 12.924},
-                                                           {1.533,     2.132,  2.776,  3.747,  4.604,  7.173,  8.610},
-                                                               {1.476, 2.015,  2.571,  3.365,  4.032,  5.894,  6.869},
-                                                               {1.440, 1.943,  2.447,  3.143,  3.707,  5.208,  5.959},
-                                                               {1.415, 1.895,  2.365,  2.998,  3.499,  4.785,  5.408},
-                                                               {1.397, 1.860,  2.306,  2.896,  3.355,  4.501,  5.041},
-                                                               {1.383, 1.833,  2.262,  2.821,  3.250,  4.297,  4.781},
-                                                               {1.372, 1.812,  2.228,  2.764,  3.169,  4.144,  4.587},
-                                                               {1.363, 1.796,  2.201,  2.718,  3.106,  4.025,  4.437},
-                                                               {1.356, 1.782,  2.179,  2.681,  3.055,  3.930,  4.318},
-                                                               {1.350, 1.771,  2.160,  2.650,  3.012,  3.852,  4.221},
-                                                               {1.345, 1.761,  2.145,  2.624,  2.977,  3.787,  4.140},
-                                                               {1.341, 1.753,  2.131,  2.602,  2.947,  3.733,  4.073},
-                                                               {1.337, 1.746,  2.120,  2.583,  2.921,  3.686,  4.015},
-                                                               {1.333, 1.740,  2.110,  2.567,  2.898,  3.646,  3.965},
-                                                               {1.330, 1.734,  2.101,  2.552,  2.878,  3.610,  3.922},
-                                                               {1.328, 1.729,  2.093,  2.539,  2.861,  3.579,  3.883},
-                                                               {1.325, 1.725,  2.086,  2.528,  2.845,  3.552,  3.850},
-                                                               {1.323, 1.721,  2.080,  2.518,  2.831,  3.527,  3.819},
-                                                               {1.321, 1.717,  2.074,  2.508,  2.819,  3.505,  3.792},
-                                                               {1.319, 1.714,  2.069,  2.500,  2.807,  3.485,  3.768},
-                                                               {1.318, 1.711,  2.064,  2.492,  2.797,  3.467,  3.745},
-                                                               {1.316, 1.708,  2.060,  2.485,  2.787,  3.450,  3.725},
-                                                               {1.315, 1.706,  2.056,  2.479,  2.779,  3.435,  3.707},
-                                                               {1.314, 1.703,  2.052,  2.473,  2.771,  3.421,  3.689},
-                                                               {1.313, 1.701,  2.048,  2.467,  2.763,  3.408,  3.674},
-                                                               {1.311, 1.699,  2.045,  2.462,  2.756,  3.396,  3.660},
-                                                               {1.310, 1.697,  2.042,  2.457,  2.750,  3.385,  3.646}};
-                                                               
-               return values[row][col];
-       
-}
-
-/***********************************************************************/
-
-
-
diff --git a/calculator.h b/calculator.h
deleted file mode 100644 (file)
index 2c41329..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-#ifndef CALCULATOR_H
-#define CALCULATOR_H
-
-
-#include "mothur.h"
-#include "sabundvector.hpp"
-#include "sharedsabundvector.h"
-#include "rabundvector.hpp"
-#include "uvest.h"
-#include "mothurout.h"
-
-/* The calculator class is the parent class for all the different estimators implemented in mothur except the tree calculators.
-It has 2 pure functions EstOutput getValues(SAbundVector*), which works on a single group, and 
-EstOutput getValues(SharedRAbundVector* shared1, SharedRAbundVector* shared2), which compares 2 groups. */ 
-
-
-typedef vector<double> EstOutput;
-
-/***********************************************************************/
-
-class Calculator {
-
-public:
-       Calculator(){ m = MothurOut::getInstance(); needsAll = false; }
-       virtual ~Calculator(){};
-       Calculator(string n, int c, bool f) : name(n), cols(c), multiple(f) { m = MothurOut::getInstance(); needsAll = false; };
-       Calculator(string n, int c, bool f, bool a) : name(n), cols(c), multiple(f), needsAll(a) { m = MothurOut::getInstance(); };
-       virtual EstOutput getValues(SAbundVector*) = 0; 
-       virtual EstOutput getValues(vector<SharedRAbundVector*>) = 0;
-       virtual void print(ostream& f)  { f.setf(ios::fixed, ios::floatfield); f.setf(ios::showpoint);
-                                                                         f << data[0]; for(int i=1;i<data.size();i++){ f << '\t' << data[i];   }}
-       virtual string getName()                {       return name;    }
-       virtual int getCols()           {       return cols;    }
-       virtual bool getMultiple()  {   return multiple;   }
-       virtual bool getNeedsAll()  {   return needsAll;   }
-       virtual string getCitation() = 0;
-       void citation() { m->mothurOut(getCitation()); m->mothurOutEndLine(); }
-protected:
-       MothurOut* m;
-       EstOutput data;
-       string name;
-       int cols;
-       bool multiple;
-       bool needsAll;
-
-};
-
-/**************************************************************************************************/
-/*This Class holds all of the methods that manipulate vectors.
-These methods are used in the other classes.
-This class must be included if any of the other classes are to be used. */
-
-class VecCalc
-{
-       // The methods seen in the order here is how they are ordered throughout the class.
-       public:
-               VecCalc(){};
-               //void printElements(vector<double>); //This prints the values of the vector on one line with a space between each value.
-               //void printElements(vector<string>); //This prints the values of the vector on one line with a space between each value.
-               //int findString(vector<string>, string);//This returns the index of the given string in the given <string> vector, if the string does not exist in the vector it returns -1.
-               //double mean(vector<double>); //This returns the mean value of the vector.
-               //double stError(vector<double>); //This returns the standard error of the vector.
-               int sumElements(vector<int>, int);
-               int sumElements(vector<int>);
-               double sumElements(vector<double>); //This returns the sum of all the values in the vector.
-               double sumElements(vector<double>, int); //This returns the sum of all the values in the vector excluding those whose index is before the given index.  
-               //double findMax(vector<double>); //This returns the maximum value in the vector.
-               int numNZ(vector<int>); //This returns the number of non-zero values in the vector.
-               double numNZ(vector<double>); //This returns the number of non-zero values in the vector.
-               //double numPos(vector<double>); //This returns the number of positive values in the vector.
-               //double findMaxDiff(vector<double>, vector<double>); //This returns the absolute value of the maximum difference between the two vectors.
-               //double findDStat(vector<double>, vector<double>, double); //This returns the D-Statistic of the two vectors with the given total number of species.
-               //vector<int> findQuartiles(vector<double>); //This returns a vector with the first element being the index of the lower quartile of the vector and the second element being the index of the upper quartile of the vector.
-               //vector<double> add(vector<double>, double); //This adds the given number to every element in the given vector and returns the new vector.
-               //vector<double> multiply(vector<double>, double); //This multiplies every element in the given vector by the given number and returns the new vector.
-               //vector<double> power(vector<double>, double); //This raises every element in the given vector to the given number and returns the new vector.
-               //vector<double> addVecs(vector<double>,vector<double>); //The given vectors must be the same size. This adds the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
-               //vector<double> multVecs(vector<double>,vector<double>); //The given vectors must be the same size. This multiplies the ith element of the first given vector to the ith element of the second given vector and returns the new vector.
-               //vector<double> remDup(vector<double>); //This returns a vector that contains 1 of each unique element in the given vector. The order of the elements is not changed.
-               //vector<double> genCVec(vector<double>); //This returns a cumilative vector of the given vector. The ith element of the returned vector is the sum of all the elements in the given vector up to i.
-               //vector<double> genRelVec(vector<double>); //This finds the sum of all the elements in the given vector and then divides the ith element in the given vector by that sum and then puts the result into a new vector, which is returned after all of the elements in the given vector have been used.
-               ///vector<double> genDiffVec(vector<double>, vector<double>);//This subtracts the ith element of the second given vector from the ith element of the first given vector and returns the new vector.
-               //vector<double> genCSVec(vector<double>);//This calculates the number of species that have the same number of individuals as the ith element of the given vector and then returns a cumulative vector.
-               //vector<double> genTotVec(vector<vector<double> >); //This adds up the ith element of all the columns and puts that value into a new vector. It those this for all the rows and then returns the new vector.
-               //vector<double> quicksort(vector<double>); //This sorts the given vector from highest to lowest and returns the sorted vector.
-               //vector<vector<double> > gen2DVec(vector<double>, int, int); //(vector, #rows/columns, 0 if the second parameter was rows, 1 if the second parameter was columns) Transforms a single vector that was formatted like a table into a 2D vector.
-               //vector<string> getSData(char[]);//This takes a file name as a parameter and reads all of the data in the file into a <string> vector.
-};
-
-/**************************************************************************************************/
-
-/*This Class is similar to the GeometricSeries.h class. It calculates
-the broken stick distribution of the table and prints the D-Statistic 
-and the confidence limits for the Kolmogorov-Smirnov 1-Sample test
-with a 95% confidence level.
-
-class BrokenStick
-{
-       public:
-               void doBStick(vector<double>);
-};
-
-/**************************************************************************************************/
-/*This Class calculates the geometric series distribution for the data.
-It prints the D-Statistic and the critical values for the Kolmogorov-Smirnov
-1-sample test at the 95% confidence interval.*/
-
-/*class GeometricSeries
-{
-       public:
-               void doGeomTest(vector<double>);
-};*/
-
-/**************************************************************************************************
-//This Class calculates the jackknifed estimate of the data and
-//prints it and the confidence limits at a chosen confidence level.
-
-class Jackknifing
-{
-       public:
-               void doJK(vector<double>, double);
-};
-/**************************************************************************************************
-/*This Class stores calculates the Kolmogorov-Smirnov 2-Sample test between two samples.
-It prints the D-Statistic and the critical value for the test at 
-the 90% and 95% confidence interval.
-
-class KS2SampleTest
-{
-       public:
-               void doKSTest(vector<double>, vector<double>);
-};
-
-/**************************************************************************************************
-//This Class calculates and prints the Q-Statistic for the data.
-class QStatistic
-{
-       public:
-               void doQStat(vector<double>);
-};
-/**************************************************************************************************
-class SSBPDiversityIndices
-{
-       public:
-               void doSSBP(vector<double>);
-               double getShan(vector<double> vec);//The Shannon Index
-               double getSimp(vector<double> vec);//The Simpson Index
-               double getBP(vector<double> vec);//The Berger-Parker Index
-};
-/**************************************************************************************************/
-//This Class stores the table of the confidence limits of the Student-T distribution.
-class TDTable
-{
-       public:
-               double getConfLimit(int,int);
-};
-
-/**************************************************************************************************
-//This Class stores the table of the confidence limits of the One-Sample Kolmogorov-Smirnov Test.
-class KOSTable
-{
-       public:
-               double getConfLimit(int);
-};
-
-/**************************************************************************************************/
-/*This Class calculates the truncated lognormal for the data.
-It then prints the D-Statistic and the critical values for the
-Kolmogorov-Smirnov 1-Sample test.*
-
-class TrunLN
-{
-       public:
-               void doTrunLN(vector<double>, vector<double>);
-};
-/**************************************************************************************************/
-
-#endif
-
diff --git a/canberra.cpp b/canberra.cpp
deleted file mode 100644 (file)
index 9ab6234..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *  canberra.cpp
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "canberra.h"
-
-/***********************************************************************/
-
-EstOutput Canberra::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               int numSharedOTUS = 0;
-               
-               double sum = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       //is this otu shared
-                       if ((Aij != 0) && (Bij != 0)) { numSharedOTUS++; }
-                       
-                       if ((Aij + Bij) != 0) { 
-                               sum += ((abs(Aij - Bij)) / (float) (Aij + Bij));
-                       }
-               }
-               
-               data[0] = (1 / (float) shared[0]->getNumBins()) * sum;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Canberra", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/canberra.h b/canberra.h
deleted file mode 100644 (file)
index 483d119..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef CANBERRA_H
-#define CANBERRA_H
-
-/*
- *  canberra.h
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Canberra : public Calculator  {
-       
-public:
-       Canberra() :  Calculator("canberra", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Canberra"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/catchallcommand.cpp b/catchallcommand.cpp
deleted file mode 100644 (file)
index bf866cb..0000000
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- *  catchallcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/11/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "catchallcommand.h"
-
-//**********************************************************************************************************************
-vector<string> CatchAllCommand::setParameters(){       
-       try {
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               //can choose shared or sabund not both, so put them in the same chooseOnlyOneGroup
-               CommandParameter pshared("shared", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none",false,false); parameters.push_back(pshared);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "catchallInputs", "catchallInputs", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CatchAllCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The catchall command interfaces mothur with the catchall program written by Linda Woodard, Sean Connolly and John Bunge.\n";
-               helpString += "For more information about catchall refer to http://www.northeastern.edu/catchall/index.html \n";
-               helpString += "The catchall executable must be in the same folder as your mothur executable. \n";
-               helpString += "If you are a MAC or Linux user you must also have installed mono, a link to mono is on the webpage. \n";
-               helpString += "The catchall command parameters are shared, sabund and label.  shared or sabund is required. \n";
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "The catchall command should be in the following format: \n";
-               helpString += "catchall(sabund=yourSabundFile) \n";
-               helpString += "Example: catchall(sabund=abrecovery.fn.sabund) \n";      
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CatchAllCommand::CatchAllCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               //initialize outputTypes
-               vector<string> tempOutNames;
-               outputTypes["csv"] = tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-CatchAllCommand::CatchAllCommand(string option)  {     
-       try {
-               
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["csv"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-
-                       //check for required parameters
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }
-                       else if (sabundfile == "not found") { sabundfile = "";  }
-                       else { m->setSabundFile(sabundfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }
-                       else if (sharedfile == "not found") { sharedfile = "";   }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       string label = validParameter.validFile(parameters, "label", false);                    
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-               
-                       if ((sharedfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to shared, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") {  m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       sabundfile = m->getSabundFile(); 
-                                       if (sabundfile != "") {  m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a sabund or shared file before you can use the catchall command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           
-                       if (outputDir == "not found"){  
-                               if (sabundfile != "") {  outputDir = m->hasPath(sabundfile); }
-                               else { outputDir = m->hasPath(sharedfile); }
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "CatchAllCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int CatchAllCommand::execute() {       
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get location of catchall
-               path = m->argv;
-               path = path.substr(0, (path.find_last_of("othur")-5));
-               path = m->getFullPathName(path);
-               
-               savedOutputDir = outputDir;
-               string catchAllCommandExe = ""; 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       catchAllCommandExe += "mono " + path + "CatchAllcmdL.exe ";
-                       if (outputDir == "") { outputDir = "./"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd.
-               #else
-                       catchAllCommandExe += "\"" + path + "CatchAllcmdW.exe\"" + " ";
-                       if (outputDir == "") { outputDir = ".\\"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd.
-               #endif
-               
-               //prepare full output directory
-               outputDir = m->getFullPathName(outputDir);
-               
-               vector<string> inputFileNames;
-               if (sharedfile != "") { inputFileNames = parseSharedFile(sharedfile);   }
-               else {  inputFileNames.push_back(sabundfile);  }                
-               
-               for (int p = 0; p < inputFileNames.size(); p++) {
-                       if (inputFileNames.size() > 1) {
-                               m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       }
-                       
-                       InputData* input = new InputData(inputFileNames[p], "sabund");
-                       SAbundVector* sabund = input->getSAbundVector();
-                       string lastLabel = sabund->getLabel();
-                                                       
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       string summaryfilename = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "catchall.summary";
-                       summaryfilename = m->getFullPathName(summaryfilename);
-                       
-                       ofstream out;
-                       m->openOutputFile(summaryfilename, out);        
-                       
-                       out << "label\tmodel\testimate\tlci\tuci" << endl;
-                       
-                       //for each label the user selected
-                       while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                                               
-                               if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
-                                               m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                                               
-                                               //create catchall input file from mothur's inputfile
-                                               string filename = process(sabund, inputFileNames[p]);
-                                               string outputPath = m->getPathName(filename);
-                                                                                       
-                                               //create system command
-                                               string catchAllCommand = "";
-                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                                       catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
-                                               #else
-                                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
-                                                       //wrap entire string in ""
-                                                       catchAllCommand = "\"" + catchAllCommand + "\"";
-                                               #endif
-                                       
-                                               //run catchall
-                                               system(catchAllCommand.c_str());
-                                       
-                                               m->mothurRemove(filename);
-                                       
-                                               filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
-                                               if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
-                                       
-                                               outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
-                                       
-                                               createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
-                                                                                       
-                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);   }  delete input;  delete sabund;  return 0; }
-
-                                               processedLabels.insert(sabund->getLabel());
-                                               userLabels.erase(sabund->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                               string saveLabel = sabund->getLabel();
-                                               
-                                               delete sabund;          
-                                               sabund = (input->getSAbundVector(lastLabel));
-                                               
-                                               m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                                               
-
-                                               //create catchall input file from mothur's inputfile
-                                               string filename = process(sabund, inputFileNames[p]);
-                                               string outputPath = m->getPathName(filename);
-                                                                                       
-                                               //create system command
-                                               string catchAllCommand = "";
-                                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                                       catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
-                                               #else
-                                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
-                                                       catchAllCommand = "\"" + catchAllCommand + "\"";
-                                               #endif
-
-                                               //run catchall
-                                               system(catchAllCommand.c_str());
-                                       
-                                               m->mothurRemove(filename);
-                                       
-                                               filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
-                                               if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
-                                       
-                                               outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");
-                                       
-                                               createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
-                                       
-                                               if (m->control_pressed) { out.close(); for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);   }  delete input;  delete sabund;  return 0; }
-
-                                               processedLabels.insert(sabund->getLabel());
-                                               userLabels.erase(sabund->getLabel());
-                                               
-                                               //restore real lastlabel to save below
-                                               sabund->setLabel(saveLabel);
-                               }
-                               
-                               
-                               lastLabel = sabund->getLabel(); 
-                               
-                               delete sabund;          
-                               sabund = (input->getSAbundVector());
-                       }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + ".");  m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (sabund != NULL) {   delete sabund;  }
-                               sabund = (input->getSAbundVector(lastLabel));
-                               
-                               m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                               
-                               //create catchall input file from mothur's inputfile
-                               string filename = process(sabund, inputFileNames[p]);
-                               string outputPath = m->getPathName(filename);
-                               
-                               //create system command
-                               string catchAllCommand = "";
-                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                       catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1";
-                               #else
-                                       if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); }
-                                       catchAllCommand += catchAllCommandExe + "\"" + filename + "\" \""  + outputPath + "\" 1";
-                                       catchAllCommand = "\"" + catchAllCommand + "\"";
-                               #endif
-                               
-                               //run catchall
-                               system(catchAllCommand.c_str());
-                               
-                               m->mothurRemove(filename);
-                               
-                               filename = m->getRootName(filename); filename = filename.substr(0, filename.length()-1); //rip off extra .
-                               if (savedOutputDir == "") { filename = m->getSimpleName(filename); }
-                               
-                               outputNames.push_back(filename + "_Analysis.csv"); outputTypes["csv"].push_back(filename + "_Analysis.csv");
-                               outputNames.push_back(filename + "_BestModelsAnalysis.csv"); outputTypes["csv"].push_back(filename + "_BestModelsAnalysis.csv");
-                               outputNames.push_back(filename + "_BestModelsFits.csv"); outputTypes["csv"].push_back(filename + "_BestModelsFits.csv");
-                               outputNames.push_back(filename + "_BubblePlot.csv"); outputTypes["csv"].push_back(filename + "_BubblePlot.csv");        
-                               
-                               createSummaryFile(filename + "_BestModelsAnalysis.csv", sabund->getLabel(), out);
-                               
-                               delete sabund;
-                       }
-                       
-                       out.close();
-                       delete input; 
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {m->mothurRemove(outputNames[i]);        } return 0; }
-                               
-               }
-               
-               if (sharedfile == "") {  
-                       string summaryfilename = savedOutputDir + m->getRootName(m->getSimpleName(inputFileNames[0])) + "catchall.summary";
-                       summaryfilename = m->getFullPathName(summaryfilename);
-                       outputNames.push_back(summaryfilename); outputTypes["summary"].push_back(summaryfilename);
-               }else { //combine summaries
-                       vector<string> sumNames;
-                       for (int i = 0; i < inputFileNames.size(); i++) {
-                               sumNames.push_back(m->getFullPathName(outputDir + m->getRootName(m->getSimpleName(inputFileNames[i])) + "catchall.summary"));
-                       }
-                       string summaryfilename = combineSummmary(sumNames);
-                       outputNames.push_back(summaryfilename); outputTypes["summary"].push_back(summaryfilename);
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CatchAllCommand::process(SAbundVector* sabund, string file1) {
-       try {
-               string filename = outputDir + m->getRootName(m->getSimpleName(file1)) + sabund->getLabel() + ".csv";
-               filename = m->getFullPathName(filename);
-       
-               ofstream out;
-               m->openOutputFile(filename, out);
-               
-               for (int i = 1; i <= sabund->getMaxRank(); i++) {
-                       int temp = sabund->get(i);
-                       
-                       if (temp != 0) {
-                               out << i << "," << temp << endl;
-                       }
-               }
-               out.close();
-               
-               return filename;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "process");
-               exit(1);
-       }
-}
-//*********************************************************************************************************************
-string CatchAllCommand::combineSummmary(vector<string>& outputNames) {
-       try {
-               
-               ofstream out;
-               string combineFileName = savedOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "catchall.summary";
-               
-               //open combined file
-               m->openOutputFile(combineFileName, out);
-               
-               out << "label\tgroup\tmodel\testimate\tlci\tuci" << endl;
-               
-               //open each groups summary file
-               string newLabel = "";
-               int numLines = 0;
-               map<string, vector<string> > files;
-               for (int i=0; i<outputNames.size(); i++) {
-                       vector<string> thisFilesLines;
-                       
-                       ifstream temp;
-                       m->openInputFile(outputNames[i], temp);
-                       
-                       //read through first line - labels
-                       m->getline(temp);                       
-                       m->gobble(temp);
-                       
-                       //for each label
-                       while (!temp.eof()) {
-                               
-                               string thisLine = "";
-                               string tempLabel;
-                               
-                               for (int j = 0; j < 5; j++) {  
-                                       temp >> tempLabel; 
-                                       
-                                       //save for later
-                                       if (j == 1) { thisLine += groups[i] + "\t" + tempLabel + "\t";  }
-                                       else{  thisLine += tempLabel + "\t";    }
-                               }
-                               
-                               thisLine += "\n";
-                               
-                               thisFilesLines.push_back(thisLine);
-                               
-                               m->gobble(temp);
-                       }
-                       
-                       files[outputNames[i]] = thisFilesLines;
-                       
-                       numLines = thisFilesLines.size();
-                       
-                       temp.close();
-                       m->mothurRemove(outputNames[i]);
-               }
-               
-               //for each label
-               for (int k = 0; k < numLines; k++) {
-                       
-                       //grab summary data for each group
-                       for (int i=0; i<outputNames.size(); i++) {
-                               out << files[outputNames[i]][k];
-                       }
-               }       
-               
-               
-               out.close();
-               
-               //return combine file name
-               return combineFileName;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "combineSummmary");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CatchAllCommand::createSummaryFile(string file1, string label, ofstream& out) {
-       try {
-               
-               ifstream in;
-               int able = m->openInputFile(file1, in, "noerror");
-               
-               if (able == 1) {  m->mothurOut("[ERROR]: the catchall program did not run properly. Please check to make sure it is located in the same folder as your mothur executable.");m->mothurOutEndLine();  m->control_pressed = true; return 0; }
-                       
-               if (!in.eof()) {
-                       
-                       string header = m->getline(in); m->gobble(in);
-                       
-                       int pos = header.find("Total Number of Observed Species =");
-                       string numString = "";
-                       
-                       
-                       if (pos == string::npos) { m->mothurOut("[ERROR]: cannot parse " + file1); m->mothurOutEndLine(); }
-                       else {
-                               //pos will be the position of the T in total, so we want to count to the position of =
-                               pos += 34;
-                               char c=header[pos];
-                               while (c != ','){
-                                       if (c != ' ') {
-                                               numString += c;
-                                       }
-                                       pos++;
-                                       c=header[pos];
-                                       
-                                       //sanity check
-                                       if (pos > header.length()) { m->mothurOut("Cannot find number of OTUs in " + file1); m->mothurOutEndLine(); in.close(); return 0; }
-                               }
-                       }
-                                                                                                                         
-                       string firstline = m->getline(in); m->gobble(in);
-                       vector<string> values;
-                       m->splitAtComma(firstline, values);
-                       
-                       values.pop_back(); //last value is always a blank string since the last character in the line is always a ','
-                       
-                       if (values.size() == 1) { //grab next line if firstline didn't have what you wanted
-                               string secondline = m->getline(in); m->gobble(in);
-                               values.clear();
-                               m->splitAtComma(secondline, values);
-                               
-                               values.pop_back(); //last value is always a blank string since the last character in the line is always a ','
-                       }
-                       
-                       if (values.size() == 1) { //still not what we wanted fill values with numOTUs
-                               values.resize(8, "");
-                               values[1] = "Sobs";
-                               values[4] = numString;
-                               values[6] = numString;
-                               values[7] = numString;
-                       }
-                       
-                       if (values.size() < 8) { values.resize(8, ""); }
-                       
-                       out << label << '\t' << values[1] << '\t' << values[4] << '\t' << values[6] << '\t' << values[7] << endl;
-               }
-               
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "createSummaryFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> CatchAllCommand::parseSharedFile(string filename) {
-       try {
-               vector<string> filenames;
-               
-               //read first line
-               InputData* input = new InputData(filename, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               
-               string sharedFileRoot = outputDir + m->getRootName(m->getSimpleName(filename));
-               
-               //clears file before we start to write to it below
-               for (int i=0; i<lookup.size(); i++) {
-                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
-                       filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".sabund"));
-                       groups.push_back(lookup[i]->getGroup());
-               }
-               
-               while(lookup[0] != NULL) {
-                       
-                       for (int i = 0; i < lookup.size(); i++) {
-                               SAbundVector sav = lookup[i]->getSAbundVector();
-                               ofstream out;
-                               m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".sabund", out);
-                               sav.print(out);
-                               out.close();
-                       }
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               delete input;
-               
-               return filenames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CatchAllCommand", "parseSharedFile");
-               exit(1);
-       }
-}
-/**************************************************************************************/
diff --git a/catchallcommand.h b/catchallcommand.h
deleted file mode 100644 (file)
index 238dfb6..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef CATCHALLCOMMAND_H
-#define CATCHALLCOMMAND_H
-
-/*
- *  catchallcommand.h
- *  Mothur
- *
- *  Created by westcott on 5/11/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "sabundvector.hpp"
-
-/* 
- citation goes here
- */ 
-
-/****************************************************************************/
-
-class CatchAllCommand : public Command {
-
-public:
-
-       CatchAllCommand(string);
-       CatchAllCommand();
-       ~CatchAllCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "catchall";                    }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "Bunge, J. (2011). Estimating the number of species with CatchAll. Forthcoming in Proceedings of the Pacific Symposium on Biocomputing 2011.\nhttp://www.northeastern.edu/catchall/index.html http://www.mothur.org/wiki/Catchall"; }
-       string getDescription()         { return "estimate number of species"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string outputDir, sharedfile, sabundfile, format, path, savedOutputDir;
-       bool abort, allLines;
-       set<string> labels;
-       vector<string> outputNames;
-       vector<string> groups;
-       
-       string process(SAbundVector*, string);
-       int createSummaryFile(string, string, ofstream&); 
-       vector<string> parseSharedFile(string);
-       string combineSummmary(vector<string>&);
-};
-
-/****************************************************************************/
-
-#endif
-
-
diff --git a/ccode.cpp b/ccode.cpp
deleted file mode 100644 (file)
index 00cd3f1..0000000
--- a/ccode.cpp
+++ /dev/null
@@ -1,1091 +0,0 @@
-/*
- *  ccode.cpp
- *  Mothur
- *
- *  Created by westcott on 8/24/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "ccode.h"
-#include "ignoregaps.h"
-#include "eachgapdist.h"
-
-//***************************************************************************************************************
-Ccode::Ccode(string filename, string temp, bool f, string mask, int win, int numW, string o) : Chimera() {  
- try { 
-       
-       fastafile = filename;  
-       outputDir = o; 
-       templateFileName = temp;  templateSeqs = readSeqs(temp); 
-       setMask(mask);
-       filter = f;
-       window = win;
-       numWanted = numW;
-       
-       distCalc = new eachGapDist();
-       decalc = new DeCalculator();
-       
-       mapInfo = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "mapinfo";
-       
-       #ifdef USE_MPI
-               
-               //char* inFileName = new char[mapInfo.length()];
-               //memcpy(inFileName, mapInfo.c_str(), mapInfo.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, mapInfo.c_str());
-               
-               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, outMode, MPI_INFO_NULL, &outMap);  //comm, filename, mode, info, filepointer
-               
-               //delete inFileName;
-
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               if (pid == 0) {
-                       string outString = "Place in masked, filtered and trimmed sequence\tPlace in original alignment\n";
-                       
-                       MPI_Status status;
-                       int length = outString.length();
-                       char* buf2 = new char[length];
-                       memcpy(buf2, outString.c_str(), length);
-                               
-                       MPI_File_write_shared(outMap, buf2, length, MPI_CHAR, &status);
-                       delete buf2;
-               }
-       #else
-
-               ofstream out2;
-               m->openOutputFile(mapInfo, out2);
-               
-               out2 << "Place in masked, filtered and trimmed sequence\tPlace in original alignment" << endl;
-               out2.close();
-       #endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "Ccode");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Ccode::~Ccode() {
-       delete distCalc;
-       delete decalc;
-       
-       #ifdef USE_MPI
-               MPI_File_close(&outMap);
-       #endif
-}      
-//***************************************************************************************************************
-Sequence Ccode::print(ostream& out, ostream& outAcc) {
-       try {
-               
-               ofstream out2;
-               m->openOutputFileAppend(mapInfo, out2);
-               
-               out2 << querySeq->getName() << endl;
-               for (it = spotMap.begin(); it!= spotMap.end(); it++) {
-                       out2 << it->first << '\t' << it->second << endl;
-               }
-               out2.close();
-               out << querySeq->getName() << endl << endl << "Reference sequences used and distance to query:" << endl;
-                       
-               for (int j = 0; j < closest.size(); j++) {
-                       out << closest[j].seq->getName() << '\t' << closest[j].dist << endl;
-               }
-               out << endl << endl;
-               
-               //for each window
-               //window mapping info.
-               out << "Mapping information: ";
-               //you mask and did not filter
-               if ((seqMask != "") && (!filter)) { out << "mask and trim."; }
-                               
-               //you filtered and did not mask
-               if ((seqMask == "") && (filter)) { out << "filter and trim."; }
-                               
-               //you masked and filtered
-               if ((seqMask != "") && (filter)) { out << "mask, filter and trim."; }
-                       
-               out << endl << "Window\tStartPos\tEndPos" << endl;
-               it = trim.begin();
-               for (int k = 0; k < windows.size()-1; k++) {
-                       out << k+1 << '\t' << spotMap[windows[k]-it->first] << '\t' << spotMap[windows[k]-it->first+windowSizes] << endl;
-               }
-                       
-               out << windows.size() << '\t' << spotMap[windows[windows.size()-1]-it->first] << '\t' << spotMap[it->second-it->first-1] << endl;
-               out << endl;
-               out << "Window\tAvgQ\t(sdQ)\tAvgR\t(sdR)\tRatio\tAnova" << endl;
-               for (int k = 0; k < windows.size(); k++) {
-                       float ds = averageQuery[k] / averageRef[k]; 
-                       out << k+1 << '\t' << averageQuery[k] << '\t' << sdQuery[k] << '\t' << averageRef[k] << '\t'<< sdRef[k] << '\t' << ds << '\t' << anova[k] << endl;
-               }
-               out << endl;
-                       
-               //varRef
-               //varQuery
-               /* F test for differences among variances.
-               * varQuery is expected to be higher or similar than varRef */
-               //float fs = varQuery[query] / varRef[query];   /* F-Snedecor, test for differences of variances */
-                       
-               bool results = false;   
-                                       
-               //confidence limit, t - Student, anova
-               out << "Window\tConfidenceLimit\tt-Student\tAnova" << endl;
-                       
-               for (int k = 0; k < windows.size(); k++) {
-                       string temp = "";
-                       if (isChimericConfidence[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                               
-                       if (isChimericTStudent[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                               
-                       if (isChimericANOVA[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                       
-                       out << k+1 << '\t' << temp << endl;
-                               
-                       if (temp == "*\t*\t*\t") {  results = true;  }
-               }
-               out << endl;    
-                       
-               if (results) {
-                       m->mothurOut(querySeq->getName() + " was found have at least one chimeric window."); m->mothurOutEndLine();
-                       outAcc << querySeq->getName() << endl;
-               }
-
-               //free memory
-               for (int i = 0; i < closest.size(); i++) {  delete closest[i].seq;  }
-
-               return *querySeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "print");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-//***************************************************************************************************************
-Sequence Ccode::print(MPI_File& out, MPI_File& outAcc) {
-       try {
-               
-               string outMapString = "";
-               
-               outMapString += querySeq->getName() + "\n";
-               for (it = spotMap.begin(); it!= spotMap.end(); it++) {
-                       outMapString += toString(it->first)  + "\t" + toString(it->second)  + "\n";
-               }
-               printMapping(outMapString);
-               outMapString = "";
-               
-               string outString = "";
-               string outAccString = "";
-               
-               outString +=  querySeq->getName() + "\n\nReference sequences used and distance to query:\n";
-                       
-               for (int j = 0; j < closest.size(); j++) {
-                       outString += closest[j].seq->getName() + "\t" + toString(closest[j].dist) + "\n";
-               }
-               outString += "\n\nMapping information: ";
-               
-               //for each window
-               //window mapping info.
-               //you mask and did not filter
-               if ((seqMask != "") && (!filter)) { outString += "mask and trim."; }
-                               
-               //you filtered and did not mask
-               if ((seqMask == "") && (filter)) { outString += "filter and trim."; }
-                               
-               //you masked and filtered
-               if ((seqMask != "") && (filter)) { outString += "mask, filter and trim."; }
-                       
-               outString += "\nWindow\tStartPos\tEndPos\n";
-               it = trim.begin();
-               for (int k = 0; k < windows.size()-1; k++) {
-                       outString += toString(k+1) + "\t" + toString(spotMap[windows[k]-it->first]) + "\t" + toString(spotMap[windows[k]-it->first+windowSizes]) + "\n";
-               }
-                       
-               outString += toString(windows.size()) + "\t" + toString(spotMap[windows[windows.size()-1]-it->first]) + "\t" + toString(spotMap[it->second-it->first-1]) + "\n\n";
-               
-               outString += "Window\tAvgQ\t(sdQ)\tAvgR\t(sdR)\tRatio\tAnova\n";
-               for (int k = 0; k < windows.size(); k++) {
-                       float ds = averageQuery[k] / averageRef[k]; 
-                       outString += toString(k+1) + "\t" + toString(averageQuery[k]) + "\t" + toString(sdQuery[k]) + "\t" + toString(averageRef[k]) + "\t" + toString(sdRef[k]) + "\t" + toString(ds) + "\t" + toString(anova[k]) + "\n";
-               }
-                       
-               //varRef
-               //varQuery
-               /* F test for differences among variances.
-               * varQuery is expected to be higher or similar than varRef */
-               //float fs = varQuery[query] / varRef[query];   /* F-Snedecor, test for differences of variances */
-                       
-               bool results = false;   
-                                       
-               //confidence limit, t - Student, anova
-               outString += "\nWindow\tConfidenceLimit\tt-Student\tAnova\n";
-                       
-               for (int k = 0; k < windows.size(); k++) {
-                       string temp = "";
-                       if (isChimericConfidence[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                               
-                       if (isChimericTStudent[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                               
-                       if (isChimericANOVA[k]) {  temp += "*\t"; }
-                       else { temp += "\t"; }
-                       
-                       outString += toString(k+1) + "\t" + temp + "\n";
-                               
-                       if (temp == "*\t*\t*\t") {  results = true;  }
-               }
-               outString += "\n";      
-               
-               MPI_Status status;
-               int length = outString.length();
-               char* buf2 = new char[length];
-               memcpy(buf2, outString.c_str(), length);
-                               
-               MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status);
-               delete buf2;
-
-               if (results) {
-                       m->mothurOut(querySeq->getName() + " was found have at least one chimeric window."); m->mothurOutEndLine();
-                       outAccString += querySeq->getName() + "\n";
-                       
-                       MPI_Status statusAcc;
-                       length = outAccString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outAccString.c_str(), length);
-                               
-                       MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc);
-                       delete buf;
-               }
-
-               //free memory
-               for (int i = 0; i < closest.size(); i++) {  delete closest[i].seq;  }
-
-               return *querySeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "print");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int Ccode::printMapping(string& output) {
-       try {
-                       MPI_Status status;
-                       int length = output.length();
-                       char* buf = new char[length];
-                       memcpy(buf, output.c_str(), length);
-                               
-                       MPI_File_write_shared(outMap, buf, length, MPI_CHAR, &status);
-                       delete buf;
-                       
-                       return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "printMapping");
-               exit(1);
-       }
-}
-#endif
-//***************************************************************************************************************
-int Ccode::getChimeras(Sequence* query) {
-       try {
-       
-               closest.clear();
-               refCombo = 0;
-               sumRef.clear(); 
-               varRef.clear(); 
-               varQuery.clear(); 
-               sdRef.clear(); 
-               sdQuery.clear();     
-               sumQuery.clear();
-               sumSquaredRef.clear(); 
-               sumSquaredQuery.clear(); 
-               averageRef.clear();
-               averageQuery.clear();
-               anova.clear();
-               isChimericConfidence.clear();
-               isChimericTStudent.clear();
-               isChimericANOVA.clear();
-               trim.clear();
-               spotMap.clear();
-               windowSizes = window;
-               windows.clear();
-
-       
-               querySeq = query;
-               
-               //find closest matches to query
-               closest = findClosest(query, numWanted);
-               
-               if (m->control_pressed) {  return 0;  }
-               
-               //initialize spotMap
-               for (int i = 0; i < query->getAligned().length(); i++) {        spotMap[i] = i;         }
-       
-               //mask sequences if the user wants to 
-               if (seqMask != "") {
-                       decalc->setMask(seqMask);
-                       
-                       decalc->runMask(query);
-                       
-                       //mask closest
-                       for (int i = 0; i < closest.size(); i++) {      decalc->runMask(closest[i].seq);        }
-                       
-                       spotMap = decalc->getMaskMap();
-               }
-               
-               if (filter) {
-                       vector<Sequence*> temp;
-                       for (int i = 0; i < closest.size(); i++) { temp.push_back(closest[i].seq);  }
-                       temp.push_back(query);  
-                       
-                       createFilter(temp, 0.5);
-               
-                       for (int i = 0; i < temp.size(); i++) { 
-                               if (m->control_pressed) {  return 0;  }
-                               runFilter(temp[i]);  
-                       }
-                       
-                       //update spotMap
-                       map<int, int> newMap;
-                       int spot = 0;
-                       
-                       for (int i = 0; i < filterString.length(); i++) {
-                               if (filterString[i] == '1') {
-                                       //add to newMap
-                                       newMap[spot] = spotMap[i];
-                                       spot++;  
-                               }
-                       }
-                       spotMap = newMap;
-               }
-
-               //trim sequences - this follows ccodes remove_extra_gaps 
-               trimSequences(query);
-               if (m->control_pressed) {  return 0;  }
-               
-               //windows are equivalent to words - ccode paper recommends windows are between 5% and 20% on alignment length().  
-               //Our default will be 10% and we will warn if user tries to use a window above or below these recommendations
-               windows = findWindows();  
-               if (m->control_pressed) {  return 0;  }
-
-               //remove sequences that are more than 20% different and less than 0.5% different - may want to allow user to specify this later 
-               removeBadReferenceSeqs(closest);
-               if (m->control_pressed) {  return 0;  }
-               
-               //find the averages for each querys references
-               getAverageRef(closest);  //fills sumRef, averageRef, sumSquaredRef and refCombo.
-               getAverageQuery(closest, query);  //fills sumQuery, averageQuery, sumSquaredQuery.
-               if (m->control_pressed) {  return 0;  }                 
-               
-               //find the averages for each querys references 
-               findVarianceRef();  //fills varRef and sdRef also sets minimum error rate to 0.001 to avoid divide by 0.
-               if (m->control_pressed) {  return 0;  } 
-                       
-               //find the averages for the query 
-               findVarianceQuery();  //fills varQuery and sdQuery also sets minimum error rate to 0.001 to avoid divide by 0.
-               if (m->control_pressed) {  return 0;  }
-                                       
-               determineChimeras();  //fills anova, isChimericConfidence, isChimericTStudent and isChimericANOVA. 
-               if (m->control_pressed) {  return 0;  }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getChimeras");
-               exit(1);
-       }
-}
-/***************************************************************************************************************/
-//ccode algo says it does this to "Removes the initial and final gaps to avoid biases due to incomplete sequences."
-void Ccode::trimSequences(Sequence* query) {
-       try {
-               
-               int frontPos = 0;  //should contain first position in all seqs that is not a gap character
-               int rearPos = query->getAligned().length();
-               
-               //********find first position in closest seqs that is a non gap character***********//
-               //find first position all query seqs that is a non gap character
-               for (int i = 0; i < closest.size(); i++) {
-                       
-                       string aligned = closest[i].seq->getAligned();
-                       int pos = 0;
-                       
-                       //find first spot in this seq
-                       for (int j = 0; j < aligned.length(); j++) {
-                               if (isalpha(aligned[j])) {
-                                       pos = j;
-                                       break;
-                               }
-                       }
-                       
-                       //save this spot if it is the farthest
-                       if (pos > frontPos) { frontPos = pos; }
-               }
-               
-               //find first position all querySeq[query] that is a non gap character
-               string aligned = query->getAligned();
-               int pos = 0;
-                       
-               //find first spot in this seq
-               for (int j = 0; j < aligned.length(); j++) {
-                       if (isalpha(aligned[j])) {
-                               pos = j;
-                               break;
-                       }
-               }
-               
-               //save this spot if it is the farthest
-               if (pos > frontPos) { frontPos = pos; }
-               
-               
-               //********find last position in closest seqs that is a non gap character***********//
-               for (int i = 0; i < closest.size(); i++) {
-                       
-                       string aligned = closest[i].seq->getAligned();
-                       int pos = aligned.length();
-                       
-                       //find first spot in this seq
-                       for (int j = aligned.length()-1; j >= 0; j--) {
-                               if (isalpha(aligned[j])) {
-                                       pos = j;
-                                       break;
-                               }
-                       }
-                       
-                       //save this spot if it is the farthest
-                       if (pos < rearPos) { rearPos = pos; }
-               }
-               
-               //find last position all querySeqs[query] that is a non gap character
-               aligned = query->getAligned();
-               pos = aligned.length();
-               
-               //find first spot in this seq
-               for (int j = aligned.length()-1; j >= 0; j--) {
-                       if (isalpha(aligned[j])) {
-                               pos = j;
-                               break;
-                       }
-               }
-               
-               //save this spot if it is the farthest
-               if (pos < rearPos) { rearPos = pos; }
-
-               
-               //check to make sure that is not whole seq
-               if ((rearPos - frontPos - 1) <= 0) {  m->mothurOut("Error, when I trim your sequences, the entire sequence is trimmed."); m->mothurOutEndLine(); exit(1);  }
-               
-               map<int, int> tempTrim;
-               tempTrim[frontPos] = rearPos;
-               
-               //save trimmed locations
-               trim = tempTrim;
-                                               
-               //update spotMask
-               map<int, int> newMap;
-               int spot = 0;
-               
-               for (int i = frontPos; i < rearPos; i++) {
-                       //add to newMap
-                       newMap[spot] = spotMap[i];
-                       spot++;  
-               }
-               spotMap = newMap;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "trimSequences");
-               exit(1);
-       }
-}
-/***************************************************************************************************************/
-vector<int> Ccode::findWindows() {
-       try {
-               
-               vector<int> win; 
-               it = trim.begin();
-               
-               int length = it->second - it->first;
-       
-               //default is wanted = 10% of total length
-               if (windowSizes > length) { 
-                       m->mothurOut("You have slected a window larger than your sequence length after all filters, masks and trims have been done. I will use the default 10% of sequence length.");
-                       windowSizes = length / 10;
-               }else if (windowSizes == 0) { windowSizes = length / 10;  }
-               else if (windowSizes > (length * 0.20)) {
-                       m->mothurOut("You have selected a window that is larger than 20% of your sequence length.  This is not recommended, but I will continue anyway."); m->mothurOutEndLine();
-               }else if (windowSizes < (length * 0.05)) {
-                       m->mothurOut("You have selected a window that is smaller than 5% of your sequence length.  This is not recommended, but I will continue anyway."); m->mothurOutEndLine();
-               }
-               
-               //save starting points of each window
-               for (int m = it->first;  m < (it->second-windowSizes); m+=windowSizes) {  win.push_back(m);  }
-               
-               //save last window
-               if (win[win.size()-1] < (it->first+length)) {
-                       win.push_back(win[win.size()-1]+windowSizes); // ex. string length is 115, window is 25, without this you would get 0, 25, 50, 75
-               }                                                                                                                                                                                                       //with this you would get 1,25,50,75,100
-               
-               return win;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "findWindows");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int Ccode::getDiff(string seqA, string seqB) {
-       try {
-               
-               int numDiff = 0;
-               
-               for (int i = 0; i < seqA.length(); i++) {
-                       //if you are both not gaps
-                       //if (isalpha(seqA[i]) && isalpha(seqA[i])) {
-                               //are you different
-                               if (seqA[i] != seqB[i]) { 
-                                        int ok; /* ok=1 means equivalent base. Checks for degenerate bases */
-
-                                       /* the char in base_a and base_b have been checked and they are different */
-                                       if ((seqA[i] == 'N') && (seqB[i] != '-')) ok = 1;
-                                       else if ((seqB[i] == 'N') && (seqA[i] != '-')) ok = 1;
-                                       else if ((seqA[i] == 'Y') && ((seqB[i] == 'C') || (seqB[i] == 'T'))) ok = 1;
-                                       else if ((seqB[i] == 'Y') && ((seqA[i] == 'C') || (seqA[i] == 'T'))) ok = 1;
-                                       else if ((seqA[i] == 'R') && ((seqB[i] == 'G') || (seqB[i] == 'A'))) ok = 1;
-                                       else if ((seqB[i] == 'R') && ((seqA[i] == 'G') || (seqA[i] == 'A'))) ok = 1;
-                                       else if ((seqA[i] == 'S') && ((seqB[i] == 'C') || (seqB[i] == 'G'))) ok = 1;
-                                       else if ((seqB[i] == 'S') && ((seqA[i] == 'C') || (seqA[i] == 'G'))) ok = 1;
-                                       else if ((seqA[i] == 'W') && ((seqB[i] == 'T') || (seqB[i] == 'A'))) ok = 1;
-                                       else if ((seqB[i] == 'W') && ((seqA[i] == 'T') || (seqA[i] == 'A'))) ok = 1;
-                                       else if ((seqA[i] == 'M') && ((seqB[i] == 'A') || (seqB[i] == 'C'))) ok = 1;
-                                       else if ((seqB[i] == 'M') && ((seqA[i] == 'A') || (seqA[i] == 'C'))) ok = 1;
-                                       else if ((seqA[i] == 'K') && ((seqB[i] == 'T') || (seqB[i] == 'G'))) ok = 1;
-                                       else if ((seqB[i] == 'K') && ((seqA[i] == 'T') || (seqA[i] == 'G'))) ok = 1;
-                                       else if ((seqA[i] == 'V') && ((seqB[i] == 'C') || (seqB[i] == 'A') || (seqB[i] == 'G'))) ok = 1;
-                                       else if ((seqB[i] == 'V') && ((seqA[i] == 'C') || (seqA[i] == 'A') || (seqA[i] == 'G'))) ok = 1;
-                                       else if ((seqA[i] == 'H') && ((seqB[i] == 'T') || (seqB[i] == 'A') || (seqB[i] == 'C'))) ok = 1;
-                                       else if ((seqB[i] == 'H') && ((seqA[i] == 'T') || (seqA[i] == 'A') || (seqA[i] == 'C'))) ok = 1;
-                                       else if ((seqA[i] == 'D') && ((seqB[i] == 'T') || (seqB[i] == 'A') || (seqB[i] == 'G'))) ok = 1;
-                                       else if ((seqB[i] == 'D') && ((seqA[i] == 'T') || (seqA[i] == 'A') || (seqA[i] == 'G'))) ok = 1;
-                                       else if ((seqA[i] == 'B') && ((seqB[i] == 'C') || (seqB[i] == 'T') || (seqB[i] == 'G'))) ok = 1;
-                                       else if ((seqB[i] == 'B') && ((seqA[i] == 'C') || (seqA[i] == 'T') || (seqA[i] == 'G'))) ok = 1;
-                                       else ok = 0;  /* the bases are different and not equivalent */
-                                       
-                                       //check if they are both blanks
-                                       if ((seqA[i] == '.') && (seqB[i] == '-')) ok = 1;
-                                       else if ((seqB[i] == '.') && (seqA[i] == '-')) ok = 1;
-                                       
-                                       if (ok == 0) {  numDiff++;  }
-                               }
-                       //}
-               }
-               
-               return numDiff;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getDiff");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//tried to make this look most like ccode original implementation
-void Ccode::removeBadReferenceSeqs(vector<SeqDist>& seqs) {
-       try {
-               
-               vector< vector<int> > numDiffBases;
-               numDiffBases.resize(seqs.size());
-               //initialize to 0
-               for (int i = 0; i < numDiffBases.size(); i++) { numDiffBases[i].resize(seqs.size(),0); }
-               
-               it = trim.begin();
-               int length = it->second - it->first;
-               
-               //calc differences from each sequence to everyother seq in the set
-               for (int i = 0; i < seqs.size(); i++) {
-                       
-                       string seqA = seqs[i].seq->getAligned().substr(it->first, length);
-                       
-                       //so you don't calc i to j and j to i since they are the same
-                       for (int j = 0; j < i; j++) {
-                               
-                               string seqB = seqs[j].seq->getAligned().substr(it->first, length);
-                               
-                               //compare strings
-                               int numDiff = getDiff(seqA, seqB);
-                               
-                               numDiffBases[i][j] = numDiff;
-                               numDiffBases[j][i] = numDiff;
-                       }
-               }
-               
-               //initailize remove to 0
-               vector<int> remove;  remove.resize(seqs.size(), 0);
-               float top = ((20*length) / (float) 100);
-               float bottom = ((0.5*length) / (float) 100);
-               
-               //check each numDiffBases and if any are higher than threshold set remove to 1 so you can remove those seqs from the closest set
-               for (int i = 0; i < numDiffBases.size(); i++) {
-                       for (int j = 0; j < i; j++) {   
-                               //are you more than 20% different
-                               if (numDiffBases[i][j] > top)           {  remove[j] = 1;  }
-                               //are you less than 0.5% different
-                               if (numDiffBases[i][j] < bottom)        {  remove[j] = 1;  }
-                       }
-               }
-               
-               int numSeqsLeft = 0;
-               
-               //count seqs that are not going to be removed
-               for (int i = 0; i < remove.size(); i++) {  
-                       if (remove[i] == 0)  { numSeqsLeft++;  }
-               }
-               
-               //if you have enough then remove bad ones
-               if (numSeqsLeft >= 3) {
-                       vector<SeqDist> goodSeqs;
-                       //remove bad seqs
-                       for (int i = 0; i < remove.size(); i++) {
-                               if (remove[i] == 0) { 
-                                       goodSeqs.push_back(seqs[i]);
-                               }
-                       }
-                       
-                       seqs = goodSeqs;
-                       
-               }else { //warn, but dont remove any
-                       m->mothurOut(querySeq->getName() + " does not have an adaquate number of reference sequences that are within 20% and 0.5% similarity.  I will continue, but please check."); m->mothurOutEndLine();  
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "removeBadReferenceSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//makes copy of templateseq for filter
-vector<SeqDist>  Ccode::findClosest(Sequence* q, int numWanted) {
-       try{
-       
-               vector<SeqDist>  topMatches;  
-               
-               Sequence query = *(q);
-                       
-               //calc distance to each sequence in template seqs
-               for (int i = 0; i < templateSeqs.size(); i++) {
-                       
-                       Sequence ref = *(templateSeqs[i]); 
-                                       
-                       //find overall dist
-                       distCalc->calcDist(query, ref);
-                       float dist = distCalc->getDist();       
-                               
-                       //save distance
-                       SeqDist temp;
-                       temp.seq = new Sequence(templateSeqs[i]->getName(), templateSeqs[i]->getAligned());
-                       temp.dist = dist;
-
-                       topMatches.push_back(temp);
-               }
-                       
-               sort(topMatches.begin(), topMatches.end(), compareSeqDist);
-               
-               for (int i = numWanted; i < topMatches.size(); i++) {  delete topMatches[i].seq;  }
-               
-               topMatches.resize(numWanted);
-                       
-               return topMatches;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "findClosestSides");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-//find the distances from each reference sequence to every other reference sequence for each window for this query
-void Ccode::getAverageRef(vector<SeqDist> ref) {
-       try {
-               
-               vector< vector< vector<int> > >  diffs;  //diffs[0][1][2] is the number of differences between ref seq 0 and ref seq 1 at window 2.
-               
-               //initialize diffs vector
-               diffs.resize(ref.size());
-               for (int i = 0; i < diffs.size(); i++) {  
-                       diffs[i].resize(ref.size());
-                       for (int j = 0; j < diffs[i].size(); j++) {
-                               diffs[i][j].resize(windows.size(), 0);
-                       }
-               }
-               
-               it = trim.begin();
-                               
-               //find the distances from each reference sequence to every other reference sequence for each window for this query              
-               for (int i = 0; i < ref.size(); i++) {
-                       
-                       string refI = ref[i].seq->getAligned();
-                       
-                       //j<i, so you don't find distances from i to j and then j to i.
-                       for (int j = 0; j < i; j++) {
-                       
-                               string refJ = ref[j].seq->getAligned();
-                       
-                               for (int k = 0; k < windows.size(); k++) {
-                                       
-                                       string refIWindowk, refJWindowk;
-                                       
-                                       if (k < windows.size()-1) {
-                                               //get window strings
-                                               refIWindowk = refI.substr(windows[k], windowSizes);
-                                               refJWindowk = refJ.substr(windows[k], windowSizes);
-                                       }else { //last window may be smaller than rest - see findwindows
-                                               //get window strings
-                                               refIWindowk = refI.substr(windows[k], (it->second-windows[k]));
-                                               refJWindowk = refJ.substr(windows[k], (it->second-windows[k]));
-                                       }
-                                       
-                                       //find differences
-                                       int diff = getDiff(refIWindowk, refJWindowk);
-
-                                       //save differences in [i][j][k] and [j][i][k] since they are the same
-                                       diffs[i][j][k] = diff;
-                                       diffs[j][i][k] = diff;
-
-                               }//k
-                               
-                       }//j
-               
-               }//i
-               
-               //initialize sumRef for this query 
-               sumRef.resize(windows.size(), 0);
-               sumSquaredRef.resize(windows.size(), 0);
-               averageRef.resize(windows.size(), 0);
-               
-               //find the sum of the differences for hte reference sequences
-               for (int i = 0; i < diffs.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                       
-                               //increment this querys reference sequences combos
-                               refCombo++;
-                               
-                               for (int k = 0; k < diffs[i][j].size(); k++) {
-                                       sumRef[k] += diffs[i][j][k];
-                                       sumSquaredRef[k] += (diffs[i][j][k]*diffs[i][j][k]);
-                               }//k
-                               
-                       }//j
-               }//i
-
-               
-               //find the average of the differences for the references for each window
-               for (int i = 0; i < windows.size(); i++) {
-                       averageRef[i] = sumRef[i] / (float) refCombo;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getAverageRef");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Ccode::getAverageQuery (vector<SeqDist> ref, Sequence* query) {
-       try {
-       
-               vector< vector<int> >  diffs;  //diffs[1][2] is the number of differences between querySeqs[query] and ref seq 1 at window 2.
-               
-               //initialize diffs vector
-               diffs.resize(ref.size());
-               for (int j = 0; j < diffs.size(); j++) {
-                       diffs[j].resize(windows.size(), 0);
-               }
-               
-               it = trim.begin();
-                                                       
-               string refQuery = query->getAligned();
-                        
-               //j<i, so you don't find distances from i to j and then j to i.
-               for (int j = 0; j < ref.size(); j++) {
-                        
-                        string refJ = ref[j].seq->getAligned();
-                        
-                        for (int k = 0; k < windows.size(); k++) {
-                                       
-                                       string QueryWindowk, refJWindowk;
-                                       
-                                       if (k < windows.size()-1) {
-                                               //get window strings
-                                               QueryWindowk = refQuery.substr(windows[k], windowSizes);
-                                               refJWindowk = refJ.substr(windows[k], windowSizes);                                     
-                                       }else { //last window may be smaller than rest - see findwindows
-                                               //get window strings
-                                               QueryWindowk = refQuery.substr(windows[k], (it->second-windows[k]));
-                                               refJWindowk = refJ.substr(windows[k], (it->second-windows[k]));
-                                       }
-                                       
-                                       //find differences
-                                       int diff = getDiff(QueryWindowk, refJWindowk);
-                                       
-                                       //save differences 
-                                       diffs[j][k] = diff;
-                        
-                        }//k
-               }//j
-                        
-               
-               //initialize sumRef for this query 
-               sumQuery.resize(windows.size(), 0);
-               sumSquaredQuery.resize(windows.size(), 0);
-               averageQuery.resize(windows.size(), 0);
-               
-               //find the sum of the differences 
-               for (int j = 0; j < diffs.size(); j++) {
-                       for (int k = 0; k < diffs[j].size(); k++) {
-                               sumQuery[k] += diffs[j][k];
-                               sumSquaredQuery[k] += (diffs[j][k]*diffs[j][k]);
-                       }//k
-               }//j
-               
-               
-               //find the average of the differences for the references for each window
-               for (int i = 0; i < windows.size(); i++) {
-                       averageQuery[i] = sumQuery[i] / (float) ref.size();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getAverageQuery");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Ccode::findVarianceRef() {
-       try {
-               
-               varRef.resize(windows.size(), 0);
-               sdRef.resize(windows.size(), 0);
-               
-               //for each window
-               for (int i = 0; i < windows.size(); i++) {
-                       varRef[i] = (sumSquaredRef[i] - ((sumRef[i]*sumRef[i])/(float)refCombo)) / (float)(refCombo-1);
-                       sdRef[i] = sqrt(varRef[i]);
-                       
-                       //set minimum error rate to 0.001 - to avoid potential divide by zero - not sure if this is necessary but it follows ccode implementation
-                       if (averageRef[i] < 0.001)                      {       averageRef[i] = 0.001;          }
-                       if (sumRef[i] < 0.001)                          {       sumRef[i] = 0.001;                      }
-                       if (varRef[i] < 0.001)                          {       varRef[i] = 0.001;                      }
-                       if (sumSquaredRef[i] < 0.001)           {       sumSquaredRef[i] = 0.001;       }
-                       if (sdRef[i] < 0.001)                           {       sdRef[i] = 0.001;                       }
-                               
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "findVarianceRef");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Ccode::findVarianceQuery() {
-       try {
-               varQuery.resize(windows.size(), 0);
-               sdQuery.resize(windows.size(), 0);
-               
-               //for each window
-               for (int i = 0; i < windows.size(); i++) {
-                       varQuery[i] = (sumSquaredQuery[i] - ((sumQuery[i]*sumQuery[i])/(float) closest.size())) / (float) (closest.size()-1);
-                       sdQuery[i] = sqrt(varQuery[i]);
-                       
-                       //set minimum error rate to 0.001 - to avoid potential divide by zero - not sure if this is necessary but it follows ccode implementation
-                       if (averageQuery[i] < 0.001)                    {       averageQuery[i] = 0.001;                }
-                       if (sumQuery[i] < 0.001)                                {       sumQuery[i] = 0.001;                    }
-                       if (varQuery[i] < 0.001)                                {       varQuery[i] = 0.001;                    }
-                       if (sumSquaredQuery[i] < 0.001)         {       sumSquaredQuery[i] = 0.001;     }
-                       if (sdQuery[i] < 0.001)                         {       sdQuery[i] = 0.001;                     }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "findVarianceQuery");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Ccode::determineChimeras() {
-       try {
-               
-               isChimericConfidence.resize(windows.size(), false);
-               isChimericTStudent.resize(windows.size(), false);
-               isChimericANOVA.resize(windows.size(), false);
-               anova.resize(windows.size());
-
-               
-               //for each window
-               for (int i = 0; i < windows.size(); i++) {
-               
-                       //get confidence limits
-                       float t = getT(closest.size()-1);  //how many seqs you are comparing to this querySeq
-                       float dsUpper = (averageQuery[i] + (t * sdQuery[i])) / averageRef[i]; 
-                       float dsLower = (averageQuery[i] - (t * sdQuery[i])) / averageRef[i]; 
-               
-                       if ((dsUpper > 1.0) && (dsLower > 1.0) && (averageQuery[i] > averageRef[i])) {  /* range does not include 1 */
-                                       isChimericConfidence[i] = true;   /* significantly higher at P<0.05 */ 
-
-                       }
-                       
-                       //student t test
-                       int degreeOfFreedom = refCombo + closest.size() - 2;
-                       float denomForT = (((refCombo-1) * varQuery[i] + (closest.size() - 1) * varRef[i]) / (float) degreeOfFreedom) * ((refCombo + closest.size()) / (float) (refCombo * closest.size()));    /* denominator, without sqrt(), for ts calculations */
-                               
-                       float ts = fabs((averageQuery[i] - averageRef[i]) / (sqrt(denomForT)));  /* value of ts for t-student test */   
-                       t = getT(degreeOfFreedom);
-       
-                       if ((ts >= t) && (averageQuery[i] > averageRef[i])) {   
-                               isChimericTStudent[i] = true;   /* significantly higher at P<0.05 */ 
-                       }
-               
-                       //anova test
-                       float value1 = sumQuery[i] + sumRef[i];
-                       float value2 = sumSquaredQuery[i] + sumSquaredRef[i];
-                       float value3 = ((sumQuery[i]*sumQuery[i]) / (float) (closest.size())) + ((sumRef[i] * sumRef[i]) / (float) refCombo);
-                       float value4 = (value1 * value1) / ( (float) (closest.size() + refCombo) );
-                       float value5 = value2 - value4;
-                       float value6 = value3 - value4;
-                       float value7 = value5 - value6;
-                       float value8 = value7 / ((float) degreeOfFreedom);
-                       float anovaValue = value6 / value8;
-                       
-                       float f = getF(degreeOfFreedom);
-                       
-                        if ((anovaValue >= f) && (averageQuery[i] > averageRef[i]))  {
-                      isChimericANOVA[i] = true;   /* significant P<0.05 */
-               }
-                       
-                       if (isnan(anovaValue) || isinf(anovaValue)) { anovaValue = 0.0; }
-                       
-                       anova[i] = anovaValue;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "determineChimeras");
-               exit(1);
-       }
-}
-/**************************************************************************************************/   
-float Ccode::getT(int numseq) {
-       try {
-       
-               float tvalue = 0;
-               
-               /* t-student critical values for different degrees of freedom and alpha 0.1 in one-tail tests (equivalent to 0.05) */
-               if (numseq > 120) tvalue = 1.645;
-               else if (numseq > 60) tvalue = 1.658;
-        else if (numseq > 40) tvalue = 1.671;
-        else if (numseq > 30) tvalue = 1.684;
-        else if (numseq > 29) tvalue = 1.697;
-        else if (numseq > 28) tvalue = 1.699;
-        else if (numseq > 27) tvalue = 1.701;
-        else if (numseq > 26) tvalue = 1.703;
-        else if (numseq > 25) tvalue = 1.706;
-        else if (numseq > 24) tvalue = 1.708;
-        else if (numseq > 23) tvalue = 1.711;
-        else if (numseq > 22) tvalue = 1.714;
-        else if (numseq > 21) tvalue = 1.717;
-        else if (numseq > 20) tvalue = 1.721;
-        else if (numseq > 19) tvalue = 1.725;
-        else if (numseq > 18) tvalue = 1.729;
-        else if (numseq > 17) tvalue = 1.734;
-        else if (numseq > 16) tvalue = 1.740;
-        else if (numseq > 15) tvalue = 1.746;
-        else if (numseq > 14) tvalue = 1.753;
-        else if (numseq > 13) tvalue = 1.761;
-        else if (numseq > 12) tvalue = 1.771;
-        else if (numseq > 11) tvalue = 1.782;
-        else if (numseq > 10) tvalue = 1.796;
-        else if (numseq > 9) tvalue = 1.812;
-        else if (numseq > 8) tvalue = 1.833;
-        else if (numseq > 7) tvalue = 1.860;
-        else if (numseq > 6) tvalue = 1.895;
-        else if (numseq > 5) tvalue = 1.943;
-        else if (numseq > 4) tvalue = 2.015;
-        else if (numseq > 3) tvalue = 2.132;
-        else if (numseq > 2) tvalue = 2.353;
-        else if (numseq > 1) tvalue = 2.920;
-               else if (numseq <= 1) {
-                       m->mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); m->mothurOutEndLine();
-               }
-               
-               return tvalue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getT");
-               exit(1);
-       }
-}
-/**************************************************************************************************/   
-float Ccode::getF(int numseq) {
-       try {
-       
-               float fvalue = 0;
-               
-                /* F-Snedecor critical values for v1=1 and different degrees of freedom v2 and alpha 0.05 */
-        if (numseq > 120) fvalue = 3.84;
-        else if (numseq > 60) fvalue = 3.92;
-        else if (numseq > 40) fvalue = 4.00;
-        else if (numseq > 30) fvalue = 4.08;
-        else if (numseq > 29) fvalue = 4.17;
-        else if (numseq > 28) fvalue = 4.18;
-        else if (numseq > 27) fvalue = 4.20;
-        else if (numseq > 26) fvalue = 4.21;
-        else if (numseq > 25) fvalue = 4.23;
-        else if (numseq > 24) fvalue = 4.24;
-        else if (numseq > 23) fvalue = 4.26;
-        else if (numseq > 22) fvalue = 4.28;
-        else if (numseq > 21) fvalue = 4.30;
-        else if (numseq > 20) fvalue = 4.32;
-        else if (numseq > 19) fvalue = 4.35;
-        else if (numseq > 18) fvalue = 4.38;
-        else if (numseq > 17) fvalue = 4.41;
-        else if (numseq > 16) fvalue = 4.45;
-        else if (numseq > 15) fvalue = 4.49;
-        else if (numseq > 14) fvalue = 4.54;
-        else if (numseq > 13) fvalue = 4.60;
-        else if (numseq > 12) fvalue = 4.67;
-        else if (numseq > 11) fvalue = 4.75;
-        else if (numseq > 10) fvalue = 4.84;
-        else if (numseq > 9) fvalue = 4.96;
-        else if (numseq > 8) fvalue = 5.12;
-        else if (numseq > 7) fvalue = 5.32;
-        else if (numseq > 6) fvalue = 5.59;
-        else if (numseq > 5) fvalue = 5.99;
-        else if (numseq > 4) fvalue = 6.61;
-        else if (numseq > 3) fvalue = 7.71;
-        else if (numseq > 2) fvalue = 10.1;
-        else if (numseq > 1) fvalue = 18.5;
-        else if (numseq > 0) fvalue = 161;
-               else if (numseq <= 0) {
-                       m->mothurOut("Two or more reference sequences are required, your data will be flawed.\n"); m->mothurOutEndLine();
-        }
-               
-               return fvalue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ccode", "getF");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-
-
diff --git a/ccode.h b/ccode.h
deleted file mode 100644 (file)
index 456b735..0000000
--- a/ccode.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef CCODE_H
-#define CCODE_H
-
-/*
- *  ccode.h
- *  Mothur
- *
- *  Created by westcott on 8/24/09.
- *  Copyright 2009 Schloss LAB. All rights reserved.
- *
- */
-
-#include "chimera.h"
-#include "dist.h"
-#include "decalc.h"
-
-/***********************************************************/
-//This class was created using the algorythms described in the 
-// "Evaluating putative chimeric sequences from PCR-amplified products" paper 
-//by Juan M. Gonzalez, Johannes Zimmerman and Cesareo Saiz-Jimenez.
-
-/***********************************************************/
-
-class Ccode : public Chimera {
-       
-       public:
-               Ccode(string, string, bool, string, int, int, string);  //fasta, template, filter, mask, window, numWanted, outputDir
-               ~Ccode();
-               
-               int getChimeras(Sequence* query);
-               Sequence print(ostream&, ostream&);
-               
-               #ifdef USE_MPI
-               Sequence print(MPI_File&, MPI_File&);
-               #endif
-       private:
-       
-               Dist* distCalc;
-               DeCalculator* decalc;
-               int iters, window, numWanted;
-               string fastafile, mapInfo;
-               
-               Sequence* querySeq;
-               
-               map<int, int> spotMap;
-               map<int, int>::iterator it;
-               
-               vector<int>  windows; //windows is the vector of window breaks for query
-               int windowSizes;  //windowSizes is the size of the windows for query
-               map<int, int> trim;  //trim is the map containing the starting and ending positions for query
-               vector<SeqDist>  closest;  //closest is a vector of sequence at are closest to query
-               vector<float>  averageRef;  //averageRef is the average distance at each window for the references for query
-               vector<float>  averageQuery;  //averageQuery is the average distance at each winow for the query for query
-               vector<float>   sumRef;  //sumRef is the sum of distances at each window for the references for query
-               vector<float>   sumSquaredRef;  //sumSquaredRef is the sum of squared distances at each window for the references for query
-               vector<float> sumQuery;  //sumQuery is the sum of distances at each window for the comparison of query to references for query
-               vector<float>  sumSquaredQuery;  //sumSquaredQuery is the sum of squared distances at each window for the comparison of query to references for query
-               vector<float> varRef;  //varRef is the variance among references seqs at each window for query
-               vector<float> varQuery;  //varQuery is the variance among references and query at each window
-               vector<float> sdRef;  //sdRef is the standard deviation of references seqs at each window for query
-               vector<float> sdQuery;  //sdQuery is the standard deviation of references and query at each window
-               vector<float> anova;  //anova is the vector of anova scores for each window for query
-               int refCombo;  //refCombo is the number of reference sequences combinations for query
-               vector<bool>  isChimericConfidence;  //isChimericConfidence indicates whether query is chimeric at a given window according to the confidence limits
-               vector<bool>  isChimericTStudent;  //isChimericConfidence indicates whether query is chimeric at a given window according to the confidence limits
-               vector<bool>  isChimericANOVA;  //isChimericConfidence indicates whether query is chimeric at a given window according to the confidence limits
-               
-               vector<SeqDist>  findClosest(Sequence*, int); 
-               void removeBadReferenceSeqs(vector<SeqDist>&);  //removes sequences from closest that are to different of too similar to eachother. 
-               void trimSequences(Sequence*);
-               vector<int> findWindows();
-               void getAverageRef(vector<SeqDist>);            //fills sumRef, averageRef, sumSquaredRef and refCombo.
-               void getAverageQuery (vector<SeqDist>, Sequence*);      //fills sumQuery, averageQuery, sumSquaredQuery.
-               void findVarianceRef ();                                                //fills varRef and sdRef also sets minimum error rate to 0.001 to avoid divide by 0.
-               void findVarianceQuery ();                                      //fills varQuery and sdQuery
-               void determineChimeras ();                                      //fills anova, isChimericConfidence, isChimericTStudent and isChimericANOVA.
-               
-               int getDiff(string, string);  //return number of mismatched bases, a gap to base is not counted as a mismatch
-               float getT(int); 
-               float getF(int); 
-               
-               #ifdef USE_MPI
-               int printMapping(string&);
-               MPI_File outMap;
-               #endif
-
-};
-
-/***********************************************************/
-
-#endif
-
-
diff --git a/chao1.cpp b/chao1.cpp
deleted file mode 100644 (file)
index ad1faa2..0000000
--- a/chao1.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- *  chao1.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "chao1.h"
-
-/***********************************************************************/
-EstOutput Chao1::getValues(SAbundVector* rank){
-       try {
-               data.resize(3,0);
-       
-               double sobs = (double)rank->getNumBins();
-               
-               //this is a modification do to a vector fill error that occurs when an empty sharedRabund creates a sabund
-               //in that case there is no 1 0r 2.
-               double singles;
-               if (rank->size() > 1) {
-                       singles = (double)rank->get(1);
-               }else{ singles = 0.0;  }
-
-               double doubles;
-               if (rank->size() > 2) {
-                        doubles = (double)rank->get(2);
-               }else{ doubles = 0.0;  }
-
-               double chaovar = 0.0000;
-//cout << "singles = " << singles << " doubles = " << doubles << " sobs = " << sobs << endl;   
-               double chao = sobs + singles*(singles-1)/(2*(doubles+1));
-       
-               if(singles > 0 && doubles > 0){
-                       chaovar = singles*(singles-1)/(2*(doubles+1))
-                                       + singles*pow(2*singles-1, 2)/(4*pow(doubles+1,2))
-                                       + pow(singles, 2)*doubles*pow(singles-1, 2)/(4*pow(doubles+1,4));
-               }
-               else if(singles > 0 && doubles == 0){
-                       chaovar = singles*(singles-1)/2 + singles*pow(2*singles-1, 2)/4 - pow(singles, 4)/(4*chao); 
-               }
-               else if(singles == 0){
-                       chaovar = sobs*exp(-1*rank->getNumSeqs()/sobs)*(1-exp(-1*rank->getNumSeqs()/sobs));
-               }
-                       
-               double chaohci, chaolci;
-       
-               if(singles>0){
-                       double denom = pow(chao-sobs,2);
-                       double c = exp(1.96*pow((log(1+chaovar/denom)),0.5));
-                       chaolci = sobs+(chao-sobs)/c;//chao lci
-                       chaohci = sobs+(chao-sobs)*c;//chao hci
-               }
-               else{
-                       double p = exp(-1*rank->getNumSeqs()/sobs);
-                       chaolci = sobs/(1-p)-1.96*pow(sobs*p/(1-p), 0.5);
-                       chaohci = sobs/(1-p)+1.96*pow(sobs*p/(1-p), 0.5);
-                       if(chaolci < sobs){     chaolci = sobs; }
-               }
-               
-               data[0] = chao;
-               data[1] = chaolci;
-               data[2] = chaohci;
-
-           if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chao1", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/chao1.h b/chao1.h
deleted file mode 100644 (file)
index 21224eb..0000000
--- a/chao1.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef CHAO1_H
-#define CHAO1_H
-/*
- *  chao1.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the Ace estimator on single group. 
-It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Chao1 : public Calculator  {
-       
-public: 
-       Chao1() : Calculator("chao", 3, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Chao"; }
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/chimera.cpp b/chimera.cpp
deleted file mode 100644 (file)
index 53e7732..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- *  chimera.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 8/11/09.
- *  Copyright 2009 Schloss Lab Umass Amherst. All rights reserved.
- *
- */
-
-#include "chimera.h"
-#include "referencedb.h"
-
-//***************************************************************************************************************
-//this is a vertical soft filter
-string Chimera::createFilter(vector<Sequence*> seqs, float t) {
-       try {
-               filterString = "";
-               int threshold = int (t * seqs.size());
-//cout << "threshhold = " << threshold << endl;
-               
-               vector<int> gaps;       gaps.resize(seqs[0]->getAligned().length(), 0);
-               vector<int> a;          a.resize(seqs[0]->getAligned().length(), 0);
-               vector<int> t;          t.resize(seqs[0]->getAligned().length(), 0);
-               vector<int> g;          g.resize(seqs[0]->getAligned().length(), 0);
-               vector<int> c;          c.resize(seqs[0]->getAligned().length(), 0);
-       
-               filterString = (string(seqs[0]->getAligned().length(), '1'));
-               
-               //for each sequence
-               for (int i = 0; i < seqs.size(); i++) {
-               
-                       if (m->control_pressed) { return filterString; }
-               
-                       string seqAligned = seqs[i]->getAligned();
-                       
-                       if (seqAligned.length() != filterString.length()) {  m->mothurOut(seqs[i]->getName() + " is not the same length as the template sequences. Aborting!\n");  exit(1); }
-               
-                       for (int j = 0; j < seqAligned.length(); j++) {
-                               //if this spot is a gap
-                               if ((seqAligned[j] == '-') || (seqAligned[j] == '.'))   {       gaps[j]++;      }
-                               else if (toupper(seqAligned[j]) == 'A')                                 {       a[j]++;         }
-                               else if (toupper(seqAligned[j]) == 'T')                                 {       t[j]++;         }
-                               else if (toupper(seqAligned[j]) == 'G')                                 {       g[j]++;         }
-                               else if (toupper(seqAligned[j]) == 'C')                                 {       c[j]++;         }
-                       }
-               }
-               
-               //zero out spot where all sequences have blanks
-               int numColRemoved = 0;
-               for(int i = 0;i < seqs[0]->getAligned().length(); i++){
-               
-                       if (m->control_pressed) { return filterString; }
-                       
-                       if(gaps[i] == seqs.size())      {       filterString[i] = '0';  numColRemoved++;  }
-                       
-                       else if (((a[i] < threshold) && (t[i] < threshold) && (g[i] < threshold) && (c[i] < threshold))) {      filterString[i] = '0';  numColRemoved++;  }
-                       //cout << "a = " << a[i] <<  " t = " << t[i] <<  " g = " << g[i] <<  " c = " << c[i] << endl;
-               }
-
-               if (threshold != 0.0) {  m->mothurOut("Filter removed " + toString(numColRemoved) + " columns.");  m->mothurOutEndLine();  }
-               
-               return filterString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chimera", "createFilter");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-map<int, int> Chimera::runFilter(Sequence* seq) {
-       try {
-               map<int, int> maskMap;
-               string seqAligned = seq->getAligned();
-               string newAligned = "";
-               int count = 0;
-                       
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //if this spot is a gap
-                       if (filterString[j] == '1') { 
-                               newAligned += seqAligned[j]; 
-                               maskMap[count] = j;
-                               count++;
-                       }
-               }
-                       
-               seq->setAligned(newAligned);
-               
-               return maskMap;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chimera", "runFilter");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<Sequence*> Chimera::readSeqs(string file) {
-       try {
-               
-               vector<Sequence*> container;
-               int count = 0;
-               length = 0;
-               unaligned = false;
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               if (file == "saved") {
-                       
-                       
-                       m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + " that are saved in memory.");        m->mothurOutEndLine();
-                       
-                       for (int i = 0; i < rdb->referenceSeqs.size(); i++) {
-                               Sequence* temp = new Sequence(rdb->referenceSeqs[i].getName(), rdb->referenceSeqs[i].getAligned());
-                               
-                               if (count == 0) {  length = temp->getAligned().length();  count++;  } //gets first seqs length
-                               else if (length != temp->getAligned().length()) {       unaligned = true;       }
-                               
-                               if (temp->getName() != "") {  container.push_back(temp);  }
-                       }
-                       
-                       templateFileName = rdb->getSavedReference();
-                       
-               }else {
-                       
-                       m->mothurOut("Reading sequences from " + file + "..."); cout.flush();
-                       
-                       #ifdef USE_MPI
-                               int pid, processors;
-                               vector<unsigned long long> positions;
-                               int numSeqs;
-                               int tag = 2001;
-                               MPI_File inMPI;
-                               MPI_Status status; 
-                       
-                               if (byGroup) {
-                                       char inFileName[1024];
-                                       strcpy(inFileName, file.c_str());
-                                       
-                                       MPI_File_open(MPI_COMM_SELF, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                                       
-                                       positions = m->setFilePosFasta(file, numSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //read file 
-                                       for(int i=0;i<numSeqs;i++){
-                                               
-                                               if (m->control_pressed) { MPI_File_close(&inMPI); return container; }
-                                               
-                                               //read next sequence
-                                               int seqlength = positions[i+1] - positions[i];
-                                               char* buf4 = new char[seqlength];
-                                               
-                                               MPI_File_read_at(inMPI, positions[i], buf4, seqlength, MPI_CHAR, &status);
-                                               
-                                               string tempBuf = buf4;
-                                               if (tempBuf.length() > seqlength) { tempBuf = tempBuf.substr(0, seqlength); }
-                                               delete buf4;
-                                               
-                                               istringstream iss (tempBuf,istringstream::in);
-                                               
-                                               Sequence* current = new Sequence(iss);   
-                                               if (current->getName() != "") {
-                                                       if (count == 0) {  length = current->getAligned().length();  count++;  } //gets first seqs length
-                                                       else if (length != current->getAligned().length()) {    unaligned = true;       }
-                                                       
-                                                       container.push_back(current);  
-                                                       if (rdb->save) { rdb->referenceSeqs.push_back(*current); }
-                                               }
-                                       }
-                                       
-                                       MPI_File_close(&inMPI);
-                                       
-                               }else {                                 
-                                       
-                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                                       MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                                       
-                                       //char* inFileName = new char[file.length()];
-                                       //memcpy(inFileName, file.c_str(), file.length());
-                                       
-                                       char inFileName[1024];
-                                       strcpy(inFileName, file.c_str());
-                                       
-                                       MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                                       //delete inFileName;
-                                       
-                                       if (pid == 0) {
-                                               positions = m->setFilePosFasta(file, numSeqs); //fills MPIPos, returns numSeqs
-                                               
-                                               //send file positions to all processes
-                                               for(int i = 1; i < processors; i++) { 
-                                                       MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                                       MPI_Send(&positions[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                               }
-                                       }else{
-                                               MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                               positions.resize(numSeqs+1);
-                                               MPI_Recv(&positions[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       }
-                                       
-                                       //read file 
-                                       for(int i=0;i<numSeqs;i++){
-                                               
-                                               if (m->control_pressed) { MPI_File_close(&inMPI); return container; }
-                                               
-                                               //read next sequence
-                                               int seqlength = positions[i+1] - positions[i];
-                                               char* buf4 = new char[seqlength];
-                                               
-                                               MPI_File_read_at(inMPI, positions[i], buf4, seqlength, MPI_CHAR, &status);
-                                               
-                                               string tempBuf = buf4;
-                                               if (tempBuf.length() > seqlength) { tempBuf = tempBuf.substr(0, seqlength); }
-                                               delete buf4;
-                                               
-                                               istringstream iss (tempBuf,istringstream::in);
-                                               
-                                               Sequence* current = new Sequence(iss);   
-                                               if (current->getName() != "") {
-                                                       if (count == 0) {  length = current->getAligned().length();  count++;  } //gets first seqs length
-                                                       else if (length != current->getAligned().length()) {    unaligned = true;       }
-                                                       
-                                                       container.push_back(current);  
-                                                       if (rdb->save) { rdb->referenceSeqs.push_back(*current); }
-                                               }
-                                       }
-                                       
-                                       MPI_File_close(&inMPI);
-                                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               }
-               #else
-
-                       ifstream in;
-                       m->openInputFile(file, in);
-                       
-                       //read in seqs and store in vector
-                       while(!in.eof()){
-                               
-                               if (m->control_pressed) { return container; }
-                               
-                               Sequence* current = new Sequence(in);  m->gobble(in);
-                               
-                               if (count == 0) {  length = current->getAligned().length();  count++;  } //gets first seqs length
-                               else if (length != current->getAligned().length()) {   unaligned = true;        }
-                                                       
-                               if (current->getName() != "") {  
-                                       container.push_back(current);  
-                                       if (rdb->save) { rdb->referenceSeqs.push_back(*current); }
-                               }
-                       }
-                       in.close();
-               #endif
-               
-                       m->mothurOut("Done."); m->mothurOutEndLine();
-                       
-                       filterString = (string(container[0]->getAligned().length(), '1'));
-               }
-               
-               return container;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chimera", "readSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-void Chimera::setMask(string filename) {
-       try {
-               
-               if (filename == "default") {
-                       //default is from wigeon  236627 EU009184.1 Shigella dysenteriae str. FBD013
-                       seqMask = ".....................................................................................................AAATTGAAGAGTTT-GA--T-CA-T-G-GCTC-AG-AT-TGAA-C-GC--TGG-C--G-GC-A-GG--C----C-T--AACACA-T-GC-A-AGT-CGA-A-CG----------G-TAA-CA-G----------------------------GAAG-A-AG----------------------------------------------------CTT-G----------------------------------------------------------------------------------CT-TCTTT----------------G-CT--G--AC--G--AG-T-GG-C-GG-A--C-------------GGG-TGAGT-A--AT-GT-C-T-G-GG---A-A--A-CT-G--C-C-TGA--TG-G------------------------------------------------------------------A-GG----GGG-AT-AA-CTA-------------------------C-T-G-----------------------GAA-A---CGG-TAG-CTAA-TA---CC-G--C-AT-A----------A--------------------C-------------------------------------GT-C-----------------------------------------------------------------------------------------------------------------------G-CA-A--------------------------------------------------------------------------------------------------------------------------------------G-A-C---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------CAAA--G-A-G-GG-----G--GA-C-CT--------------------------------------------------------------------------------------------------------------------TCG-G----------------------------------------------------------------------------------------------------------------------G----CC-TC--T---T-G--------------C----C-A---T-CG-G---AT---G-T-----G-CCC-AGA--T-GGG--A------TT--A--G-CT-A----G---TAGG-T-G-GG-G-T----AAC-GG-C-T-C-ACCT--A-GG-C-G--A-CG-A------------TCC-C-T------AG-CT-G-G-TCT-G-AG----A--GG-AT--G-AC-C-AG-CCAC-A-CTGGA--A-C-TG-A-GA-C-AC-G-G-TCCAGA-CTCC-TAC-G--G-G-A-G-GC-A-GC-A-G-TG---GG-G-A-ATA-TTGCA-C-AA-T-GG--GC-GC-A----A-G-CC-T-GA-TG-CA-GCCA-TGCC-G-CG-T---G-T-A--T--GA-A-G--A--A-G-G-CC-----TT-CG---------G-G-T-T-G-T--A---AA-G-TAC--------TT-TC-A-G--C-GGG----GA-G--G---AA-GGGA---GTAA-AG----T--T--AA-T---A----C-----CT-T-TGC-TCA-TT-GA-CG-TT-A-C-CC-G-CA-G---------AA-----------GAAGC-ACC-GG-C-TAA---C--T-CCGT--GCCA--G-C---A--GCCG---C-GG--TA-AT--AC---GG-AG-GGT-GCA-A-G-CG-TTAA-T-CGG-AA-TT-A--C-T--GGGC-GTA----AA-GCGC-AC--G-CA-G-G-C-G------------G--T-TT-G-T-T-AA----G-T-C-A---G-ATG-TG-A-AA-TC--CC-CGG-G--------------------------------------------------------------------CT-C-AA-------------------------------------------------------------------------CC-T-G-GG-AA-C----T-G-C-A-T-C--------T--GA-T-A-C-T-G-GCA--A-G-C---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------T-T-G-A-G-T-C-----T-CG--TA-G-A------------G-GG-G-GG-T----AG--AATT-CCA-G-GT--GT-A-GCG-GTGAAA-TG-CGT-AGAG-A-TC-T-GGA--GG-A-AT-A-CC-GG--T--G--GC-GAA-G--G-C---G----G--C-C-CCCTG------G-AC-GA--------------------------------------------------------------AG-A-C-T--GA--CG-----CT-CA-GG--T-G-CGA--AA-G-C--------------G-TGGG-GAG-C-A-AACA--GG-ATTA-G-ATA-C-----CC-T-G-GTA-G-T----C-CA--C-G-CCG-T-AAA--C-GATG-TC--GA-CT---------T-GG--A--G-G-TT-G-TG-C--C--------------------------------------------------------------------------------------CTT-GA--------------------------------------------------------------------------------------------------------------------------------------------------G-G-C-GT--G-G-C-T-TC-C------GG--A----GC-TAA--CG-C-G-T--T--AA-GT--C----G-ACC-GCC-T-G-GG-GAG-TA---CGG-----C-C--G-C-A-A-GGT-T--AAA-ACTC-AAA---------TGAA-TTG-ACGGG-G-G-CCCG----C-A--C-A-A-GCG-GT-G--G--AG-CA-T--GT-GGT-TT-AATT-C-G-ATG-CAAC-G-CG-A-AG-A-A-CC-TT-A-CC-TGGTC-TT-G-AC-A-T-C--------------CAC-G-G-------------A-AG-T-T-T--TC--A-GA-G-A-T--G-A-G--A-A-T-G--T-G-----CC-------------------------------------T--TC-G------------------------------------------GG----A----A---CC-GTG---A--GA---------------------------------------------------C-A-G-G-T-GCTG-CA-TGG-CT--GTC-GTC-A-GC-TC---G-TG-TT-G--TGA-AA-TGT-T-GG-G-TT-AA-GT-CCCGC-AA--------C-GAG-CGC-A-ACC-C-T-TA--TC--C-TTTG--T-T-G-C-C---AG-C-G-----G-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------TCC------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------GG---C----C-G------------G----G---A-A--CT---------------C-A-A-A-G-GA-G--AC-T-G-CCA--G-T------------------------------------G-A---TAA----------------------------------A-C-T-G--G-A-GG-A--AGG-T--GGGG-A-TGAC-GTC--AAGT-C---ATC-A-T-G-G-C-C-CTT----AC-G--AC-C-A-GG-GC-TA-CAC-ACGTG-C--TA--CAATG---G-CGCA-T-A--C-AAA-GA-GA--------------------------------------------------------------------------------------------------A-G-C-G-A--C-CTCG-C--G---------------------------------------A-GA-G-C-----------A--A-G-CG---G----------A--CCT-C------A-T-AAAGT-GC-G-T-C-G-TAG-TCC--------GGA-T-TGGAG-TC--T-GCAA-CT-C-------------------------------------------------------------------------------------------------G-ACTCC-A-T-G-AA-G-TC-GGAAT-CG-C-TA--G-TA-AT-C-G-T----GGA-TC-A-G--A------AT--GCC-AC-G-GT-G-AAT-ACGT-T-CCCGGGCCT-TGTA----CACACCG-CCC-GTC-----A---CA--CCA-TG-GG-A--G---TGG-G-TT-GC-AAA--A-GAA------G--T-AGG-TA-G-C-T-T-AA-C-C--------------------------------------------------------------TT----C-------------------------------------------------------------------------------------------------G--GG-A--GG-G--C---GC-TTA--CC--ACT-T----T-GTG-AT-TCA------------------------TG--ACT-GGGG-TG-AAG-TCGTAACAA-GGTAA-CCGT-AGGGGAA-CCTG-CGGT-TGGATCACCTCCTTA................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................";
-               }else if (filename == "") {  //do nothing 
-                       seqMask = "";
-               }else{
-               
-       #ifdef USE_MPI  
-                       MPI_File inMPI;
-                       MPI_Offset size;
-                       MPI_Status status;
-                       
-                       //char* inFileName = new char[filename.length()];
-                       //memcpy(inFileName, filename.c_str(), filename.length());
-                       
-                       char inFileName[1024];
-                       strcpy(inFileName, filename.c_str());
-       
-                       MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                       MPI_File_get_size(inMPI, &size);
-
-                       //delete inFileName;
-                       
-                       char* buffer = new char[size];
-                       MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-                       
-                       string tempBuf = buffer;
-                       if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-                       istringstream iss (tempBuf,istringstream::in);
-
-                       delete buffer;
-                       
-                       if (!iss.eof()) {
-                               Sequence temp(iss);
-                               seqMask = temp.getAligned();
-                       }else {
-                               m->mothurOut("Problem with mask."); m->mothurOutEndLine(); 
-                               seqMask = "";
-                       }
-                       
-                       MPI_File_close(&inMPI);
-       #else
-       
-                       ifstream infile;
-                       m->openInputFile(filename, infile);
-                       
-                       if (!infile.eof()) {
-                               Sequence temp(infile);
-                               seqMask = temp.getAligned();
-                       }else {
-                               m->mothurOut("Problem with mask."); m->mothurOutEndLine(); 
-                               seqMask = "";
-                       }
-                       infile.close();
-       #endif
-       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chimera", "setMask");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Sequence* Chimera::getSequence(string name) {
-       try{
-               Sequence* temp;
-               
-               //look through templateSeqs til you find it
-               int spot = -1;
-               for (int i = 0; i < templateSeqs.size(); i++) {
-                       if (name == templateSeqs[i]->getName()) {  
-                               spot = i;
-                               break;
-                       }
-               }
-               
-               if(spot == -1) { m->mothurOut("Error: Could not find sequence."); m->mothurOutEndLine(); return NULL; }
-               
-               temp = new Sequence(templateSeqs[spot]->getName(), templateSeqs[spot]->getAligned());
-               
-               return temp;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Chimera", "getSequence");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-
-
-
diff --git a/chimera.h b/chimera.h
deleted file mode 100644 (file)
index bb4c29c..0000000
--- a/chimera.h
+++ /dev/null
@@ -1,187 +0,0 @@
-#ifndef CHIMERA_H
-#define CHIMERA_H
-
-/*
- *  chimera.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "sequence.hpp"
-/***********************************************************************/
-struct data_struct { 
-       float divr_qla_qrb;
-       float divr_qlb_qra;
-       float qla_qrb;
-       float qlb_qra;
-       float qla;
-       float qrb;
-       float ab; 
-       float qa;
-       float qb; 
-       float lab; 
-       float rab; 
-       float qra; 
-       float qlb; 
-       int winLStart;
-       int winLEnd; 
-       int winRStart; 
-       int winREnd; 
-       Sequence querySeq; 
-       Sequence parentA;
-       Sequence parentB;
-       float bsa;
-       float bsb;
-       float bsMax;
-       float chimeraMax;
-       
-};
-/***********************************************************************/
-struct data_results {
-       vector<data_struct> results;
-       string flag;
-       Sequence trimQuery;
-       //results malignerResults;
-       
-       data_results(vector<data_struct> d, string f, map<int, int> s, Sequence t) : results(d), flag(f), trimQuery(t) {}
-       data_results() {}
-};
-/***********************************************************************/
-//sorts lowest to highest first by bsMax, then if tie by chimeraMax
-inline bool compareDataStruct(data_struct left, data_struct right){
-       if (left.bsMax < right.bsMax) { return true; }
-       else if (left.bsMax == right.bsMax) {
-               return (left.chimeraMax < right.chimeraMax);
-       }else { return false;   }
-} 
-/***********************************************************************/
-struct Preference {
-               string name;
-               string leftParent; //keep the name of closest left 
-               string rightParent; //keep the name of closest 
-               float score;  //preference score
-               float closestLeft;  //keep the closest left 
-               float closestRight; //keep the closest right 
-               int midpoint;
-               Preference() { name = ""; leftParent = ""; rightParent = ""; score = 0.0; closestLeft = 10000.0; closestRight = 10000.0; midpoint = 0;  }
-               ~Preference() {}
-};
-/***********************************************************************/
-struct score_struct {
-       int prev;
-       int score;
-       int row;
-       int col;
-//     int mismatches;
-};
-/***********************************************************************/
-struct trace_struct {
-       int col;
-       int oldCol;
-       int row;
-};
-/***********************************************************************/
-struct results {
-       int regionStart;
-       int regionEnd;
-       int nastRegionStart;
-       int nastRegionEnd;
-       string parent;
-       string parentAligned;
-       float queryToParent;
-       float queryToParentLocal;
-       float divR;
-};
-/***********************************************************************/
-struct SeqDist {
-       Sequence* seq;
-       float dist;
-       int index;
-};
-/***********************************************************************/
-struct SeqCompare {
-       Sequence seq;
-       float dist;
-       int index;
-};
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareRegionStart(results left, results right){
-       return (left.nastRegionStart < right.nastRegionStart);  
-} 
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSeqDist(SeqDist left, SeqDist right){
-       return (left.dist < right.dist);        
-} 
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSeqCompare(SeqCompare left, SeqCompare right){
-       return (left.dist < right.dist);        
-} 
-//********************************************************************************************************************
-struct sim {
-               string leftParent;
-               string rightParent; 
-               float score;  
-               int midpoint;
-};
-
-struct linePair {
-                       unsigned long long start;
-                       unsigned long long end;
-                       linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-                       linePair(){}
-};
-
-
-/***********************************************************************/
-
-class Chimera {
-
-       public:
-       
-               Chimera(){ m = MothurOut::getInstance(); length = 0; unaligned = false;  byGroup = false; }
-               virtual ~Chimera(){     for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i];  } for (int i = 0; i < filteredTemplateSeqs.size(); i++) { delete filteredTemplateSeqs[i];  } };
-               virtual bool getUnaligned()                             {       return unaligned;                       }
-               virtual int getLength()                                 {   return length;      }
-               virtual vector<Sequence*> readSeqs(string);
-               virtual void setMask(string);
-               virtual map<int, int> runFilter(Sequence*);
-               virtual string createFilter(vector<Sequence*>, float);
-               virtual void printHeader(ostream&){};
-               virtual int getChimeras(Sequence*){ return 0; }
-               virtual int getChimeras(){ return 0; }
-               virtual Sequence print(ostream&, ostream&){  Sequence temp; return temp; }
-               virtual Sequence print(ostream&, ostream&, data_results, data_results) { Sequence temp; return temp; }
-               virtual int print(ostream&, ostream&, string){  return 0; }
-               virtual int getNumNoParents(){  return 0; }
-               virtual data_results getResults() { data_results results; return results; }
-               
-               #ifdef USE_MPI
-               virtual Sequence print(MPI_File&, MPI_File&){  Sequence temp; return temp; }
-               virtual Sequence print(MPI_File&, MPI_File&, data_results, data_results){  Sequence temp; return temp; }
-               virtual int print(MPI_File&, MPI_File&, string){  return 0; }
-               #endif
-               
-               
-       protected:
-               
-               vector<Sequence*> templateSeqs;
-               vector<Sequence*> filteredTemplateSeqs;
-               bool filter, unaligned, byGroup; 
-               int length; 
-               string seqMask, filterString, outputDir, templateFileName; 
-               Sequence* getSequence(string);  //find sequence from name       
-               MothurOut* m;
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/chimerabellerophoncommand.cpp b/chimerabellerophoncommand.cpp
deleted file mode 100644 (file)
index 1fc87db..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-/*
- *  chimerabellerophoncommand.cpp
- *  Mothur
- *
- *  Created by westcott on 4/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimerabellerophoncommand.h"
-#include "bellerophon.h"
-
-//**********************************************************************************************************************
-vector<string> ChimeraBellerophonCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none","none","none",false,true); parameters.push_back(pfasta);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pcorrection("filter", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcorrection);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pincrement("increment", "Number", "", "25", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraBellerophonCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The chimera.bellerophon command reads a fastafile and creates list of potentially chimeric sequences.\n";
-               helpString += "The chimera.bellerophon command parameters are fasta, filter, correction, processors, window, increment. The fasta parameter is required, unless you have a valid current file.\n";
-               helpString += "The fasta parameter is required.  You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The filter parameter allows you to specify if you would like to apply a vertical and 50% soft filter, default=false. \n";
-               helpString += "The correction parameter allows you to put more emphasis on the distance between highly similar sequences and less emphasis on the differences between remote homologs, default=true.\n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The window parameter allows you to specify the window size for searching for chimeras, default is 1/4 sequence length. \n";
-               helpString += "The increment parameter allows you to specify how far you move each window while finding chimeric sequences, default is 25.\n";
-               helpString += "chimera.bellerophon(fasta=yourFastaFile, filter=yourFilter, correction=yourCorrection, processors=yourProcessors) \n";
-               helpString += "Example: chimera.bellerophon(fasta=AD.align, filter=True, correction=true, window=200) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraBellerophonCommand::ChimeraBellerophonCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraBellerophonCommand::ChimeraBellerophonCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.bellerophon");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "filter", false);                   if (temp == "not found") { temp = "F"; }
-                       filter = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "correction", false);               if (temp == "not found") { temp = "T"; }
-                       correction = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "window", false);                   if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, window);
-                       
-                       temp = validParameter.validFile(parameters, "increment", false);                if (temp == "not found") { temp = "25"; }
-                       m->mothurConvert(temp, increment);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "ChimeraBellerophonCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int ChimeraBellerophonCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int i = 0; i < fastaFileNames.size(); i++) {
-                       
-                       m->mothurOut("Checking sequences from " + fastaFileNames[i] + " ..." ); m->mothurOutEndLine();
-                       
-                       int start = time(NULL); 
-                       
-                       chimera = new Bellerophon(fastaFileNames[i], filter, correction, window, increment, processors, outputDir);     
-                       
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[i]);  }//if user entered a file with a path then preserve it               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) +  "bellerophon.chimeras";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i])) + "bellerophon.accnos";
-                       
-                       chimera->getChimeras();
-                       
-                       if (m->control_pressed) { delete chimera; for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear(); return 0;        }
-                       
-               #ifdef USE_MPI
-                       MPI_File outMPI;
-                       MPI_File outMPIAccnos;
-                       
-                       int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                       
-                       char outFilename[1024];
-                       strcpy(outFilename, accnosFileName.c_str());
-
-                       char FileName[1024];
-                       strcpy(FileName, outputFileName.c_str());
-
-                       MPI_File_open(MPI_COMM_WORLD, FileName, outMode, MPI_INFO_NULL, &outMPI);  //comm, filename, mode, info, filepointer
-                       MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-       
-                       numSeqs = chimera->print(outMPI, outMPIAccnos, "");
-                       
-                       MPI_File_close(&outMPI);
-                       MPI_File_close(&outMPIAccnos);
-
-               #else
-               
-                       ofstream out;
-                       m->openOutputFile(outputFileName, out);
-                       
-                       ofstream out2;
-                       m->openOutputFile(accnosFileName, out2);
-                       
-                       numSeqs = chimera->print(out, out2, "");
-                       out.close();
-                       out2.close(); 
-                       
-               #endif
-                       
-                       if (m->control_pressed) { m->mothurRemove(accnosFileName); m->mothurRemove(outputFileName); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);        } outputTypes.clear(); delete chimera;  return 0;       }
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       
-                       outputNames.push_back(outputFileName);  outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(accnosFileName);  outputTypes["accnos"].push_back(accnosFileName);
-                       
-                       delete chimera;
-               }
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraBellerophonCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/chimerabellerophoncommand.h b/chimerabellerophoncommand.h
deleted file mode 100644 (file)
index b759d5a..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef CHIMERABELLEROPHONCOMMAND_H
-#define CHIMERABELLEROPHONCOMMAND_H
-
-/*
- *  chimerabellerophoncommand.h
- *  Mothur
- *
- *  Created by westcott on 4/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "chimera.h"
-
-
-/***********************************************************/
-
-class ChimeraBellerophonCommand : public Command {
-public:
-       ChimeraBellerophonCommand(string);
-       ChimeraBellerophonCommand();
-       ~ChimeraBellerophonCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.bellerophon"; }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Huber T, Faulkner G, Hugenholtz P (2004). Bellerophon: a program to detect chimeric sequences in multiple sequence alignments. Bioinformatics 20: 2317-9. \nhttp://www.mothur.org/wiki/Chimera.bellerophon"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-               
-private:
-
-       bool abort, filter, correction;
-       string fastafile, outputDir;
-       int processors, window, increment, numSeqs;
-       Chimera* chimera;
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-};
-
-/***********************************************************/
-
-#endif
-
-
diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp
deleted file mode 100644 (file)
index fc98e0f..0000000
+++ /dev/null
@@ -1,666 +0,0 @@
-/*
- *  chimeraccodecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 3/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimeraccodecommand.h"
-#include "ccode.h"
-#include "referencedb.h"
-//**********************************************************************************************************************
-vector<string> ChimeraCcodeCommand::setParameters(){   
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pnumwanted("numwanted", "Number", "", "20", "", "", "",false,false); parameters.push_back(pnumwanted);
-               CommandParameter pmask("mask", "String", "", "", "", "", "",false,false); parameters.push_back(pmask);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraCcodeCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The chimera.ccode command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
-               helpString += "This command was created using the algorythms described in the 'Evaluating putative chimeric sequences from PCR-amplified products' paper by Juan M. Gonzalez, Johannes Zimmerman and Cesareo Saiz-Jimenez.\n";
-               helpString += "The chimera.ccode command parameters are fasta, reference, filter, mask, processors, window and numwanted.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required unless you have a valid current fasta file. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The reference parameter allows you to enter a reference file containing known non-chimeric sequences, and is required. \n";
-               helpString += "The filter parameter allows you to specify if you would like to apply a vertical and 50% soft filter. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The mask parameter allows you to specify a file containing one sequence you wish to use as a mask for the your sequences. \n";
-               helpString += "The window parameter allows you to specify the window size for searching for chimeras. \n";
-               helpString += "The numwanted parameter allows you to specify how many sequences you would each query sequence compared with.\n";
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The chimera.ccode command should be in the following format: \n";
-               helpString += "chimera.ccode(fasta=yourFastaFile, reference=yourTemplate) \n";
-               helpString += "Example: chimera.ccode(fasta=AD.align, reference=core_set_aligned.imputed.fasta) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraCcodeCommand::ChimeraCcodeCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["mapinfo"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "ChimeraCcodeCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraCcodeCommand::ChimeraCcodeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.ccode");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["mapinfo"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("reference");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       maskfile = validParameter.validFile(parameters, "mask", false);
-                       if (maskfile == "not found") { maskfile = "";  }        
-                       else if (maskfile != "default")  { 
-                               if (inputDir != "") {
-                                       string path = m->hasPath(maskfile);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       maskfile = inputDir + maskfile;         }
-                               }
-
-                               ifstream in;
-                               int     ableToOpen = m->openInputFile(maskfile, in);
-                               if (ableToOpen == 1) { abort = true; }
-                               in.close();
-                       }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "filter", false);                   if (temp == "not found") { temp = "F"; }
-                       filter = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "window", false);                   if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, window);
-                       
-                       temp = validParameter.validFile(parameters, "numwanted", false);                if (temp == "not found") { temp = "20"; }
-                       m->mothurConvert(temp, numwanted);
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       templatefile = validParameter.validFile(parameters, "reference", true);
-                       if (templatefile == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templatefile = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (templatefile == "not open") { abort = true; } 
-                       else {  if (save) {     rdb->setSavedReference(templatefile);   }       }
-                       
-
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "ChimeraCcodeCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int ChimeraCcodeCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                               
-                       m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-               
-                       int start = time(NULL); 
-                       
-                       //set user options
-                       if (maskfile == "default") { m->mothurOut("I am using the default 236627 EU009184.1 Shigella dysenteriae str. FBD013."); m->mothurOutEndLine();  }
-
-                       chimera = new Ccode(fastaFileNames[s], templatefile, filter, maskfile, window, numwanted, outputDir);   
-                       
-                       //is your template aligned?
-                       if (chimera->getUnaligned()) { m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); delete chimera; return 0; }
-                       templateSeqsLength = chimera->getLength();
-                       
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it
-                       string outputFileName, accnosFileName;
-                       if (maskfile != "") {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + ".ccode.accnos";
-                       }else {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "ccode.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "ccode.accnos";
-                       }
-
-                       string mapInfo = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "mapinfo";
-                       
-                       if (m->control_pressed) { delete chimera;  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } outputTypes.clear(); return 0;        }
-                       
-               #ifdef USE_MPI
-               
-                               int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                                                               
-                               MPI_Status status; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-
-                               MPI_File inMPI;
-                               MPI_File outMPI;
-                               MPI_File outMPIAccnos;
-                               
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                               
-                               char outFilename[1024];
-                               strcpy(outFilename, outputFileName.c_str());
-                               
-                               char outAccnosFilename[1024];
-                               strcpy(outAccnosFilename, accnosFileName.c_str());
-                               
-                               char inFileName[1024];
-                               strcpy(inFileName, fastaFileNames[s].c_str());
-
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-                               MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   m->mothurRemove(outputNames[j]);        } outputTypes.clear();  delete chimera; return 0;  }
-                       
-                               if (pid == 0) { //you are the root process 
-                                       string outTemp = "For full window mapping info refer to " + mapInfo + "\n";
-                                       
-                                       //print header
-                                       int length = outTemp.length();
-                                       char* buf2 = new char[length];
-                                       memcpy(buf2, outTemp.c_str(), length);
-
-                                       MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
-                                       delete buf2;
-
-                                       MPIPos = m->setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                       
-                               
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  m->mothurRemove(outputFileName);  m->mothurRemove(accnosFileName);  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } outputTypes.clear();  delete chimera; return 0;  }
-
-                               }else{ //you are a child process
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                       
-                                       
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {   m->mothurRemove(outputNames[j]);        }  outputTypes.clear(); delete chimera; return 0;  }
-                               }
-                               
-                               //close files 
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPI);
-                               MPI_File_close(&outMPIAccnos);
-                               
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                                       
-               #else
-                       ofstream outHeader;
-                       string tempHeader = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + maskfile + "ccode.chimeras.tempHeader";
-                       m->openOutputFile(tempHeader, outHeader);
-                       
-                       outHeader << "For full window mapping info refer to " << mapInfo << endl << endl;
-
-                       outHeader.close();
-                       
-                       
-                       
-                       //break up file
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               vector<unsigned long long> positions = m->divideFile(fastaFileNames[s], processors);
-                       
-                               for (int i = 0; i < (positions.size()-1); i++) {
-                                       lines.push_back(new linePair(positions[i], positions[(i+1)]));
-                               }       
-                       
-                               if(processors == 1){
-                                                                               
-                                       numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
-                                       
-                                       if (m->control_pressed) { m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
-                                       
-                               }else{
-                                       processIDS.resize(0);
-                                       
-                                       numSeqs = createProcesses(outputFileName, fastaFileNames[s], accnosFileName); 
-                               
-                                       rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
-                                       rename((accnosFileName + toString(processIDS[0]) + ".temp").c_str(), accnosFileName.c_str());
-                                               
-                                       //append output files
-                                       for(int i=1;i<processors;i++){
-                                               m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
-                                               m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
-                                       }
-                                       
-                                       //append output files
-                                       for(int i=1;i<processors;i++){
-                                               m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
-                                               m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp"));
-                                       }
-                                       
-                                       if (m->control_pressed) { 
-                                               m->mothurRemove(outputFileName); 
-                                               m->mothurRemove(accnosFileName);
-                                               for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        } outputTypes.clear();
-                                               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                                               delete chimera;
-                                               return 0;
-                                       }
-
-                               }
-
-                       #else
-                               lines.push_back(new linePair(0, 1000));
-                               numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
-                               
-                               if (m->control_pressed) { m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
-                               
-                       #endif
-       
-                       m->appendFiles(outputFileName, tempHeader);
-               
-                       m->mothurRemove(outputFileName);
-                       rename(tempHeader.c_str(), outputFileName.c_str());
-               #endif
-               
-                       delete chimera;
-                       
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(mapInfo); outputTypes["mapinfo"].push_back(mapInfo);
-                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
-                        
-                       for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
-               }
-               
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string filename, string accnos){
-       try {
-               ofstream out;
-               m->openOutputFile(outputFName, out);
-               
-               ofstream out2;
-               m->openOutputFile(accnos, out2);
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-               
-                       if (m->control_pressed) {       return 1;       }
-               
-                       Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               
-                               if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (m->control_pressed) {       delete candidateSeq; return 1;  }
-               
-                                       //print results
-                                       chimera->print(out, out2);
-                               }
-                               count++;
-                       }
-                       delete candidateSeq;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-               out.close();
-               out2.close();
-               inFASTA.close();
-                               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<unsigned long long>& MPIPos){
-       try {
-                               
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               for(int i=0;i<num;i++){
-               
-                       if (m->control_pressed) { return 0; }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-       
-                       char* buf4 = new char[length];
-                               
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence* candidateSeq = new Sequence(iss);  m->gobble(iss);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               
-                               if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (m->control_pressed) {       delete candidateSeq; return 1;  }
-               
-                                       //print results
-                                       chimera->print(outMPI, outAccMPI);
-                               }
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((i+1) % 100 == 0){  cout << "Processing sequence: " << (i+1) << endl;        m->mothurOutJustToLog("Processing sequence: " + toString(i+1) + "\n");          }
-               }
-               //report progress
-               if(num % 100 != 0){             cout << "Processing sequence: " << num << endl; m->mothurOutJustToLog("Processing sequence: " + toString(num) + "\n");  }
-               
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-
-/**************************************************************************************************/
-
-int ChimeraCcodeCommand::createProcesses(string outputFileName, string filename, string accnos) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 0;
-               int num = 0;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename, accnos + toString(getpid()) + ".temp");
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-               
-               return num;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCcodeCommand", "createProcesses");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/chimeraccodecommand.h b/chimeraccodecommand.h
deleted file mode 100644 (file)
index 5b8092b..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef CHIMERACCODECOMMAND_H
-#define CHIMERACCODECOMMAND_H
-
-/*
- *  chimeraccodecommand.h
- *  Mothur
- *
- *  Created by westcott on 3/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "chimera.h"
-
-
-/***********************************************************/
-
-class ChimeraCcodeCommand : public Command {
-public:
-       ChimeraCcodeCommand(string);
-       ChimeraCcodeCommand();
-       ~ChimeraCcodeCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.ccode";               }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Gonzalez JM, Zimmermann J, Saiz-Jimenez C (2005). Evaluating putative chimeric sequences from PCR-amplified products. Bioinformatics 21: 333-7. \nhttp://www.mothur.org/wiki/Chimera.ccode"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-               
-private:
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-       
-       int driver(linePair*, string, string, string);
-       int createProcesses(string, string, string);
-       
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&);
-       #endif
-
-       bool abort, filter, save;
-       string fastafile, templatefile, outputDir, maskfile;
-       int processors, window, numwanted, numSeqs, templateSeqsLength;
-       Chimera* chimera;
-       vector<string> fastaFileNames;
-       vector<string> outputNames;
-};
-
-/***********************************************************/
-
-#endif
-
diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp
deleted file mode 100644 (file)
index cc486d3..0000000
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- *  chimeracheckcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 3/31/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimeracheckcommand.h"
-#include "referencedb.h"
-
-//**********************************************************************************************************************
-vector<string> ChimeraCheckCommand::setParameters(){   
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter psvg("svg", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psvg);
-               CommandParameter pincrement("increment", "Number", "", "10", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pksize("ksize", "Number", "", "7", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraCheckCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The chimera.check command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
-               helpString += "This command was created using the algorythms described in CHIMERA_CHECK version 2.7 written by Niels Larsen. \n";
-               helpString += "The chimera.check command parameters are fasta, reference, processors, ksize, increment, svg and name.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required unless you have a valid current fasta file. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The reference parameter allows you to enter a reference file containing known non-chimeric sequences, and is required. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The increment parameter allows you to specify how far you move each window while finding chimeric sequences, default is 10.\n";
-               helpString += "The ksize parameter allows you to input kmersize, default is 7. \n";
-               helpString += "The svg parameter allows you to specify whether or not you would like a svg file outputted for each query sequence, default is False.\n";
-               helpString += "The name parameter allows you to enter a file containing names of sequences you would like .svg files for.\n";
-               helpString += "You may enter multiple name files by separating their names with dashes. ie. fasta=abrecovery.svg.names-amzon.svg.names \n";
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The chimera.check command should be in the following format: \n";
-               helpString += "chimera.check(fasta=yourFastaFile, reference=yourTemplateFile, processors=yourProcessors, ksize=yourKmerSize) \n";
-               helpString += "Example: chimera.check(fasta=AD.fasta, reference=core_set_aligned,imputed.fasta, processors=4, ksize=8) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraCheckCommand::ChimeraCheckCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "ChimeraCheckCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraCheckCommand::ChimeraCheckCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;  
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.check");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               it = parameters.find("reference");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       string path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] +". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       namefile = validParameter.validFile(parameters, "name", false);
-                       if (namefile == "not found") { namefile = ""; }
-                       else { 
-                               m->splitAtDash(namefile, nameFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < nameFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (nameFileNames[i] == "current") { 
-                                               nameFileNames[i] = m->getNameFile(); 
-                                               if (nameFileNames[i] != "") {  m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(nameFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       nameFileNames[i] = inputDir + nameFileNames[i];         }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setNameFile(nameFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (nameFileNames.size() != 0) {
-                                       if (nameFileNames.size() != fastaFileNames.size()) { 
-                                                m->mothurOut("Different number of valid name files and fasta files, aborting command."); m->mothurOutEndLine(); 
-                                                abort = true;
-                                       }
-                               }
-                       }
-
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       templatefile = validParameter.validFile(parameters, "reference", true);
-                       if (templatefile == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templatefile = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (templatefile == "not open") { abort = true; } 
-                       else {  if (save) {     rdb->setSavedReference(templatefile);   }       }
-                       
-                       
-                       temp = validParameter.validFile(parameters, "ksize", false);                    if (temp == "not found") { temp = "7"; }
-                       m->mothurConvert(temp, ksize);
-                       
-                       temp = validParameter.validFile(parameters, "svg", false);                              if (temp == "not found") { temp = "F"; }
-                       svg = m->isTrue(temp);
-                       if (nameFileNames.size() != 0) { svg = true; }
-                       
-                       temp = validParameter.validFile(parameters, "increment", false);                if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, increment);                      
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "ChimeraCheckCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ChimeraCheckCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int i = 0; i < fastaFileNames.size(); i++) {
-                               
-                       m->mothurOut("Checking sequences from " + fastaFileNames[i] + " ..." ); m->mothurOutEndLine();
-                       
-                       int start = time(NULL); 
-                       
-                       string thisNameFile = "";
-                       if (nameFileNames.size() != 0) { thisNameFile = nameFileNames[i]; }
-                       
-                       chimera = new ChimeraCheckRDP(fastaFileNames[i], templatefile, thisNameFile, svg, increment, ksize, outputDir);                 
-
-                       if (m->control_pressed) { delete chimera;       return 0;       }
-                       
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[i]);  }//if user entered a file with a path then preserve it
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[i]))  + "chimeracheck.chimeras";
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       
-               #ifdef USE_MPI
-               
-                               int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                               
-                               MPI_Status status; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-
-                               MPI_File inMPI;
-                               MPI_File outMPI;
-                                                       
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                                                       
-                               char outFilename[1024];
-                               strcpy(outFilename, outputFileName.c_str());
-                       
-                               char inFileName[1024];
-                               strcpy(inFileName, fastaFileNames[i].c_str());
-
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-                               
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    m->mothurRemove(outputNames[j]);        } outputTypes.clear(); delete chimera; return 0;  }
-                               
-                               if (pid == 0) { //you are the root process 
-                                       MPIPos = m->setFilePosFasta(fastaFileNames[i], numSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //send file positions to all processes
-                                       for(int j = 1; j < processors; j++) { 
-                                               MPI_Send(&numSeqs, 1, MPI_INT, j, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, j, tag, MPI_COMM_WORLD);
-                                       }       
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                       
-                               
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  for (int j = 0; j < outputNames.size(); j++) {    m->mothurRemove(outputNames[j]);        }   outputTypes.clear(); delete chimera; return 0;  }
-                                       
-                                       //wait on chidren
-                                       for(int j = 1; j < processors; j++) { 
-                                               char buf[5];
-                                               MPI_Recv(buf, 5, MPI_CHAR, j, tag, MPI_COMM_WORLD, &status); 
-                                       }
-                               }else{ //you are a child process
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                       
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   for (int j = 0; j < outputNames.size(); j++) {   m->mothurRemove(outputNames[j]);        }  outputTypes.clear(); delete chimera; return 0;  }
-                                       
-                                       //tell parent you are done.
-                                       char buf[5];
-                                       strcpy(buf, "done"); 
-                                       MPI_Send(buf, 5, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                               }
-                               
-                               //close files 
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPI);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               #else
-                       
-                       
-                       
-                       //break up file
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               vector<unsigned long long> positions = m->divideFile(fastaFileNames[i], processors);
-                       
-                               for (int s = 0; s < (positions.size()-1); s++) {
-                                       lines.push_back(new linePair(positions[s], positions[(s+1)]));
-                               }       
-                       
-                               if(processors == 1){
-                                       numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]);
-                                       
-                                       if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        } for (int j = 0; j < lines.size(); j++) {  delete lines[j];  } outputTypes.clear();  lines.clear(); delete chimera; return 0; }
-                                                                       
-                               }else{
-                                       processIDS.resize(0);
-                                       
-                                       numSeqs = createProcesses(outputFileName, fastaFileNames[i]); 
-                               
-                                       rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
-                                               
-                                       //append output files
-                                       for(int j=1;j<processors;j++){
-                                               m->appendFiles((outputFileName + toString(processIDS[j]) + ".temp"), outputFileName);
-                                               m->mothurRemove((outputFileName + toString(processIDS[j]) + ".temp"));
-                                       }
-                                       
-                                       if (m->control_pressed) { 
-                                               for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        } outputTypes.clear();
-                                               for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear();
-                                               delete chimera;
-                                               return 0;
-                                       }
-                               }
-
-                       #else
-                               lines.push_back(new linePair(0, 1000));
-                               numSeqs = driver(lines[0], outputFileName, fastaFileNames[i]);
-                               
-                               if (m->control_pressed) { for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear(); for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        } outputTypes.clear(); delete chimera; return 0; }
-                       #endif
-               #endif          
-                       delete chimera;
-                       for (int j = 0; j < lines.size(); j++) {  delete lines[j];  }  lines.clear();
-                       
-                       m->mothurOutEndLine(); m->mothurOut("This method does not determine if a sequence is chimeric, but allows you to make that determination based on the IS values."); m->mothurOutEndLine(); 
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-       
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChimeraCheckCommand::driver(linePair* filePos, string outputFName, string filename){
-       try {
-               ofstream out;
-               m->openOutputFile(outputFName, out);
-               
-               ofstream out2;
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-
-                       if (m->control_pressed) {       return 1;       }
-               
-                       Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               //find chimeras
-                               chimera->getChimeras(candidateSeq);
-                               
-                               if (m->control_pressed) {       delete candidateSeq; return 1;  }
-       
-                               //print results
-                               chimera->print(out, out2);
-                       }
-                       delete candidateSeq;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-               out.close();
-               inFASTA.close();
-                               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long long>& MPIPos){
-       try {
-               MPI_File outAccMPI;
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               for(int i=0;i<num;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-       
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence* candidateSeq = new Sequence(iss);  m->gobble(iss);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               //find chimeras
-                               chimera->getChimeras(candidateSeq);
-                                       
-                               //print results
-                               chimera->print(outMPI, outAccMPI);
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((i+1) % 100 == 0){  cout << "Processing sequence: " << (i+1) << endl;        m->mothurOutJustToLog("Processing sequence: " + toString(i+1) + "\n");          }
-               }
-               //report progress
-               if(num % 100 != 0){             cout << "Processing sequence: " << num << endl; m->mothurOutJustToLog("Processing sequence: " + toString(num) + "\n");  }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-
-/**************************************************************************************************/
-
-int ChimeraCheckCommand::createProcesses(string outputFileName, string filename) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 0;
-               int num = 0;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-               
-               return num;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
diff --git a/chimeracheckcommand.h b/chimeracheckcommand.h
deleted file mode 100644 (file)
index 918b4e5..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef CHIMERACHECKCOMMAND_H
-#define CHIMERACHECKCOMMAND_H
-
-/*
- *  chimeracheckcommand.h
- *  Mothur
- *
- *  Created by westcott on 3/31/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "chimera.h"
-#include "chimeracheckrdp.h"
-
-
-/***********************************************************/
-
-class ChimeraCheckCommand : public Command {
-public:
-       ChimeraCheckCommand(string);
-       ChimeraCheckCommand();
-       ~ChimeraCheckCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.check";               }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "CHIMERA_CHECK version 2.7 written by Niels Larsen (http://wdcm.nig.ac.jp/RDP/docs/chimera_doc.html) \nhttp://www.mothur.org/wiki/Chimera.check"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-       
-       int driver(linePair*, string, string);
-       int createProcesses(string, string);
-               
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, vector<unsigned long long>&);
-       #endif
-
-       bool abort, svg, save;
-       string fastafile, templatefile, namefile, outputDir;
-       int processors, increment, ksize, numSeqs, templateSeqsLength;
-       Chimera* chimera;
-       vector<string> fastaFileNames;
-       vector<string> nameFileNames;
-       vector<string> outputNames;
-};
-
-/***********************************************************/
-
-#endif
-
-
diff --git a/chimeracheckrdp.cpp b/chimeracheckrdp.cpp
deleted file mode 100644 (file)
index 42b5312..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- *  chimeracheckrdp.cpp
- *  Mothur
- *
- *  Created by westcott on 9/8/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimeracheckrdp.h"
-               
-//***************************************************************************************************************
-ChimeraCheckRDP::ChimeraCheckRDP(string filename, string temp, string n, bool s, int inc, int k, string o) : Chimera() { 
-       try {
-               fastafile = filename; 
-               templateFileName = temp;  
-               name = n;
-               svg = s;
-               increment = inc;
-               kmerSize = k;
-               outputDir = o; 
-               
-               templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, rand());
-               m->mothurOutEndLine();
-               
-               kmer = new Kmer(kmerSize);
-               
-               if (name != "") { 
-                       readName(name);  //fills name map with names of seqs the user wants to have .svg for.  
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "ChimeraCheckRDP");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-ChimeraCheckRDP::~ChimeraCheckRDP() {
-       try {
-               delete templateDB;
-               delete kmer;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "~ChimeraCheckRDP");
-               exit(1);
-       }
-}      
-//***************************************************************************************************************
-Sequence ChimeraCheckRDP::print(ostream& out, ostream& outAcc) {
-       try {
-               
-               m->mothurOut("Processing: " + querySeq->getName()); m->mothurOutEndLine();
-               
-               out << querySeq->getName() << endl;
-               out << "IS scores: " << '\t';
-                       
-               for (int k = 0; k < IS.size(); k++) {
-                       out << IS[k].score << '\t'; 
-               }
-               out << endl;
-               
-               if (svg) {
-                       if (name != "") { //if user has specific names
-                               map<string, string>::iterator it = names.find(querySeq->getName());
-                               
-                               if (it != names.end()) { //user wants pic of this
-                                       makeSVGpic(IS);  //zeros out negative results
-                               }
-                       }else{//output them all
-                               makeSVGpic(IS);  //zeros out negative results
-                       }
-               }
-               
-               return *querySeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "print");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-//***************************************************************************************************************
-Sequence ChimeraCheckRDP::print(MPI_File& out, MPI_File& outAcc) {
-       try {
-               
-               cout << "Processing: " << querySeq->getName() << endl; 
-               
-               string outString = "";
-               
-               outString += querySeq->getName() + "\nIS scores: \t";
-                       
-               for (int k = 0; k < IS.size(); k++) {
-                       outString += toString(IS[k].score)  + "\t"; 
-               }
-               outString += "\n";
-               
-               MPI_Status status;
-               int length = outString.length();
-               char* buf = new char[length];
-               memcpy(buf, outString.c_str(), length);
-                               
-               MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-               delete buf;
-
-               if (svg) {
-                       if (name != "") { //if user has specific names
-                               map<string, string>::iterator it = names.find(querySeq->getName());
-                               
-                               if (it != names.end()) { //user wants pic of this
-                                       makeSVGpic(IS);  //zeros out negative results
-                               }
-                       }else{//output them all
-                               makeSVGpic(IS);  //zeros out negative results
-                       }
-               }
-               
-               return *querySeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "print");
-               exit(1);
-       }
-}
-#endif
-//***************************************************************************************************************
-int ChimeraCheckRDP::getChimeras(Sequence* query) {
-       try {
-               
-               IS.clear();
-                               
-               querySeq = query;
-                       
-               closest = templateDB->findClosestSequence(query);  
-       
-               IS = findIS(); 
-                                       
-               //determine chimera report cutoff - window score above 95%
-               //getCutoff();  - not very acurate predictor
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "getChimeras");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<sim> ChimeraCheckRDP::findIS() {
-       try {
-               
-               
-               vector< map<int, int> > queryKmerInfo;  //vector of maps - each entry in the vector is a map of the kmers up to that spot in the unaligned seq
-                                                                                               //example:  seqKmerInfo[50] = map containing the kmers found in the first 50 + kmersize characters of ecoli.
-                                                                                               //i chose to store the kmers numbers in a map so you wouldn't have to check for dupilcate entries and could easily find the 
-                                                                                               //kmers 2 seqs had in common.  There may be a better way to do this thats why I am leaving so many comments...
-               vector< map<int, int> > subjectKmerInfo;
-               
-               vector<sim>  isValues;
-               string queryName = querySeq->getName();
-               string seq = querySeq->getUnaligned();
-               
-               queryKmerInfo = kmer->getKmerCounts(seq);
-               subjectKmerInfo = kmer->getKmerCounts(closest.getUnaligned());
-               
-               //find total kmers you have in common with closest[query] by looking at the last entry in the vector of maps for each
-               int nTotal = calcKmers(queryKmerInfo[(queryKmerInfo.size()-1)], subjectKmerInfo[(subjectKmerInfo.size()-1)]);
-
-               //you don't want the starting point to be virtually at hte end so move it in 10%
-               int start = seq.length() / 10;
-                       
-               //for each window
-               for (int f = start; f < (seq.length() - start); f+=increment) {
-               
-                       if (m->control_pressed) { return isValues; }
-                       
-                       if ((f - kmerSize) < 0)  { m->mothurOut("Your sequence is too short for your kmerSize."); m->mothurOutEndLine(); exit(1); }
-                       
-                       sim temp;
-                       
-                       string fragLeft = seq.substr(0, f);  //left side of breakpoint
-                       string fragRight = seq.substr(f);  //right side of breakpoint
-                       
-                       //make a sequence of the left side and right side
-                       Sequence* left = new Sequence(queryName, fragLeft);
-                       Sequence* right = new Sequence(queryName, fragRight);
-                       
-                       //find seqs closest to each fragment
-                       Sequence closestLeft = templateDB->findClosestSequence(left); 
-       
-                       Sequence closestRight = templateDB->findClosestSequence(right); 
-               
-                       //get kmerinfo for the closest left
-                       vector< map<int, int> > closeLeftKmerInfo = kmer->getKmerCounts(closestLeft.getUnaligned());
-                       
-                       //get kmerinfo for the closest right
-                       vector< map<int, int> > closeRightKmerInfo = kmer->getKmerCounts(closestRight.getUnaligned());
-                       
-                       //right side is tricky - since the counts grow on eachother to find the correct counts of only the right side you must subtract the counts of the left side
-                       //iterate through left sides map to subtract the number of times you saw things before you got the the right side
-                       map<int, int> rightside = queryKmerInfo[queryKmerInfo.size()-1];
-                       for (map<int, int>::iterator itleft = queryKmerInfo[f-kmerSize].begin(); itleft != queryKmerInfo[f-kmerSize].end(); itleft++) {
-                               int howManyTotal = queryKmerInfo[queryKmerInfo.size()-1][itleft->first];   //times that kmer was seen in total
-
-                               //itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
-                               int howmanyright = howManyTotal - itleft->second;
-                               
-                               //if any were seen just on the left erase
-                               if (howmanyright == 0) {
-                                       rightside.erase(itleft->first);
-                               }
-                       }
-                       
-                       map<int, int> closerightside = closeRightKmerInfo[closeRightKmerInfo.size()-1];
-                       for (map<int, int>::iterator itright = closeRightKmerInfo[f-kmerSize].begin(); itright != closeRightKmerInfo[f-kmerSize].end(); itright++) {
-                               int howManyTotal = closeRightKmerInfo[(closeRightKmerInfo.size()-1)][itright->first];   //times that kmer was seen in total
-
-                               //itleft->second is times it was seen in left side, so howmanytotal - leftside should give you right side
-                               int howmanyright = howManyTotal - itright->second;
-                               
-                               //if any were seen just on the left erase
-                               if (howmanyright == 0) {
-                                       closerightside.erase(itright->first);
-                               }
-                       }
-
-                       
-                       int nLeft = calcKmers(closeLeftKmerInfo[f-kmerSize], queryKmerInfo[f-kmerSize]);
-
-                       int nRight = calcKmers(closerightside, rightside);
-
-                       int is = nLeft + nRight - nTotal;
-
-                       //save IS, leftparent, rightparent, breakpoint
-                       temp.leftParent = closestLeft.getName();
-                       temp.rightParent = closestRight.getName();
-                       temp.score = is;
-                       temp.midpoint = f;
-                       
-                       isValues.push_back(temp);
-                       
-                       delete left;
-                       delete right;
-               }
-               
-               return isValues;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "findIS");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-void ChimeraCheckRDP::readName(string namefile) {
-       try{
-       
-               string name;
-
-       #ifdef USE_MPI
-               
-               MPI_File inMPI;
-               MPI_Offset size;
-               MPI_Status status;
-
-               //char* inFileName = new char[namefile.length()];
-               //memcpy(inFileName, namefile.c_str(), namefile.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, namefile.c_str());
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
-               MPI_File_get_size(inMPI, &size);
-
-               //delete inFileName;
-
-               char* buffer = new char[size];
-               MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-
-               string tempBuf = buffer;
-               if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-               istringstream iss (tempBuf,istringstream::in);
-               delete buffer;
-               
-               while(!iss.eof()) {
-                       iss >> name; m->gobble(iss);
-                       names[name] = name;
-               }
-       
-               MPI_File_close(&inMPI);
-               
-       #else   
-       
-               ifstream in;
-               m->openInputFile(namefile, in);
-                               
-               while (!in.eof()) {
-                       in >> name; m->gobble(in);
-                       names[name] = name;
-               }
-               in.close();
-       
-       #endif
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "readName");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-//find the smaller map and iterate through it and count kmers in common
-int ChimeraCheckRDP::calcKmers(map<int, int> query, map<int, int> subject) {
-       try{
-               
-               int common = 0;
-               
-               map<int, int>::iterator smallone;
-               map<int, int>::iterator largeone;
-
-               if (query.size() < subject.size()) {
-               
-                       for (smallone = query.begin(); smallone != query.end(); smallone++) {
-                               largeone = subject.find(smallone->first);
-                               
-                               //if you found it they have that kmer in common
-                               if (largeone != subject.end()) {        common++;       }
-                       }
-                       
-               }else { 
-                
-                       for (smallone = subject.begin(); smallone != subject.end(); smallone++) {
-                               largeone = query.find(smallone->first);
-                               
-                               //if you found it they have that kmer in common
-                               if (largeone != query.end()) {          common++;        }
-                       }
-               }
-               
-               return common;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "calcKmers");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-//***************************************************************************************************************
-void ChimeraCheckRDP::makeSVGpic(vector<sim> info) {
-       try{
-               
-               string file = outputDir + querySeq->getName() + ".chimeracheck.svg";
-               
-               MPI_File outSVG;
-               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
-
-               //char* FileName = new char[file.length()];
-               //memcpy(FileName, file.c_str(), file.length());
-               
-               char FileName[1024];
-               strcpy(FileName, file.c_str());
-
-               MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outSVG);  //comm, filename, mode, info, filepointer
-               
-               //delete FileName;
-
-               int width = (info.size()*5) + 150;
-               
-               string outString = "";
-               
-               outString += "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 " + toString(width) + "\">\n";
-               outString += "<g>\n";
-               outString += "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"25\">Plotted IS values for " + querySeq->getName() + "</text>\n";
-               
-               outString +=  "<line x1=\"75\" y1=\"600\" x2=\"" + toString((info.size()*5) + 75) + "\" y2=\"600\" stroke=\"black\" stroke-width=\"2\"/>\n";  
-               outString +=  "<line x1=\"75\" y1=\"600\" x2=\"75\" y2=\"125\" stroke=\"black\" stroke-width=\"2\"/>\n";
-               
-               outString += "<text fill=\"black\" class=\"seri\" x=\"80\" y=\"620\">" + toString(info[0].midpoint) + "</text>\n";
-               outString += "<text fill=\"black\" class=\"seri\" x=\"" + toString((info.size()*5) + 75) + "\" y=\"620\">" + toString(info[info.size()-1].midpoint) + "</text>\n";
-               outString += "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"650\">Base Positions</text>\n";
-               
-               outString += "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"580\">0</text>\n";
-               
-               outString += "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"350\">IS</text>\n";
-               
-               
-               //find max is score
-               float biggest = 0.0;
-               for (int i = 0; i < info.size(); i++) {
-                       if (info[i].score > biggest)  {
-                               biggest = info[i].score;
-                       }
-               }
-               
-               outString += "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"135\">" + toString(biggest) + "</text>\n";
-               
-               int scaler2 = 500 / biggest;
-               
-               
-               outString += "<polyline fill=\"none\" stroke=\"red\" stroke-width=\"2\" points=\"";
-               //160,200 180,230 200,210 234,220\"/> "; 
-               for (int i = 0; i < info.size(); i++) {
-                       if(info[i].score < 0) { info[i].score = 0; }
-                       outString += toString(((i*5) + 75)) + "," + toString((600 - (info[i].score * scaler2))) + " ";
-               }
-               
-               outString += "\"/> ";
-               outString += "</g>\n</svg>\n";
-               
-               MPI_Status status;
-               int length = outString.length();
-               char* buf2 = new char[length];
-               memcpy(buf2, outString.c_str(), length);
-                               
-               MPI_File_write(outSVG, buf2, length, MPI_CHAR, &status);
-               delete buf2;
-               
-               MPI_File_close(&outSVG);
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
-               exit(1);
-       }
-}
-#else
-//***************************************************************************************************************
-void ChimeraCheckRDP::makeSVGpic(vector<sim> info) {
-       try{
-               
-               string file = outputDir + querySeq->getName() + ".chimeracheck.svg";
-               ofstream outsvg;
-               m->openOutputFile(file, outsvg);
-               
-               int width = (info.size()*5) + 150;
-               
-               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 700 " + toString(width) + "\">\n";
-               outsvg << "<g>\n";
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"25\">Plotted IS values for " + querySeq->getName() + "</text>\n";
-               
-               outsvg <<  "<line x1=\"75\" y1=\"600\" x2=\"" + toString((info.size()*5) + 75) + "\" y2=\"600\" stroke=\"black\" stroke-width=\"2\"/>\n";  
-               outsvg <<  "<line x1=\"75\" y1=\"600\" x2=\"75\" y2=\"125\" stroke=\"black\" stroke-width=\"2\"/>\n";
-               
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"80\" y=\"620\">" + toString(info[0].midpoint) + "</text>\n";
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((info.size()*5) + 75) + "\" y=\"620\">" + toString(info[info.size()-1].midpoint) + "</text>\n";
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString((width / 2) - 150) + "\" y=\"650\">Base Positions</text>\n";
-               
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"580\">0</text>\n";
-               
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"350\">IS</text>\n";
-               
-               
-               //find max is score
-               float biggest = 0.0;
-               for (int i = 0; i < info.size(); i++) {
-                       if (info[i].score > biggest)  {
-                               biggest = info[i].score;
-                       }
-               }
-               
-               outsvg << "<text fill=\"black\" class=\"seri\" x=\"50\" y=\"135\">" + toString(biggest) + "</text>\n";
-               
-               int scaler2 = 500 / biggest;
-               
-               
-               outsvg << "<polyline fill=\"none\" stroke=\"red\" stroke-width=\"2\" points=\"";
-               //160,200 180,230 200,210 234,220\"/> "; 
-               for (int i = 0; i < info.size(); i++) {
-                       if(info[i].score < 0) { info[i].score = 0; }
-                       outsvg << ((i*5) + 75) << "," << (600 - (info[i].score * scaler2)) << " ";
-               }
-               
-               outsvg << "\"/> ";
-               outsvg << "</g>\n</svg>\n";
-               
-               outsvg.close();
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraCheckRDP", "makeSVGpic");
-               exit(1);
-       }
-}
-#endif
-//***************************************************************************************************************/
-
-
diff --git a/chimeracheckrdp.h b/chimeracheckrdp.h
deleted file mode 100644 (file)
index cc23c2e..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef CHIMERACHECK_H
-#define CHIMERACHECK_H
-
-/*
- *  chimeracheckrdp.h
- *  Mothur
- *
- *  Created by westcott on 9/8/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "chimera.h"
-#include "kmer.hpp"
-#include "kmerdb.hpp"
-#include "alignmentdb.h"
-
-/***********************************************************/
-//This class was created using the algorythms described in 
-//CHIMERA_CHECK version 2.7 written by Niels Larsen. 
-
-/***********************************************************/
-
-class ChimeraCheckRDP : public Chimera {
-       
-       public:
-               ChimeraCheckRDP(string, string, string, bool, int, int, string); //fasta, template, name, svg, increment, ksize, outputDir      
-               ~ChimeraCheckRDP();
-               
-               int getChimeras(Sequence*);
-               Sequence print(ostream&, ostream&);
-               
-               #ifdef USE_MPI
-               Sequence print(MPI_File&, MPI_File&);
-               #endif
-               
-       private:
-               
-               Sequence* querySeq;
-               AlignmentDB* templateDB;
-               Kmer* kmer;
-               Sequence closest;               //closest is the closest overall seq to query
-
-               vector<sim>  IS;  //IS is the vector of IS values for each window for query
-               string fastafile;
-               map<string, string> names;
-               string name;
-               bool svg;
-               int kmerSize, increment;
-               
-               vector<sim> findIS();
-               int calcKmers(map<int, int>, map<int, int>);
-               void makeSVGpic(vector<sim>);
-               void readName(string);
-};
-/***********************************************************/
-
-#endif
-
diff --git a/chimeraperseuscommand.cpp b/chimeraperseuscommand.cpp
deleted file mode 100644 (file)
index e7294a8..0000000
+++ /dev/null
@@ -1,1027 +0,0 @@
-/*
- *  chimeraperseuscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/26/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimeraperseuscommand.h"
-#include "deconvolutecommand.h"
-#include "sequence.hpp"
-//**********************************************************************************************************************
-vector<string> ChimeraPerseusCommand::setParameters(){ 
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter palpha("alpha", "Number", "", "-5.54", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pbeta("beta", "Number", "", "0.33", "", "", "",false,false); parameters.push_back(pbeta);
-                       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraPerseusCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The chimera.perseus command reads a fastafile and namefile and outputs potentially chimeric sequences.\n";
-               helpString += "The chimera.perseus command parameters are fasta, name, group, cutoff, processors, alpha and beta.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required, unless you have a valid current fasta file. \n";
-               helpString += "The name parameter allows you to provide a name file associated with your fasta file. It is required. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amazon.fasta \n";
-               helpString += "The group parameter allows you to provide a group file.  When checking sequences, only sequences from the same group as the query sequence will be used as the reference. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-               helpString += "The alpha parameter ....  The default is -5.54. \n";
-               helpString += "The beta parameter ....  The default is 0.33. \n";
-               helpString += "The cutoff parameter ....  The default is 0.50. \n";
-               helpString += "The chimera.perseus command should be in the following format: \n";
-               helpString += "chimera.perseus(fasta=yourFastaFile, name=yourNameFile) \n";
-               helpString += "Example: chimera.perseus(fasta=AD.align, name=AD.names) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraPerseusCommand::ChimeraPerseusCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "ChimeraPerseusCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraPerseusCommand::ChimeraPerseusCommand(string option)  {
-       try {
-               abort = false; calledHelp = false; 
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.uchime");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       
-                       //check for required parameters
-                       bool hasName = true;
-                       namefile = validParameter.validFile(parameters, "name", false);
-                       if (namefile == "not found") { 
-                               //if there is a current fasta file, use it
-                               string filename = m->getNameFile(); 
-                               if (filename != "") { nameFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current namefile and the name parameter is required."); m->mothurOutEndLine(); abort = true; }                                
-                               hasName = false;
-                       }else { 
-                               m->splitAtDash(namefile, nameFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < nameFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (nameFileNames[i] == "current") { 
-                                               nameFileNames[i] = m->getNameFile(); 
-                                               if (nameFileNames[i] != "") {  m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(nameFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       nameFileNames[i] = inputDir + nameFileNames[i];         }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setNameFile(nameFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (nameFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid name files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasName && (nameFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of namefiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       bool hasGroup = true;
-                       groupfile = validParameter.validFile(parameters, "group", false);
-                       if (groupfile == "not found") { groupfile = "";  hasGroup = false; }
-                       else { 
-                               m->splitAtDash(groupfile, groupFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < groupFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (groupFileNames[i] == "current") { 
-                                               groupFileNames[i] = m->getGroupFile(); 
-                                               if (groupFileNames[i] != "") {  m->mothurOut("Using " + groupFileNames[i] + " as input file for the group parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(groupFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       groupFileNames[i] = inputDir + groupFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(groupFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + groupFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setGroupFile(groupFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (groupFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid group files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasGroup && (groupFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of groupfiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);   if (temp == "not found"){       temp = "0.50";  }
-                       m->mothurConvert(temp, cutoff);
-                       
-                       temp = validParameter.validFile(parameters, "alpha", false);    if (temp == "not found"){       temp = "-5.54"; }
-                       m->mothurConvert(temp, alpha);
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);   if (temp == "not found"){       temp = "0.33";  }
-                       m->mothurConvert(temp, beta);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "ChimeraPerseusCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ChimeraPerseusCommand::execute(){
-       try{
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-                               
-               //process each file
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                       
-                       m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       int start = time(NULL); 
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "perseus.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "perseus.accnos";
-                       //string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
-                       
-                       //you provided a groupfile
-                       string groupFile = "";
-                       if (groupFileNames.size() != 0) { groupFile = groupFileNames[s]; }
-                       
-                       string nameFile = "";
-                       if (nameFileNames.size() != 0) { //you provided a namefile and we don't need to create one
-                               nameFile = nameFileNames[s];
-                       }else { nameFile = getNamesFile(fastaFileNames[s]); }
-                       
-                       if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } return 0;     }                               
-                       
-                       int numSeqs = 0;
-                       int numChimeras = 0;
-                       
-                       if (groupFile != "") {
-                               //Parse sequences by group
-                               SequenceParser parser(groupFile, fastaFileNames[s], nameFile);
-                               vector<string> groups = parser.getNamesOfGroups();
-                               
-                               if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0; }
-                               
-                               //clears files
-                               ofstream out, out1, out2;
-                               m->openOutputFile(outputFileName, out); out.close(); 
-                               m->openOutputFile(accnosFileName, out1); out1.close();
-                               
-                               if(processors == 1)     {       numSeqs = driverGroups(parser, outputFileName, accnosFileName, 0, groups.size(), groups);       }
-                               else                            {       numSeqs = createProcessesGroups(parser, outputFileName, accnosFileName, groups, groupFile, fastaFileNames[s], nameFile);                        }
-                               
-                               if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }                               
-                               
-                               numChimeras = deconvoluteResults(parser, outputFileName, accnosFileName);
-                               
-                               m->mothurOut("The number of sequences checked may be larger than the number of unique sequences because some sequences are found in several samples."); m->mothurOutEndLine(); 
-                               
-                               if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }                               
-                               
-                       }else{
-                               if (processors != 1) { m->mothurOut("Without a groupfile, mothur can only use 1 processor, continuing."); m->mothurOutEndLine(); processors = 1; }
-                               
-                               //read sequences and store sorted by frequency
-                               vector<seqData> sequences = readFiles(fastaFileNames[s], nameFile);
-                               
-                               if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        } return 0; }
-                               
-                               numSeqs = driver(outputFileName, sequences, accnosFileName, numChimeras); 
-                       }
-                       
-                       if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        } return 0; }
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences. " + toString(numChimeras) + " chimeras were found.");      m->mothurOutEndLine();
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
-               }
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraPerseusCommand::getNamesFile(string& inputFile){
-       try {
-               string nameFile = "";
-               
-               m->mothurOutEndLine(); m->mothurOut("No namesfile given, running unique.seqs command to generate one."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               //use unique.seqs to create new name and fastafile
-               string inputString = "fasta=" + inputFile;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-               m->mothurCalling = true;
-        
-               Command* uniqueCommand = new DeconvoluteCommand(inputString);
-               uniqueCommand->execute();
-               
-               map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-               
-               delete uniqueCommand;
-               m->mothurCalling = false;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               
-               nameFile = filenames["name"][0];
-               inputFile = filenames["fasta"][0];
-               
-               return nameFile;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "getNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraPerseusCommand::driverGroups(SequenceParser& parser, string outputFName, string accnos, int start, int end, vector<string> groups){
-       try {
-               
-               int totalSeqs = 0;
-               int numChimeras = 0;
-               
-               for (int i = start; i < end; i++) {
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Checking sequences from group " + groups[i] + "...");      m->mothurOutEndLine();                                  
-                       
-                       int start = time(NULL);  if (m->control_pressed) {  return 0; }
-                       
-                       vector<seqData> sequences = loadSequences(parser, groups[i]);
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       int numSeqs = driver((outputFName + groups[i]), sequences, (accnos+groups[i]), numChimeras);
-                       totalSeqs += numSeqs;
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //append files
-                       m->appendFiles((outputFName+groups[i]), outputFName); m->mothurRemove((outputFName+groups[i]));
-                       m->appendFiles((accnos+groups[i]), accnos); m->mothurRemove((accnos+groups[i]));
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + groups[i] + ".");    m->mothurOutEndLine();                                  
-               }       
-               
-               return totalSeqs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "driverGroups");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-vector<seqData> ChimeraPerseusCommand::loadSequences(SequenceParser& parser, string group){
-       try {
-               
-               vector<Sequence> thisGroupsSeqs = parser.getSeqs(group);
-               map<string, string> nameMap = parser.getNameMap(group);
-               map<string, string>::iterator it;
-               
-               vector<seqData> sequences;
-               bool error = false;
-        alignLength = 0;
-               
-               for (int i = 0; i < thisGroupsSeqs.size(); i++) {
-               
-                       if (m->control_pressed) {  return sequences; }
-                       
-                       it = nameMap.find(thisGroupsSeqs[i].getName());
-                       if (it == nameMap.end()) { error = true; m->mothurOut("[ERROR]: " + thisGroupsSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct."); m->mothurOutEndLine(); }
-                       else {
-                               int num = m->getNumNames(it->second);
-                               sequences.push_back(seqData(thisGroupsSeqs[i].getName(), thisGroupsSeqs[i].getUnaligned(), num));
-                if (thisGroupsSeqs[i].getUnaligned().length() > alignLength) { alignLength = thisGroupsSeqs[i].getUnaligned().length(); }
-                       }
-               }
-               
-               if (error) { m->control_pressed = true; }
-               
-               //sort by frequency
-               sort(sequences.rbegin(), sequences.rend());
-               
-               return sequences;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "loadSequences");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-vector<seqData> ChimeraPerseusCommand::readFiles(string inputFile, string name){
-       try {
-               map<string, int>::iterator it;
-               map<string, int> nameMap = m->readNames(name);
-               
-               //read fasta file and create sequenceData structure - checking for file mismatches
-               vector<seqData> sequences;
-               bool error = false;
-               ifstream in;
-               m->openInputFile(inputFile, in);
-               alignLength = 0;
-        
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return sequences; }
-                       
-                       Sequence temp(in); m->gobble(in);
-                       
-                       it = nameMap.find(temp.getName());
-                       if (it == nameMap.end()) { error = true; m->mothurOut("[ERROR]: " + temp.getName() + " is in your fasta file and not in your namefile, please correct."); m->mothurOutEndLine(); }
-                       else {
-                               sequences.push_back(seqData(temp.getName(), temp.getUnaligned(), it->second));
-                if (temp.getUnaligned().length() > alignLength) { alignLength = temp.getUnaligned().length(); }
-                       }
-               }
-               in.close();
-               
-               if (error) { m->control_pressed = true; }
-               
-               //sort by frequency
-               sort(sequences.rbegin(), sequences.rend());
-               
-               return sequences;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "getNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraPerseusCommand::driver(string chimeraFileName, vector<seqData>& sequences, string accnosFileName, int& numChimeras){
-       try {
-               
-               vector<vector<double> > correctModel(4);        //could be an option in the future to input own model matrix
-               for(int i=0;i<4;i++){   correctModel[i].resize(4);      }
-               
-               correctModel[0][0] = 0.000000;  //AA
-               correctModel[1][0] = 11.619259; //CA
-               correctModel[2][0] = 11.694004; //TA
-               correctModel[3][0] = 7.748623;  //GA
-               
-               correctModel[1][1] = 0.000000;  //CC
-               correctModel[2][1] = 7.619657;  //TC
-               correctModel[3][1] = 12.852562; //GC
-               
-               correctModel[2][2] = 0.000000;  //TT
-               correctModel[3][2] = 10.964048; //TG
-               
-               correctModel[3][3] = 0.000000;  //GG
-               
-               for(int i=0;i<4;i++){
-                       for(int j=0;j<i;j++){
-                               correctModel[j][i] = correctModel[i][j];
-                       }
-               }
-               
-               int numSeqs = sequences.size();
-               //int alignLength = sequences[0].sequence.size();
-               
-               ofstream chimeraFile;
-               ofstream accnosFile;
-               m->openOutputFile(chimeraFileName, chimeraFile); 
-               m->openOutputFile(accnosFileName, accnosFile); 
-               
-               Perseus myPerseus;
-               vector<vector<double> > binMatrix = myPerseus.binomial(alignLength);
-               
-               chimeraFile << "SequenceIndex\tName\tDiffsToBestMatch\tBestMatchIndex\tBestMatchName\tDiffstToChimera\tIndexofLeftParent\tIndexOfRightParent\tNameOfLeftParent\tNameOfRightParent\tDistanceToBestMatch\tcIndex\t(cIndex - singleDist)\tloonIndex\tMismatchesToChimera\tMismatchToTrimera\tChimeraBreakPoint\tLogisticProbability\tTypeOfSequence\n";
-               
-               vector<bool> chimeras(numSeqs, 0);
-               
-               for(int i=0;i<numSeqs;i++){     
-                       if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-    
-                       vector<bool> restricted = chimeras;
-                       
-                       vector<vector<int> > leftDiffs(numSeqs);
-                       vector<vector<int> > leftMaps(numSeqs);
-                       vector<vector<int> > rightDiffs(numSeqs);
-                       vector<vector<int> > rightMaps(numSeqs);
-                       
-                       vector<int> singleLeft, bestLeft;
-                       vector<int> singleRight, bestRight;
-                       
-                       int bestSingleIndex, bestSingleDiff;
-                       vector<pwAlign> alignments(numSeqs);
-                       
-                       int comparisons = myPerseus.getAlignments(i, sequences, alignments, leftDiffs, leftMaps, rightDiffs, rightMaps, bestSingleIndex, bestSingleDiff, restricted);
-                       if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-
-                       int minMismatchToChimera, leftParentBi, rightParentBi, breakPointBi;
-                       
-                       string dummyA, dummyB;
-                       
-            if (sequences[i].sequence.size() < 3) { 
-                chimeraFile << i << '\t' << sequences[i].seqName << "\t0\t0\tNull\t0\t0\t0\tNull\tNull\t0.0\t0.0\t0.0\t0\t0\t0\t0.0\t0.0\tgood" << endl;
-            }else if(comparisons >= 2){        
-                               minMismatchToChimera = myPerseus.getChimera(sequences, leftDiffs, rightDiffs, leftParentBi, rightParentBi, breakPointBi, singleLeft, bestLeft, singleRight, bestRight, restricted);
-                               if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-
-                               int minMismatchToTrimera = numeric_limits<int>::max();
-                               int leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB;
-                               
-                               if(minMismatchToChimera >= 3 && comparisons >= 3){
-                                       minMismatchToTrimera = myPerseus.getTrimera(sequences, leftDiffs, leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB, singleLeft, bestLeft, singleRight, bestRight, restricted);
-                                       if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-                               }
-                               
-                               double singleDist = myPerseus.modeledPairwiseAlignSeqs(sequences[i].sequence, sequences[bestSingleIndex].sequence, dummyA, dummyB, correctModel);
-                               
-                               if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-
-                               string type;
-                               string chimeraRefSeq;
-                               
-                               if(minMismatchToChimera - minMismatchToTrimera >= 3){
-                                       type = "trimera";
-                                       chimeraRefSeq = myPerseus.stitchTrimera(alignments, leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB, leftMaps, rightMaps);
-                               }
-                               else{
-                                       type = "chimera";
-                                       chimeraRefSeq = myPerseus.stitchBimera(alignments, leftParentBi, rightParentBi, breakPointBi, leftMaps, rightMaps);
-                               }
-                               ;
-                               if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-                               
-                               double chimeraDist = myPerseus.modeledPairwiseAlignSeqs(sequences[i].sequence, chimeraRefSeq, dummyA, dummyB, correctModel);
-                               
-                               if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-
-                               double cIndex = chimeraDist;//modeledPairwiseAlignSeqs(sequences[i].sequence, chimeraRefSeq);
-                               double loonIndex = myPerseus.calcLoonIndex(sequences[i].sequence, sequences[leftParentBi].sequence, sequences[rightParentBi].sequence, breakPointBi, binMatrix);                
-                               
-                               if (m->control_pressed) { chimeraFile.close(); m->mothurRemove(chimeraFileName); accnosFile.close(); m->mothurRemove(accnosFileName); return 0; }
-
-                               chimeraFile << i << '\t' << sequences[i].seqName << '\t' << bestSingleDiff << '\t' << bestSingleIndex << '\t' << sequences[bestSingleIndex].seqName << '\t';
-                               chimeraFile << minMismatchToChimera << '\t' << leftParentBi << '\t' << rightParentBi << '\t' << sequences[leftParentBi].seqName << '\t' << sequences[rightParentBi].seqName << '\t';
-                               chimeraFile << singleDist << '\t' << cIndex << '\t' << (cIndex - singleDist) << '\t' << loonIndex << '\t';
-                               chimeraFile << minMismatchToChimera << '\t' << minMismatchToTrimera << '\t' << breakPointBi << '\t';
-                               
-                               double probability = myPerseus.classifyChimera(singleDist, cIndex, loonIndex, alpha, beta);
-                               
-                               chimeraFile << probability << '\t';
-                               
-                               if(probability > cutoff){ 
-                                       chimeraFile << type << endl;
-                                       accnosFile << sequences[i].seqName << endl;
-                                       chimeras[i] = 1;
-                                       numChimeras++;
-                               }
-                               else{
-                                       chimeraFile << "good" << endl;
-                               }
-                               
-                       }
-                       else{
-                               chimeraFile << i << '\t' << sequences[i].seqName << "\t0\t0\tNull\t0\t0\t0\tNull\tNull\t0.0\t0.0\t0.0\t0\t0\t0\t0.0\t0.0\tgood" << endl;
-                       }
-       
-                       //report progress
-                       if((i+1) % 100 == 0){   m->mothurOut("Processing sequence: " + toString(i+1) + "\n");           }
-               }
-               
-               if((numSeqs) % 100 != 0){       m->mothurOut("Processing sequence: " + toString(numSeqs) + "\n");               }
-               
-               chimeraFile.close();
-               accnosFile.close();
-               
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int ChimeraPerseusCommand::createProcessesGroups(SequenceParser& parser, string outputFName, string accnos, vector<string> groups, string group, string fasta, string name) {
-       try {
-               
-               vector<int> processIDS;
-               int process = 1;
-               int num = 0;
-               
-               //sanity check
-               if (groups.size() < processors) { processors = groups.size(); }
-               
-               //divide the groups between the processors
-               vector<linePair> lines;
-               int numGroupsPerProcessor = groups.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numGroupsPerProcessor;
-                       int endIndex = (i+1) * numGroupsPerProcessor;
-                       if(i == (processors - 1)){      endIndex = groups.size();       }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverGroups(parser, outputFName + toString(getpid()) + ".temp", accnos + toString(getpid()) + ".temp", lines[process].start, lines[process].end, groups);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driverGroups(parser, outputFName, accnos, lines[0].start, lines[0].end, groups);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-               
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the preClusterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<perseusData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = toString(i) + ".temp";
-                       
-                       perseusData* tempPerseus = new perseusData(alpha, beta, cutoff, outputFName+extension, fasta, name, group, accnos+extension, groups, m, lines[i].start, lines[i].end, i);
-                       
-                       pDataArray.push_back(tempPerseus);
-                       processIDS.push_back(i);
-                       
-                       //MyPerseusThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyPerseusThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-               
-               //using the main process as a worker saves time and memory
-               num = driverGroups(parser, outputFName, accnos, lines[0].start, lines[0].end, groups);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-                       
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif         
-               
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((outputFName + toString(processIDS[i]) + ".temp"), outputFName);
-                       m->mothurRemove((outputFName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
-                       m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));
-               }
-               
-               return num;     
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "createProcessesGroups");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraPerseusCommand::deconvoluteResults(SequenceParser& parser, string outputFileName, string accnosFileName){
-       try {
-               map<string, string> uniqueNames = parser.getAllSeqsMap();
-               map<string, string>::iterator itUnique;
-               int total = 0;
-               
-               //edit accnos file
-               ifstream in2; 
-               m->openInputFile(accnosFileName, in2);
-               
-               ofstream out2;
-               m->openOutputFile(accnosFileName+".temp", out2);
-               
-               string name;
-               set<string> namesInFile; //this is so if a sequence is found to be chimera in several samples we dont write it to the results file more than once
-               set<string>::iterator itNames;
-               set<string> chimerasInFile;
-               set<string>::iterator itChimeras;
-               
-               
-               while (!in2.eof()) {
-                       if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName+".temp")); return 0; }
-                       
-                       in2 >> name; m->gobble(in2);
-                       
-                       //find unique name
-                       itUnique = uniqueNames.find(name);
-                       
-                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       else {
-                               itChimeras = chimerasInFile.find((itUnique->second));
-                               
-                               if (itChimeras == chimerasInFile.end()) {
-                                       out2 << itUnique->second << endl;
-                                       chimerasInFile.insert((itUnique->second));
-                                       total++;
-                               }
-                       }
-               }
-               in2.close();
-               out2.close();
-               
-               m->mothurRemove(accnosFileName);
-               rename((accnosFileName+".temp").c_str(), accnosFileName.c_str());
-               
-               //edit chimera file
-               ifstream in; 
-               m->openInputFile(outputFileName, in);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName+".temp", out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               int DiffsToBestMatch, BestMatchIndex, DiffstToChimera, IndexofLeftParent, IndexOfRightParent;
-               float temp1,temp2, temp3, temp4, temp5, temp6, temp7, temp8;
-               string index, BestMatchName, parent1, parent2, flag;
-               name = "";
-               namesInFile.clear();    
-               //assumptions - in file each read will always look like 
-               /*                                                                              
-                SequenceIndex  Name    DiffsToBestMatch        BestMatchIndex  BestMatchName   DiffstToChimera IndexofLeftParent       IndexOfRightParent      NameOfLeftParent        NameOfRightParent       DistanceToBestMatch     cIndex  (cIndex - singleDist)   loonIndex       MismatchesToChimera     MismatchToTrimera       ChimeraBreakPoint       LogisticProbability     TypeOfSequence
-                0      F01QG4L02JVBQY  0       0       Null    0       0       0       Null    Null    0.0     0.0     0.0     0.0     0       0       0       0.0     0.0     good
-                1      F01QG4L02ICTC6  0       0       Null    0       0       0       Null    Null    0.0     0.0     0.0     0.0     0       0       0       0.0     0.0     good
-                2      F01QG4L02JZOEC  48      0       F01QG4L02JVBQY  47      0       0       F01QG4L02JVBQY  F01QG4L02JVBQY  2.0449  2.03545 -0.00944493     0       47      2147483647      138     0       good
-                3      F01QG4L02G7JEC  42      0       F01QG4L02JVBQY  40      1       0       F01QG4L02ICTC6  F01QG4L02JVBQY  1.87477 1.81113 -0.0636404      5.80145 40      2147483647      25      0       good
-                */
-               
-               //get and print headers
-               BestMatchName = m->getline(in); m->gobble(in);
-               out << BestMatchName << endl;
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove((outputFileName+".temp")); return 0; }
-                       
-                       bool print = false;
-                       in >> index;    m->gobble(in);
-                       
-                       if (index != "SequenceIndex") { //if you are not a header line, there will be a header line for each group if group file is given
-                               in >> name;             m->gobble(in);
-                               in >> DiffsToBestMatch; m->gobble(in);
-                               in >> BestMatchIndex; m->gobble(in);
-                               in >> BestMatchName; m->gobble(in);
-                               in >> DiffstToChimera; m->gobble(in);
-                               in >> IndexofLeftParent; m->gobble(in);
-                               in >> IndexOfRightParent; m->gobble(in);
-                               in >> parent1;  m->gobble(in);
-                               in >> parent2;  m->gobble(in);
-                               in >> temp1 >> temp2 >> temp3 >> temp4 >> temp5 >> temp6 >> temp7 >> temp8 >> flag; m->gobble(in);
-                               
-                               //find unique name
-                               itUnique = uniqueNames.find(name);
-                               
-                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                               else {
-                                       name = itUnique->second;
-                                       //is this name already in the file
-                                       itNames = namesInFile.find((name));
-                                       
-                                       if (itNames == namesInFile.end()) { //no not in file
-                                               if (flag == "good") { //are you really a no??
-                                                       //is this sequence really not chimeric??
-                                                       itChimeras = chimerasInFile.find(name);
-                                                       
-                                                       //then you really are a no so print, otherwise skip
-                                                       if (itChimeras == chimerasInFile.end()) { print = true; }
-                                               }else{ print = true; }
-                                       }
-                               }
-                               
-                               if (print) {
-                                       out << index << '\t' << name  << '\t' << DiffsToBestMatch << '\t' << BestMatchIndex << '\t';
-                                       namesInFile.insert(name);
-                                       
-                                       if (BestMatchName != "Null") {
-                                               itUnique = uniqueNames.find(BestMatchName);
-                                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find BestMatchName "+ BestMatchName + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else {  out << itUnique->second << '\t';        }                                       
-                                       }else { out << "Null" << '\t'; }
-                                       
-                                       out << DiffstToChimera << '\t' << IndexofLeftParent << '\t' << IndexOfRightParent << '\t';
-                                       
-                                       if (parent1 != "Null") {
-                                               itUnique = uniqueNames.find(parent1);
-                                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parent1 "+ parent1 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else {  out << itUnique->second << '\t';        }
-                                       }else { out << "Null" << '\t'; }
-                                       
-                                       if (parent1 != "Null") {
-                                               itUnique = uniqueNames.find(parent2);
-                                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parent2 "+ parent2 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else {  out << itUnique->second << '\t';        }
-                                       }else { out << "Null" << '\t'; }
-                                       
-                                       out << temp1 << '\t' << temp2 << '\t' << temp3 << '\t' << temp4 << '\t' << temp5 << '\t' << temp6 << '\t' << temp7 << '\t' << temp8 << '\t' << flag << endl;    
-                               }
-                       }else { index = m->getline(in); m->gobble(in); }
-               }
-               in.close();
-               out.close();
-               
-               m->mothurRemove(outputFileName);
-               rename((outputFileName+".temp").c_str(), outputFileName.c_str());
-               
-               return total;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPerseusCommand", "deconvoluteResults");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-
-
diff --git a/chimeraperseuscommand.h b/chimeraperseuscommand.h
deleted file mode 100644 (file)
index 01f5768..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-#ifndef CHIMERAPERSEUSCOMMAND_H
-#define CHIMERAPERSEUSCOMMAND_H
-
-
-/*
- *  chimeraperseuscommand.h
- *  Mothur
- *
- *  Created by westcott on 10/26/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "mothur.h"
-#include "command.hpp"
-#include "sequenceparser.h"
-#include "myPerseus.h"
-
-/***********************************************************/
-class ChimeraPerseusCommand : public Command {
-public:
-       ChimeraPerseusCommand(string);
-       ChimeraPerseusCommand();
-       ~ChimeraPerseusCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.perseus";             }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Chimera.perseus\n"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-       
-private:
-       struct linePair {
-               int start;
-               int end;
-               linePair(int i, int j) : start(i), end(j) {}
-       };
-       
-       bool abort;
-       string fastafile, groupfile, outputDir, namefile;
-       int processors, alignLength;
-       double cutoff, alpha, beta;
-       
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-       vector<string> nameFileNames;
-       vector<string> groupFileNames;
-       
-       string getNamesFile(string&);
-       int driver(string, vector<seqData>&, string, int&);
-       vector<seqData> readFiles(string, string);
-       vector<seqData> loadSequences(SequenceParser&, string);
-       int deconvoluteResults(SequenceParser&, string, string);
-       int driverGroups(SequenceParser&, string, string, int, int, vector<string>);
-       int createProcessesGroups(SequenceParser&, string, string, vector<string>, string, string, string);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct perseusData {
-       string fastafile; 
-       string namefile; 
-       string groupfile;
-       string outputFName;
-       string accnos;
-       MothurOut* m;
-       int start;
-       int end;
-       int threadID, count, numChimeras;
-       double alpha, beta, cutoff;
-       vector<string> groups;
-       
-       perseusData(){}
-       perseusData(double a, double b, double c, string o,  string f, string n, string g, string ac, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
-               alpha = a;
-               beta = b;
-               cutoff = c;
-               fastafile = f;
-               namefile = n;
-               groupfile = g;
-               outputFName = o;
-               accnos = ac;
-               m = mout;
-               start = st;
-               end = en;
-               threadID = tid;
-               groups = gr;
-               count = 0;
-               numChimeras = 0;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ 
-       perseusData* pDataArray;
-       pDataArray = (perseusData*)lpParam;
-       
-       try {
-               
-               //clears files
-               ofstream out, out1, out2;
-               pDataArray->m->openOutputFile(pDataArray->outputFName, out); out.close(); 
-               pDataArray->m->openOutputFile(pDataArray->accnos, out1); out1.close();
-               
-               //parse fasta and name file by group
-               SequenceParser* parser;
-               if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile);      }
-               else                                                    { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile);                                            }
-               
-               int totalSeqs = 0;
-               int numChimeras = 0;
-               
-               for (int i = pDataArray->start; i < pDataArray->end; i++) {
-                       
-                       int start = time(NULL);  if (pDataArray->m->control_pressed) {  delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group " + pDataArray->groups[i] + "...");  pDataArray->m->mothurOutEndLine();                                      
-                       
-                       //vector<seqData> sequences = loadSequences(parser, groups[i]); - same function below
-                       ////////////////////////////////////////////////////////////////////////////////////////
-                       vector<Sequence> thisGroupsSeqs = parser->getSeqs(pDataArray->groups[i]);
-                       map<string, string> nameMap = parser->getNameMap(pDataArray->groups[i]);
-                       map<string, string>::iterator it;
-                       
-                       vector<seqData> sequences;
-                       bool error = false;
-                       
-                       for (int j = 0; j < thisGroupsSeqs.size(); j++) {
-                               
-                               if (pDataArray->m->control_pressed) {  delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
-                               
-                               it = nameMap.find(thisGroupsSeqs[j].getName());
-                               if (it == nameMap.end()) { error = true; pDataArray->m->mothurOut("[ERROR]: " + thisGroupsSeqs[j].getName() + " is in your fasta file and not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
-                               else {
-                                       int num = pDataArray->m->getNumNames(it->second);
-                                       sequences.push_back(seqData(thisGroupsSeqs[j].getName(), thisGroupsSeqs[j].getUnaligned(), num));
-                               }
-                       }
-                       
-                       if (error) { pDataArray->m->control_pressed = true; }
-                       
-                       //sort by frequency
-                       sort(sequences.rbegin(), sequences.rend());
-                       ////////////////////////////////////////////////////////////////////////////////////////
-
-                       if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
-                       
-                       //int numSeqs = driver((outputFName + groups[i]), sequences, (accnos+groups[i]), numChimeras); - same function below
-                       ////////////////////////////////////////////////////////////////////////////////////////
-                       string chimeraFileName = pDataArray->outputFName+pDataArray->groups[i];
-                       string accnosFileName = pDataArray->accnos+pDataArray->groups[i];
-                       
-                       vector<vector<double> > correctModel(4);        //could be an option in the future to input own model matrix
-                       for(int j=0;j<4;j++){   correctModel[j].resize(4);      }
-                       
-                       correctModel[0][0] = 0.000000;  //AA
-                       correctModel[1][0] = 11.619259; //CA
-                       correctModel[2][0] = 11.694004; //TA
-                       correctModel[3][0] = 7.748623;  //GA
-                       
-                       correctModel[1][1] = 0.000000;  //CC
-                       correctModel[2][1] = 7.619657;  //TC
-                       correctModel[3][1] = 12.852562; //GC
-                       
-                       correctModel[2][2] = 0.000000;  //TT
-                       correctModel[3][2] = 10.964048; //TG
-                       
-                       correctModel[3][3] = 0.000000;  //GG
-                       
-                       for(int k=0;k<4;k++){
-                               for(int j=0;j<k;j++){
-                                       correctModel[j][k] = correctModel[k][j];
-                               }
-                       }
-                       
-                       int numSeqs = sequences.size();
-                       int alignLength = sequences[0].sequence.size();
-                       
-                       ofstream chimeraFile;
-                       ofstream accnosFile;
-                       pDataArray->m->openOutputFile(chimeraFileName, chimeraFile); 
-                       pDataArray->m->openOutputFile(accnosFileName, accnosFile); 
-                       
-                       Perseus myPerseus;
-                       vector<vector<double> > binMatrix = myPerseus.binomial(alignLength);
-                       
-                       chimeraFile << "SequenceIndex\tName\tDiffsToBestMatch\tBestMatchIndex\tBestMatchName\tDiffstToChimera\tIndexofLeftParent\tIndexOfRightParent\tNameOfLeftParent\tNameOfRightParent\tDistanceToBestMatch\tcIndex\t(cIndex - singleDist)\tloonIndex\tMismatchesToChimera\tMismatchToTrimera\tChimeraBreakPoint\tLogisticProbability\tTypeOfSequence\n";
-                       
-                       vector<bool> chimeras(numSeqs, 0);
-                       
-                       for(int j=0;j<numSeqs;j++){     
-                               
-                               if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                               
-                               vector<bool> restricted = chimeras;
-                               
-                               vector<vector<int> > leftDiffs(numSeqs);
-                               vector<vector<int> > leftMaps(numSeqs);
-                               vector<vector<int> > rightDiffs(numSeqs);
-                               vector<vector<int> > rightMaps(numSeqs);
-                               
-                               vector<int> singleLeft, bestLeft;
-                               vector<int> singleRight, bestRight;
-                               
-                               int bestSingleIndex, bestSingleDiff;
-                               vector<pwAlign> alignments(numSeqs);
-                               
-                               int comparisons = myPerseus.getAlignments(j, sequences, alignments, leftDiffs, leftMaps, rightDiffs, rightMaps, bestSingleIndex, bestSingleDiff, restricted);
-                               
-                               if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                               
-                               int minMismatchToChimera, leftParentBi, rightParentBi, breakPointBi;
-                               
-                               string dummyA, dummyB;
-                               
-                               if(comparisons >= 2){   
-                                       minMismatchToChimera = myPerseus.getChimera(sequences, leftDiffs, rightDiffs, leftParentBi, rightParentBi, breakPointBi, singleLeft, bestLeft, singleRight, bestRight, restricted);
-                                       
-                                       if (pDataArray->m->control_pressed) { delete parser;  pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       
-                                       int minMismatchToTrimera = numeric_limits<int>::max();
-                                       int leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB;
-                                       
-                                       if(minMismatchToChimera >= 3 && comparisons >= 3){
-                                               minMismatchToTrimera = myPerseus.getTrimera(sequences, leftDiffs, leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB, singleLeft, bestLeft, singleRight, bestRight, restricted);
-                                               
-                                               if (pDataArray->m->control_pressed) { delete parser;  pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       }
-                                       
-                                       double singleDist = myPerseus.modeledPairwiseAlignSeqs(sequences[j].sequence, sequences[bestSingleIndex].sequence, dummyA, dummyB, correctModel);
-                                       
-                                       if (pDataArray->m->control_pressed) { delete parser;  pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       
-                                       string type;
-                                       string chimeraRefSeq;
-                                       
-                                       if(minMismatchToChimera - minMismatchToTrimera >= 3){
-                                               type = "trimera";
-                                               chimeraRefSeq = myPerseus.stitchTrimera(alignments, leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB, leftMaps, rightMaps);
-                                       }
-                                       else{
-                                               type = "chimera";
-                                               chimeraRefSeq = myPerseus.stitchBimera(alignments, leftParentBi, rightParentBi, breakPointBi, leftMaps, rightMaps);
-                                       }
-                                       
-                                       if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       
-                                       double chimeraDist = myPerseus.modeledPairwiseAlignSeqs(sequences[j].sequence, chimeraRefSeq, dummyA, dummyB, correctModel);
-                                       
-                                       if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       
-                                       double cIndex = chimeraDist;//modeledPairwiseAlignSeqs(sequences[j].sequence, chimeraRefSeq);
-                                       double loonIndex = myPerseus.calcLoonIndex(sequences[j].sequence, sequences[leftParentBi].sequence, sequences[rightParentBi].sequence, breakPointBi, binMatrix);                
-                                       
-                                       if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); chimeraFile.close(); pDataArray->m->mothurRemove(chimeraFileName); accnosFile.close(); pDataArray->m->mothurRemove(accnosFileName); return 0; }
-                                       
-                                       chimeraFile << j << '\t' << sequences[j].seqName << '\t' << bestSingleDiff << '\t' << bestSingleIndex << '\t' << sequences[bestSingleIndex].seqName << '\t';
-                                       chimeraFile << minMismatchToChimera << '\t' << leftParentBi << '\t' << rightParentBi << '\t' << sequences[leftParentBi].seqName << '\t' << sequences[rightParentBi].seqName << '\t';
-                                       chimeraFile << singleDist << '\t' << cIndex << '\t' << (cIndex - singleDist) << '\t' << loonIndex << '\t';
-                                       chimeraFile << minMismatchToChimera << '\t' << minMismatchToTrimera << '\t' << breakPointBi << '\t';
-                                       
-                                       double probability = myPerseus.classifyChimera(singleDist, cIndex, loonIndex, pDataArray->alpha, pDataArray->beta);
-                                       
-                                       chimeraFile << probability << '\t';
-                                       
-                                       if(probability > pDataArray->cutoff){ 
-                                               chimeraFile << type << endl;
-                                               accnosFile << sequences[j].seqName << endl;
-                                               chimeras[j] = 1;
-                                               numChimeras++;
-                                       }
-                                       else{
-                                               chimeraFile << "good" << endl;
-                                       }
-                                       
-                               }
-                               else{
-                                       chimeraFile << j << '\t' << sequences[j].seqName << "\t0\t0\tNull\t0\t0\t0\tNull\tNull\t0.0\t0.0\t0.0\t0\t0\t0\t0.0\t0.0\tgood" << endl;
-                               }
-                               //report progress
-                               if((j+1) % 100 == 0){   pDataArray->m->mothurOut("Processing sequence: " + toString(j+1) + "\n");               }
-                       }
-                       
-                       if((numSeqs) % 100 != 0){       pDataArray->m->mothurOut("Processing sequence: " + toString(numSeqs) + "\n");           }
-                       
-                       chimeraFile.close();
-                       accnosFile.close();
-                       ////////////////////////////////////////////////////////////////////////////////////////
-
-                       totalSeqs += numSeqs;
-                       
-                       //append files
-                       pDataArray->m->appendFiles(chimeraFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(chimeraFileName);
-                       pDataArray->m->appendFiles(accnosFileName, pDataArray->accnos); pDataArray->m->mothurRemove(accnosFileName);
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->groups[i] + ".");        pDataArray->m->mothurOutEndLine();                                      
-                       
-                       if (pDataArray->m->control_pressed) { delete parser; pDataArray->m->mothurRemove(pDataArray->outputFName); pDataArray->m->mothurRemove(pDataArray->accnos); return 0; }
-               }       
-               
-               pDataArray->count = totalSeqs;
-               delete parser;
-               return totalSeqs;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ChimeraUchimeCommand", "MyPerseusThreadFunction");
-               exit(1);
-       }
-} 
-/**************************************************************************************************/
-
-#endif
-
-#endif
-
-
diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp
deleted file mode 100644 (file)
index 7311173..0000000
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- *  chimerapintailcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 4/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimerapintailcommand.h"
-#include "pintail.h"
-
-
-//**********************************************************************************************************************
-vector<string> ChimeraPintailCommand::setParameters(){ 
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pconservation("conservation", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pconservation);
-               CommandParameter pquantile("quantile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pquantile);
-               CommandParameter pfilter("filter", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfilter);
-               CommandParameter pwindow("window", "Number", "", "0", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pincrement("increment", "Number", "", "25", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pmask("mask", "String", "", "", "", "", "",false,false); parameters.push_back(pmask);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraPintailCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The chimera.pintail command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
-               helpString += "This command was created using the algorythms described in the 'At Least 1 in 20 16S rRNA Sequence Records Currently Held in the Public Repositories is Estimated To Contain Substantial Anomalies' paper by Kevin E. Ashelford 1, Nadia A. Chuzhanova 3, John C. Fry 1, Antonia J. Jones 2 and Andrew J. Weightman 1.\n";
-               helpString += "The chimera.pintail command parameters are fasta, reference, filter, mask, processors, window, increment, conservation and quantile.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required unless you have a valid current fasta file. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The reference parameter allows you to enter a reference file containing known non-chimeric sequences, and is required. \n";
-               helpString += "The filter parameter allows you to specify if you would like to apply a vertical and 50% soft filter. \n";
-               helpString += "The mask parameter allows you to specify a file containing one sequence you wish to use as a mask for the your sequences, by default no mask is applied.  You can apply an ecoli mask by typing, mask=default. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The window parameter allows you to specify the window size for searching for chimeras, default=300. \n";
-               helpString += "The increment parameter allows you to specify how far you move each window while finding chimeric sequences, default=25.\n";
-               helpString += "The conservation parameter allows you to enter a frequency file containing the highest bases frequency at each place in the alignment.\n";
-               helpString += "The quantile parameter allows you to enter a file containing quantiles for a template files sequences, if you use the filter the quantile file generated becomes unique to the fasta file you used.\n";
-               helpString += "The chimera.pintail command should be in the following format: \n";
-               helpString += "chimera.pintail(fasta=yourFastaFile, reference=yourTemplate) \n";
-               helpString += "Example: chimera.pintail(fasta=AD.align, reference=silva.bacteria.fasta) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraPintailCommand::ChimeraPintailCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "ChimeraPintailCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraPintailCommand::ChimeraPintailCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.pintail");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       inputDir = validParameter.validFile(parameters, "inputdir", false);             
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("reference");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                               
-                               it = parameters.find("conservation");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["conservation"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("quantile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["quantile"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "filter", false);                   if (temp == "not found") { temp = "F"; }
-                       filter = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "window", false);                   if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, window);
-                       
-                       temp = validParameter.validFile(parameters, "increment", false);                if (temp == "not found") { temp = "25"; }
-                       m->mothurConvert(temp, increment);
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       templatefile = validParameter.validFile(parameters, "reference", true);
-                       if (templatefile == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templatefile = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (templatefile == "not open") { abort = true; } 
-                       else {  if (save) {     rdb->setSavedReference(templatefile);   }       }
-                       
-                       
-                       maskfile = validParameter.validFile(parameters, "mask", false);
-                       if (maskfile == "not found") { maskfile = "";  }        
-                       else if (maskfile != "default")  { 
-                               if (inputDir != "") {
-                                       string path = m->hasPath(maskfile);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       maskfile = inputDir + maskfile;         }
-                               }
-
-                               ifstream in;
-                               int     ableToOpen = m->openInputFile(maskfile, in, "no error");
-                               if (ableToOpen == 1) { 
-                                       if (m->getDefaultPath() != "") { //default path is set
-                                                       string tryPath = m->getDefaultPath() + m->getSimpleName(maskfile);
-                                                       m->mothurOut("Unable to open " + maskfile + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       maskfile = tryPath;
-                                       }
-                               }
-                               
-                               if (ableToOpen == 1) {
-                                               if (m->getOutputDir() != "") { //default path is set
-                                                       string tryPath = m->getOutputDir() + m->getSimpleName(maskfile);
-                                                       m->mothurOut("Unable to open " + maskfile + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       maskfile = tryPath;
-                                               }
-                               }
-                               
-                               in.close();
-                                       
-                               if (ableToOpen == 1) { 
-                                               m->mothurOut("Unable to open " + maskfile + "."); m->mothurOutEndLine(); 
-                                               abort = true;
-                               }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-               
-                       consfile = validParameter.validFile(parameters, "conservation", true);
-                       if (consfile == "not open") { abort = true; }
-                       else if (consfile == "not found") { 
-                               consfile = "";  
-                               //check for consfile
-                               string tempConsFile = m->getRootName(inputDir + m->getSimpleName(templatefile)) + "freq";
-                               ifstream FileTest(tempConsFile.c_str());
-                               if(FileTest){   
-                                       bool GoodFile = m->checkReleaseVersion(FileTest, m->getVersion());
-                                       if (GoodFile) {  
-                                               m->mothurOut("I found " + tempConsFile + " in your input file directory. I will use it to save time."); m->mothurOutEndLine();  consfile = tempConsFile;  FileTest.close();     
-                                       }
-                               }else {
-                                       string tempConsFile = m->getDefaultPath() + m->getRootName(m->getSimpleName(templatefile)) + "freq";
-                                       ifstream FileTest2(tempConsFile.c_str());
-                                       if(FileTest2){  
-                                               bool GoodFile = m->checkReleaseVersion(FileTest2, m->getVersion());
-                                               if (GoodFile) {  
-                                                       m->mothurOut("I found " + tempConsFile + " in your input file directory. I will use it to save time."); m->mothurOutEndLine();  consfile = tempConsFile;  FileTest2.close();    
-                                               }
-                                       }
-                               }
-                       }       
-                       
-                       quanfile = validParameter.validFile(parameters, "quantile", true);
-                       if (quanfile == "not open") { abort = true; }
-                       else if (quanfile == "not found") { quanfile = ""; }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "ChimeraPintailCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ChimeraPintailCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                               
-                       m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-
-                       int start = time(NULL); 
-                       
-                       //set user options
-                       if (maskfile == "default") { m->mothurOut("I am using the default 236627 EU009184.1 Shigella dysenteriae str. FBD013."); m->mothurOutEndLine();  }
-                       
-                       //check for quantile to save the time
-                       string baseName = templatefile;
-                       if (templatefile == "saved") { baseName = rdb->getSavedReference(); }
-                       
-                       string tempQuan = "";
-                       if ((!filter) && (maskfile == "")) {
-                               tempQuan = inputDir + m->getRootName(m->getSimpleName(baseName)) + "pintail.quan";
-                       }else if ((!filter) && (maskfile != "")) { 
-                               tempQuan = inputDir + m->getRootName(m->getSimpleName(baseName)) + "pintail.masked.quan";
-                       }else if ((filter) && (maskfile != "")) { 
-                               tempQuan = inputDir + m->getRootName(m->getSimpleName(baseName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "masked.quan";
-                       }else if ((filter) && (maskfile == "")) { 
-                               tempQuan = inputDir + m->getRootName(m->getSimpleName(baseName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "quan";
-                       }
-                       
-                       ifstream FileTest(tempQuan.c_str());
-                       if(FileTest){   
-                               bool GoodFile = m->checkReleaseVersion(FileTest, m->getVersion());
-                               if (GoodFile) {  
-                                       m->mothurOut("I found " + tempQuan + " in your input file directory. I will use it to save time."); m->mothurOutEndLine();  quanfile = tempQuan;  FileTest.close();     
-                               }
-                       }else {
-                               string tryPath = m->getDefaultPath();
-                               string tempQuan = "";
-                               if ((!filter) && (maskfile == "")) {
-                                       tempQuan = tryPath + m->getRootName(m->getSimpleName(baseName)) + "pintail.quan";
-                               }else if ((!filter) && (maskfile != "")) { 
-                                       tempQuan = tryPath + m->getRootName(m->getSimpleName(baseName)) + "pintail.masked.quan";
-                               }else if ((filter) && (maskfile != "")) { 
-                                       tempQuan = tryPath + m->getRootName(m->getSimpleName(baseName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "masked.quan";
-                               }else if ((filter) && (maskfile == "")) { 
-                                       tempQuan = tryPath + m->getRootName(m->getSimpleName(baseName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastaFileNames[s])) + "quan";
-                               }
-                               
-                               ifstream FileTest2(tempQuan.c_str());
-                               if(FileTest2){  
-                                       bool GoodFile = m->checkReleaseVersion(FileTest2, m->getVersion());
-                                       if (GoodFile) {  
-                                               m->mothurOut("I found " + tempQuan + " in your input file directory. I will use it to save time."); m->mothurOutEndLine();  quanfile = tempQuan;  FileTest2.close();    
-                                       }
-                               }
-                       }
-                       chimera = new Pintail(fastaFileNames[s], templatefile, filter, processors, maskfile, consfile, quanfile, window, increment, outputDir);
-                       
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it
-                       string outputFileName, accnosFileName;
-                       if (maskfile != "") {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + ".pintail.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + m->getSimpleName(m->getRootName(maskfile)) + ".pintail.accnos";
-                       }else {
-                               outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "pintail.chimeras";
-                               accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "pintail.accnos";
-                       }
-                       
-                       if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0;    }
-                       
-                       if (chimera->getUnaligned()) { 
-                               m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); 
-                               delete chimera;
-                               return 0; 
-                       }
-                       templateSeqsLength = chimera->getLength();
-               
-               #ifdef USE_MPI
-                       int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                               
-                               MPI_Status status; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-
-                               MPI_File inMPI;
-                               MPI_File outMPI;
-                               MPI_File outMPIAccnos;
-                               
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                               
-                               char outFilename[1024];
-                               strcpy(outFilename, outputFileName.c_str());
-                               
-                               char outAccnosFilename[1024];
-                               strcpy(outAccnosFilename, accnosFileName.c_str());
-                               
-                               char inFileName[1024];
-                               strcpy(inFileName, fastaFileNames[s].c_str());
-
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-                               MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-                               
-                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      m->mothurRemove(outputNames[j]);        }  delete chimera; return 0;  }
-
-                               if (pid == 0) { //you are the root process 
-                                                               
-                                       MPIPos = m->setFilePosFasta(fastaFileNames[s], numSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                               
-                                       //do your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  m->mothurRemove(outputFileName);  m->mothurRemove(accnosFileName);  for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        }  delete chimera; return 0;  }
-                                       
-                               }else{ //you are a child process
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                       
-                                       //do your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
-                                       
-                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);   MPI_File_close(&outMPIAccnos);  for (int j = 0; j < outputNames.size(); j++) {      m->mothurRemove(outputNames[j]);        }  delete chimera; return 0;  }
-                               }
-                               
-                               //close files 
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPI);
-                               MPI_File_close(&outMPIAccnos);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               #else
-                                               
-                       //break up file
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               vector<unsigned long long> positions = m->divideFile(fastaFileNames[s], processors);
-                       
-                               for (int i = 0; i < (positions.size()-1); i++) {
-                                       lines.push_back(new linePair(positions[i], positions[(i+1)]));
-                               }       
-                       
-                               if(processors == 1){
-               
-                                       numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
-                                       
-                                       if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
-                                       
-                               }else{
-                                       processIDS.resize(0);
-                                       
-                                       numSeqs = createProcesses(outputFileName, fastaFileNames[s], accnosFileName); 
-                               
-                                       rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
-                                       rename((accnosFileName + toString(processIDS[0]) + ".temp").c_str(), accnosFileName.c_str());
-                                               
-                                       //append output files
-                                       for(int i=1;i<processors;i++){
-                                               m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
-                                               m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
-                                       }
-                                       
-                                       //append output files
-                                       for(int i=1;i<processors;i++){
-                                               m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
-                                               m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp"));
-                                       }
-                                                                               
-                                       if (m->control_pressed) { 
-                                               m->mothurRemove(outputFileName); 
-                                               m->mothurRemove(accnosFileName);
-                                               for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        } outputTypes.clear();
-                                               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                                               delete chimera;
-                                               return 0;
-                                       }
-                               }
-
-                       #else
-                               lines.push_back(new linePair(0, 1000));
-                               numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName);
-                               
-                               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear(); delete chimera; return 0; }
-                       #endif
-                       
-               #endif  
-               
-                       delete chimera;
-                       for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                       
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
-                       
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
-               }
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-                       
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string filename, string accnos){
-       try {
-               ofstream out;
-               m->openOutputFile(outputFName, out);
-               
-               ofstream out2;
-               m->openOutputFile(accnos, out2);
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-                               
-                       if (m->control_pressed) {       return 1;       }
-               
-                       Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               
-                               if (candidateSeq->getAligned().length() != templateSeqsLength)  {  //chimeracheck does not require seqs to be aligned
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (m->control_pressed) {       delete candidateSeq; return 1;  }
-               
-                                       //print results
-                                       chimera->print(out, out2);
-                               }
-                               count++;
-                       }
-                       delete candidateSeq;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-               out.close();
-               out2.close();
-               inFASTA.close();
-                               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector<unsigned long long>& MPIPos){
-       try {
-                               
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               for(int i=0;i<num;i++){
-                       
-                       if (m->control_pressed) {       return 1;       }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-       
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence* candidateSeq = new Sequence(iss);  m->gobble(iss);
-                               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               
-                               if      (candidateSeq->getAligned().length() != templateSeqsLength) {  //chimeracheck does not require seqs to be aligned
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (m->control_pressed) {       delete candidateSeq; return 1;  }
-               
-                                       //print results
-                                       chimera->print(outMPI, outAccMPI);
-                               }
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((i+1) % 100 == 0){  cout << "Processing sequence: " << (i+1) << endl;        m->mothurOutJustToLog("Processing sequence: " + toString(i+1) + "\n");          }
-               }
-               //report progress
-               if(num % 100 != 0){             cout << "Processing sequence: " << num << endl; m->mothurOutJustToLog("Processing sequence: " + toString(num) + "\n");  }
-               
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-
-/**************************************************************************************************/
-
-int ChimeraPintailCommand::createProcesses(string outputFileName, string filename, string accnos) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 0;
-               int num = 0;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename, accnos + toString(getpid()) + ".temp");
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-               
-               return num;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraPintailCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-
diff --git a/chimerapintailcommand.h b/chimerapintailcommand.h
deleted file mode 100644 (file)
index ddbb648..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef CHIMERAPINTAILCOMMAND_H
-#define CHIMERAPINTAILCOMMAND_H
-
-/*
- *  chimerapintailcommand.h
- *  Mothur
- *
- *  Created by westcott on 4/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "chimera.h"
-#include "referencedb.h"
-
-/***********************************************************/
-
-class ChimeraPintailCommand : public Command {
-
-public:
-
-       ChimeraPintailCommand(string);
-       ChimeraPintailCommand();
-       ~ChimeraPintailCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.pintail";             }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Ashelford KE, Chuzhanova NA, Fry JC, Jones AJ, Weightman AJ (2005). At least 1 in 20 16S rRNA sequence records currently held in public repositories is estimated to contain substantial anomalies. Appl Environ Microbiol 71: 7724-36. \nAshelford KE, Chuzhanova NA, Fry JC, Jones AJ, Weightman AJ (2006). New screening software shows that most recent large 16S rRNA gene clone libraries contain chimeras. Appl Environ Microbiol 72: 5734-41. \nhttp://www.mothur.org/wiki/Chimera.pintail"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-private:
-       ReferenceDB* rdb;
-       
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-       
-       int driver(linePair*, string, string, string);
-       int createProcesses(string, string, string);
-       
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&);
-       #endif
-
-       bool abort, filter, save;
-       string fastafile, templatefile, consfile, quanfile, maskfile, outputDir, inputDir;
-       int processors, window, increment, numSeqs, templateSeqsLength;
-       Chimera* chimera;
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-};
-
-/***********************************************************/
-
-#endif
-
-
diff --git a/chimerarealigner.cpp b/chimerarealigner.cpp
deleted file mode 100644 (file)
index c95a1e7..0000000
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- *  chimerarealigner.cpp
- *  Mothur
- *
- *  Created by westcott on 2/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimerarealigner.h"
-#include "needlemanoverlap.hpp"
-#include "nast.hpp"
-
-//***************************************************************************************************************
-ChimeraReAligner::ChimeraReAligner()  {  m = MothurOut::getInstance(); }
-//***************************************************************************************************************
-ChimeraReAligner::~ChimeraReAligner() {}       
-//***************************************************************************************************************
-void ChimeraReAligner::reAlign(Sequence* query, vector<string> parents) {
-
-       
-       try {
-//             if (parents.size() != 0) {
-//                     vector<Sequence*> queryParts;
-//                     vector<Sequence*> parentParts;  //queryParts[0] relates to parentParts[0]
-//                     
-//                     string qAligned = query->getAligned();
-//                     string newQuery = "";
-//             
-//                     //sort parents by region start
-//                     sort(parents.begin(), parents.end(), compareRegionStart);
-//
-//                     //make sure you don't cutoff beginning of query 
-//                     if (parents[0].nastRegionStart > 0) {  newQuery += qAligned.substr(0, parents[0].nastRegionStart);  }
-//                     int longest = 0;
-//
-//                     //take query and break apart into pieces using breakpoints given by results of parents
-//                     for (int i = 0; i < parents.size(); i++) {
-//                             int length = parents[i].nastRegionEnd - parents[i].nastRegionStart+1;
-//                             string q = qAligned.substr(parents[i].nastRegionStart, length);
-//     
-//                             Sequence* queryFrag = new Sequence(query->getName(), q);
-//                             queryParts.push_back(queryFrag);
-//             
-//                             string p = parents[i].parentAligned;
-//                             p = p.substr(parents[i].nastRegionStart, length);
-//                             Sequence* parent = new Sequence(parents[i].parent, p);
-//                             parentParts.push_back(parent);
-//
-//                             if (queryFrag->getUnaligned().length() > longest)       { longest = queryFrag->getUnaligned().length(); }
-//                             if (parent->getUnaligned().length() > longest)  { longest = parent->getUnaligned().length();    }
-//                     }
-//
-//                     //align each peice to correct parent from results
-//                     for (int i = 0; i < queryParts.size(); i++) {
-//                             if ((queryParts[i]->getUnaligned() == "") || (parentParts[i]->getUnaligned() == "")) {;}
-//                             else {
-//                                     Alignment* alignment = new NeedlemanOverlap(-2.0, 1.0, -1.0, longest+1); //default gapopen, match, mismatch, longestbase
-//                             
-//                                     Nast nast(alignment, queryParts[i], parentParts[i]);
-//                                     delete alignment;
-//                             }
-//                     }
-//
-//                     //recombine pieces to form new query sequence
-//                     for (int i = 0; i < queryParts.size(); i++) {
-//                             //sometimes the parent regions do not meet, for example region 1 may end at 1000 and region 2 starts at 1100.  
-//                             //we don't want to loose length so in this case we will leave query alone
-//                             if (i != 0) {
-//                                     int space = parents[i].nastRegionStart - parents[i-1].nastRegionEnd - 1;
-//                                     if (space > 0) { //they don't meet and we need to add query piece
-//                                             string q = qAligned.substr(parents[i-1].nastRegionEnd+1, space);
-//                                             newQuery += q;
-//                                     }
-//                             }
-//
-//                             newQuery += queryParts[i]->getAligned();
-//                     }
-//                     
-//                     //make sure you don't cutoff end of query 
-//                     if (parents[parents.size()-1].nastRegionEnd < (qAligned.length()-1)) {  newQuery += qAligned.substr(parents[parents.size()-1].nastRegionEnd+1);  }
-//                     
-//                     query->setAligned(newQuery);
-//
-//                     //free memory
-//                     for (int i = 0; i < queryParts.size(); i++) { delete queryParts[i];  }
-//                     for (int i = 0; i < parentParts.size(); i++) { delete parentParts[i];  }
-//                     
-//             } //else leave query alone, you have bigger problems...
-
-               if(parents.size() != 0){
-
-                       alignmentLength = query->getAlignLength();      //x
-                       int queryUnalignedLength = query->getNumBases();        //y
-                       
-                       buildTemplateProfile(parents);
-                       
-                       createAlignMatrix(queryUnalignedLength, alignmentLength);
-                       fillAlignMatrix(query->getUnaligned());
-                       query->setAligned(getNewAlignment(query->getUnaligned()));
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "reAlign");
-               exit(1);
-       }
-}
-/***************************************************************************************************************/
-
-void ChimeraReAligner::buildTemplateProfile(vector<string> parents) {
-       try{    
-               int numParents = parents.size();
-
-               profile.resize(alignmentLength);
-                               
-               for(int i=0;i<numParents;i++){
-                       string seq = parents[i];
-
-                       for(int j=0;j<alignmentLength;j++){
-                                       
-                               
-                               if(seq[j] == 'A')               {       profile[j].A++;         }
-                               else if(seq[j] == 'T')  {       profile[j].T++;         }
-                               else if(seq[j] == 'G')  {       profile[j].G++;         }
-                               else if(seq[j] == 'C')  {       profile[j].C++;         }
-                               else if(seq[j] == '-')  {       profile[j].Gap++;       }
-                               else if(seq[j] == '.')  {       profile[j].Gap++;       }
-//                             else                                    {       profile[j].A++;         }
-                               
-                       }
-               }
-               
-
-               for(int i=0;i<alignmentLength;i++){
-                       profile[i].Chars = profile[i].A + profile[i].T + profile[i].G + profile[i].C;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "buildTemplateProfile");
-               exit(1);
-       }
-}
-       
-/***************************************************************************************************************/
-
-void ChimeraReAligner::createAlignMatrix(int queryUnalignedLength, int alignmentLength){
-       
-       try{
-               alignMatrix.resize(alignmentLength+1);
-               for(int i=0;i<=alignmentLength;i++){
-                       alignMatrix[i].resize(queryUnalignedLength+1);
-               }
-
-               for(int i=1;i<=alignmentLength;i++)             {       alignMatrix[i][0].direction = 'l';      }
-               for(int j=1;j<=queryUnalignedLength;j++){       alignMatrix[0][j].direction = 'u';      }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "createAlignMatrix");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************/
-
-void ChimeraReAligner::fillAlignMatrix(string query){
-       try{
-               int GAP = -4;
-               
-               int nrows = alignMatrix.size()-1;
-               int ncols = alignMatrix[0].size()-1;
-                               
-               for(int i=1;i<=nrows;i++){
-                       
-                       bases p = profile[i-1];
-                       int numChars = p.Chars;
-                       
-                       for(int j=1;j<=ncols;j++){
-                       
-                               char q = query[j-1];
-                               
-                               //      score it for if there was a match
-                               int maxScore = calcMatchScore(p, q) + alignMatrix[i-1][j-1].score;
-                               int maxDirection = 'd';
-                               
-                               //      score it for if there was a gap in the query
-                               int score = alignMatrix[i-1][j].score + (numChars * GAP);
-                               if (score > maxScore) {
-                                       maxScore = score;
-                                       maxDirection = 'l';
-                               }
-                               
-                               alignMatrix[i][j].score = maxScore;
-                               alignMatrix[i][j].direction = maxDirection;
-                               
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "fillAlignMatrix");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************/
-
-int ChimeraReAligner::calcMatchScore(bases p, char q){
-       try{
-               
-               int MATCH = 5;
-               int MISMATCH = -4;
-               
-               int score = 0;
-               
-               if(q == 'G')            {       score = (MATCH * p.G + MISMATCH * (p.A + p.T + p.C + p.Gap));           }
-               else if(q == 'A')       {       score = (MATCH * p.A + MISMATCH * (p.G + p.T + p.C + p.Gap));           }
-               else if(q == 'T')       {       score = (MATCH * p.T + MISMATCH * (p.G + p.A + p.C + p.Gap));           }
-               else if(q == 'C')       {       score = (MATCH * p.C + MISMATCH * (p.G + p.A + p.T + p.Gap));           }
-               else                            {       score = (MATCH * p.A + MISMATCH * (p.G + p.T + p.C + p.Gap));           }
-
-               return score;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "calcMatchScore");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************/
-
-string ChimeraReAligner::getNewAlignment(string query){
-       try{
-               string queryAlignment(alignmentLength, '.');
-               string referenceAlignment(alignmentLength, '.');
-               
-               
-               int maxScore = -99999999;
-               
-               int nrows = alignMatrix.size()-1;
-               int ncols = alignMatrix[0].size()-1;
-
-               int bestCol = -1;
-               int bestRow = -1;
-               
-               for(int i=1;i<=nrows;i++){
-                       int score = alignMatrix[i][ncols].score;
-                       if (score > maxScore) {
-                               maxScore = score;
-                               bestRow = i;
-                               bestCol = ncols;
-                       }
-               }
-               
-               for(int j=1;j<=ncols;j++){
-                       int score = alignMatrix[nrows][j].score;
-                       if (score > maxScore) {
-                               maxScore = score;
-                               bestRow = nrows;
-                               bestCol = j;
-                       }
-               }
-               
-               int currentRow = bestRow;
-               int currentCol = bestCol;
-               
-               int alignmentPosition = 0;
-               if(currentRow < alignmentLength){
-                       for(int i=alignmentLength;i>currentRow;i--){
-                               alignmentPosition++;
-                       }
-               }
-               
-               AlignCell c = alignMatrix[currentRow][currentCol];
-               while(c.direction != 'x'){
-                       
-                       char q;
-
-                       if(c.direction == 'd'){
-                               q = query[currentCol-1];
-                               currentCol--;
-                               currentRow--;
-                       }
-                       
-                       
-                       else if (c.direction == 'u') {
-                               break;
-                       }                                       
-                       else if(c.direction == 'l'){
-                               char gapChar;
-                               if(currentCol == 0)     {       gapChar = '.';  }
-                               else                            {       gapChar = '-';  }
-                                                               
-                               q = gapChar;
-                               currentRow--;
-                       }
-                       else{
-                               cout << "you shouldn't be here..." << endl;
-                       }
-
-                       queryAlignment[alignmentPosition] = q;
-                       alignmentPosition++;
-                       c = alignMatrix[currentRow][currentCol];
-               }
-
-//             need to reverse the string
-               string flipSeq = "";
-               for(int i=alignmentLength-1;i>=0;i--){
-                       flipSeq += queryAlignment[i];                   
-               }
-
-               return flipSeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraReAligner", "getNewAlignment");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************/
-
-// Sequence* ChimeraReAligner::getSequence(string name) {
-//     try{
-//             Sequence* temp;
-//             
-//             //look through templateSeqs til you find it
-//             int spot = -1;
-//             for (int i = 0; i < templateSeqs.size(); i++) {
-//                     if (name == templateSeqs[i]->getName()) {  
-//                             spot = i;
-//                             break;
-//                     }
-//             }
-//             
-//             if(spot == -1) { m->mothurOut("Error: Could not find sequence."); m->mothurOutEndLine(); return NULL; }
-//             
-//             temp = new Sequence(templateSeqs[spot]->getName(), templateSeqs[spot]->getAligned());
-//             
-//             return temp;
-//     }
-//     catch(exception& e) {
-//             m->errorOut(e, "ChimeraReAligner", "getSequence");
-//             exit(1);
-//     }
-//}
-
-//***************************************************************************************************************/
diff --git a/chimerarealigner.h b/chimerarealigner.h
deleted file mode 100644 (file)
index 5809f42..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef CHIMERAREALIGNER_H
-#define CHIMERAREALIGNER_H
-
-/*
- *  chimerarealigner.h
- *  Mothur
- *
- *  Created by westcott on 2/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimera.h"
-#include "alignment.hpp"
-
-/***********************************************************/
-
-struct AlignCell {
-       int score;
-       char direction;
-       AlignCell() : score(0), direction('x') {};
-};
-
-/***********************************************************/
-
-struct  bases {
-       int A, T, G, C, Gap, Chars;
-       bases() : A(0), T(0), G(0), C(0), Gap(0), Chars(0){};
-};
-
-/***********************************************************/
-
-
-class ChimeraReAligner  {
-       
-public:
-       ChimeraReAligner();      
-       ~ChimeraReAligner();
-       
-       void reAlign(Sequence*, vector<string>);
-                               
-private:
-       void buildTemplateProfile(vector<string>);
-       void createAlignMatrix(int, int);
-       void fillAlignMatrix(string);
-       int calcMatchScore(bases, char);
-       string getNewAlignment(string);
-
-       int alignmentLength;
-       vector<bases> profile;
-       vector<vector<AlignCell> > alignMatrix;
-
-       MothurOut* m;
-};
-
-/***********************************************************/
-
-#endif
-
diff --git a/chimeraslayer.cpp b/chimeraslayer.cpp
deleted file mode 100644 (file)
index 9ceba52..0000000
+++ /dev/null
@@ -1,1289 +0,0 @@
-/*
- *  chimeraslayer.cpp
- *  Mothur
- *
- *  Created by westcott on 9/25/09.
- *  Copyright 2009 Pschloss Lab. All rights reserved.
- *
- */
-
-#include "chimeraslayer.h"
-#include "chimerarealigner.h"
-#include "kmerdb.hpp"
-#include "blastdb.hpp"
-
-//***************************************************************************************************************
-ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, string mode, int k, int ms, int mms, int win, float div, 
-int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas, int tid) : Chimera()  {        
-       try {
-               fastafile = file;
-               templateFileName = temp; templateSeqs = readSeqs(temp);
-               searchMethod = mode;
-               kmerSize = k;
-               match = ms;
-               misMatch = mms;
-               window = win;
-               divR = div;
-               minSim = minsim;
-               minCov = mincov;
-               minBS = minbs;
-               minSNP = minsnp;
-               parents = par;
-               iters = it;
-               increment = inc;
-               numWanted = numw;
-               realign = r; 
-               trimChimera = trim;
-               numNoParents = 0;
-               blastlocation = blas;
-               threadID = tid;
-       
-               doPrep();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "ChimeraSlayer");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//template=self, byGroup parameter used for mpienabled version to read the template as MPI_COMM_SELF instead of MPI_COMM_WORLD
-ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, map<string, int>& prior, string mode, int k, int ms, int mms, int win, float div, 
-                                                        int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas, int tid, bool bg) : Chimera()  {       
-       try {
-               byGroup = bg;
-               fastafile = file; templateSeqs = readSeqs(fastafile);
-               templateFileName = temp; 
-               searchMethod = mode;
-               kmerSize = k;
-               match = ms;
-               misMatch = mms;
-               window = win;
-               divR = div;
-               minSim = minsim;
-               minCov = mincov;
-               minBS = minbs;
-               minSNP = minsnp;
-               parents = par;
-               iters = it;
-               increment = inc;
-               numWanted = numw;
-               realign = r; 
-               trimChimera = trim;
-               priority = prior;
-               numNoParents = 0;
-               blastlocation = blas;
-               threadID = tid;
-               
-               
-               createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
-               
-               if (searchMethod == "distance") { 
-                       //createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
-                       
-                       //run filter on template copying templateSeqs into filteredTemplateSeqs
-                       for (int i = 0; i < templateSeqs.size(); i++) {  
-                               if (m->control_pressed) {  break; }
-                               
-                               Sequence* newSeq = new Sequence(templateSeqs[i]->getName(), templateSeqs[i]->getAligned());
-                               runFilter(newSeq);  
-                               filteredTemplateSeqs.push_back(newSeq);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "ChimeraSlayer");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//template=self
-ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, map<string, int>& prior, string mode, int k, int ms, int mms, int win, float div, 
-                                                        int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas, int tid) : Chimera()  {        
-       try {
-               fastafile = file; templateSeqs = readSeqs(fastafile);
-               templateFileName = temp; 
-               searchMethod = mode;
-               kmerSize = k;
-               match = ms;
-               misMatch = mms;
-               window = win;
-               divR = div;
-               minSim = minsim;
-               minCov = mincov;
-               minBS = minbs;
-               minSNP = minsnp;
-               parents = par;
-               iters = it;
-               increment = inc;
-               numWanted = numw;
-               realign = r; 
-               trimChimera = trim;
-               priority = prior;
-               numNoParents = 0;
-               blastlocation = blas;
-               threadID = tid;
-               
-               
-               createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
-               
-               if (searchMethod == "distance") { 
-                       //createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
-                       
-                       //run filter on template copying templateSeqs into filteredTemplateSeqs
-                       for (int i = 0; i < templateSeqs.size(); i++) {  
-                               if (m->control_pressed) {  break; }
-                               
-                               Sequence* newSeq = new Sequence(templateSeqs[i]->getName(), templateSeqs[i]->getAligned());
-                               runFilter(newSeq);  
-                               filteredTemplateSeqs.push_back(newSeq);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "ChimeraSlayer");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int ChimeraSlayer::doPrep() {
-       try {
-               if (searchMethod == "distance") { 
-                       //read in all query seqs
-                       vector<Sequence*> tempQuerySeqs = readSeqs(fastafile);
-               
-                       vector<Sequence*> temp = templateSeqs;
-                       for (int i = 0; i < tempQuerySeqs.size(); i++) {  temp.push_back(tempQuerySeqs[i]);  }
-               
-                       createFilter(temp, 0.0); //just removed columns where all seqs have a gap
-               
-                       for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i];  }
-               
-                       if (m->control_pressed) {  return 0; } 
-               
-                       //run filter on template copying templateSeqs into filteredTemplateSeqs
-                       for (int i = 0; i < templateSeqs.size(); i++) {  
-                               if (m->control_pressed) {  return 0; }
-                               
-                               Sequence* newSeq = new Sequence(templateSeqs[i]->getName(), templateSeqs[i]->getAligned());
-                               runFilter(newSeq);  
-                               filteredTemplateSeqs.push_back(newSeq);
-                       }
-               }
-               string  kmerDBNameLeft;
-               string  kmerDBNameRight;
-       
-               //generate the kmerdb to pass to maligner
-               if (searchMethod == "kmer") { 
-                       string templatePath = m->hasPath(templateFileName);
-                       string rightTemplateFileName = templatePath + "right." + m->getRootName(m->getSimpleName(templateFileName));
-                       databaseRight = new KmerDB(rightTemplateFileName, kmerSize);
-                               
-                       string leftTemplateFileName = templatePath + "left." + m->getRootName(m->getSimpleName(templateFileName));
-                       databaseLeft = new KmerDB(leftTemplateFileName, kmerSize);      
-               #ifdef USE_MPI
-                       for (int i = 0; i < templateSeqs.size(); i++) {
-                                       
-                               if (m->control_pressed) { return 0; } 
-                                       
-                               string leftFrag = templateSeqs[i]->getUnaligned();
-                               leftFrag = leftFrag.substr(0, int(leftFrag.length() * 0.33));
-                                       
-                               Sequence leftTemp(templateSeqs[i]->getName(), leftFrag);
-                               databaseLeft->addSequence(leftTemp);    
-                       }
-                       databaseLeft->generateDB();
-                       databaseLeft->setNumSeqs(templateSeqs.size());
-                       
-                       for (int i = 0; i < templateSeqs.size(); i++) {
-                               if (m->control_pressed) { return 0; } 
-                                       
-                               string rightFrag = templateSeqs[i]->getUnaligned();
-                               rightFrag = rightFrag.substr(int(rightFrag.length() * 0.66));
-                                       
-                               Sequence rightTemp(templateSeqs[i]->getName(), rightFrag);
-                               databaseRight->addSequence(rightTemp);  
-                       }
-                       databaseRight->generateDB();
-                       databaseRight->setNumSeqs(templateSeqs.size());
-
-               #else   
-                       //leftside
-                       kmerDBNameLeft = leftTemplateFileName.substr(0,leftTemplateFileName.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-                       ifstream kmerFileTestLeft(kmerDBNameLeft.c_str());
-                       bool needToGenerateLeft = true;
-                       
-                       if(kmerFileTestLeft){   
-                               bool GoodFile = m->checkReleaseVersion(kmerFileTestLeft, m->getVersion());
-                               if (GoodFile) {  needToGenerateLeft = false;    }
-                       }
-                       
-                       if(needToGenerateLeft){ 
-                       
-                               for (int i = 0; i < templateSeqs.size(); i++) {
-                                       
-                                       if (m->control_pressed) { return 0; } 
-                                       
-                                       string leftFrag = templateSeqs[i]->getUnaligned();
-                                       leftFrag = leftFrag.substr(0, int(leftFrag.length() * 0.33));
-                                       
-                                       Sequence leftTemp(templateSeqs[i]->getName(), leftFrag);
-                                       databaseLeft->addSequence(leftTemp);    
-                               }
-                               databaseLeft->generateDB();
-                               
-                       }else { 
-                               databaseLeft->readKmerDB(kmerFileTestLeft);     
-                       }
-                       kmerFileTestLeft.close();
-                       
-                       databaseLeft->setNumSeqs(templateSeqs.size());
-                       
-                       //rightside
-                       kmerDBNameRight = rightTemplateFileName.substr(0,rightTemplateFileName.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-                       ifstream kmerFileTestRight(kmerDBNameRight.c_str());
-                       bool needToGenerateRight = true;
-                       
-                       if(kmerFileTestRight){  
-                               bool GoodFile = m->checkReleaseVersion(kmerFileTestRight, m->getVersion());
-                               if (GoodFile) {  needToGenerateRight = false;   }
-                       }
-                       
-                       if(needToGenerateRight){        
-                       
-                               for (int i = 0; i < templateSeqs.size(); i++) {
-                                       if (m->control_pressed) { return 0; } 
-                                       
-                                       string rightFrag = templateSeqs[i]->getUnaligned();
-                                       rightFrag = rightFrag.substr(int(rightFrag.length() * 0.66));
-                                       
-                                       Sequence rightTemp(templateSeqs[i]->getName(), rightFrag);
-                                       databaseRight->addSequence(rightTemp);  
-                               }
-                               databaseRight->generateDB();
-                               
-                       }else { 
-                               databaseRight->readKmerDB(kmerFileTestRight);   
-                       }
-                       kmerFileTestRight.close();
-                       
-                       databaseRight->setNumSeqs(templateSeqs.size());
-               #endif  
-               }else if (searchMethod == "blast") {
-               
-                       //generate blastdb
-                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(fastafile)), -1.0, -1.0, 1, -3, blastlocation, threadID);
-                       
-                       if (m->control_pressed) { return 0; }
-
-                       for (int i = 0; i < templateSeqs.size(); i++) {         databaseLeft->addSequence(*templateSeqs[i]);    }
-                       databaseLeft->generateDB();
-                       databaseLeft->setNumSeqs(templateSeqs.size());
-               }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "doprep");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<Sequence*> ChimeraSlayer::getTemplate(Sequence q, vector<Sequence*>& userTemplateFiltered) {
-       try {
-               
-               //when template=self, the query file is sorted from most abundance to least abundant
-               //userTemplate grows as the query file is processed by adding sequences that are not chimeric and more abundant
-               vector<Sequence*> userTemplate;
-               
-               int myAbund = priority[q.getName()];
-               
-               for (int i = 0; i < templateSeqs.size(); i++) {
-                       
-                       if (m->control_pressed) { return userTemplate; } 
-                       
-                       //have I reached a sequence with the same abundance as myself?
-                       if (!(priority[templateSeqs[i]->getName()] > myAbund)) { break; }
-                       
-                       //if its am not chimeric add it
-                       if (chimericSeqs.count(templateSeqs[i]->getName()) == 0) { 
-                               userTemplate.push_back(templateSeqs[i]); 
-                               if (searchMethod == "distance") { userTemplateFiltered.push_back(filteredTemplateSeqs[i]); }
-                       }
-               }
-               
-               //avoids nuisance error from formatdb for making blank blast database
-               if (userTemplate.size() == 0) {
-                       return userTemplate;
-               }
-               
-               string  kmerDBNameLeft;
-               string  kmerDBNameRight;
-               
-               //generate the kmerdb to pass to maligner
-               if (searchMethod == "kmer") { 
-                       string templatePath = m->hasPath(templateFileName);
-                       string rightTemplateFileName = templatePath + "right." + m->getRootName(m->getSimpleName(templateFileName));
-                       databaseRight = new KmerDB(rightTemplateFileName, kmerSize);
-                       
-                       string leftTemplateFileName = templatePath + "left." + m->getRootName(m->getSimpleName(templateFileName));
-                       databaseLeft = new KmerDB(leftTemplateFileName, kmerSize);      
-#ifdef USE_MPI
-                       for (int i = 0; i < userTemplate.size(); i++) {
-                               
-                               if (m->control_pressed) { return userTemplate; } 
-                               
-                               string leftFrag = userTemplate[i]->getUnaligned();
-                               leftFrag = leftFrag.substr(0, int(leftFrag.length() * 0.33));
-                               
-                               Sequence leftTemp(userTemplate[i]->getName(), leftFrag);
-                               databaseLeft->addSequence(leftTemp);    
-                       }
-                       databaseLeft->generateDB();
-                       databaseLeft->setNumSeqs(userTemplate.size());
-                       
-                       for (int i = 0; i < userTemplate.size(); i++) {
-                               if (m->control_pressed) { return userTemplate; } 
-                               
-                               string rightFrag = userTemplate[i]->getUnaligned();
-                               rightFrag = rightFrag.substr(int(rightFrag.length() * 0.66));
-                               
-                               Sequence rightTemp(userTemplate[i]->getName(), rightFrag);
-                               databaseRight->addSequence(rightTemp);  
-                       }
-                       databaseRight->generateDB();
-                       databaseRight->setNumSeqs(userTemplate.size());
-                       
-#else  
-                       
-                       
-                       for (int i = 0; i < userTemplate.size(); i++) {
-                               
-                               if (m->control_pressed) { return userTemplate; } 
-                               
-                               string leftFrag = userTemplate[i]->getUnaligned();
-                               leftFrag = leftFrag.substr(0, int(leftFrag.length() * 0.33));
-                               
-                               Sequence leftTemp(userTemplate[i]->getName(), leftFrag);
-                               databaseLeft->addSequence(leftTemp);    
-                       }
-                       databaseLeft->generateDB();
-                       databaseLeft->setNumSeqs(userTemplate.size());
-                               
-                       for (int i = 0; i < userTemplate.size(); i++) {
-                               if (m->control_pressed) { return userTemplate; }  
-                                       
-                               string rightFrag = userTemplate[i]->getUnaligned();
-                               rightFrag = rightFrag.substr(int(rightFrag.length() * 0.66));
-                                       
-                               Sequence rightTemp(userTemplate[i]->getName(), rightFrag);
-                               databaseRight->addSequence(rightTemp);  
-                       }
-                       databaseRight->generateDB();
-                       databaseRight->setNumSeqs(userTemplate.size());
-#endif 
-               }else if (searchMethod == "blast") {
-                       
-                       //generate blastdb
-                       databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(templateFileName)), -1.0, -1.0, 1, -3, blastlocation, threadID);
-                       
-                       if (m->control_pressed) { return userTemplate; }
-
-                       for (int i = 0; i < userTemplate.size(); i++) { if (m->control_pressed) { return userTemplate; }   databaseLeft->addSequence(*userTemplate[i]); }
-                       databaseLeft->generateDB();
-                       databaseLeft->setNumSeqs(userTemplate.size());
-               }
-               
-               return userTemplate;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getTemplate");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-ChimeraSlayer::~ChimeraSlayer() {      
-       if (templateFileName != "self") {
-               if (searchMethod == "kmer") {  delete databaseRight;  delete databaseLeft;  }   
-               else if (searchMethod == "blast") {  delete databaseLeft; }
-       }
-}
-//***************************************************************************************************************
-void ChimeraSlayer::printHeader(ostream& out) {
-       m->mothurOutEndLine();
-       m->mothurOut("Only reporting sequence supported by " + toString(minBS) + "% of bootstrapped results.");
-       m->mothurOutEndLine();
-       
-       out << "Name\tLeftParent\tRightParent\tDivQLAQRB\tPerIDQLAQRB\tBootStrapA\tDivQLBQRA\tPerIDQLBQRA\tBootStrapB\tFlag\tLeftWindow\tRightWindow\n";
-}
-//***************************************************************************************************************
-Sequence ChimeraSlayer::print(ostream& out, ostream& outAcc) {
-       try {
-               Sequence trim;
-               if (trimChimera) { trim.setName(trimQuery.getName()); trim.setAligned(trimQuery.getAligned()); }
-               
-               if (chimeraFlags == "yes") {
-                       string chimeraFlag = "no";
-                       if(  (chimeraResults[0].bsa >= minBS && chimeraResults[0].divr_qla_qrb >= divR)
-                          ||
-                          (chimeraResults[0].bsb >= minBS && chimeraResults[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       
-                       
-                       if (chimeraFlag == "yes") {     
-                               if ((chimeraResults[0].bsa >= minBS) || (chimeraResults[0].bsb >= minBS)) {
-                                       m->mothurOut(querySeq.getName() + "\tyes"); m->mothurOutEndLine();
-                                       outAcc << querySeq.getName() << endl;
-                                       
-                                       if (templateFileName == "self") {  chimericSeqs.insert(querySeq.getName()); }
-                                       
-                                       if (trimChimera) {  
-                                               int lengthLeft = chimeraResults[0].winLEnd - chimeraResults[0].winLStart;
-                                               int lengthRight = chimeraResults[0].winREnd - chimeraResults[0].winRStart;
-                                               
-                                               string newAligned = trim.getAligned();
-
-                                               if (lengthLeft > lengthRight) { //trim right
-                                                       for (int i = (chimeraResults[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                               }else { //trim left
-                                                       for (int i = 0; i < chimeraResults[0].winLEnd; i++) { newAligned[i] = '.'; }
-                                               }
-                                               trim.setAligned(newAligned);
-                                       }
-                               }
-                       }
-                       
-                       printBlock(chimeraResults[0], chimeraFlag, out);
-                       out << endl;
-               }else {  
-                       out << querySeq.getName() << "\tno" << endl; 
-               }
-               
-               return trim;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "print");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Sequence ChimeraSlayer::print(ostream& out, ostream& outAcc, data_results leftPiece, data_results rightPiece) {
-       try {
-               Sequence trim;
-                               
-               if (trimChimera) { 
-                       string aligned = leftPiece.trimQuery.getAligned() + rightPiece.trimQuery.getAligned();
-                       trim.setName(leftPiece.trimQuery.getName()); trim.setAligned(aligned); 
-               }
-               
-               if ((leftPiece.flag == "yes") || (rightPiece.flag == "yes")) {
-                       
-                       string chimeraFlag = "no";
-                       if (leftPiece.flag == "yes") {
-                               
-                               if(  (leftPiece.results[0].bsa >= minBS && leftPiece.results[0].divr_qla_qrb >= divR)
-                                       ||
-                                       (leftPiece.results[0].bsb >= minBS && leftPiece.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       }
-                       
-                       if (rightPiece.flag == "yes") {
-                               if ( (rightPiece.results[0].bsa >= minBS && rightPiece.results[0].divr_qla_qrb >= divR)
-                                ||
-                                (rightPiece.results[0].bsb >= minBS && rightPiece.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       }
-                       
-                       bool rightChimeric = false;
-                       bool leftChimeric = false;
-                       
-                       if (chimeraFlag == "yes") {     
-                               //which peice is chimeric or are both
-                               if (rightPiece.flag == "yes") { if ((rightPiece.results[0].bsa >= minBS) || (rightPiece.results[0].bsb >= minBS)) { rightChimeric = true; } }
-                               if (leftPiece.flag == "yes") { if ((leftPiece.results[0].bsa >= minBS) || (leftPiece.results[0].bsb >= minBS))  { leftChimeric = true;  } }
-                               
-                               if (rightChimeric || leftChimeric) {
-                                       m->mothurOut(querySeq.getName() + "\tyes"); m->mothurOutEndLine();
-                                       outAcc << querySeq.getName() << endl;
-                                       
-                                       if (templateFileName == "self") {  chimericSeqs.insert(querySeq.getName()); }
-                                       
-                                       if (trimChimera) {  
-                                               string newAligned = trim.getAligned();
-                                                                                               
-                                               //right side is fine so keep that
-                                               if ((leftChimeric) && (!rightChimeric)) {
-                                                       for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                               }else if ((!leftChimeric) && (rightChimeric)) { //leftside is fine so keep that
-                                                       for (int i = (rightPiece.results[0].winLStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                               }else { //both sides are chimeric, keep longest piece
-                                                       
-                                                       int lengthLeftLeft = leftPiece.results[0].winLEnd - leftPiece.results[0].winLStart;
-                                                       int lengthLeftRight = leftPiece.results[0].winREnd - leftPiece.results[0].winRStart;
-                                                       
-                                                       int longest = 1; // leftleft = 1, leftright = 2, rightleft = 3 rightright = 4
-                                                       int length = lengthLeftLeft;
-                                                       if (lengthLeftLeft < lengthLeftRight) { longest = 2;  length = lengthLeftRight; }
-                                                       
-                                                       int lengthRightLeft = rightPiece.results[0].winLEnd - rightPiece.results[0].winLStart;
-                                                       int lengthRightRight = rightPiece.results[0].winREnd - rightPiece.results[0].winRStart;
-                                                       
-                                                       if (lengthRightLeft > length) { longest = 3; length = lengthRightLeft;  }
-                                                       if (lengthRightRight > length) { longest = 4; }
-                                                       
-                                                       if (longest == 1) { //leftleft
-                                                               for (int i = (leftPiece.results[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else if (longest == 2) { //leftright
-                                                               //get rid of leftleft
-                                                               for (int i = (leftPiece.results[0].winLStart-1); i < (leftPiece.results[0].winLEnd-1); i++) { newAligned[i] = '.'; }
-                                                               //get rid of right
-                                                               for (int i = (rightPiece.results[0].winLStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else if (longest == 3) { //rightleft
-                                                               //get rid of left
-                                                               for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                                               //get rid of rightright
-                                                               for (int i = (rightPiece.results[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else { //rightright
-                                                               //get rid of left
-                                                               for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                                               //get rid of rightleft
-                                                               for (int i = (rightPiece.results[0].winLStart-1); i < (rightPiece.results[0].winLEnd-1); i++) { newAligned[i] = '.'; }
-                                                       }
-                                               }
-                                                       
-                                               trim.setAligned(newAligned);
-                                       }
-                                       
-                               }
-                       }
-                       
-                       printBlock(leftPiece, rightPiece, leftChimeric, rightChimeric, chimeraFlag, out);
-                       out << endl;
-               }else {  
-                       out << querySeq.getName() << "\tno" << endl;  
-               }
-               
-               return trim;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "print");
-               exit(1);
-       }
-}
-
-#ifdef USE_MPI
-//***************************************************************************************************************
-Sequence ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc, data_results leftPiece, data_results rightPiece) {
-       try {
-               MPI_Status status;
-               bool results = false;
-               string outAccString = "";
-               string outputString = "";
-               
-               Sequence trim;
-               
-               if (trimChimera) { 
-                       string aligned = leftPiece.trimQuery.getAligned() + rightPiece.trimQuery.getAligned();
-                       trim.setName(leftPiece.trimQuery.getName());  trim.setAligned(aligned);
-               }
-               
-               
-               if ((leftPiece.flag == "yes") || (rightPiece.flag == "yes")) {
-                       
-                       string chimeraFlag = "no";
-                       if (leftPiece.flag == "yes") {
-                               
-                               if(  (leftPiece.results[0].bsa >= minBS && leftPiece.results[0].divr_qla_qrb >= divR)
-                                  ||
-                                  (leftPiece.results[0].bsb >= minBS && leftPiece.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       }
-                       
-                       if (rightPiece.flag == "yes") {
-                               if ( (rightPiece.results[0].bsa >= minBS && rightPiece.results[0].divr_qla_qrb >= divR)
-                                       ||
-                                       (rightPiece.results[0].bsb >= minBS && rightPiece.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       }
-                       
-                       bool rightChimeric = false;
-                       bool leftChimeric = false;
-
-                       cout << endl;
-                       
-                       if (chimeraFlag == "yes") {     
-                               //which peice is chimeric or are both
-                               if (rightPiece.flag == "yes") { if ((rightPiece.results[0].bsa >= minBS) || (rightPiece.results[0].bsb >= minBS)) { rightChimeric = true; } }
-                               if (leftPiece.flag == "yes") { if ((leftPiece.results[0].bsa >= minBS) || (leftPiece.results[0].bsb >= minBS))  { leftChimeric = true;  } }
-                               
-                               if (rightChimeric || leftChimeric) {
-                                       cout << querySeq.getName() <<  "\tyes" << endl;
-                                       outAccString += querySeq.getName() + "\n";
-                                       results = true;
-                                       
-                                       if (templateFileName == "self") {  chimericSeqs.insert(querySeq.getName()); }
-                                       
-                                       //write to accnos file
-                                       int length = outAccString.length();
-                                       char* buf2 = new char[length];
-                                       memcpy(buf2, outAccString.c_str(), length);
-                               
-                                       MPI_File_write_shared(outAcc, buf2, length, MPI_CHAR, &status);
-                                       delete buf2;
-                                       
-                                       if (trimChimera) {  
-                                               string newAligned = trim.getAligned();
-                                               
-                                               //right side is fine so keep that
-                                               if ((leftChimeric) && (!rightChimeric)) {
-                                                       for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                               }else if ((!leftChimeric) && (rightChimeric)) { //leftside is fine so keep that
-                                                       for (int i = (rightPiece.results[0].winLStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                               }else { //both sides are chimeric, keep longest piece
-                                                       
-                                                       int lengthLeftLeft = leftPiece.results[0].winLEnd - leftPiece.results[0].winLStart;
-                                                       int lengthLeftRight = leftPiece.results[0].winREnd - leftPiece.results[0].winRStart;
-                                                       
-                                                       int longest = 1; // leftleft = 1, leftright = 2, rightleft = 3 rightright = 4
-                                                       int length = lengthLeftLeft;
-                                                       if (lengthLeftLeft < lengthLeftRight) { longest = 2;  length = lengthLeftRight; }
-                                                       
-                                                       int lengthRightLeft = rightPiece.results[0].winLEnd - rightPiece.results[0].winLStart;
-                                                       int lengthRightRight = rightPiece.results[0].winREnd - rightPiece.results[0].winRStart;
-                                                       
-                                                       if (lengthRightLeft > length) { longest = 3; length = lengthRightLeft;  }
-                                                       if (lengthRightRight > length) { longest = 4; }
-                                                       
-                                                       if (longest == 1) { //leftleft
-                                                               for (int i = (leftPiece.results[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else if (longest == 2) { //leftright
-                                                               //get rid of leftleft
-                                                               for (int i = (leftPiece.results[0].winLStart-1); i < (leftPiece.results[0].winLEnd-1); i++) { newAligned[i] = '.'; }
-                                                               //get rid of right
-                                                               for (int i = (rightPiece.results[0].winLStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else if (longest == 3) { //rightleft
-                                                               //get rid of left
-                                                               for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                                               //get rid of rightright
-                                                               for (int i = (rightPiece.results[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                                       }else { //rightright
-                                                               //get rid of left
-                                                               for (int i = 0; i < leftPiece.results[0].winREnd; i++) { newAligned[i] = '.'; } 
-                                                               //get rid of rightleft
-                                                               for (int i = (rightPiece.results[0].winLStart-1); i < (rightPiece.results[0].winLEnd-1); i++) { newAligned[i] = '.'; }
-                                                       }
-                                               }
-                                               
-                                               trim.setAligned(newAligned);
-                                       }
-                                       
-                               }
-                       }
-                       
-                       outputString = getBlock(leftPiece, rightPiece, leftChimeric, rightChimeric, chimeraFlag);
-                       outputString += "\n";
-               
-                       //write to output file
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                               
-                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-                       delete buf;
-
-               }else {  
-                       outputString += querySeq.getName() + "\tno\n";  
-       
-                       //write to output file
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                               
-                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-                       delete buf;
-               }
-               
-               
-               return trim;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "print");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Sequence ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc) {
-       try {
-               MPI_Status status;
-               bool results = false;
-               string outAccString = "";
-               string outputString = "";
-               
-               Sequence trim;
-               if (trimChimera) { trim.setName(trimQuery.getName()); trim.setAligned(trimQuery.getAligned()); }
-               
-               if (chimeraFlags == "yes") {
-                       string chimeraFlag = "no";
-                       if(  (chimeraResults[0].bsa >= minBS && chimeraResults[0].divr_qla_qrb >= divR)
-                          ||
-                          (chimeraResults[0].bsb >= minBS && chimeraResults[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                       
-                       
-                       if (chimeraFlag == "yes") {     
-                               if ((chimeraResults[0].bsa >= minBS) || (chimeraResults[0].bsb >= minBS)) {
-                                       cout << querySeq.getName() <<  "\tyes" << endl;
-                                       outAccString += querySeq.getName() + "\n";
-                                       results = true;
-                                       
-                                       if (templateFileName == "self") {  chimericSeqs.insert(querySeq.getName()); }
-                                       
-                                       //write to accnos file
-                                       int length = outAccString.length();
-                                       char* buf2 = new char[length];
-                                       memcpy(buf2, outAccString.c_str(), length);
-                                       
-                                       MPI_File_write_shared(outAcc, buf2, length, MPI_CHAR, &status);
-                                       delete buf2;
-                                       
-                                       if (trimChimera) {  
-                                               int lengthLeft = chimeraResults[0].winLEnd - chimeraResults[0].winLStart;
-                                               int lengthRight = chimeraResults[0].winREnd - chimeraResults[0].winRStart;
-                                               
-                                               string newAligned = trim.getAligned();
-                                               if (lengthLeft > lengthRight) { //trim right
-                                                       for (int i = (chimeraResults[0].winRStart-1); i < newAligned.length(); i++) { newAligned[i] = '.'; }
-                                               }else { //trim left
-                                                       for (int i = 0; i < (chimeraResults[0].winLEnd-1); i++) { newAligned[i] = '.'; }
-                                               }
-                                               trim.setAligned(newAligned);    
-                                       }
-                               }
-                       }
-                       
-                       outputString = getBlock(chimeraResults[0], chimeraFlag);
-                       outputString += "\n";
-                       
-                       //write to output file
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-                       delete buf;
-                       
-               }else {  
-                       outputString += querySeq.getName() + "\tno\n";  
-                       
-                       //write to output file
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-                       delete buf;
-               }
-               
-               return trim;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "print");
-               exit(1);
-       }
-}
-#endif
-
-//***************************************************************************************************************
-int ChimeraSlayer::getChimeras(Sequence* query) {
-       try {
-               
-               trimQuery.setName(query->getName()); trimQuery.setAligned(query->getAligned());
-               printResults.trimQuery = trimQuery; 
-               
-               chimeraFlags = "no";
-               printResults.flag = "no";
-               
-               querySeq = *query;
-               
-               //you must create a template
-               vector<Sequence*> thisTemplate;
-               vector<Sequence*> thisFilteredTemplate;
-               if (templateFileName != "self") { thisTemplate = templateSeqs; thisFilteredTemplate = filteredTemplateSeqs; }
-               else {  thisTemplate = getTemplate(*query, thisFilteredTemplate);  } //fills this template and creates the databases
-               
-               if (m->control_pressed) {  return 0;  }
-               if (thisTemplate.size() == 0) {  return 0; } //not chimeric
-               
-               //moved this out of maligner - 4/29/11
-               vector<Sequence> refSeqs = getRefSeqs(*query, thisTemplate, thisFilteredTemplate);
-               
-               Maligner maligner(refSeqs, match, misMatch, divR, minSim, minCov); 
-               Slayer slayer(window, increment, minSim, divR, iters, minSNP, minBS);
-               
-               if (templateFileName == "self") {
-                       if (searchMethod == "kmer") {  delete databaseRight;  delete databaseLeft;  }   
-                       else if (searchMethod == "blast") {  delete databaseLeft; }
-               }
-       
-               if (m->control_pressed) {  return 0;  }
-
-               string chimeraFlag = maligner.getResults(*query, decalc);
-
-               if (m->control_pressed) {  return 0;  }
-               
-               vector<results> Results = maligner.getOutput();
-               
-               //for (int i = 0; i < refSeqs.size(); i++) {  delete refSeqs[i];        }
-               
-               if (chimeraFlag == "yes") {
-                       
-                       if (realign) {
-                               vector<string> parents;
-                               for (int i = 0; i < Results.size(); i++) {
-                                       parents.push_back(Results[i].parentAligned);
-                               }
-                               
-                               ChimeraReAligner realigner;             
-                               realigner.reAlign(query, parents);
-
-                       }
-                       
-//                     cout << query->getAligned() << endl;
-                       //get sequence that were given from maligner results
-                       vector<SeqCompare> seqs;
-                       map<string, float> removeDups;
-                       map<string, float>::iterator itDup;
-                       map<string, string> parentNameSeq;
-                       map<string, string>::iterator itSeq;
-                       for (int j = 0; j < Results.size(); j++) {
-
-                               float dist = (Results[j].regionEnd - Results[j].regionStart + 1) * Results[j].queryToParentLocal;
-                               //only add if you are not a duplicate
-//                             cout << Results[j].parent << '\t' << Results[j].regionEnd << '\t' << Results[j].regionStart << '\t' << Results[j].regionEnd - Results[j].regionStart +1 << '\t' << Results[j].queryToParentLocal << '\t' << dist << endl;
-                               
-                               
-                               if(Results[j].queryToParentLocal >= 90){        //local match has to be over 90% similarity
-                               
-                                       itDup = removeDups.find(Results[j].parent);
-                                       if (itDup == removeDups.end()) { //this is not duplicate
-                                               removeDups[Results[j].parent] = dist;
-                                               parentNameSeq[Results[j].parent] = Results[j].parentAligned;
-                                       }else if (dist > itDup->second) { //is this a stronger number for this parent
-                                               removeDups[Results[j].parent] = dist;
-                                               parentNameSeq[Results[j].parent] = Results[j].parentAligned;
-                                       }
-                               
-                               }
-                               
-                       }
-                       
-                       for (itDup = removeDups.begin(); itDup != removeDups.end(); itDup++) {
-                               itSeq = parentNameSeq.find(itDup->first);
-                               Sequence seq(itDup->first, itSeq->second);
-                               
-                               SeqCompare member;
-                               member.seq = seq;
-                               member.dist = itDup->second;
-                               seqs.push_back(member);
-                       }
-                       
-                       //limit number of parents to explore - default 3
-                       if (Results.size() > parents) {
-                               //sort by distance
-                               sort(seqs.begin(), seqs.end(), compareSeqCompare);
-                               //prioritize larger more similiar sequence fragments
-                               reverse(seqs.begin(), seqs.end());
-                               
-                               //for (int k = seqs.size()-1; k > (parents-1); k--)  {  
-                               //      delete seqs[k].seq;
-                                       //seqs.pop_back();      
-                               //}
-                       }
-               
-                       //put seqs into vector to send to slayer
-                       
-//                     cout << query->getAligned() << endl;
-                       vector<Sequence> seqsForSlayer;
-                       for (int k = 0; k < seqs.size(); k++) {  
-//                             cout << seqs[k].seq->getAligned() << endl;
-                               seqsForSlayer.push_back(seqs[k].seq);   
-//                             cout << seqs[k].seq->getName() << endl;
-                       }
-                       
-                       if (m->control_pressed) {  return 0;  }
-
-                       //send to slayer
-                       chimeraFlags = slayer.getResults(*query, seqsForSlayer);
-                       if (m->control_pressed) {  return 0;  }
-                       chimeraResults = slayer.getOutput();
-                       
-                       printResults.flag = chimeraFlags;
-                       printResults.results = chimeraResults;
-                       
-                       //free memory
-                       //for (int k = 0; k < seqs.size(); k++) {  delete seqs[k].seq;   }
-               }
-               //cout << endl << endl;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getChimeras");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-void ChimeraSlayer::printBlock(data_struct data, string flag, ostream& out){
-       try {
-               out << querySeq.getName() << '\t';
-               out << data.parentA.getName() << "\t" << data.parentB.getName()  << '\t';
-       
-               out << data.divr_qla_qrb << '\t' << data.qla_qrb << '\t' << data.bsa << '\t';
-               out << data.divr_qlb_qra << '\t' << data.qlb_qra << '\t' << data.bsb << '\t';
-               
-               out << flag << '\t' << data.winLStart << "-" << data.winLEnd << '\t' << data.winRStart << "-" << data.winREnd << '\t';
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "printBlock");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-void ChimeraSlayer::printBlock(data_results leftdata, data_results rightdata, bool leftChimeric, bool rightChimeric, string flag, ostream& out){
-       try {
-               
-               if ((leftChimeric) && (!rightChimeric)) { //print left
-                       out << querySeq.getName() << '\t';
-                       out << leftdata.results[0].parentA.getName() << "\t" << leftdata.results[0].parentB.getName()  << '\t';
-                       
-                       out << leftdata.results[0].divr_qla_qrb << '\t' << leftdata.results[0].qla_qrb << '\t' << leftdata.results[0].bsa << '\t';
-                       out << leftdata.results[0].divr_qlb_qra << '\t' << leftdata.results[0].qlb_qra << '\t' << leftdata.results[0].bsb << '\t';
-               
-                       out << flag << '\t' << leftdata.results[0].winLStart << "-" << leftdata.results[0].winLEnd << '\t' << leftdata.results[0].winRStart << "-" << leftdata.results[0].winREnd << '\t';
-               
-               }else if ((!leftChimeric) && (rightChimeric)) {  //print right
-                       out << querySeq.getName() << '\t';
-                       out << rightdata.results[0].parentA.getName() << "\t" << rightdata.results[0].parentB.getName()  << '\t';
-                       
-                       out << rightdata.results[0].divr_qla_qrb << '\t' << rightdata.results[0].qla_qrb << '\t' << rightdata.results[0].bsa << '\t';
-                       out << rightdata.results[0].divr_qlb_qra << '\t' << rightdata.results[0].qlb_qra << '\t' << rightdata.results[0].bsb << '\t';
-                       
-                       out << flag << '\t' << rightdata.results[0].winLStart << "-" << rightdata.results[0].winLEnd << '\t' << rightdata.results[0].winRStart << "-" << rightdata.results[0].winREnd << '\t';                  
-                       
-               }else  { //print both results
-                       if (leftdata.flag == "yes") {
-                               out << querySeq.getName() + "_LEFT" << '\t';
-                               out << leftdata.results[0].parentA.getName() << "\t" << leftdata.results[0].parentB.getName()  << '\t';
-                               
-                               out << leftdata.results[0].divr_qla_qrb << '\t' << leftdata.results[0].qla_qrb << '\t' << leftdata.results[0].bsa << '\t';
-                               out << leftdata.results[0].divr_qlb_qra << '\t' << leftdata.results[0].qlb_qra << '\t' << leftdata.results[0].bsb << '\t';
-                               
-                               out << flag << '\t' << leftdata.results[0].winLStart << "-" << leftdata.results[0].winLEnd << '\t' << leftdata.results[0].winRStart << "-" << leftdata.results[0].winREnd << '\t';
-                       }
-                       
-                       if (rightdata.flag == "yes") {
-                               if (leftdata.flag == "yes") { out << endl; }
-                               
-                               out << querySeq.getName() + "_RIGHT"<< '\t';
-                               out << rightdata.results[0].parentA.getName() << "\t" << rightdata.results[0].parentB.getName()  << '\t';
-                               
-                               out << rightdata.results[0].divr_qla_qrb << '\t' << rightdata.results[0].qla_qrb << '\t' << rightdata.results[0].bsa << '\t';
-                               out << rightdata.results[0].divr_qlb_qra << '\t' << rightdata.results[0].qlb_qra << '\t' << rightdata.results[0].bsb << '\t';
-                               
-                               out << flag << '\t' << rightdata.results[0].winLStart << "-" << rightdata.results[0].winLEnd << '\t' << rightdata.results[0].winRStart << "-" << rightdata.results[0].winREnd << '\t';                  
-               
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "printBlock");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-string ChimeraSlayer::getBlock(data_results leftdata, data_results rightdata, bool leftChimeric, bool rightChimeric, string flag){
-       try {
-               
-               string out = "";
-               
-               if ((leftChimeric) && (!rightChimeric)) { //get left
-                       out += querySeq.getName() + "\t";
-                       out += leftdata.results[0].parentA.getName() + "\t" + leftdata.results[0].parentB.getName() + "\t";
-                       
-                       out += toString(leftdata.results[0].divr_qla_qrb) + "\t" + toString(leftdata.results[0].qla_qrb) + "\t" + toString(leftdata.results[0].bsa) + "\t";
-                       out += toString(leftdata.results[0].divr_qlb_qra) + "\t" + toString(leftdata.results[0].qlb_qra) + "\t" + toString(leftdata.results[0].bsb) + "\t";
-                       
-                       out += flag + "\t" + toString(leftdata.results[0].winLStart) + "-" + toString(leftdata.results[0].winLEnd) + "\t" + toString(leftdata.results[0].winRStart) + "-" + toString(leftdata.results[0].winREnd) + "\t";
-                       
-               }else if ((!leftChimeric) && (rightChimeric)) {  //print right
-                       out += querySeq.getName() + "\t";
-                       out += rightdata.results[0].parentA.getName() + "\t" + rightdata.results[0].parentB.getName()  + "\t";
-                       
-                       out += toString(rightdata.results[0].divr_qla_qrb) + "\t" + toString(rightdata.results[0].qla_qrb) + "\t" + toString(rightdata.results[0].bsa) + "\t";
-                       out += toString(rightdata.results[0].divr_qlb_qra) + "\t" + toString(rightdata.results[0].qlb_qra) + "\t" + toString(rightdata.results[0].bsb) + "\t";
-                       
-                       out += flag + "\t" + toString(rightdata.results[0].winLStart) + "-" + toString(rightdata.results[0].winLEnd) + "\t" + toString(rightdata.results[0].winRStart) + "-" + toString(rightdata.results[0].winREnd) + "\t";                   
-                       
-               }else  { //print both results
-                       
-                       if (leftdata.flag == "yes") {
-                               out += querySeq.getName() + "_LEFT\t";
-                               out += leftdata.results[0].parentA.getName() + "\t" + leftdata.results[0].parentB.getName() + "\t";
-                               
-                               out += toString(leftdata.results[0].divr_qla_qrb) + "\t" + toString(leftdata.results[0].qla_qrb) + "\t" + toString(leftdata.results[0].bsa) + "\t";
-                               out += toString(leftdata.results[0].divr_qlb_qra) + "\t" + toString(leftdata.results[0].qlb_qra) + "\t" + toString(leftdata.results[0].bsb) + "\t";
-                               
-                               out += flag + "\t" + toString(leftdata.results[0].winLStart) + "-" + toString(leftdata.results[0].winLEnd) + "\t" + toString(leftdata.results[0].winRStart) + "-" + toString(leftdata.results[0].winREnd) + "\t";
-                       }
-                       
-                       if (rightdata.flag == "yes") {
-                               if (leftdata.flag == "yes") { out += "\n"; }
-                               out +=  querySeq.getName() + "_RIGHT\t";
-                               out += rightdata.results[0].parentA.getName() + "\t" + rightdata.results[0].parentB.getName()  + "\t";
-                               
-                               out += toString(rightdata.results[0].divr_qla_qrb) + "\t" + toString(rightdata.results[0].qla_qrb) + "\t" + toString(rightdata.results[0].bsa) + "\t";
-                               out += toString(rightdata.results[0].divr_qlb_qra) + "\t" + toString(rightdata.results[0].qlb_qra) + "\t" + toString(rightdata.results[0].bsb) + "\t";
-                               
-                               out += flag + "\t" + toString(rightdata.results[0].winLStart) + "-" + toString(rightdata.results[0].winLEnd) + "\t" + toString(rightdata.results[0].winRStart) + "-" + toString(rightdata.results[0].winREnd) + "\t";                   
-                       }
-               }
-               
-               return out;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getBlock");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-string ChimeraSlayer::getBlock(data_struct data, string flag){
-       try {
-               
-               string outputString = "";
-               
-               outputString += querySeq.getName() + "\t";
-               outputString += data.parentA.getName() + "\t" + data.parentB.getName()  + "\t";
-                       
-               outputString += toString(data.divr_qla_qrb) + "\t" + toString(data.qla_qrb) + "\t" + toString(data.bsa) + "\t";
-               outputString += toString(data.divr_qlb_qra) + "\t" + toString(data.qlb_qra) + "\t" + toString(data.bsb) + "\t";
-               
-               outputString += flag + "\t" + toString(data.winLStart) + "-" + toString(data.winLEnd) + "\t" + toString(data.winRStart) + "-" + toString(data.winREnd) + "\t";
-               
-               return outputString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getBlock");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<Sequence> ChimeraSlayer::getRefSeqs(Sequence q, vector<Sequence*>& thisTemplate, vector<Sequence*>& thisFilteredTemplate){
-       try {
-               
-               vector<Sequence> refSeqs;
-               
-               if (searchMethod == "distance") {
-                       //find closest seqs to query in template - returns copies of seqs so trim does not destroy - remember to deallocate
-                       Sequence* newSeq = new Sequence(q.getName(), q.getAligned());
-                       runFilter(newSeq);
-                       refSeqs = decalc.findClosest(*newSeq, thisTemplate, thisFilteredTemplate, numWanted, minSim);
-                       delete newSeq;
-               }else if (searchMethod == "blast")  {
-                       refSeqs = getBlastSeqs(q, thisTemplate, numWanted); //fills indexes
-               }else if (searchMethod == "kmer") {
-                       refSeqs = getKmerSeqs(q, thisTemplate, numWanted); //fills indexes
-               }else { m->mothurOut("not valid search."); exit(1);  } //should never get here
-               
-               return refSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getRefSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************/
-vector<Sequence> ChimeraSlayer::getBlastSeqs(Sequence q, vector<Sequence*>& db, int num) {
-       try {   
-               
-               vector<Sequence> refResults;
-               
-               //get parts of query
-               string queryUnAligned = q.getUnaligned();
-               string leftQuery = queryUnAligned.substr(0, int(queryUnAligned.length() * 0.33)); //first 1/3 of the sequence
-               string rightQuery = queryUnAligned.substr(int(queryUnAligned.length() * 0.66)); //last 1/3 of the sequence
-//cout << "whole length = " << queryUnAligned.length() << '\t' << "left length = " << leftQuery.length() << '\t' << "right length = "<< rightQuery.length() << endl;   
-               Sequence* queryLeft = new Sequence(q.getName(), leftQuery);
-               Sequence* queryRight = new Sequence(q.getName(), rightQuery);
-               
-               vector<int> tempIndexesLeft = databaseLeft->findClosestMegaBlast(queryLeft, num+1, minSim);
-               vector<int> tempIndexesRight = databaseLeft->findClosestMegaBlast(queryRight, num+1, minSim);
-                               
-               
-               //cout << q->getName() << '\t' << leftQuery << '\t' << "leftMatches = " << tempIndexesLeft.size() << '\t' << rightQuery << " rightMatches = " << tempIndexesRight.size() << endl;
-//             vector<int> smaller;
-//             vector<int> larger;
-//             
-//             if (tempIndexesRight.size() < tempIndexesLeft.size()) { smaller = tempIndexesRight;  larger = tempIndexesLeft;  }
-//             else { smaller = tempIndexesLeft;  larger = tempIndexesRight;  } 
-               
-               //merge results         
-               map<int, int> seen;
-               map<int, int>::iterator it;
-               vector<int> mergedResults;
-               
-               int index = 0;
-//             for (int i = 0; i < smaller.size(); i++) {
-               while(index < tempIndexesLeft.size() && index < tempIndexesRight.size()){
-                       
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-       
-                       //add left if you havent already
-                       it = seen.find(tempIndexesLeft[index]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesLeft[index]);
-                               seen[tempIndexesLeft[index]] = tempIndexesLeft[index];
-                       }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesRight[index]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesRight[index]);
-                               seen[tempIndexesRight[index]] = tempIndexesRight[index];
-                       }
-                       index++;
-               }
-
-               
-               for (int i = index; i < tempIndexesLeft.size(); i++) {
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesLeft[i]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesLeft[i]);
-                               seen[tempIndexesLeft[i]] = tempIndexesLeft[i];
-                       }
-               }
-
-               for (int i = index; i < tempIndexesRight.size(); i++) {
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesRight[i]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesRight[i]);
-                               seen[tempIndexesRight[i]] = tempIndexesRight[i];
-                       }
-               }
-               //string qname = q->getName().substr(0, q->getName().find_last_of('_'));        
-               //cout << qname << endl;        
-               
-               if (mergedResults.size() == 0) { numNoParents++; }
-               
-               for (int i = 0; i < mergedResults.size(); i++) {
-                       //cout << q->getName() << mergedResults[i]  << '\t' << db[mergedResults[i]]->getName() << endl; 
-                       if (db[mergedResults[i]]->getName() != q.getName()) { 
-                               Sequence temp(db[mergedResults[i]]->getName(), db[mergedResults[i]]->getAligned());
-                               refResults.push_back(temp);
-                       }
-               }
-               //cout << endl << endl;
-
-               delete queryRight;
-               delete queryLeft;
-               
-               return refResults;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getBlastSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<Sequence> ChimeraSlayer::getKmerSeqs(Sequence q, vector<Sequence*>& db, int num) {
-       try {   
-               vector<Sequence> refResults;
-               
-               //get parts of query
-               string queryUnAligned = q.getUnaligned();
-               string leftQuery = queryUnAligned.substr(0, int(queryUnAligned.length() * 0.33)); //first 1/3 of the sequence
-               string rightQuery = queryUnAligned.substr(int(queryUnAligned.length() * 0.66)); //last 1/3 of the sequence
-               
-               Sequence* queryLeft = new Sequence(q.getName(), leftQuery);
-               Sequence* queryRight = new Sequence(q.getName(), rightQuery);
-               
-               vector<int> tempIndexesLeft = databaseLeft->findClosestSequences(queryLeft, num);
-               vector<int> tempIndexesRight = databaseRight->findClosestSequences(queryRight, num);
-               
-               //merge results         
-               map<int, int> seen;
-               map<int, int>::iterator it;
-               vector<int> mergedResults;
-               
-               int index = 0;
-               //              for (int i = 0; i < smaller.size(); i++) {
-               while(index < tempIndexesLeft.size() && index < tempIndexesRight.size()){
-                       
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-                       
-                       //add left if you havent already
-                       it = seen.find(tempIndexesLeft[index]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesLeft[index]);
-                               seen[tempIndexesLeft[index]] = tempIndexesLeft[index];
-                       }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesRight[index]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesRight[index]);
-                               seen[tempIndexesRight[index]] = tempIndexesRight[index];
-                       }
-                       index++;
-               }
-               
-               
-               for (int i = index; i < tempIndexesLeft.size(); i++) {
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesLeft[i]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesLeft[i]);
-                               seen[tempIndexesLeft[i]] = tempIndexesLeft[i];
-                       }
-               }
-               
-               for (int i = index; i < tempIndexesRight.size(); i++) {
-                       if (m->control_pressed) { delete queryRight; delete queryLeft; return refResults; }
-                       
-                       //add right if you havent already
-                       it = seen.find(tempIndexesRight[i]);
-                       if (it == seen.end()) {  
-                               mergedResults.push_back(tempIndexesRight[i]);
-                               seen[tempIndexesRight[i]] = tempIndexesRight[i];
-                       }
-               }
-               
-               for (int i = 0; i < mergedResults.size(); i++) {
-                       //cout << mergedResults[i]  << '\t' << db[mergedResults[i]]->getName() << endl; 
-                       if (db[mergedResults[i]]->getName() != q.getName()) { 
-                               Sequence temp(db[mergedResults[i]]->getName(), db[mergedResults[i]]->getAligned());
-                               refResults.push_back(temp);
-                               
-                       }
-               }
-
-               //cout << endl;         
-               delete queryRight;
-               delete queryLeft;
-               
-               return refResults;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayer", "getKmerSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-
diff --git a/chimeraslayer.h b/chimeraslayer.h
deleted file mode 100644 (file)
index c409c50..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef CHIMERASLAYER_H
-#define CHIMERASLAYER_H
-
-/*
- *  chimeraslayer.h
- *  Mothur
- *
- *  Created by westcott on 9/25/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "chimera.h"
-#include "maligner.h"
-#include "slayer.h"
-
-
-
-//***********************************************************************/
-//This class was modeled after the chimeraSlayer written by the Broad Institute
-/***********************************************************************/
-
-class ChimeraSlayer : public Chimera {
-       
-       public:
-               ChimeraSlayer(string, string, bool, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string, int);
-               ChimeraSlayer(string, string, bool, map<string, int>&, string,  int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string, int);
-               ChimeraSlayer(string, string, bool, map<string, int>&, string,  int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string, int, bool);
-
-               ~ChimeraSlayer();
-               
-               int getChimeras(Sequence*);
-               Sequence print(ostream&, ostream&);
-               Sequence print(ostream&, ostream&, data_results, data_results);
-               void printHeader(ostream&);
-               int doPrep();
-               int getNumNoParents() { return numNoParents; }
-               data_results getResults() { return printResults; }
-               
-               #ifdef USE_MPI
-               Sequence print(MPI_File&, MPI_File&);
-               Sequence print(MPI_File&, MPI_File&, data_results, data_results);
-               #endif
-               
-       private:
-               Sequence querySeq;
-               Sequence trimQuery;
-               DeCalculator decalc;
-               Database* databaseRight;
-               Database* databaseLeft;
-               map<string, int> priority; //for template=self, seqname, seqAligned, abundance
-               set<string> chimericSeqs; //for template=self, so we don't add chimeric sequences to the userTemplate set
-               int numNoParents, threadID;
-       
-               vector<data_struct>  chimeraResults;
-               data_results printResults;
-               string chimeraFlags, searchMethod, fastafile, blastlocation;
-               bool realign, trimChimera;
-               int window, numWanted, kmerSize, match, misMatch, minSim, minCov, minBS, minSNP, parents, iters, increment;
-               float divR;
-       
-               void printBlock(data_struct, string, ostream&);
-               void printBlock(data_results, data_results, bool, bool, string, ostream&);
-               string getBlock(data_struct, string);
-               string getBlock(data_results, data_results, bool, bool, string);
-               //int readNameFile(string);
-               vector<Sequence*> getTemplate(Sequence, vector<Sequence*>&);
-               vector<Sequence> getRefSeqs(Sequence, vector<Sequence*>&, vector<Sequence*>&);
-               vector<Sequence> getBlastSeqs(Sequence, vector<Sequence*>&, int);
-               vector<Sequence> getKmerSeqs(Sequence, vector<Sequence*>&, int);
-               
-};
-
-/************************************************************************/
-
-#endif
-
-
diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp
deleted file mode 100644 (file)
index 2c435ca..0000000
+++ /dev/null
@@ -1,1884 +0,0 @@
-/*
- *  chimeraslayercommand.cpp
- *  Mothur
- *
- *  Created by westcott on 3/31/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimeraslayercommand.h"
-#include "deconvolutecommand.h"
-#include "referencedb.h"
-#include "sequenceparser.h"
-
-//**********************************************************************************************************************
-vector<string> ChimeraSlayerCommand::setParameters(){  
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pwindow("window", "Number", "", "50", "", "", "",false,false); parameters.push_back(pwindow);
-               CommandParameter pksize("ksize", "Number", "", "7", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmatch("match", "Number", "", "5.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-4.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pminsim("minsim", "Number", "", "90", "", "", "",false,false); parameters.push_back(pminsim);
-               CommandParameter pmincov("mincov", "Number", "", "70", "", "", "",false,false); parameters.push_back(pmincov);
-               CommandParameter pminsnp("minsnp", "Number", "", "10", "", "", "",false,false); parameters.push_back(pminsnp);
-               CommandParameter pminbs("minbs", "Number", "", "90", "", "", "",false,false); parameters.push_back(pminbs);
-               CommandParameter psearch("search", "Multiple", "kmer-blast", "blast", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prealign("realign", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(prealign);
-               CommandParameter ptrim("trim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptrim);
-               CommandParameter psplit("split", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psplit);
-               CommandParameter pnumwanted("numwanted", "Number", "", "15", "", "", "",false,false); parameters.push_back(pnumwanted);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pdivergence("divergence", "Number", "", "1.007", "", "", "",false,false); parameters.push_back(pdivergence);
-               CommandParameter pparents("parents", "Number", "", "3", "", "", "",false,false); parameters.push_back(pparents);
-               CommandParameter pincrement("increment", "Number", "", "5", "", "", "",false,false); parameters.push_back(pincrement);
-               CommandParameter pblastlocation("blastlocation", "String", "", "", "", "", "",false,false); parameters.push_back(pblastlocation);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraSlayerCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "The chimera.slayer command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
-               helpString += "This command was modeled after the chimeraSlayer written by the Broad Institute.\n";
-               helpString += "The chimera.slayer command parameters are fasta, name, template, processors, trim, ksize, window, match, mismatch, divergence. minsim, mincov, minbs, minsnp, parents, search, iters, increment, numwanted, blastlocation and realign.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required, unless you have a valid current fasta file. \n";
-               helpString += "The name parameter allows you to provide a name file, if you are using reference=self. \n";
-               helpString += "The group parameter allows you to provide a group file. The group file can be used with a namesfile and reference=self. When checking sequences, only sequences from the same group as the query sequence will be used as the reference. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amazon.fasta \n";
-               helpString += "The reference parameter allows you to enter a reference file containing known non-chimeric sequences, and is required. You may also set template=self, in this case the abundant sequences will be used as potential parents. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The trim parameter allows you to output a new fasta file containing your sequences with the chimeric ones trimmed to include only their longest piece, default=F. \n";
-               helpString += "The split parameter allows you to check both pieces of non-chimeric sequence for chimeras, thus looking for trimeras and quadmeras. default=F. \n";
-               helpString += "The window parameter allows you to specify the window size for searching for chimeras, default=50. \n";
-               helpString += "The increment parameter allows you to specify how far you move each window while finding chimeric sequences, default=5.\n";
-               helpString += "The numwanted parameter allows you to specify how many sequences you would each query sequence compared with, default=15.\n";
-               helpString += "The ksize parameter allows you to input kmersize, default is 7, used if search is kmer. \n";
-               helpString += "The match parameter allows you to reward matched bases in blast search, default is 5. \n";
-               helpString += "The parents parameter allows you to select the number of potential parents to investigate from the numwanted best matches after rating them, default is 3. \n";
-               helpString += "The mismatch parameter allows you to penalize mismatched bases in blast search, default is -4. \n";
-               helpString += "The divergence parameter allows you to set a cutoff for chimera determination, default is 1.007. \n";
-               helpString += "The iters parameter allows you to specify the number of bootstrap iters to do with the chimeraslayer method, default=1000.\n";
-               helpString += "The minsim parameter allows you to specify a minimum similarity with the parent fragments, default=90. \n";
-               helpString += "The mincov parameter allows you to specify minimum coverage by closest matches found in template. Default is 70, meaning 70%. \n";
-               helpString += "The minbs parameter allows you to specify minimum bootstrap support for calling a sequence chimeric. Default is 90, meaning 90%. \n";
-               helpString += "The minsnp parameter allows you to specify percent of SNPs to sample on each side of breakpoint for computing bootstrap support (default: 10) \n";
-               helpString += "The search parameter allows you to specify search method for finding the closest parent. Choices are blast, and kmer, default blast. \n";
-               helpString += "The realign parameter allows you to realign the query to the potential parents. Choices are true or false, default true.  \n";
-               helpString += "The blastlocation parameter allows you to specify the location of your blast executable. By default mothur will look in ./blast/bin relative to mothur's executable.  \n";
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The chimera.slayer command should be in the following format: \n";
-               helpString += "chimera.slayer(fasta=yourFastaFile, reference=yourTemplate, search=yourSearch) \n";
-               helpString += "Example: chimera.slayer(fasta=AD.align, reference=core_set_aligned.imputed.fasta, search=kmer) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraSlayerCommand::ChimeraSlayerCommand(){  
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "ChimeraSlayerCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraSlayerCommand::ChimeraSlayerCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.slayer");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                                               
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       
-                       //check for required parameters
-                       bool hasName = true;
-                       namefile = validParameter.validFile(parameters, "name", false);
-                       if (namefile == "not found") { namefile = "";  hasName = false; }
-                       else { 
-                               m->splitAtDash(namefile, nameFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < nameFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (nameFileNames[i] == "current") { 
-                                               nameFileNames[i] = m->getNameFile(); 
-                                               if (nameFileNames[i] != "") {  m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(nameFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       nameFileNames[i] = inputDir + nameFileNames[i];         }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setNameFile(nameFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (nameFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid name files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasName && (nameFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of namefiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       bool hasGroup = true;
-                       groupfile = validParameter.validFile(parameters, "group", false);
-                       if (groupfile == "not found") { groupfile = "";  hasGroup = false; }
-                       else { 
-                               m->splitAtDash(groupfile, groupFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < groupFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (groupFileNames[i] == "current") { 
-                                               groupFileNames[i] = m->getGroupFile(); 
-                                               if (groupFileNames[i] != "") {  m->mothurOut("Using " + groupFileNames[i] + " as input file for the group parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(groupFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       groupFileNames[i] = inputDir + groupFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(groupFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + groupFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setGroupFile(groupFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (groupFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid group files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasGroup && (groupFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of groupfiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       string path;
-                       it = parameters.find("reference");
-                       //user has given a template file
-                       if(it != parameters.end()){ 
-                               if (it->second == "self") { 
-                                       templatefile = "self"; 
-                                       if (save) {
-                                               m->mothurOut("[WARNING]: You can't save reference=self, ignoring save."); 
-                                               m->mothurOutEndLine();
-                                               save = false;
-                                       }
-                               }
-                               else {
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                                       
-                                       templatefile = validParameter.validFile(parameters, "reference", true);
-                                       if (templatefile == "not open") { abort = true; }
-                                       else if (templatefile == "not found") { //check for saved reference sequences
-                                               if (rdb->referenceSeqs.size() != 0) {
-                                                       templatefile = "saved";
-                                               }else {
-                                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                                       m->mothurOutEndLine();
-                                                       abort = true; 
-                                               }
-                                       }else { if (save) {     rdb->setSavedReference(templatefile);   }       }       
-                               }
-                       }else if (hasName) {  templatefile = "self"; 
-                               if (save) {
-                                       m->mothurOut("[WARNING]: You can't save reference=self, ignoring save."); 
-                                       m->mothurOutEndLine();
-                                       save = false;
-                               }
-                       }
-                       else { 
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templatefile = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       templatefile = ""; abort = true; 
-                               } 
-                       }
-                       
-                       
-                       
-                       temp = validParameter.validFile(parameters, "ksize", false);                    if (temp == "not found") { temp = "7"; }
-                       m->mothurConvert(temp, ksize);
-                                               
-                       temp = validParameter.validFile(parameters, "window", false);                   if (temp == "not found") { temp = "50"; }                       
-                       m->mothurConvert(temp, window);
-                       
-                       temp = validParameter.validFile(parameters, "match", false);                    if (temp == "not found") { temp = "5"; }
-                       m->mothurConvert(temp, match);
-                       
-                       temp = validParameter.validFile(parameters, "mismatch", false);                 if (temp == "not found") { temp = "-4"; }
-                       m->mothurConvert(temp, mismatch);
-                       
-                       temp = validParameter.validFile(parameters, "divergence", false);               if (temp == "not found") { temp = "1.007"; }
-                       m->mothurConvert(temp, divR);
-                       
-                       temp = validParameter.validFile(parameters, "minsim", false);                   if (temp == "not found") { temp = "90"; }
-                       m->mothurConvert(temp, minSimilarity);
-                       
-                       temp = validParameter.validFile(parameters, "mincov", false);                   if (temp == "not found") { temp = "70"; }
-                       m->mothurConvert(temp, minCoverage);
-                       
-                       temp = validParameter.validFile(parameters, "minbs", false);                    if (temp == "not found") { temp = "90"; }
-                       m->mothurConvert(temp, minBS);
-                       
-                       temp = validParameter.validFile(parameters, "minsnp", false);                   if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, minSNP);
-
-                       temp = validParameter.validFile(parameters, "parents", false);                  if (temp == "not found") { temp = "3"; }
-                       m->mothurConvert(temp, parents); 
-                       
-                       temp = validParameter.validFile(parameters, "realign", false);                  if (temp == "not found") { temp = "t"; }
-                       realign = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "trim", false);                             if (temp == "not found") { temp = "f"; }
-                       trim = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "split", false);                    if (temp == "not found") { temp = "f"; }
-                       trimera = m->isTrue(temp); 
-                       
-                       search = validParameter.validFile(parameters, "search", false);                 if (search == "not found") { search = "blast"; }
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }             
-                       m->mothurConvert(temp, iters); 
-                        
-                       temp = validParameter.validFile(parameters, "increment", false);                if (temp == "not found") { temp = "5"; }
-                       m->mothurConvert(temp, increment);
-                       
-                       temp = validParameter.validFile(parameters, "numwanted", false);                if (temp == "not found") { temp = "15"; }               
-                       m->mothurConvert(temp, numwanted);
-                       
-                       blastlocation = validParameter.validFile(parameters, "blastlocation", false);   
-                       if (blastlocation == "not found") { blastlocation = ""; }
-                       else {
-                               //add / to name if needed
-                               string lastChar = blastlocation.substr(blastlocation.length()-1);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               if (lastChar != "/") { blastlocation += "/"; }
-#else
-                               if (lastChar != "\\") { blastlocation += "\\"; }        
-#endif
-                               blastlocation = m->getFullPathName(blastlocation);
-                               string formatdbCommand = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               formatdbCommand = blastlocation + "formatdb";   
-#else
-                               formatdbCommand = blastlocation + "formatdb.exe";
-#endif
-                               
-                               //test to make sure formatdb exists
-                               ifstream in;
-                               formatdbCommand = m->getFullPathName(formatdbCommand);
-                               int ableToOpen = m->openInputFile(formatdbCommand, in, "no error"); in.close();
-                               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe to run chimera.slayer."); m->mothurOutEndLine(); abort = true; }
-                               
-                               string blastCommand = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               blastCommand = blastlocation + "megablast";     
-#else
-                               blastCommand = blastlocation + "megablast.exe";
-#endif
-                               //test to make sure formatdb exists
-                               ifstream in2;
-                               blastCommand = m->getFullPathName(blastCommand);
-                               ableToOpen = m->openInputFile(blastCommand, in2, "no error"); in2.close();
-                               if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + blastCommand + " file does not exist. mothur requires blastall.exe to run chimera.slayer."); m->mothurOutEndLine(); abort = true; }
-                       }
-
-                       if ((search != "blast") && (search != "kmer")) { m->mothurOut(search + " is not a valid search."); m->mothurOutEndLine(); abort = true;  }
-                       
-                       if (hasName && (templatefile != "self")) { m->mothurOut("You have provided a namefile and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
-                       if (hasGroup && (templatefile != "self")) { m->mothurOut("You have provided a group file and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
-
-                       //until we resolve the issue 10-18-11
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-                       //processors=1;
-#endif
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "ChimeraSlayerCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ChimeraSlayerCommand::execute(){
-       try{
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                               
-                       m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-               
-                       int start = time(NULL); 
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "slayer.accnos";
-                       string trimFastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "slayer.fasta";           
-                       
-                       //clears files
-                       ofstream out, out1, out2;
-                       m->openOutputFile(outputFileName, out); out.close(); 
-                       m->openOutputFile(accnosFileName, out1); out1.close();
-                       if (trim) { m->openOutputFile(trimFastaFileName, out2); out2.close(); }
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
-                       if (trim) {  outputNames.push_back(trimFastaFileName); outputTypes["fasta"].push_back(trimFastaFileName); }                     
-                       
-                       //maps a filename to priority map. 
-                       //if no groupfile this is fastafileNames[s] -> prioirity
-                       //if groupfile then this is each groups seqs -> priority
-                       map<string, map<string, int> > fileToPriority; 
-                       map<string, map<string, int> >::iterator itFile;
-                       map<string, string> fileGroup;
-                       fileToPriority[fastaFileNames[s]] = priority; //default
-                       fileGroup[fastaFileNames[s]] = "noGroup";
-                       SequenceParser* parser = NULL;
-                       int totalChimeras = 0;
-                       lines.clear();
-                       
-                       if (templatefile == "self") { setUpForSelfReference(parser, fileGroup, fileToPriority, s); }
-                       
-                       if (m->control_pressed) {  if (parser != NULL) { delete parser; } for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0;    }
-
-                       if (fileToPriority.size() == 1) { //you running without a groupfile
-                               itFile = fileToPriority.begin();
-                               string thisFastaName = itFile->first;
-                               map<string, int> thisPriority = itFile->second;
-#ifdef USE_MPI 
-                               MPIExecute(thisFastaName, outputFileName, accnosFileName, trimFastaFileName, thisPriority);
-#else
-                               //break up file
-                               vector<unsigned long long> positions; 
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               positions = m->divideFile(thisFastaName, processors);
-                               for (int i = 0; i < (positions.size()-1); i++) {        lines.push_back(linePair(positions[i], positions[(i+1)]));      }
-#else
-                               if (processors == 1) {  lines.push_back(linePair(0, 1000)); }
-                               else {
-                                       positions = m->setFilePosFasta(thisFastaName, numSeqs); 
-                    if (positions.size() < processors) { processors = positions.size(); }
-                                       
-                                       //figure out how many sequences you have to process
-                                       int numSeqsPerProcessor = numSeqs / processors;
-                                       for (int i = 0; i < processors; i++) {
-                                               int startIndex =  i * numSeqsPerProcessor;
-                                               if(i == (processors - 1)){      numSeqsPerProcessor = numSeqs - i * numSeqsPerProcessor;        }
-                                               lines.push_back(linePair(positions[startIndex], numSeqsPerProcessor));
-                                       }
-                               }
-#endif
-                               if(processors == 1){ numSeqs = driver(lines[0], outputFileName, thisFastaName, accnosFileName, trimFastaFileName, thisPriority);  }
-                               else{ numSeqs = createProcesses(outputFileName, thisFastaName, accnosFileName, trimFastaFileName, thisPriority); }
-                               
-                               if (m->control_pressed) { if (parser != NULL) { delete parser; }  outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0; }                          
-#endif
-                       }else { //you have provided a groupfile
-#ifdef USE_MPI 
-                               MPIExecuteGroups(outputFileName, accnosFileName, trimFastaFileName, fileToPriority, fileGroup);
-#else
-                               if (processors == 1) { numSeqs = driverGroups(outputFileName, accnosFileName, trimFastaFileName, fileToPriority, fileGroup);    }
-                               else {  numSeqs = createProcessesGroups(outputFileName, accnosFileName, trimFastaFileName, fileToPriority, fileGroup);          } //destroys fileToPriority
-#endif
-
-#ifdef USE_MPI 
-                               int pid; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               
-                               if (pid == 0) {
-#endif
-                               
-                               totalChimeras = deconvoluteResults(parser, outputFileName, accnosFileName, trimFastaFileName);
-#ifdef USE_MPI 
-                               }
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait
-#endif
-                       }
-       
-                       if (parser != NULL) { delete parser; } 
-                       
-                       m->mothurOutEndLine(); m->mothurOut(toString(totalChimeras) + " chimera found."); m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences.");       m->mothurOutEndLine();
-               }
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               if (trim) {
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraSlayerCommand::MPIExecuteGroups(string outputFileName, string accnosFileName, string trimFastaFileName, map<string, map<string, int> >& fileToPriority, map<string, string>& fileGroup){
-       try {
-#ifdef USE_MPI 
-               int pid; 
-               int tag = 2001;
-               
-               MPI_Status status; 
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-       
-               //put filenames in a vector, then pass each process a starting and ending point in the vector
-               //all processes already have the fileToPriority and fileGroup, they just need to know which files to process
-               map<string, map<string, int> >::iterator itFile;
-               vector<string> filenames;
-               for(itFile = fileToPriority.begin(); itFile != fileToPriority.end(); itFile++) { filenames.push_back(itFile->first); }
-               
-               int numGroupsPerProcessor = filenames.size() / processors;
-               int startIndex =  pid * numGroupsPerProcessor;
-               int endIndex = (pid+1) * numGroupsPerProcessor;
-               if(pid == (processors - 1)){    endIndex = filenames.size();    }
-               
-               vector<unsigned long long> MPIPos;
-               
-               MPI_File outMPI;
-               MPI_File outMPIAccnos;
-               MPI_File outMPIFasta;
-               
-               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-               int inMode=MPI_MODE_RDONLY; 
-               
-               char outFilename[1024];
-               strcpy(outFilename, outputFileName.c_str());
-               
-               char outAccnosFilename[1024];
-               strcpy(outAccnosFilename, accnosFileName.c_str());
-               
-               char outFastaFilename[1024];
-               strcpy(outFastaFilename, trimFastaFileName.c_str());
-               
-               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-               MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-               if (trim) { MPI_File_open(MPI_COMM_WORLD, outFastaFilename, outMode, MPI_INFO_NULL, &outMPIFasta); }
-               
-               if (m->control_pressed) {   MPI_File_close(&outMPI); if (trim) {  MPI_File_close(&outMPIFasta);  } MPI_File_close(&outMPIAccnos);  return 0;  }
-               
-               //print headers
-               if (pid == 0) { //you are the root process 
-                       m->mothurOutEndLine();
-                       m->mothurOut("Only reporting sequence supported by " + toString(minBS) + "% of bootstrapped results.");
-                       m->mothurOutEndLine();
-                       
-                       string outTemp = "Name\tLeftParent\tRightParent\tDivQLAQRB\tPerIDQLAQRB\tBootStrapA\tDivQLBQRA\tPerIDQLBQRA\tBootStrapB\tFlag\tLeftWindow\tRightWindow\n";
-                       
-                       //print header
-                       int length = outTemp.length();
-                       char* buf2 = new char[length];
-                       memcpy(buf2, outTemp.c_str(), length);
-                       
-                       MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
-                       delete buf2;
-               }
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait
-               
-               for (int i = startIndex; i < endIndex; i++) {
-                       
-                       int start = time(NULL);
-                       int num = 0;
-                       string thisFastaName = filenames[i];
-                       map<string, int> thisPriority = fileToPriority[thisFastaName];
-                       
-                       char inFileName[1024];
-                       strcpy(inFileName, thisFastaName.c_str());
-                       MPI_File inMPI;
-                       MPI_File_open(MPI_COMM_SELF, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                       
-                       MPIPos = m->setFilePosFasta(thisFastaName, num); //fills MPIPos, returns numSeqs
-                       
-                       cout << endl << "Checking sequences from group: " << fileGroup[thisFastaName] << "." << endl; 
-                       
-                       driverMPI(0, num, inMPI, outMPI, outMPIAccnos, outMPIFasta, MPIPos, thisFastaName, thisPriority, true);
-                       numSeqs += num;
-                       
-                       MPI_File_close(&inMPI);
-                       m->mothurRemove(thisFastaName);
-                                               
-                       cout << endl << "It took " << toString(time(NULL) - start) << " secs to check " + toString(num) + " sequences from group " << fileGroup[thisFastaName] << "." << endl;
-               }
-               
-               if (pid == 0) {
-                       for(int i = 1; i < processors; i++) { 
-                               int temp = 0;
-                               MPI_Recv(&temp, 1, MPI_INT, i, 2001, MPI_COMM_WORLD, &status);
-                               numSeqs += temp;
-                       }
-               }else{ MPI_Send(&numSeqs, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD); }
-               
-               MPI_File_close(&outMPI);
-               MPI_File_close(&outMPIAccnos); 
-               if (trim) { MPI_File_close(&outMPIFasta); }
-               
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait
-#endif
-               return 0;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "MPIExecuteGroups");
-               exit(1);
-       }
-}              
-//**********************************************************************************************************************
-int ChimeraSlayerCommand::MPIExecute(string inputFile, string outputFileName, string accnosFileName, string trimFastaFileName, map<string, int>& priority){
-       try {
-               
-#ifdef USE_MPI 
-               int pid, numSeqsPerProcessor; 
-               int tag = 2001;
-               vector<unsigned long long> MPIPos;
-               
-               MPI_Status status; 
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-               
-               MPI_File inMPI;
-               MPI_File outMPI;
-               MPI_File outMPIAccnos;
-               MPI_File outMPIFasta;
-               
-               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-               int inMode=MPI_MODE_RDONLY; 
-               
-               char outFilename[1024];
-               strcpy(outFilename, outputFileName.c_str());
-               
-               char outAccnosFilename[1024];
-               strcpy(outAccnosFilename, accnosFileName.c_str());
-               
-               char outFastaFilename[1024];
-               strcpy(outFastaFilename, trimFastaFileName.c_str());
-               
-               char inFileName[1024];
-               strcpy(inFileName, inputFile.c_str());
-               
-               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-               MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-               if (trim) { MPI_File_open(MPI_COMM_WORLD, outFastaFilename, outMode, MPI_INFO_NULL, &outMPIFasta); }
-               
-               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI); if (trim) {  MPI_File_close(&outMPIFasta);  } MPI_File_close(&outMPIAccnos);  return 0;  }
-               
-               if (pid == 0) { //you are the root process 
-                       m->mothurOutEndLine();
-                       m->mothurOut("Only reporting sequence supported by " + toString(minBS) + "% of bootstrapped results.");
-                       m->mothurOutEndLine();
-                       
-                       string outTemp = "Name\tLeftParent\tRightParent\tDivQLAQRB\tPerIDQLAQRB\tBootStrapA\tDivQLBQRA\tPerIDQLBQRA\tBootStrapB\tFlag\tLeftWindow\tRightWindow\n";
-                       
-                       //print header
-                       int length = outTemp.length();
-                       char* buf2 = new char[length];
-                       memcpy(buf2, outTemp.c_str(), length);
-                       
-                       MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
-                       delete buf2;
-                       
-                       MPIPos = m->setFilePosFasta(inputFile, numSeqs); //fills MPIPos, returns numSeqs
-                       
-                       if (templatefile != "self") { //if template=self we can only use 1 processor
-                               //send file positions to all processes
-                               for(int i = 1; i < processors; i++) { 
-                                       MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                               }
-                       }
-                       //figure out how many sequences you have to align
-                       numSeqsPerProcessor = numSeqs / processors;
-                       int startIndex =  pid * numSeqsPerProcessor;
-                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                       
-                       if (templatefile == "self") { //if template=self we can only use 1 processor
-                               startIndex = 0;
-                               numSeqsPerProcessor = numSeqs;
-                       }
-                       
-                       //do your part
-                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, outMPIFasta, MPIPos, inputFile, priority, false);
-                                               
-                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); }  MPI_File_close(&outMPIAccnos);   return 0;  }
-                       
-               }else{ //you are a child process
-                       if (templatefile != "self") { //if template=self we can only use 1 processor
-                               MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPIPos.resize(numSeqs+1);
-                               MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                               //figure out how many sequences you have to align
-                               numSeqsPerProcessor = numSeqs / processors;
-                               int startIndex =  pid * numSeqsPerProcessor;
-                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                               
-                               //do your part
-                               driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, outMPIFasta, MPIPos, inputFile, priority, false);
-                               
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI); if (trim) { MPI_File_close(&outMPIFasta); }  MPI_File_close(&outMPIAccnos);  return 0;  }
-                               
-                       }
-               }
-               
-               //close files 
-               MPI_File_close(&inMPI);
-               MPI_File_close(&outMPI);
-               MPI_File_close(&outMPIAccnos); 
-               if (trim) { MPI_File_close(&outMPIFasta); }
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               
-               
-#endif         
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "MPIExecute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraSlayerCommand::deconvoluteResults(SequenceParser* parser, string outputFileName, string accnosFileName, string trimFileName){
-       try {
-               map<string, string> uniqueNames = parser->getAllSeqsMap();
-               map<string, string>::iterator itUnique;
-               int total = 0;
-        
-        if (trimera) { //add in more potential uniqueNames
-            map<string, string> newUniqueNames = uniqueNames;
-            for (map<string, string>::iterator it = uniqueNames.begin(); it != uniqueNames.end(); it++) {
-                newUniqueNames[(it->first)+"_LEFT"] = (it->first)+"_LEFT";
-                newUniqueNames[(it->first)+"_RIGHT"] = (it->first)+"_RIGHT";
-            }
-            uniqueNames = newUniqueNames;
-            newUniqueNames.clear();
-        }
-               
-               //edit accnos file
-               ifstream in2; 
-               m->openInputFile(accnosFileName, in2, "no error");
-               
-               ofstream out2;
-               m->openOutputFile(accnosFileName+".temp", out2);
-               
-               string name; name = "";
-               set<string> chimerasInFile;
-               set<string>::iterator itChimeras;
-               
-               while (!in2.eof()) {
-                       if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName+".temp")); return 0; }
-                       
-                       in2 >> name; m->gobble(in2);
-                       
-                       //find unique name
-                       itUnique = uniqueNames.find(name);
-                       
-                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       else {
-                               itChimeras = chimerasInFile.find((itUnique->second));
-                               
-                               if (itChimeras == chimerasInFile.end()) {
-                                       out2 << itUnique->second << endl;
-                                       chimerasInFile.insert((itUnique->second));
-                                       total++;
-                               }
-                       }
-               }
-               in2.close();
-               out2.close();
-               
-               m->mothurRemove(accnosFileName);
-               rename((accnosFileName+".temp").c_str(), accnosFileName.c_str());
-               
-               
-               //edit chimera file
-               ifstream in; 
-               m->openInputFile(outputFileName, in);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName+".temp", out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-
-               string rest, parent1, parent2, line;
-               set<string> namesInFile; //this is so if a sequence is found to be chimera in several samples we dont write it to the results file more than once
-               set<string>::iterator itNames;
-               
-               //assumptions - in file each read will always look like...
-               /*
-                F11Fcsw_92754  no
-                F11Fcsw_63104  F11Fcsw_33372   F11Fcsw_37007   0.89441 80.4469 0.2     1.03727 93.2961 52.2    no      0-241   243-369 
-                */
-               
-               //get header line
-               if (!in.eof()) {
-                       line = m->getline(in); m->gobble(in);
-                       out << line << endl;
-               }
-               
-               //for the chimera file, we want to make sure if any group finds a sequence to be chimeric then all groups do, 
-               //so if this is a report that did not find it to be chimeric, but it appears in the accnos file, 
-               //then ignore this report and continue until we find the report that found it to be chimeric
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove((outputFileName+".temp")); return 0; }
-                       
-                       in >> name;             m->gobble(in);
-                       in >> parent1;  m->gobble(in);
-                       
-                       if (name == "Name") { //name = "Name" because we append the header line each time we add results from the groups
-                               line = m->getline(in); m->gobble(in);
-                       }else {
-                               if (parent1 == "no") {
-                                       //find unique name
-                                       itUnique = uniqueNames.find(name);
-                                       
-                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else {
-                                               //is this sequence really not chimeric??
-                                               itChimeras = chimerasInFile.find(itUnique->second);
-                                               
-                                               if (itChimeras == chimerasInFile.end()) {
-                                                       //is this sequence not already in the file
-                                                       itNames = namesInFile.find((itUnique->second));
-                                                       
-                                                       if (itNames == namesInFile.end()) { out << itUnique->second << '\t' << "no" << endl; namesInFile.insert(itUnique->second); }
-                                               }
-                                       }
-                               }else { //read the rest of the line
-                                       double DivQLAQRB,PerIDQLAQRB,BootStrapA,DivQLBQRA,PerIDQLBQRA,BootStrapB;
-                                       string flag, range1, range2;
-                                       bool print = false;
-                                       in >> parent2 >> DivQLAQRB >> PerIDQLAQRB >> BootStrapA >> DivQLBQRA >> PerIDQLBQRA >> BootStrapB >> flag >> range1 >> range2;  m->gobble(in);
-                                       
-                                       //find unique name
-                                       itUnique = uniqueNames.find(name);
-                                       
-                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else {
-                                               name = itUnique->second;
-                                               //is this name already in the file
-                                               itNames = namesInFile.find((name));
-                                               
-                                               if (itNames == namesInFile.end()) { //no not in file
-                                                       if (flag == "no") { //are you really a no??
-                                                               //is this sequence really not chimeric??
-                                                               itChimeras = chimerasInFile.find(name);
-                                                               
-                                                               //then you really are a no so print, otherwise skip
-                                                               if (itChimeras == chimerasInFile.end()) { print = true; }
-                                                               
-                                                       }else{ print = true; }
-                                               }
-                                       }
-                                       
-                                       if (print) {
-                                               out << name << '\t';
-                                               
-                                               namesInFile.insert(name);
-
-                                               //output parent1's name
-                                               itUnique = uniqueNames.find(parent1);
-                                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parentA "+ parent1 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else { out << itUnique->second << '\t'; }
-                                               
-                                               //output parent2's name
-                                               itUnique = uniqueNames.find(parent2);
-                                               if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parentA "+ parent2 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else { out << itUnique->second << '\t'; }
-                                               
-                                               out << DivQLAQRB << '\t' << PerIDQLAQRB << '\t' << BootStrapA << '\t' << DivQLBQRA << '\t' << PerIDQLBQRA << '\t' << BootStrapB << '\t' << flag << '\t' << range1 << '\t' << range2 << endl;
-                                       }
-                               }                               
-                       }
-               }
-               in.close();
-               out.close();
-               
-               m->mothurRemove(outputFileName);
-               rename((outputFileName+".temp").c_str(), outputFileName.c_str());
-               
-               //edit fasta file
-               if (trim) {
-                       ifstream in3; 
-                       m->openInputFile(trimFileName, in3);
-                       
-                       ofstream out3;
-                       m->openOutputFile(trimFileName+".temp", out3);
-                       
-                       namesInFile.clear();
-                       
-                       while (!in3.eof()) {
-                               if (m->control_pressed) { in3.close(); out3.close(); m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); m->mothurRemove((trimFileName+".temp")); return 0; }
-                               
-                               Sequence seq(in3); m->gobble(in3);
-                               
-                               if (seq.getName() != "") {
-                                       //find unique name
-                                       itUnique = uniqueNames.find(seq.getName());
-                                       
-                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find "+ seq.getName() + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else {
-                                               itNames = namesInFile.find((itUnique->second));
-                                               
-                                               if (itNames == namesInFile.end()) {
-                                                       seq.printSequence(out3);
-                                               }
-                                       }
-                               }
-                       }
-                       in3.close();
-                       out3.close();
-                       
-                       m->mothurRemove(trimFileName);
-                       rename((trimFileName+".temp").c_str(), trimFileName.c_str());
-               }
-               
-               return total;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "deconvoluteResults");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraSlayerCommand::setUpForSelfReference(SequenceParser*& parser, map<string, string>& fileGroup, map<string, map<string, int> >& fileToPriority, int s){
-       try {
-               fileGroup.clear();
-               fileToPriority.clear();
-               
-               string nameFile = "";
-               if (nameFileNames.size() != 0) { //you provided a namefile and we don't need to create one
-                       nameFile = nameFileNames[s];
-               }else {  nameFile = getNamesFile(fastaFileNames[s]); }
-               
-               //you provided a groupfile
-               string groupFile = "";
-               if (groupFileNames.size() != 0) { groupFile = groupFileNames[s]; }
-               
-               if (groupFile == "") { 
-                       if (processors != 1) { m->mothurOut("When using template=self, mothur can only use 1 processor, continuing."); m->mothurOutEndLine(); processors = 1; }
-                                               
-                       //sort fastafile by abundance, returns new sorted fastafile name
-                       m->mothurOut("Sorting fastafile according to abundance..."); cout.flush(); 
-                       priority = sortFastaFile(fastaFileNames[s], nameFile);
-                       m->mothurOut("Done."); m->mothurOutEndLine();
-                       
-                       fileToPriority[fastaFileNames[s]] = priority;
-                       fileGroup[fastaFileNames[s]] = "noGroup";
-               }else {
-                       //Parse sequences by group
-                       parser = new SequenceParser(groupFile, fastaFileNames[s], nameFile);
-                       vector<string> groups = parser->getNamesOfGroups();
-                       
-                       for (int i = 0; i < groups.size(); i++) {
-                               vector<Sequence> thisGroupsSeqs = parser->getSeqs(groups[i]);
-                               map<string, string> thisGroupsMap = parser->getNameMap(groups[i]);
-                               string newFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + groups[i] + "-sortedTemp.fasta";
-                               priority = sortFastaFile(thisGroupsSeqs, thisGroupsMap, newFastaFile); 
-                               fileToPriority[newFastaFile] = priority;
-                               fileGroup[newFastaFile] = groups[i];
-                       }
-               }
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "setUpForSelfReference");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-string ChimeraSlayerCommand::getNamesFile(string& inputFile){
-       try {
-               string nameFile = "";
-               
-               m->mothurOutEndLine(); m->mothurOut("No namesfile given, running unique.seqs command to generate one."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               //use unique.seqs to create new name and fastafile
-               string inputString = "fasta=" + inputFile;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-               m->mothurCalling = true;
-        
-               Command* uniqueCommand = new DeconvoluteCommand(inputString);
-               uniqueCommand->execute();
-               
-               map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-               
-               delete uniqueCommand;
-               m->mothurCalling = false;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               
-               nameFile = filenames["name"][0];
-               inputFile = filenames["fasta"][0];
-               
-               return nameFile;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "getNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChimeraSlayerCommand::driverGroups(string outputFName, string accnos, string fasta, map<string, map<string, int> >& fileToPriority, map<string, string>& fileGroup){
-       try {
-               int totalSeqs = 0;
-               
-               for (map<string, map<string, int> >::iterator itFile = fileToPriority.begin(); itFile != fileToPriority.end(); itFile++) {
-                       
-                       if (m->control_pressed) {  return 0;  }
-                       
-                       int start = time(NULL);
-                       string thisFastaName = itFile->first;
-                       map<string, int> thisPriority = itFile->second;
-                       string thisoutputFileName = outputDir + m->getRootName(m->getSimpleName(thisFastaName)) + fileGroup[thisFastaName] + "slayer.chimera";
-                       string thisaccnosFileName = outputDir + m->getRootName(m->getSimpleName(thisFastaName)) + fileGroup[thisFastaName] + "slayer.accnos";
-                       string thistrimFastaFileName = outputDir + m->getRootName(m->getSimpleName(thisFastaName)) + fileGroup[thisFastaName] + "slayer.fasta";
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Checking sequences from group: " + fileGroup[thisFastaName] + "."); m->mothurOutEndLine(); 
-                       
-                       lines.clear();
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       int proc = 1;
-                       vector<unsigned long long> positions = m->divideFile(thisFastaName, proc);
-                       lines.push_back(linePair(positions[0], positions[1]));  
-#else
-                       lines.push_back(linePair(0, 1000)); 
-#endif                 
-                       int numSeqs = driver(lines[0], thisoutputFileName, thisFastaName, thisaccnosFileName, thistrimFastaFileName, thisPriority);
-                       
-                       //append files
-                       m->appendFiles(thisoutputFileName, outputFName); m->mothurRemove(thisoutputFileName); 
-                       m->appendFiles(thisaccnosFileName, accnos); m->mothurRemove(thisaccnosFileName);
-                       if (trim) { m->appendFiles(thistrimFastaFileName, fasta); m->mothurRemove(thistrimFastaFileName); }
-                       m->mothurRemove(thisFastaName);
-                       
-                       totalSeqs += numSeqs;
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + fileGroup[thisFastaName] + ".");     m->mothurOutEndLine();
-               }
-               
-               return totalSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "driverGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int ChimeraSlayerCommand::createProcessesGroups(string outputFName, string accnos, string fasta, map<string, map<string, int> >& fileToPriority, map<string, string>& fileGroup) {
-       try {
-               int process = 1;
-               int num = 0;
-               processIDS.clear();
-               
-               if (fileToPriority.size() < processors) { processors = fileToPriority.size(); }
-               
-               int groupsPerProcessor = fileToPriority.size() / processors;
-               int remainder = fileToPriority.size() % processors;
-               
-               vector< map<string, map<string, int> > > breakUp;
-               
-               for (int i = 0; i < processors; i++) {
-                       map<string, map<string, int> > thisFileToPriority;
-                       map<string, map<string, int> >::iterator itFile;
-                       int count = 0;
-                       int enough = groupsPerProcessor;
-                       if (i == 0) { enough = groupsPerProcessor + remainder; }
-                       
-                       for (itFile = fileToPriority.begin(); itFile != fileToPriority.end();) {
-                               thisFileToPriority[itFile->first] = itFile->second;
-                               fileToPriority.erase(itFile++);
-                               count++;
-                               if (count == enough) { break; }
-                       }       
-                       breakUp.push_back(thisFileToPriority);
-               }
-                               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverGroups(outputFName + toString(getpid()) + ".temp", accnos + toString(getpid()) + ".temp", fasta + toString(getpid()) + ".temp", breakUp[process], fileGroup);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               num = driverGroups(outputFName, accnos, fasta, breakUp[0], fileGroup);
-
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0;  in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-#else
-               
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the slayerData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<slayerData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for(int i=1; i<processors; i++ ){
-                       string extension = toString(i) + ".temp";
-                       slayerData* tempslayer = new slayerData((outputFName + extension), (fasta + extension), (accnos + extension), templatefile, search, blastlocation, trimera, trim, realign, m, breakUp[i], fileGroup, ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, divR, priority, i);
-                       pDataArray.push_back(tempslayer);
-                       processIDS.push_back(i);
-                       
-                       //MySlayerThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MySlayerGroupThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-               num = driverGroups(outputFName, accnos, fasta, breakUp[0], fileGroup);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif 
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((outputFName + toString(processIDS[i]) + ".temp"), outputFName);
-                       m->mothurRemove((outputFName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
-                       m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));
-                       
-                       if (trim) {
-                               m->appendFiles((fasta + toString(processIDS[i]) + ".temp"), fasta);
-                               m->mothurRemove((fasta + toString(processIDS[i]) + ".temp"));
-                       }
-               }
-               
-               
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "createProcessesGroups");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChimeraSlayerCommand::driver(linePair filePos, string outputFName, string filename, string accnos, string fasta, map<string, int>& priority){
-       try {
-               
-               Chimera* chimera;
-               if (templatefile != "self") { //you want to run slayer with a reference template
-                       chimera = new ChimeraSlayer(filename, templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());       
-               }else {
-                       chimera = new ChimeraSlayer(filename, templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());     
-               }
-               
-               if (m->control_pressed) { delete chimera; return 0; }
-               
-               if (chimera->getUnaligned()) { delete chimera; m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-               templateSeqsLength = chimera->getLength();
-               
-               ofstream out;
-               m->openOutputFile(outputFName, out);
-               
-               ofstream out2;
-               m->openOutputFile(accnos, out2);
-               
-               ofstream out3;
-               if (trim) {  m->openOutputFile(fasta, out3); }
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos.start);
-               
-               if (filePos.start == 0) { chimera->printHeader(out); }
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-               
-                       if (m->control_pressed) {       delete chimera; out.close(); out2.close(); if (trim) { out3.close(); } inFASTA.close(); return 1;       }
-               
-                       Sequence* candidateSeq = new Sequence(inFASTA);  m->gobble(inFASTA);
-                       string candidateAligned = candidateSeq->getAligned();
-                       
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (m->control_pressed) {       delete chimera; delete candidateSeq; return 1;  }
-                                               
-                                       //if you are not chimeric, then check each half
-                                       data_results wholeResults = chimera->getResults();
-                                       
-                                       //determine if we need to split
-                                       bool isChimeric = false;
-                                       
-                                       if (wholeResults.flag == "yes") {
-                                               string chimeraFlag = "no";
-                                               if(  (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
-                                                  ||
-                                                  (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                                               
-                                               
-                                               if (chimeraFlag == "yes") {     
-                                                       if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
-                                               }
-                                       }
-                                       
-                                       if ((!isChimeric) && trimera) {
-                                               
-                                               //split sequence in half by bases
-                                               string leftQuery, rightQuery;
-                                               Sequence tempSeq(candidateSeq->getName(), candidateAligned);
-                                               divideInHalf(tempSeq, leftQuery, rightQuery);
-                                               
-                                               //run chimeraSlayer on each piece
-                                               Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
-                                               Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-                                               
-                                               //find chimeras
-                                               chimera->getChimeras(left);
-                                               data_results leftResults = chimera->getResults();
-                                               
-                                               chimera->getChimeras(right);
-                                               data_results rightResults = chimera->getResults();
-                                               
-                                               //if either piece is chimeric then report
-                                               Sequence trimmed = chimera->print(out, out2, leftResults, rightResults);
-                                               if (trim) { trimmed.printSequence(out3);  }
-                                               
-                                               delete left; delete right;
-                                               
-                                       }else { //already chimeric
-                                               //print results
-                                               Sequence trimmed = chimera->print(out, out2);
-                                               if (trim) { trimmed.printSequence(out3);  }
-                                       }
-                                       
-                                       
-                               }
-                               count++;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos.end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       delete candidateSeq;
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-               int numNoParents = chimera->getNumNoParents();
-               if (numNoParents == count) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); } 
-               
-               out.close();
-               out2.close();
-               if (trim) { out3.close(); }
-               inFASTA.close();
-               delete chimera;
-                               
-               return count;
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, MPI_File& outFastaMPI, vector<unsigned long long>& MPIPos, string filename, map<string, int>& priority, bool byGroup){
-       try {
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               Chimera* chimera;
-               if (templatefile != "self") { //you want to run slayer with a reference template
-                       chimera = new ChimeraSlayer(filename, templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());       
-               }else {
-                       chimera = new ChimeraSlayer(filename, templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand(), byGroup);    
-               }
-               
-               if (m->control_pressed) { delete chimera; return 0; }
-               
-               if (chimera->getUnaligned()) { delete chimera; m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-               templateSeqsLength = chimera->getLength();
-               
-               for(int i=0;i<num;i++){
-                       
-                       if (m->control_pressed) {       delete chimera; return 1;       }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-
-                       delete buf4;
-
-                       Sequence* candidateSeq = new Sequence(iss);  m->gobble(iss);
-                       string candidateAligned = candidateSeq->getAligned();
-               
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               
-                               if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                       m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine();
-                               }else{
-               
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                       
-                                       if (m->control_pressed) {       delete chimera; delete candidateSeq; return 1;  }
-                                       
-                                       //if you are not chimeric, then check each half
-                                       data_results wholeResults = chimera->getResults();
-                                       
-                                       //determine if we need to split
-                                       bool isChimeric = false;
-                                       
-                                       if (wholeResults.flag == "yes") {
-                                               string chimeraFlag = "no";
-                                               if(  (wholeResults.results[0].bsa >= minBS && wholeResults.results[0].divr_qla_qrb >= divR)
-                                                  ||
-                                                  (wholeResults.results[0].bsb >= minBS && wholeResults.results[0].divr_qlb_qra >= divR) ) { chimeraFlag = "yes"; }
-                                               
-                                               
-                                               if (chimeraFlag == "yes") {     
-                                                       if ((wholeResults.results[0].bsa >= minBS) || (wholeResults.results[0].bsb >= minBS)) { isChimeric = true; }
-                                               }
-                                       }
-                                       
-                                       if ((!isChimeric) && trimera) {                                                 
-                                               //split sequence in half by bases
-                                               string leftQuery, rightQuery;
-                                               Sequence tempSeq(candidateSeq->getName(), candidateAligned);
-                                               divideInHalf(tempSeq, leftQuery, rightQuery);
-                                               
-                                               //run chimeraSlayer on each piece
-                                               Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
-                                               Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-                                               
-                                               //find chimeras
-                                               chimera->getChimeras(left);
-                                               data_results leftResults = chimera->getResults();
-                                               
-                                               chimera->getChimeras(right);
-                                               data_results rightResults = chimera->getResults();
-                                               
-                                               //if either piece is chimeric then report
-                                               Sequence trimmed = chimera->print(outMPI, outAccMPI, leftResults, rightResults);
-                                               if (trim) {  
-                                                       string outputString = ">" + trimmed.getName() + "\n" + trimmed.getAligned() + "\n";
-                                                       
-                                                       //write to accnos file
-                                                       int length = outputString.length();
-                                                       char* buf2 = new char[length];
-                                                       memcpy(buf2, outputString.c_str(), length);
-                                                       
-                                                       MPI_File_write_shared(outFastaMPI, buf2, length, MPI_CHAR, &status);
-                                                       delete buf2;
-                                               }
-                                               
-                                               delete left; delete right;
-                                               
-                                       }else { 
-                                               //print results
-                                               Sequence trimmed = chimera->print(outMPI, outAccMPI);
-                                               
-                                               if (trim) {  
-                                                       string outputString = ">" + trimmed.getName() + "\n" + trimmed.getAligned() + "\n";
-                                                       
-                                                       //write to accnos file
-                                                       int length = outputString.length();
-                                                       char* buf2 = new char[length];
-                                                       memcpy(buf2, outputString.c_str(), length);
-                                                       
-                                                       MPI_File_write_shared(outFastaMPI, buf2, length, MPI_CHAR, &status);
-                                                       delete buf2;
-                                               }
-                                       }
-                                       
-                               }
-                       }
-                       delete candidateSeq;
-                       
-                       //report progress
-                       if((i+1) % 100 == 0){  cout << "Processing sequence: " << (i+1) << endl;        m->mothurOutJustToLog("Processing sequence: " + toString(i+1) + "\n");          }
-               }
-               //report progress
-               if(num % 100 != 0){             cout << "Processing sequence: " << num << endl; m->mothurOutJustToLog("Processing sequence: " + toString(num) + "\n");  }
-               
-               int numNoParents = chimera->getNumNoParents();
-               if (numNoParents == num) { cout << "[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors." << endl; }
-               
-               delete chimera;         
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-
-/**************************************************************************************************/
-
-int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename, string accnos, string fasta, map<string, int>& thisPriority) {
-       try {
-               int process = 0;
-               int num = 0;
-               processIDS.clear();
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], outputFileName + toString(getpid()) + ".temp", filename, accnos + toString(getpid()) + ".temp", fasta + toString(getpid()) + ".temp", thisPriority);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processors;i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0;  in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-#else
-               
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the slayerData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<slayerData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors];
-               HANDLE  hThreadArray[processors]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors; i++ ){
-                       string extension = toString(i) + ".temp";
-                       slayerData* tempslayer = new slayerData((outputFileName + extension), (fasta + extension), (accnos + extension), filename, templatefile, search, blastlocation, trimera, trim, realign, m, lines[i].start, lines[i].end, ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, divR, priority, i);
-                       pDataArray.push_back(tempslayer);
-                       processIDS.push_back(i);
-                       
-                       //MySlayerThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MySlayerThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-                               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif 
-               
-               rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
-               rename((accnos + toString(processIDS[0]) + ".temp").c_str(), accnos.c_str());
-               if (trim) {  rename((fasta + toString(processIDS[0]) + ".temp").c_str(), fasta.c_str()); }
-               
-               //append output files
-               for(int i=1;i<processIDS.size();i++){
-                       m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
-                       m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
-                       m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));
-                       
-                       if (trim) {
-                               m->appendFiles((fasta + toString(processIDS[i]) + ".temp"), fasta);
-                               m->mothurRemove((fasta + toString(processIDS[i]) + ".temp"));
-                       }
-               }
-               
-               
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int ChimeraSlayerCommand::divideInHalf(Sequence querySeq, string& leftQuery, string& rightQuery) {
-       try {
-               
-               string queryUnAligned = querySeq.getUnaligned();
-               int numBases = int(queryUnAligned.length() * 0.5);
-               
-               string queryAligned = querySeq.getAligned();
-               leftQuery = querySeq.getAligned();
-               rightQuery = querySeq.getAligned();
-               
-               int baseCount = 0;
-               int leftSpot = 0;
-               for (int i = 0; i < queryAligned.length(); i++) {
-                       //if you are a base
-                       if (isalpha(queryAligned[i])) {         
-                               baseCount++; 
-                       }
-                       
-                       //if you have half
-                       if (baseCount >= numBases) {  leftSpot = i; break; } //first half
-               }
-               
-               //blank out right side
-               for (int i = leftSpot; i < leftQuery.length(); i++) { leftQuery[i] = '.'; }
-               
-               //blank out left side
-               for (int i = 0; i < leftSpot; i++) { rightQuery[i] = '.'; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "divideInHalf");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-map<string, int> ChimeraSlayerCommand::sortFastaFile(string fastaFile, string nameFile) {
-       try {
-               map<string, int> nameAbund;
-               
-               //read through fastafile and store info
-               map<string, string> seqs;
-               ifstream in;
-               m->openInputFile(fastaFile, in);
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return nameAbund; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       seqs[seq.getName()] = seq.getAligned();
-               }
-               
-               in.close();
-               
-               //read namefile
-               vector<seqPriorityNode> nameMapCount;
-               int error = m->readNames(nameFile, nameMapCount, seqs);
-               
-               if (m->control_pressed) { return nameAbund; }
-               
-               if (error == 1) { m->control_pressed = true; return nameAbund; }
-               if (seqs.size() != nameMapCount.size()) { m->mothurOut( "The number of sequences in your fastafile does not match the number of sequences in your namefile, aborting."); m->mothurOutEndLine(); m->control_pressed = true; return nameAbund; }
-
-               sort(nameMapCount.begin(), nameMapCount.end(), compareSeqPriorityNodes);
-               
-               string newFasta = fastaFile + ".temp";
-               ofstream out;
-               m->openOutputFile(newFasta, out);
-               
-               //print new file in order of
-               for (int i = 0; i < nameMapCount.size(); i++) {
-                       out << ">" << nameMapCount[i].name << endl << nameMapCount[i].seq << endl;
-                       nameAbund[nameMapCount[i].name] = nameMapCount[i].numIdentical;
-               }
-               out.close();
-               
-               rename(newFasta.c_str(), fastaFile.c_str());
-                               
-               return nameAbund;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "sortFastaFile");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-map<string, int> ChimeraSlayerCommand::sortFastaFile(vector<Sequence>& thisseqs, map<string, string>& nameMap, string newFile) {
-       try {
-               map<string, int> nameAbund;
-               vector<seqPriorityNode> nameVector;
-               
-               //read through fastafile and store info
-               map<string, string> seqs;
-                               
-               for (int i = 0; i < thisseqs.size(); i++) {
-                       
-                       if (m->control_pressed) { return nameAbund; }
-                       
-                       map<string, string>::iterator itNameMap = nameMap.find(thisseqs[i].getName());
-                       
-                       if (itNameMap == nameMap.end()){
-                               m->control_pressed = true;
-                               m->mothurOut("[ERROR]: " + thisseqs[i].getName() + " is in your fastafile, but is not in your namesfile, please correct."); m->mothurOutEndLine();
-                       }else {
-                               int num = m->getNumNames(itNameMap->second);
-                               
-                               seqPriorityNode temp(num, thisseqs[i].getAligned(), thisseqs[i].getName());
-                               nameVector.push_back(temp);
-                       }
-               }
-       
-               //sort by num represented
-               sort(nameVector.begin(), nameVector.end(), compareSeqPriorityNodes);
-       
-               if (m->control_pressed) { return nameAbund; }
-               
-               if (thisseqs.size() != nameVector.size()) { m->mothurOut( "The number of sequences in your fastafile does not match the number of sequences in your namefile, aborting."); m->mothurOutEndLine(); m->control_pressed = true; return nameAbund; }
-                               
-               ofstream out;
-               m->openOutputFile(newFile, out);
-               
-               //print new file in order of
-               for (int i = 0; i < nameVector.size(); i++) {
-                       out << ">" << nameVector[i].name << endl << nameVector[i].seq << endl;
-                       nameAbund[nameVector[i].name] = nameVector[i].numIdentical;
-               }
-               out.close();
-               
-               return nameAbund;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "sortFastaFile");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
diff --git a/chimeraslayercommand.h b/chimeraslayercommand.h
deleted file mode 100644 (file)
index 2c6fec8..0000000
+++ /dev/null
@@ -1,543 +0,0 @@
-#ifndef CHIMERASLAYERCOMMAND_H
-#define CHIMERASLAYERCOMMAND_H
-
-/*
- *  chimeraslayercommand.h
- *  Mothur
- *
- *  Created by westcott on 3/31/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "chimera.h"
-#include "chimeraslayer.h"
-#include "sequenceparser.h"
-
-/***********************************************************/
-
-class ChimeraSlayerCommand : public Command {
-public:
-       ChimeraSlayerCommand(string);
-       ChimeraSlayerCommand();
-       ~ChimeraSlayerCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.slayer";              }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Haas BJ, Gevers D, Earl A, Feldgarden M, Ward DV, Giannokous G, Ciulla D, Tabbaa D, Highlander SK, Sodergren E, Methe B, Desantis TZ, Petrosino JF, Knight R, Birren BW (2011). Chimeric 16S rRNA sequence formation and detection in Sanger and 454-pyrosequenced PCR amplicons. Genome Res. \nhttp://www.mothur.org/wiki/Chimera.slayer"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-       
-private:
-
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<int> processIDS;   //processid
-       vector<linePair> lines;
-       
-       int driver(linePair, string, string, string, string, map<string, int>&);
-       int createProcesses(string, string, string, string, map<string, int>&);
-       int divideInHalf(Sequence, string&, string&);
-       map<string, int> sortFastaFile(string, string);
-       map<string, int> sortFastaFile(vector<Sequence>&, map<string, string>&, string newFile);
-       string getNamesFile(string&);
-       //int setupChimera(string,);
-       int MPIExecute(string, string, string, string, map<string, int>&);
-       int deconvoluteResults(SequenceParser*, string, string, string);
-       map<string, int> priority;
-       int setUpForSelfReference(SequenceParser*&, map<string, string>&, map<string, map<string, int> >&, int);
-       int driverGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
-       int createProcessesGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
-       int MPIExecuteGroups(string, string, string, map<string, map<string, int> >&, map<string, string>&);
-
-               
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&, string, map<string, int>&, bool);
-       #endif
-
-       bool abort, realign, trim, trimera, save;
-       string fastafile, groupfile, templatefile, outputDir, search, namefile, blastlocation;
-       int processors, window, iters, increment, numwanted, ksize, match, mismatch, parents, minSimilarity, minCoverage, minBS, minSNP, numSeqs, templateSeqsLength;
-       float divR;
-       
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-       vector<string> nameFileNames;
-       vector<string> groupFileNames;
-       
-};
-
-/***********************************************************/
-
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct slayerData {
-       string outputFName; 
-       string fasta; 
-       string accnos;
-       string filename;
-       string templatefile;
-       string search;
-       string blastlocation;
-       bool trimera;
-       bool trim, realign;
-       unsigned long long start;
-       unsigned long long end;
-       int ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted;
-       MothurOut* m;
-       float divR;
-       map<string, int> priority;
-       int count;
-       int numNoParents;
-       int threadId;
-       map<string, map<string, int> > fileToPriority;
-       map<string, string> fileGroup;
-       
-       slayerData(){}
-       slayerData(string o, string fa, string ac, string f, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, unsigned long long st, unsigned long long en, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
-               outputFName = o;
-               fasta = fa;
-               accnos = ac;
-               filename = f;
-               templatefile = te;
-               search = se;
-               blastlocation = bl;
-               trimera = tri;
-               trim = trm;
-               realign = re;
-               m = mout;
-               start = st;
-               end = en;
-               ksize = ks;
-               match = ma; 
-               mismatch = mis;
-               window = win;
-               minSimilarity = minS;
-               minCoverage = minC;
-               minBS = miBS;
-               minSNP = minSN;
-               parents = par;
-               iters = it;
-               increment = inc;
-               numwanted = numw;
-               divR = div;
-               priority = prior;
-               threadId = tid;
-               count = 0;
-               numNoParents = 0;
-       }
-       slayerData(string o, string fa, string ac, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, map<string, map<string, int> >& fPriority, map<string, string>& fileG, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
-               outputFName = o;
-               fasta = fa;
-               accnos = ac;
-               templatefile = te;
-               search = se;
-               blastlocation = bl;
-               trimera = tri;
-               trim = trm;
-               realign = re;
-               m = mout;
-               fileGroup = fileG;
-               fileToPriority = fPriority;
-               ksize = ks;
-               match = ma; 
-               mismatch = mis;
-               window = win;
-               minSimilarity = minS;
-               minCoverage = minC;
-               minBS = miBS;
-               minSNP = minSN;
-               parents = par;
-               iters = it;
-               increment = inc;
-               numwanted = numw;
-               divR = div;
-               priority = prior;
-               threadId = tid;
-               count = 0;
-               numNoParents = 0;
-       }
-       
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MySlayerThreadFunction(LPVOID lpParam){ 
-       slayerData* pDataArray;
-       pDataArray = (slayerData*)lpParam;
-       
-       try {
-               ofstream out;
-               pDataArray->m->openOutputFile(pDataArray->outputFName, out);
-               
-               ofstream out2;
-               pDataArray->m->openOutputFile(pDataArray->accnos, out2);
-               
-               ofstream out3;
-               if (pDataArray->trim) {  pDataArray->m->openOutputFile(pDataArray->fasta, out3); }
-               
-               ifstream inFASTA;
-               pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
-               
-               
-               
-               Chimera* chimera;
-               if (pDataArray->templatefile != "self") { //you want to run slayer with a reference template
-                       chimera = new ChimeraSlayer(pDataArray->filename, pDataArray->templatefile, pDataArray->trim, pDataArray->search, pDataArray->ksize, pDataArray->match, pDataArray->mismatch, pDataArray->window, pDataArray->divR, pDataArray->minSimilarity, pDataArray->minCoverage, pDataArray->minBS, pDataArray->minSNP, pDataArray->parents, pDataArray->iters, pDataArray->increment, pDataArray->numwanted, pDataArray->realign, pDataArray->blastlocation, pDataArray->threadId);     
-               }else {
-                       chimera = new ChimeraSlayer(pDataArray->filename, pDataArray->templatefile, pDataArray->trim, pDataArray->priority, pDataArray->search, pDataArray->ksize, pDataArray->match, pDataArray->mismatch, pDataArray->window, pDataArray->divR, pDataArray->minSimilarity, pDataArray->minCoverage, pDataArray->minBS, pDataArray->minSNP, pDataArray->parents, pDataArray->iters, pDataArray->increment, pDataArray->numwanted, pDataArray->realign, pDataArray->blastlocation, pDataArray->threadId);       
-               }
-               
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       chimera->printHeader(out); 
-                       inFASTA.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               
-               if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera;  return 0;    }
-               
-               if (chimera->getUnaligned()) { 
-                       pDataArray->m->mothurOut("Your template sequences are different lengths, please correct."); pDataArray->m->mothurOutEndLine(); 
-                       out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close();
-                       delete chimera;
-                       return 0; 
-               }
-               int templateSeqsLength = chimera->getLength();
-               
-               if (pDataArray->start == 0) { chimera->printHeader(out); }
-               
-               int count = 0;
-               for(int i = 0; i < pDataArray->end; i++){
-                       
-                       if (pDataArray->m->control_pressed) {   out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 1;   }
-                       
-                       Sequence* candidateSeq = new Sequence(inFASTA);  pDataArray->m->gobble(inFASTA);
-                       string candidateAligned = candidateSeq->getAligned();
-                       
-                       if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                               if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                       pDataArray->m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); pDataArray->m->mothurOutEndLine();
-                               }else{
-                                       //find chimeras
-                                       chimera->getChimeras(candidateSeq);
-                                       
-                                       if (pDataArray->m->control_pressed) {   delete candidateSeq; delete chimera; return 1;  }
-                                       
-                                       //if you are not chimeric, then check each half
-                                       data_results wholeResults = chimera->getResults();
-                                       
-                                       //determine if we need to split
-                                       bool isChimeric = false;
-                                       
-                                       if (wholeResults.flag == "yes") {
-                                               string chimeraFlag = "no";
-                                               if(  (wholeResults.results[0].bsa >= pDataArray->minBS && wholeResults.results[0].divr_qla_qrb >= pDataArray->divR)
-                                                  ||
-                                                  (wholeResults.results[0].bsb >= pDataArray->minBS && wholeResults.results[0].divr_qlb_qra >= pDataArray->divR) ) { chimeraFlag = "yes"; }
-                                               
-                                               
-                                               if (chimeraFlag == "yes") {     
-                                                       if ((wholeResults.results[0].bsa >= pDataArray->minBS) || (wholeResults.results[0].bsb >= pDataArray->minBS)) { isChimeric = true; }
-                                               }
-                                       }
-                                       
-                                       if ((!isChimeric) && pDataArray->trimera) {
-                                               
-                                               //split sequence in half by bases
-                                               string leftQuery, rightQuery;
-                                               Sequence tempSeq(candidateSeq->getName(), candidateAligned);
-                                               //divideInHalf(tempSeq, leftQuery, rightQuery);
-                                               string queryUnAligned = tempSeq.getUnaligned();
-                                               int numBases = int(queryUnAligned.length() * 0.5);
-                                               
-                                               string queryAligned = tempSeq.getAligned();
-                                               leftQuery = tempSeq.getAligned();
-                                               rightQuery = tempSeq.getAligned();
-                                               
-                                               int baseCount = 0;
-                                               int leftSpot = 0;
-                                               for (int i = 0; i < queryAligned.length(); i++) {
-                                                       //if you are a base
-                                                       if (isalpha(queryAligned[i])) {         
-                                                               baseCount++; 
-                                                       }
-                                                       
-                                                       //if you have half
-                                                       if (baseCount >= numBases) {  leftSpot = i; break; } //first half
-                                               }
-                                               
-                                               //blank out right side
-                                               for (int i = leftSpot; i < leftQuery.length(); i++) { leftQuery[i] = '.'; }
-                                               
-                                               //blank out left side
-                                               for (int i = 0; i < leftSpot; i++) { rightQuery[i] = '.'; }
-                                               
-                                               //run chimeraSlayer on each piece
-                                               Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
-                                               Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-                                               
-                                               //find chimeras
-                                               chimera->getChimeras(left);
-                                               data_results leftResults = chimera->getResults();
-                                               
-                                               chimera->getChimeras(right);
-                                               data_results rightResults = chimera->getResults();
-                                               
-                                               //if either piece is chimeric then report
-                                               Sequence trimmed = chimera->print(out, out2, leftResults, rightResults);
-                                               if (pDataArray->trim) { trimmed.printSequence(out3);  }
-                                               
-                                               delete left; delete right;
-                                               
-                                       }else { //already chimeric
-                                               //print results
-                                               Sequence trimmed = chimera->print(out, out2);
-                                               if (pDataArray->trim) { trimmed.printSequence(out3);  }
-                                       }
-                                       
-                                       
-                               }
-                               count++;
-                       }
-                       
-                       delete candidateSeq;
-                       //report progress
-                       if((count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine();         }
-               
-               pDataArray->numNoParents = chimera->getNumNoParents();
-               if (pDataArray->numNoParents == count) {        pDataArray->m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors.\n"); }
-
-               out.close();
-               out2.close();
-               if (pDataArray->trim) { out3.close(); }
-               inFASTA.close();
-               delete chimera;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ChimeraSlayerCommand", "MySlayerThreadFunction");
-               exit(1);
-       }
-} 
-
-/**************************************************************************************************/
-
-static DWORD WINAPI MySlayerGroupThreadFunction(LPVOID lpParam){ 
-       slayerData* pDataArray;
-       pDataArray = (slayerData*)lpParam;
-       
-       try {
-               
-               int totalSeqs = 0;
-               
-               for (map<string, map<string, int> >::iterator itFile = pDataArray->fileToPriority.begin(); itFile != pDataArray->fileToPriority.end(); itFile++) {
-                       
-                       if (pDataArray->m->control_pressed) {  return 0;  }
-                       
-                       int start = time(NULL);
-                       string thisFastaName = itFile->first;
-                       map<string, int> thisPriority = itFile->second;
-                       string thisoutputFileName = pDataArray->m->getRootName(pDataArray->m->getSimpleName(thisFastaName)) + pDataArray->fileGroup[thisFastaName] + "slayer.chimera";
-                       string thisaccnosFileName = pDataArray->m->getRootName(pDataArray->m->getSimpleName(thisFastaName)) + pDataArray->fileGroup[thisFastaName] + "slayer.accnos";
-                       string thistrimFastaFileName = pDataArray->m->getRootName(pDataArray->m->getSimpleName(thisFastaName)) + pDataArray->fileGroup[thisFastaName] + "slayer.fasta";
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Checking sequences from group: " + pDataArray->fileGroup[thisFastaName] + "."); pDataArray->m->mothurOutEndLine(); 
-               
-                       //int numSeqs = driver(lines[0], thisoutputFileName, thisFastaName, thisaccnosFileName, thistrimFastaFileName, thisPriority);
-                       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-                       
-                       ofstream out;
-                       pDataArray->m->openOutputFile(thisoutputFileName, out);
-                       
-                       ofstream out2;
-                       pDataArray->m->openOutputFile(thisaccnosFileName, out2);
-                       
-                       ofstream out3;
-                       if (pDataArray->trim) {  pDataArray->m->openOutputFile(thistrimFastaFileName, out3); }
-                       
-                       ifstream inFASTA;
-                       pDataArray->m->openInputFile(thisFastaName, inFASTA);
-                       
-                       Chimera* chimera;
-                       chimera = new ChimeraSlayer(thisFastaName, pDataArray->templatefile, pDataArray->trim, thisPriority, pDataArray->search, pDataArray->ksize, pDataArray->match, pDataArray->mismatch, pDataArray->window, pDataArray->divR, pDataArray->minSimilarity, pDataArray->minCoverage, pDataArray->minBS, pDataArray->minSNP, pDataArray->parents, pDataArray->iters, pDataArray->increment, pDataArray->numwanted, pDataArray->realign, pDataArray->blastlocation, pDataArray->threadId);      
-                       chimera->printHeader(out); 
-                       
-                       int numSeqs = 0;
-                       
-                       if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera;  return 0;    }
-                       
-                       if (chimera->getUnaligned()) { 
-                               pDataArray->m->mothurOut("Your template sequences are different lengths, please correct."); pDataArray->m->mothurOutEndLine(); 
-                               out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close();
-                               delete chimera;
-                               return 0; 
-                       }
-                       int templateSeqsLength = chimera->getLength();
-                       
-                       bool done = false;
-                       while (!done) {
-                               
-                               if (pDataArray->m->control_pressed) {   out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 1;   }
-                               
-                               Sequence* candidateSeq = new Sequence(inFASTA);  pDataArray->m->gobble(inFASTA);
-                               string candidateAligned = candidateSeq->getAligned();
-                               
-                               if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
-                                       if (candidateSeq->getAligned().length() != templateSeqsLength) {  
-                                               pDataArray->m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); pDataArray->m->mothurOutEndLine();
-                                       }else{
-                                               //find chimeras
-                                               chimera->getChimeras(candidateSeq);
-                                               
-                                               if (pDataArray->m->control_pressed) {   out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete candidateSeq; delete chimera; return 1;      }
-                                               
-                                               //if you are not chimeric, then check each half
-                                               data_results wholeResults = chimera->getResults();
-                                               
-                                               //determine if we need to split
-                                               bool isChimeric = false;
-                                               
-                                               if (wholeResults.flag == "yes") {
-                                                       string chimeraFlag = "no";
-                                                       if(  (wholeResults.results[0].bsa >= pDataArray->minBS && wholeResults.results[0].divr_qla_qrb >= pDataArray->divR)
-                                                          ||
-                                                          (wholeResults.results[0].bsb >= pDataArray->minBS && wholeResults.results[0].divr_qlb_qra >= pDataArray->divR) ) { chimeraFlag = "yes"; }
-                                                       
-                                                       
-                                                       if (chimeraFlag == "yes") {     
-                                                               if ((wholeResults.results[0].bsa >= pDataArray->minBS) || (wholeResults.results[0].bsb >= pDataArray->minBS)) { isChimeric = true; }
-                                                       }
-                                               }
-                                               
-                                               if ((!isChimeric) && pDataArray->trimera) {
-                                                       
-                                                       //split sequence in half by bases
-                                                       string leftQuery, rightQuery;
-                                                       Sequence tempSeq(candidateSeq->getName(), candidateAligned);
-                                                       //divideInHalf(tempSeq, leftQuery, rightQuery);
-                                                       string queryUnAligned = tempSeq.getUnaligned();
-                                                       int numBases = int(queryUnAligned.length() * 0.5);
-                                                       
-                                                       string queryAligned = tempSeq.getAligned();
-                                                       leftQuery = tempSeq.getAligned();
-                                                       rightQuery = tempSeq.getAligned();
-                                                       
-                                                       int baseCount = 0;
-                                                       int leftSpot = 0;
-                                                       for (int i = 0; i < queryAligned.length(); i++) {
-                                                               //if you are a base
-                                                               if (isalpha(queryAligned[i])) {         
-                                                                       baseCount++; 
-                                                               }
-                                                               
-                                                               //if you have half
-                                                               if (baseCount >= numBases) {  leftSpot = i; break; } //first half
-                                                       }
-                                                       
-                                                       //blank out right side
-                                                       for (int i = leftSpot; i < leftQuery.length(); i++) { leftQuery[i] = '.'; }
-                                                       
-                                                       //blank out left side
-                                                       for (int i = 0; i < leftSpot; i++) { rightQuery[i] = '.'; }
-                                                       
-                                                       //run chimeraSlayer on each piece
-                                                       Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
-                                                       Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
-                                                       
-                                                       //find chimeras
-                                                       chimera->getChimeras(left);
-                                                       data_results leftResults = chimera->getResults();
-                                                       
-                                                       chimera->getChimeras(right);
-                                                       data_results rightResults = chimera->getResults();
-                                                       
-                                                       //if either piece is chimeric then report
-                                                       Sequence trimmed = chimera->print(out, out2, leftResults, rightResults);
-                                                       if (pDataArray->trim) { trimmed.printSequence(out3);  }
-                                                       
-                                                       delete left; delete right;
-                                                       
-                                               }else { //already chimeric
-                                                       //print results
-                                                       Sequence trimmed = chimera->print(out, out2);
-                                                       if (pDataArray->trim) { trimmed.printSequence(out3);  }
-                                               }
-                                               
-                                               
-                                       }
-                                       numSeqs++;
-                               }
-                               
-                               delete candidateSeq;
-                               
-                               if (inFASTA.eof()) { break; }
-                               
-                               //report progress
-                               if((numSeqs) % 100 == 0){       pDataArray->m->mothurOut("Processing sequence: " + toString(numSeqs)); pDataArray->m->mothurOutEndLine();               }
-                       }
-                       //report progress
-                       if((numSeqs) % 100 != 0){       pDataArray->m->mothurOut("Processing sequence: " + toString(numSeqs)); pDataArray->m->mothurOutEndLine();               }
-                       
-                       pDataArray->numNoParents = chimera->getNumNoParents();
-                       if (pDataArray->numNoParents == numSeqs) {      pDataArray->m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors.\n"); }
-                       
-                       out.close();
-                       out2.close();
-                       if (pDataArray->trim) { out3.close(); }
-                       inFASTA.close();
-                       delete chimera;
-                       
-                       
-                       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-                       
-                       //append files
-                       pDataArray->m->appendFiles(thisoutputFileName, pDataArray->outputFName); pDataArray->m->mothurRemove(thisoutputFileName); 
-                       pDataArray->m->appendFiles(thisaccnosFileName, pDataArray->accnos); pDataArray->m->mothurRemove(thisaccnosFileName);
-                       if (pDataArray->trim) { pDataArray->m->appendFiles(thistrimFastaFileName, pDataArray->fasta); pDataArray->m->mothurRemove(thistrimFastaFileName); }
-                       pDataArray->m->mothurRemove(thisFastaName);
-                       
-                       totalSeqs += numSeqs;
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + pDataArray->fileGroup[thisFastaName] + "."); pDataArray->m->mothurOutEndLine();
-               }
-               
-               pDataArray->count = totalSeqs;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ChimeraSlayerCommand", "MySlayerGroupThreadFunction");
-               exit(1);
-       }
-} 
-
-#endif
-
-/**************************************************************************************************/
-
-
-#endif
-
-
diff --git a/chimerauchimecommand.cpp b/chimerauchimecommand.cpp
deleted file mode 100644 (file)
index 026e91b..0000000
+++ /dev/null
@@ -1,1606 +0,0 @@
-/*
- *  chimerauchimecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/13/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chimerauchimecommand.h"
-#include "deconvolutecommand.h"
-//#include "uc.h"
-#include "sequence.hpp"
-#include "referencedb.h"
-
-
-//**********************************************************************************************************************
-vector<string> ChimeraUchimeCommand::setParameters(){  
-       try {
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pabskew("abskew", "Number", "", "1.9", "", "", "",false,false); parameters.push_back(pabskew);
-               CommandParameter pchimealns("chimealns", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pchimealns);
-               CommandParameter pminh("minh", "Number", "", "0.3", "", "", "",false,false); parameters.push_back(pminh);
-               CommandParameter pmindiv("mindiv", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pmindiv);
-               CommandParameter pxn("xn", "Number", "", "8.0", "", "", "",false,false); parameters.push_back(pxn);
-               CommandParameter pdn("dn", "Number", "", "1.4", "", "", "",false,false); parameters.push_back(pdn);
-               CommandParameter pxa("xa", "Number", "", "1", "", "", "",false,false); parameters.push_back(pxa);
-               CommandParameter pchunks("chunks", "Number", "", "4", "", "", "",false,false); parameters.push_back(pchunks);
-               CommandParameter pminchunk("minchunk", "Number", "", "64", "", "", "",false,false); parameters.push_back(pminchunk);
-               CommandParameter pidsmoothwindow("idsmoothwindow", "Number", "", "32", "", "", "",false,false); parameters.push_back(pidsmoothwindow);
-               //CommandParameter pminsmoothid("minsmoothid", "Number", "", "0.95", "", "", "",false,false); parameters.push_back(pminsmoothid);
-               CommandParameter pmaxp("maxp", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmaxp);
-               CommandParameter pskipgaps("skipgaps", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pskipgaps);
-               CommandParameter pskipgaps2("skipgaps2", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pskipgaps2);
-               CommandParameter pminlen("minlen", "Number", "", "10", "", "", "",false,false); parameters.push_back(pminlen);
-               CommandParameter pmaxlen("maxlen", "Number", "", "10000", "", "", "",false,false); parameters.push_back(pmaxlen);
-               CommandParameter pucl("ucl", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pucl);
-               CommandParameter pqueryfract("queryfract", "Number", "", "0.5", "", "", "",false,false); parameters.push_back(pqueryfract);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChimeraUchimeCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "The chimera.uchime command reads a fastafile and referencefile and outputs potentially chimeric sequences.\n";
-               helpString += "This command is a wrapper for uchime written by Robert C. Edgar.\n";
-               helpString += "The chimera.uchime command parameters are fasta, name, reference, processors, abskew, chimealns, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, skipgaps, skipgaps2, minlen, maxlen, ucl and queryfact.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your potentially chimeric sequences, and is required, unless you have a valid current fasta file. \n";
-               helpString += "The name parameter allows you to provide a name file, if you are using template=self. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amazon.fasta \n";
-               helpString += "The group parameter allows you to provide a group file. The group file can be used with a namesfile and reference=self. When checking sequences, only sequences from the same group as the query sequence will be used as the reference. \n";
-               helpString += "The reference parameter allows you to enter a reference file containing known non-chimeric sequences, and is required. You may also set template=self, in this case the abundant sequences will be used as potential parents. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-               helpString += "The abskew parameter can only be used with template=self. Minimum abundance skew. Default 1.9. Abundance skew is: min [ abund(parent1), abund(parent2) ] / abund(query).\n";
-               helpString += "The chimealns parameter allows you to indicate you would like a file containing multiple alignments of query sequences to parents in human readable format. Alignments show columns with differences that support or contradict a chimeric model.\n";
-               helpString += "The minh parameter - mininum score to report chimera. Default 0.3. Values from 0.1 to 5 might be reasonable. Lower values increase sensitivity but may report more false positives. If you decrease xn you may need to increase minh, and vice versa.\n";
-               helpString += "The mindiv parameter - minimum divergence ratio, default 0.5. Div ratio is 100%% - %%identity between query sequence and the closest candidate for being a parent. If you don't care about very close chimeras, then you could increase mindiv to, say, 1.0 or 2.0, and also decrease minh, say to 0.1, to increase sensitivity. How well this works will depend on your data. Best is to tune parameters on a good benchmark.\n";
-               helpString += "The xn parameter - weight of a no vote. Default 8.0. Decreasing this weight to around 3 or 4 may give better performance on denoised data.\n";
-               helpString += "The dn parameter - pseudo-count prior on number of no votes. Default 1.4. Probably no good reason to change this unless you can retune to a good benchmark for your data. Reasonable values are probably in the range from 0.2 to 2.\n";
-               helpString += "The xa parameter - weight of an abstain vote. Default 1. So far, results do not seem to be very sensitive to this parameter, but if you have a good training set might be worth trying. Reasonable values might range from 0.1 to 2.\n";
-               helpString += "The chunks parameter is the number of chunks to extract from the query sequence when searching for parents. Default 4.\n";
-               helpString += "The minchunk parameter is the minimum length of a chunk. Default 64.\n";
-               helpString += "The idsmoothwindow parameter is the length of id smoothing window. Default 32.\n";
-               //helpString += "The minsmoothid parameter - minimum factional identity over smoothed window of candidate parent. Default 0.95.\n";
-               helpString += "The maxp parameter - maximum number of candidate parents to consider. Default 2. In tests so far, increasing maxp gives only a very small improvement in sensivity but tends to increase the error rate quite a bit.\n";
-               helpString += "The skipgaps parameter controls how gapped columns affect counting of diffs. If skipgaps is set to T, columns containing gaps do not found as diffs. Default = T.\n";
-               helpString += "The skipgaps2 parameter controls how gapped columns affect counting of diffs. If skipgaps2 is set to T, if column is immediately adjacent to a column containing a gap, it is not counted as a diff. Default = T.\n";
-               helpString += "The minlen parameter is the minimum unaligned sequence length. Defaults 10. Applies to both query and reference sequences.\n";
-               helpString += "The maxlen parameter is the maximum unaligned sequence length. Defaults 10000. Applies to both query and reference sequences.\n";
-               helpString += "The ucl parameter - use local-X alignments. Default is global-X or false. On tests so far, global-X is always better; this option is retained because it just might work well on some future type of data.\n";
-               helpString += "The queryfract parameter - minimum fraction of the query sequence that must be covered by a local-X alignment. Default 0.5. Applies only when ucl is true.\n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The chimera.uchime command should be in the following format: \n";
-               helpString += "chimera.uchime(fasta=yourFastaFile, reference=yourTemplate) \n";
-               helpString += "Example: chimera.uchime(fasta=AD.align, reference=silva.gold.align) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChimeraUchimeCommand::ChimeraUchimeCommand(){  
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["chimera"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["alns"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "ChimeraUchimeCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ChimeraUchimeCommand::ChimeraUchimeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false; 
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("chimera.uchime");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["chimera"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       outputTypes["alns"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       
-                       //check for required parameters
-                       bool hasName = true;
-                       namefile = validParameter.validFile(parameters, "name", false);
-                       if (namefile == "not found") { namefile = "";  hasName = false; }
-                       else { 
-                               m->splitAtDash(namefile, nameFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < nameFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (nameFileNames[i] == "current") { 
-                                               nameFileNames[i] = m->getNameFile(); 
-                                               if (nameFileNames[i] != "") {  m->mothurOut("Using " + nameFileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(nameFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       nameFileNames[i] = inputDir + nameFileNames[i];         }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(nameFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(nameFileNames[i]);
-                                                               m->mothurOut("Unable to open " + nameFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               nameFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + nameFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       nameFileNames.erase(nameFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setNameFile(nameFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (nameFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid name files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasName && (nameFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of namefiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       bool hasGroup = true;
-                       groupfile = validParameter.validFile(parameters, "group", false);
-                       if (groupfile == "not found") { groupfile = "";  hasGroup = false; }
-                       else { 
-                               m->splitAtDash(groupfile, groupFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < groupFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (groupFileNames[i] == "current") { 
-                                               groupFileNames[i] = m->getGroupFile(); 
-                                               if (groupFileNames[i] != "") {  m->mothurOut("Using " + groupFileNames[i] + " as input file for the group parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(groupFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       groupFileNames[i] = inputDir + groupFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               ifstream in;
-                                               
-                                               ableToOpen = m->openInputFile(groupFileNames[i], in, "noerror");
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(groupFileNames[i]);
-                                                               m->mothurOut("Unable to open " + groupFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               groupFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + groupFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       groupFileNames.erase(groupFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setGroupFile(groupFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (groupFileNames.size() == 0) { m->mothurOut("[ERROR]: no valid group files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasGroup && (groupFileNames.size() != fastaFileNames.size())) { m->mothurOut("[ERROR]: The number of groupfiles does not match the number of fastafiles, please correct."); m->mothurOutEndLine(); abort=true; }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       string path;
-                       it = parameters.find("reference");
-                       //user has given a template file
-                       if(it != parameters.end()){ 
-                               if (it->second == "self") { templatefile = "self"; }
-                               else {
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                                       
-                                       templatefile = validParameter.validFile(parameters, "reference", true);
-                                       if (templatefile == "not open") { abort = true; }
-                                       else if (templatefile == "not found") { //check for saved reference sequences
-                                               if (rdb->getSavedReference() != "") {
-                                                       templatefile = rdb->getSavedReference();
-                                                       m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + "."); m->mothurOutEndLine();
-                                               }else {
-                                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                                       m->mothurOutEndLine();
-                                                       abort = true; 
-                                               }
-                                       }
-                               }
-                       }else if (hasName) {  templatefile = "self"; }
-                       else { 
-                               if (rdb->getSavedReference() != "") {
-                                       templatefile = rdb->getSavedReference();
-                                       m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + "."); m->mothurOutEndLine();
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       templatefile = ""; abort = true; 
-                               } 
-                       }
-                               
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       abskew = validParameter.validFile(parameters, "abskew", false); if (abskew == "not found"){     useAbskew = false;  abskew = "1.9";     }else{  useAbskew = true;  }
-                       if (useAbskew && templatefile != "self") { m->mothurOut("The abskew parameter is only valid with template=self, ignoring."); m->mothurOutEndLine(); useAbskew = false; }
-                       
-                       temp = validParameter.validFile(parameters, "chimealns", false);                        if (temp == "not found") { temp = "f"; }
-                       chimealns = m->isTrue(temp); 
-                       
-                       minh = validParameter.validFile(parameters, "minh", false);                                             if (minh == "not found")                        { useMinH = false; minh = "0.3";                                        }       else{ useMinH = true;                   }
-                       mindiv = validParameter.validFile(parameters, "mindiv", false);                                 if (mindiv == "not found")                      { useMindiv = false; mindiv = "0.5";                            }       else{ useMindiv = true;                 }
-                       xn = validParameter.validFile(parameters, "xn", false);                                                 if (xn == "not found")                          { useXn = false; xn = "8.0";                                            }       else{ useXn = true;                             }
-                       dn = validParameter.validFile(parameters, "dn", false);                                                 if (dn == "not found")                          { useDn = false; dn = "1.4";                                            }       else{ useDn = true;                             }
-                       xa = validParameter.validFile(parameters, "xa", false);                                                 if (xa == "not found")                          { useXa = false; xa = "1";                                                      }       else{ useXa = true;                             }
-                       chunks = validParameter.validFile(parameters, "chunks", false);                                 if (chunks == "not found")                      { useChunks = false; chunks = "4";                                      }       else{ useChunks = true;                 }
-                       minchunk = validParameter.validFile(parameters, "minchunk", false);                             if (minchunk == "not found")            { useMinchunk = false; minchunk = "64";                         }       else{ useMinchunk = true;               }
-                       idsmoothwindow = validParameter.validFile(parameters, "idsmoothwindow", false); if (idsmoothwindow == "not found")      { useIdsmoothwindow = false; idsmoothwindow = "32";     }       else{ useIdsmoothwindow = true; }
-                       //minsmoothid = validParameter.validFile(parameters, "minsmoothid", false);             if (minsmoothid == "not found")         { useMinsmoothid = false; minsmoothid = "0.95";         }       else{ useMinsmoothid = true;    }
-                       maxp = validParameter.validFile(parameters, "maxp", false);                                             if (maxp == "not found")                        { useMaxp = false; maxp = "2";                                          }       else{ useMaxp = true;                   }
-                       minlen = validParameter.validFile(parameters, "minlen", false);                                 if (minlen == "not found")                      { useMinlen = false; minlen = "10";                                     }       else{ useMinlen = true;                 }
-                       maxlen = validParameter.validFile(parameters, "maxlen", false);                                 if (maxlen == "not found")                      { useMaxlen = false; maxlen = "10000";                          }       else{ useMaxlen = true;                 }
-                       
-                       temp = validParameter.validFile(parameters, "ucl", false);                                              if (temp == "not found") { temp = "f"; }
-                       ucl = m->isTrue(temp);
-                       
-                       queryfract = validParameter.validFile(parameters, "queryfract", false);                 if (queryfract == "not found")          { useQueryfract = false; queryfract = "0.5";            }       else{ useQueryfract = true;             }
-                       if (!ucl && useQueryfract) { m->mothurOut("queryfact may only be used when ucl=t, ignoring."); m->mothurOutEndLine(); useQueryfract = false; }
-                       
-                       temp = validParameter.validFile(parameters, "skipgaps", false);                                 if (temp == "not found") { temp = "t"; }
-                       skipgaps = m->isTrue(temp); 
-
-                       temp = validParameter.validFile(parameters, "skipgaps2", false);                                if (temp == "not found") { temp = "t"; }
-                       skipgaps2 = m->isTrue(temp); 
-                       
-                       if (hasName && (templatefile != "self")) { m->mothurOut("You have provided a namefile and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
-                       if (hasGroup && (templatefile != "self")) { m->mothurOut("You have provided a group file and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; }
-                       
-                       //look for uchime exe
-                       path = m->argv;
-                       string tempPath = path;
-                       for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); }
-                       path = path.substr(0, (tempPath.find_last_of('m')));
-                       
-                       string uchimeCommand;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       uchimeCommand = path + "uchime";        //      format the database, -o option gives us the ability
-#else
-                       uchimeCommand = path + "uchime.exe";
-#endif
-                       
-                       //test to make sure uchime exists
-                       ifstream in;
-                       uchimeCommand = m->getFullPathName(uchimeCommand);
-                       int ableToOpen = m->openInputFile(uchimeCommand, in, "no error"); in.close();
-                       if(ableToOpen == 1) {   m->mothurOut("[ERROR]: " + uchimeCommand + " file does not exist. mothur requires the uchime executable."); m->mothurOutEndLine(); abort = true; }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraSlayerCommand", "ChimeraSlayerCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ChimeraUchimeCommand::execute(){
-       try{
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               m->mothurOut("\nuchime by Robert C. Edgar\nhttp://drive5.com/uchime\nThis code is donated to the public domain.\n\n");
-               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                       
-                       m->mothurOut("Checking sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       int start = time(NULL); 
-                       string nameFile = "";
-                       if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]);  }//if user entered a file with a path then preserve it                               
-                       string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "uchime.chimera";
-                       string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "uchime.accnos";
-                       string alnsFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s]))  + "uchime.alns";
-                       string newFasta = m->getRootName(fastaFileNames[s]) + "temp";
-                               
-                       //you provided a groupfile
-                       string groupFile = "";
-                       if (groupFileNames.size() != 0) { groupFile = groupFileNames[s]; }
-                       
-                       if ((templatefile == "self") && (groupFile == "")) { //you want to run uchime with a reference template
-
-                               if (processors != 1) { m->mothurOut("When using template=self, mothur can only use 1 processor, continuing."); m->mothurOutEndLine(); processors = 1; }
-                               if (nameFileNames.size() != 0) { //you provided a namefile and we don't need to create one
-                                       nameFile = nameFileNames[s];
-                               }else { nameFile = getNamesFile(fastaFileNames[s]); }
-                                                                               
-                               map<string, string> seqs;  
-                               readFasta(fastaFileNames[s], seqs);  if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {   m->mothurRemove(outputNames[j]);        }  return 0; }
-
-                               //read namefile
-                               vector<seqPriorityNode> nameMapCount;
-                               int error = m->readNames(nameFile, nameMapCount, seqs); if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0; }
-                               if (error == 1) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0; }
-                               if (seqs.size() != nameMapCount.size()) { m->mothurOut( "The number of sequences in your fastafile does not match the number of sequences in your namefile, aborting."); m->mothurOutEndLine(); for (int j = 0; j < outputNames.size(); j++) {  m->mothurRemove(outputNames[j]);        }  return 0; }
-                               
-                               printFile(nameMapCount, newFasta);
-                               fastaFileNames[s] = newFasta;
-                       }
-                       
-                       if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }                               
-                       
-                       if (groupFile != "") {
-                               if (nameFileNames.size() != 0) { //you provided a namefile and we don't need to create one
-                                       nameFile = nameFileNames[s];
-                               }else { nameFile = getNamesFile(fastaFileNames[s]); }
-                               
-                               //Parse sequences by group
-                               SequenceParser parser(groupFile, fastaFileNames[s], nameFile);
-                               vector<string> groups = parser.getNamesOfGroups();
-                                       
-                               if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        }  return 0; }
-                                                               
-                               //clears files
-                               ofstream out, out1, out2;
-                               m->openOutputFile(outputFileName, out); out.close(); 
-                               m->openOutputFile(accnosFileName, out1); out1.close();
-                               if (chimealns) { m->openOutputFile(alnsFileName, out2); out2.close(); }
-                               int totalSeqs = 0;
-                               
-                               if(processors == 1)     {       totalSeqs = driverGroups(parser, outputFileName, newFasta, accnosFileName, alnsFileName, 0, groups.size(), groups);     }
-                               else                            {       totalSeqs = createProcessesGroups(parser, outputFileName, newFasta, accnosFileName, alnsFileName, groups, nameFile, groupFile, fastaFileNames[s]);                      }
-
-                               if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }                               
-
-                               int totalChimeras = deconvoluteResults(parser, outputFileName, accnosFileName, alnsFileName);
-                               
-                               m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(totalSeqs) + " sequences. " + toString(totalChimeras) + " chimeras were found.");  m->mothurOutEndLine();
-                               m->mothurOut("The number of sequences checked may be larger than the number of unique sequences because some sequences are found in several samples."); m->mothurOutEndLine(); 
-                               
-                               if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }                               
-                                       
-                       }else{
-                               if (m->control_pressed) {  for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        }  return 0;    }
-                       
-                               int numSeqs = 0;
-                               int numChimeras = 0;
-
-                               if(processors == 1){ numSeqs = driver(outputFileName, fastaFileNames[s], accnosFileName, alnsFileName, numChimeras); }
-                               else{   numSeqs = createProcesses(outputFileName, fastaFileNames[s], accnosFileName, alnsFileName, numChimeras); }
-                               
-                               //add headings
-                               ofstream out;
-                               m->openOutputFile(outputFileName+".temp", out); 
-                               out << "Score\tQuery\tParentA\tParentB\tIdQM\tIdQA\tIdQB\tIdAB\tIdQT\tLY\tLN\tLA\tRY\tRN\tRA\tDiv\tYN\n";
-                               out.close();
-                               
-                               m->appendFiles(outputFileName, outputFileName+".temp");
-                               m->mothurRemove(outputFileName); rename((outputFileName+".temp").c_str(), outputFileName.c_str());
-                               
-                               if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        } return 0; }
-                       
-                               //remove file made for uchime
-                               if (templatefile == "self") {  m->mothurRemove(fastaFileNames[s]); }
-                       
-                               m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences. " + toString(numChimeras) + " chimeras were found.");      m->mothurOutEndLine();
-                       }
-                       
-                       outputNames.push_back(outputFileName); outputTypes["chimera"].push_back(outputFileName);
-                       outputNames.push_back(accnosFileName); outputTypes["accnos"].push_back(accnosFileName);
-                       if (chimealns) { outputNames.push_back(alnsFileName); outputTypes["alns"].push_back(alnsFileName); }
-               }
-       
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraUchimeCommand::deconvoluteResults(SequenceParser& parser, string outputFileName, string accnosFileName, string alnsFileName){
-       try {
-               map<string, string> uniqueNames = parser.getAllSeqsMap();
-               map<string, string>::iterator itUnique;
-               int total = 0;
-               
-               //edit accnos file
-               ifstream in2; 
-               m->openInputFile(accnosFileName, in2);
-               
-               ofstream out2;
-               m->openOutputFile(accnosFileName+".temp", out2);
-               
-               string name;
-               set<string> namesInFile; //this is so if a sequence is found to be chimera in several samples we dont write it to the results file more than once
-               set<string>::iterator itNames;
-               set<string> chimerasInFile;
-               set<string>::iterator itChimeras;
-
-               
-               while (!in2.eof()) {
-                       if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName+".temp")); return 0; }
-                       
-                       in2 >> name; m->gobble(in2);
-                       
-                       //find unique name
-                       itUnique = uniqueNames.find(name);
-                       
-                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing accnos results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       else {
-                               itChimeras = chimerasInFile.find((itUnique->second));
-                               
-                               if (itChimeras == chimerasInFile.end()) {
-                                       out2 << itUnique->second << endl;
-                                       chimerasInFile.insert((itUnique->second));
-                                       total++;
-                               }
-                       }
-               }
-               in2.close();
-               out2.close();
-               
-               m->mothurRemove(accnosFileName);
-               rename((accnosFileName+".temp").c_str(), accnosFileName.c_str());
-               
-               
-               
-               //edit chimera file
-               ifstream in; 
-               m->openInputFile(outputFileName, in);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName+".temp", out); out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               out << "Score\tQuery\tParentA\tParentB\tIdQM\tIdQA\tIdQB\tIdAB\tIdQT\tLY\tLN\tLA\tRY\tRN\tRA\tDiv\tYN\n";
-               
-               float temp1;
-               string parent1, parent2, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10, temp11, temp12, temp13, flag;
-               name = "";
-               namesInFile.clear();    
-               //assumptions - in file each read will always look like - if uchime source is updated, revisit this code.
-               /*                                                                              1       2       3       4       5       6       7       8       9       10      11      12      13      14      15
-                0.000000       F11Fcsw_33372/ab=18/            *       *       *       *       *       *       *       *       *       *       *       *       *       *       N
-                0.018300       F11Fcsw_14980/ab=16/            F11Fcsw_1915/ab=35/     F11Fcsw_6032/ab=42/     79.9    78.7    78.2    78.7    79.2    3       0       5       11      10      20      1.46    N
-               */
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove((outputFileName+".temp")); return 0; }
-                       
-                       bool print = false;
-                       in >> temp1;    m->gobble(in);
-                       in >> name;             m->gobble(in);
-                       in >> parent1;  m->gobble(in);
-                       in >> parent2;  m->gobble(in);
-                       in >> temp2 >> temp3 >> temp4 >> temp5 >> temp6 >> temp7 >> temp8 >> temp9 >> temp10 >> temp11 >> temp12 >> temp13 >> flag;
-                       m->gobble(in);
-                       
-                       //parse name - name will look like U68590/ab=1/
-                       string restOfName = "";
-                       int pos = name.find_first_of('/');
-                       if (pos != string::npos) {
-                               restOfName = name.substr(pos);
-                               name = name.substr(0, pos);
-                       }
-                       
-                       //find unique name
-                       itUnique = uniqueNames.find(name);
-                       
-                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find "+ name + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       else {
-                               name = itUnique->second;
-                               //is this name already in the file
-                               itNames = namesInFile.find((name));
-                               
-                               if (itNames == namesInFile.end()) { //no not in file
-                                       if (flag == "N") { //are you really a no??
-                                               //is this sequence really not chimeric??
-                                               itChimeras = chimerasInFile.find(name);
-                                               
-                                               //then you really are a no so print, otherwise skip
-                                               if (itChimeras == chimerasInFile.end()) { print = true; }
-                                       }else{ print = true; }
-                               }
-                       }
-                       
-                       if (print) {
-                               out << temp1 << '\t' << name << restOfName << '\t';
-                               namesInFile.insert(name);
-                               
-                               //parse parent1 names
-                               if (parent1 != "*") {
-                                       restOfName = "";
-                                       pos = parent1.find_first_of('/');
-                                       if (pos != string::npos) {
-                                               restOfName = parent1.substr(pos);
-                                               parent1 = parent1.substr(0, pos);
-                                       }
-                                       
-                                       itUnique = uniqueNames.find(parent1);
-                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parentA "+ parent1 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else {  out << itUnique->second << restOfName << '\t';  }
-                               }else { out << parent1 << '\t'; }
-                               
-                               //parse parent2 names
-                               if (parent2 != "*") {
-                                       restOfName = "";
-                                       pos = parent2.find_first_of('/');
-                                       if (pos != string::npos) {
-                                               restOfName = parent2.substr(pos);
-                                               parent2 = parent2.substr(0, pos);
-                                       }
-                                       
-                                       itUnique = uniqueNames.find(parent2);
-                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing chimera results. Cannot find parentB "+ parent2 + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else {  out << itUnique->second << restOfName << '\t';  }
-                               }else { out << parent2 << '\t'; }
-                               
-                               out << temp2 << '\t' << temp3 << '\t' << temp4 << '\t' << temp5 << '\t' << temp6 << '\t' << temp7 << '\t' << temp8 << '\t' << temp9 << '\t' << temp10 << '\t' << temp11 << '\t' << temp12 << temp13 << '\t' << flag << endl;    
-                       }
-               }
-               in.close();
-               out.close();
-               
-               m->mothurRemove(outputFileName);
-               rename((outputFileName+".temp").c_str(), outputFileName.c_str());
-               
-                               
-               //edit anls file
-               //assumptions - in file each read will always look like - if uchime source is updated, revisit this code.
-               /*
-                ------------------------------------------------------------------------
-                Query   (  179 nt) F21Fcsw_11639/ab=591/
-                ParentA (  179 nt) F11Fcsw_6529/ab=1625/
-                ParentB (  181 nt) F21Fcsw_12128/ab=1827/
-                
-                A     1 AAGgAAGAtTAATACaagATGgCaTCatgAGtccgCATgTtcAcatGATTAAAG--gTaTtcCGGTagacGATGGGGATG 78
-                Q     1 AAGTAAGACTAATACCCAATGACGTCTCTAGAAGACATCTGAAAGAGATTAAAG--ATTTATCGGTGATGGATGGGGATG 78
-                B     1 AAGgAAGAtTAATcCaggATGggaTCatgAGttcACATgTccgcatGATTAAAGgtATTTtcCGGTagacGATGGGGATG 80
-                Diffs      N    N    A N?N   N N  NNN  N?NB   N ?NaNNN          B B NN    NNNN          
-                Votes      0    0    + 000   0 0  000  000+   0 00!000            + 00    0000          
-                Model   AAAAAAAAAAAAAAAAAAAAAAxBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-                
-                A    79 CGTtccATTAGaTaGTaGGCGGGGTAACGGCCCACCtAGtCttCGATggaTAGGGGTTCTGAGAGGAAGGTCCCCCACAT 158
-                Q    79 CGTCTGATTAGCTTGTTGGCGGGGTAACGGCCCACCAAGGCAACGATCAGTAGGGGTTCTGAGAGGAAGGTCCCCCACAT 158
-                B    81 CGTtccATTAGaTaGTaGGCGGGGTAACGGCCCACCtAGtCAACGATggaTAGGGGTTCTGAGAGGAAGGTCCCCCACAT 160
-                Diffs      NNN     N N  N                   N  N BB    NNN                              
-                Votes      000     0 0  0                   0  0 ++    000                              
-                Model   BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
-                
-                A   159 TGGAACTGAGACACGGTCCAA 179
-                Q   159 TGGAACTGAGACACGGTCCAA 179
-                B   161 TGGAACTGAGACACGGTCCAA 181
-                Diffs                        
-                Votes                        
-                Model   BBBBBBBBBBBBBBBBBBBBB
-                
-                Ids.  QA 76.6%, QB 77.7%, AB 93.7%, QModel 78.9%, Div. +1.5%
-                Diffs Left 7: N 0, A 6, Y 1 (14.3%); Right 35: N 1, A 30, Y 4 (11.4%), Score 0.0047
-               */
-               if (chimealns) {
-                       ifstream in3; 
-                       m->openInputFile(alnsFileName, in3);
-               
-                       ofstream out3;
-                       m->openOutputFile(alnsFileName+".temp", out3); out3.setf(ios::fixed, ios::floatfield); out3.setf(ios::showpoint);
-               
-                       name = "";
-                       namesInFile.clear();
-                       string line = "";
-                       
-                       while (!in3.eof()) {
-                               if (m->control_pressed) { in3.close(); out3.close(); m->mothurRemove(outputFileName); m->mothurRemove((accnosFileName)); m->mothurRemove((alnsFileName+".temp")); return 0; }
-                               
-                               line = "";
-                               line = m->getline(in3); 
-                               string temp = "";
-                               
-                               if (line != "") {
-                                       istringstream iss(line);
-                                       iss >> temp;
-                                       
-                                       //are you a name line
-                                       if ((temp == "Query") || (temp == "ParentA") || (temp == "ParentB")) {
-                                               int spot = 0;
-                                               for (int i = 0; i < line.length(); i++) {
-                                                       spot = i;
-                                                       if (line[i] == ')') { break; }
-                                                       else { out3 << line[i]; }
-                                               }
-                                               
-                                               if (spot == (line.length() - 1)) { m->mothurOut("[ERROR]: could not line sequence name in line " + line + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else if ((spot+2) > (line.length() - 1)) { m->mothurOut("[ERROR]: could not line sequence name in line " + line + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                               else {
-                                                       out << line[spot] << line[spot+1];
-                                                       
-                                                       name = line.substr(spot+2);
-                                                       
-                                                       //parse name - name will either look like U68590/ab=1/ or U68590
-                                                       string restOfName = "";
-                                                       int pos = name.find_first_of('/');
-                                                       if (pos != string::npos) {
-                                                               restOfName = name.substr(pos);
-                                                               name = name.substr(0, pos);
-                                                       }
-                                                       
-                                                       //find unique name
-                                                       itUnique = uniqueNames.find(name);
-                                                       
-                                                       if (itUnique == uniqueNames.end()) { m->mothurOut("[ERROR]: trouble parsing alns results. Cannot find "+ name + "."); m->mothurOutEndLine();m->control_pressed = true;  }
-                                                       else {
-                                                               //only limit repeats on query names
-                                                               if (temp == "Query") {
-                                                                       itNames = namesInFile.find((itUnique->second));
-                                                                       
-                                                                       if (itNames == namesInFile.end()) {
-                                                                               out << itUnique->second << restOfName << endl;
-                                                                               namesInFile.insert((itUnique->second));
-                                                                       }
-                                                               }else { out << itUnique->second << restOfName << endl;  }
-                                                       }
-                                                       
-                                               }
-                                               
-                                       }else { //not need to alter line
-                                               out3 << line << endl;
-                                       }
-                               }else { out3 << endl; }
-                       }
-                       in3.close();
-                       out3.close();
-                       
-                       m->mothurRemove(alnsFileName);
-                       rename((alnsFileName+".temp").c_str(), alnsFileName.c_str());
-               }
-               
-               return total;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "deconvoluteResults");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int ChimeraUchimeCommand::printFile(vector<seqPriorityNode>& nameMapCount, string filename){
-       try {
-               
-               sort(nameMapCount.begin(), nameMapCount.end(), compareSeqPriorityNodes);
-               
-               ofstream out;
-               m->openOutputFile(filename, out);
-               
-               //print new file in order of
-               for (int i = 0; i < nameMapCount.size(); i++) {
-                       out << ">" << nameMapCount[i].name  << "/ab=" << nameMapCount[i].numIdentical << "/" << endl << nameMapCount[i].seq << endl;
-               }
-               out.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "printFile");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int ChimeraUchimeCommand::readFasta(string filename, map<string, string>& seqs){
-       try {
-               //create input file for uchime
-               //read through fastafile and store info
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       seqs[seq.getName()] = seq.getAligned();
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "readFasta");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-
-string ChimeraUchimeCommand::getNamesFile(string& inputFile){
-       try {
-               string nameFile = "";
-               
-               m->mothurOutEndLine(); m->mothurOut("No namesfile given, running unique.seqs command to generate one."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               //use unique.seqs to create new name and fastafile
-               string inputString = "fasta=" + inputFile;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-               m->mothurCalling = true;
-        
-               Command* uniqueCommand = new DeconvoluteCommand(inputString);
-               uniqueCommand->execute();
-               
-               map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-               
-               delete uniqueCommand;
-               m->mothurCalling = false;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               
-               nameFile = filenames["name"][0];
-               inputFile = filenames["fasta"][0];
-               
-               return nameFile;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "getNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ChimeraUchimeCommand::driverGroups(SequenceParser& parser, string outputFName, string filename, string accnos, string alns, int start, int end, vector<string> groups){
-       try {
-               
-               int totalSeqs = 0;
-               int numChimeras = 0;
-               
-               for (int i = start; i < end; i++) {
-                       int start = time(NULL);  if (m->control_pressed) {  return 0; }
-                       
-                       int error = parser.getSeqs(groups[i], filename, true); if ((error == 1) || m->control_pressed) {  return 0; }
-                       
-                       int numSeqs = driver((outputFName + groups[i]), filename, (accnos+ groups[i]), (alns+ groups[i]), numChimeras);
-                       totalSeqs += numSeqs;
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //remove file made for uchime
-                       m->mothurRemove(filename);
-                       
-                       //append files
-                       m->appendFiles((outputFName+groups[i]), outputFName); m->mothurRemove((outputFName+groups[i]));
-                       m->appendFiles((accnos+groups[i]), accnos); m->mothurRemove((accnos+groups[i]));
-                       if (chimealns) { m->appendFiles((alns+groups[i]), alns); m->mothurRemove((alns+groups[i])); }
-                       
-                       m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences from group " + groups[i] + ".");    m->mothurOutEndLine();                                  
-               }       
-               
-               return totalSeqs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "driverGroups");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-
-int ChimeraUchimeCommand::driver(string outputFName, string filename, string accnos, string alns, int& numChimeras){
-       try {
-               
-               outputFName = m->getFullPathName(outputFName);
-               filename = m->getFullPathName(filename);
-               alns = m->getFullPathName(alns);
-               
-               //to allow for spaces in the path
-               outputFName = "\"" + outputFName + "\"";
-               filename = "\"" + filename + "\"";
-               alns = "\"" + alns + "\"";
-                               
-               vector<char*> cPara;
-               
-               string path = m->argv;
-               string tempPath = path;
-               for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); }
-               path = path.substr(0, (tempPath.find_last_of('m')));
-               
-               string uchimeCommand = path;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               uchimeCommand += "uchime ";
-#else
-               uchimeCommand += "uchime";
-               uchimeCommand = "\"" + uchimeCommand + "\"";
-#endif
-               
-               char* tempUchime;
-               tempUchime= new char[uchimeCommand.length()+1]; 
-               *tempUchime = '\0';
-               strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
-               cPara.push_back(tempUchime);
-               
-               char* tempIn = new char[8]; 
-               *tempIn = '\0'; strncat(tempIn, "--input", 7);
-               //strcpy(tempIn, "--input"); 
-               cPara.push_back(tempIn);
-               char* temp = new char[filename.length()+1];
-               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
-               //strcpy(temp, filename.c_str());
-               cPara.push_back(temp);
-               
-               //are you using a reference file
-               if (templatefile != "self") {
-                       //add reference file
-                       char* tempRef = new char[5]; 
-                       //strcpy(tempRef, "--db"); 
-                       *tempRef = '\0'; strncat(tempRef, "--db", 4);
-                       cPara.push_back(tempRef);  
-                       char* tempR = new char[templatefile.length()+1];
-                       //strcpy(tempR, templatefile.c_str());
-                       *tempR = '\0'; strncat(tempR, templatefile.c_str(), templatefile.length());
-                       cPara.push_back(tempR);
-               }
-               
-               char* tempO = new char[12]; 
-               *tempO = '\0'; strncat(tempO, "--uchimeout", 11);
-               //strcpy(tempO, "--uchimeout"); 
-               cPara.push_back(tempO);
-               char* tempout = new char[outputFName.length()+1];
-               //strcpy(tempout, outputFName.c_str());
-               *tempout = '\0'; strncat(tempout, outputFName.c_str(), outputFName.length());
-               cPara.push_back(tempout);
-               
-               if (chimealns) {
-                       char* tempA = new char[13]; 
-                       *tempA = '\0'; strncat(tempA, "--uchimealns", 12);
-                       //strcpy(tempA, "--uchimealns"); 
-                       cPara.push_back(tempA);
-                       char* tempa = new char[alns.length()+1];
-                       //strcpy(tempa, alns.c_str());
-                       *tempa = '\0'; strncat(tempa, alns.c_str(), alns.length());
-                       cPara.push_back(tempa);
-               }
-               
-               if (useAbskew) {
-                       char* tempskew = new char[9];
-                       *tempskew = '\0'; strncat(tempskew, "--abskew", 8);
-                       //strcpy(tempskew, "--abskew"); 
-                       cPara.push_back(tempskew);
-                       char* tempSkew = new char[abskew.length()+1];
-                       //strcpy(tempSkew, abskew.c_str());
-                       *tempSkew = '\0'; strncat(tempSkew, abskew.c_str(), abskew.length());
-                       cPara.push_back(tempSkew);
-               }
-               
-               if (useMinH) {
-                       char* tempminh = new char[7]; 
-                       *tempminh = '\0'; strncat(tempminh, "--minh", 6);
-                       //strcpy(tempminh, "--minh"); 
-                       cPara.push_back(tempminh);
-                       char* tempMinH = new char[minh.length()+1];
-                       *tempMinH = '\0'; strncat(tempMinH, minh.c_str(), minh.length());
-                       //strcpy(tempMinH, minh.c_str());
-                       cPara.push_back(tempMinH);
-               }
-               
-               if (useMindiv) {
-                       char* tempmindiv = new char[9]; 
-                       *tempmindiv = '\0'; strncat(tempmindiv, "--mindiv", 8);
-                       //strcpy(tempmindiv, "--mindiv"); 
-                       cPara.push_back(tempmindiv);
-                       char* tempMindiv = new char[mindiv.length()+1];
-                       *tempMindiv = '\0'; strncat(tempMindiv, mindiv.c_str(), mindiv.length());
-                       //strcpy(tempMindiv, mindiv.c_str());
-                       cPara.push_back(tempMindiv);
-               }
-               
-               if (useXn) {
-                       char* tempxn = new char[5]; 
-                       //strcpy(tempxn, "--xn"); 
-                       *tempxn = '\0'; strncat(tempxn, "--xn", 4);
-                       cPara.push_back(tempxn);
-                       char* tempXn = new char[xn.length()+1];
-                       //strcpy(tempXn, xn.c_str());
-                       *tempXn = '\0'; strncat(tempXn, xn.c_str(), xn.length());
-                       cPara.push_back(tempXn);
-               }
-               
-               if (useDn) {
-                       char* tempdn = new char[5]; 
-                       //strcpy(tempdn, "--dn"); 
-                       *tempdn = '\0'; strncat(tempdn, "--dn", 4);
-                       cPara.push_back(tempdn);
-                       char* tempDn = new char[dn.length()+1];
-                       *tempDn = '\0'; strncat(tempDn, dn.c_str(), dn.length());
-                       //strcpy(tempDn, dn.c_str());
-                       cPara.push_back(tempDn);
-               }
-               
-               if (useXa) {
-                       char* tempxa = new char[5]; 
-                       //strcpy(tempxa, "--xa"); 
-                       *tempxa = '\0'; strncat(tempxa, "--xa", 4);
-                       cPara.push_back(tempxa);
-                       char* tempXa = new char[xa.length()+1];
-                       *tempXa = '\0'; strncat(tempXa, xa.c_str(), xa.length());
-                       //strcpy(tempXa, xa.c_str());
-                       cPara.push_back(tempXa);
-               }
-               
-               if (useChunks) {
-                       char* tempchunks = new char[9]; 
-                       //strcpy(tempchunks, "--chunks"); 
-                       *tempchunks = '\0'; strncat(tempchunks, "--chunks", 8);
-                       cPara.push_back(tempchunks);
-                       char* tempChunks = new char[chunks.length()+1];
-                       *tempChunks = '\0'; strncat(tempChunks, chunks.c_str(), chunks.length());
-                       //strcpy(tempChunks, chunks.c_str());
-                       cPara.push_back(tempChunks);
-               }
-               
-               if (useMinchunk) {
-                       char* tempminchunk = new char[11]; 
-                       //strcpy(tempminchunk, "--minchunk"); 
-                       *tempminchunk = '\0'; strncat(tempminchunk, "--minchunk", 10);
-                       cPara.push_back(tempminchunk);
-                       char* tempMinchunk = new char[minchunk.length()+1];
-                       *tempMinchunk = '\0'; strncat(tempMinchunk, minchunk.c_str(), minchunk.length());
-                       //strcpy(tempMinchunk, minchunk.c_str());
-                       cPara.push_back(tempMinchunk);
-               }
-               
-               if (useIdsmoothwindow) {
-                       char* tempidsmoothwindow = new char[17]; 
-                       *tempidsmoothwindow = '\0'; strncat(tempidsmoothwindow, "--idsmoothwindow", 16);
-                       //strcpy(tempidsmoothwindow, "--idsmoothwindow"); 
-                       cPara.push_back(tempidsmoothwindow);
-                       char* tempIdsmoothwindow = new char[idsmoothwindow.length()+1];
-                       *tempIdsmoothwindow = '\0'; strncat(tempIdsmoothwindow, idsmoothwindow.c_str(), idsmoothwindow.length());
-                       //strcpy(tempIdsmoothwindow, idsmoothwindow.c_str());
-                       cPara.push_back(tempIdsmoothwindow);
-               }
-               
-               /*if (useMinsmoothid) {
-                       char* tempminsmoothid = new char[14]; 
-                       //strcpy(tempminsmoothid, "--minsmoothid"); 
-                       *tempminsmoothid = '\0'; strncat(tempminsmoothid, "--minsmoothid", 13);
-                       cPara.push_back(tempminsmoothid);
-                       char* tempMinsmoothid = new char[minsmoothid.length()+1];
-                       *tempMinsmoothid = '\0'; strncat(tempMinsmoothid, minsmoothid.c_str(), minsmoothid.length());
-                       //strcpy(tempMinsmoothid, minsmoothid.c_str());
-                       cPara.push_back(tempMinsmoothid);
-               }*/
-               
-               if (useMaxp) {
-                       char* tempmaxp = new char[7]; 
-                       //strcpy(tempmaxp, "--maxp"); 
-                       *tempmaxp = '\0'; strncat(tempmaxp, "--maxp", 6);
-                       cPara.push_back(tempmaxp);
-                       char* tempMaxp = new char[maxp.length()+1];
-                       *tempMaxp = '\0'; strncat(tempMaxp, maxp.c_str(), maxp.length());
-                       //strcpy(tempMaxp, maxp.c_str());
-                       cPara.push_back(tempMaxp);
-               }
-               
-               if (!skipgaps) {
-                       char* tempskipgaps = new char[13]; 
-                       //strcpy(tempskipgaps, "--[no]skipgaps");
-                       *tempskipgaps = '\0'; strncat(tempskipgaps, "--noskipgaps", 12);
-                       cPara.push_back(tempskipgaps);
-               }
-               
-               if (!skipgaps2) {
-                       char* tempskipgaps2 = new char[14]; 
-                       //strcpy(tempskipgaps2, "--[no]skipgaps2"); 
-                       *tempskipgaps2 = '\0'; strncat(tempskipgaps2, "--noskipgaps2", 13);
-                       cPara.push_back(tempskipgaps2);
-               }
-               
-               if (useMinlen) {
-                       char* tempminlen = new char[9]; 
-                       *tempminlen = '\0'; strncat(tempminlen, "--minlen", 8);
-                       //strcpy(tempminlen, "--minlen"); 
-                       cPara.push_back(tempminlen);
-                       char* tempMinlen = new char[minlen.length()+1];
-                       //strcpy(tempMinlen, minlen.c_str());
-                       *tempMinlen = '\0'; strncat(tempMinlen, minlen.c_str(), minlen.length());
-                       cPara.push_back(tempMinlen);
-               }
-               
-               if (useMaxlen) {
-                       char* tempmaxlen = new char[9]; 
-                       //strcpy(tempmaxlen, "--maxlen"); 
-                       *tempmaxlen = '\0'; strncat(tempmaxlen, "--maxlen", 8);
-                       cPara.push_back(tempmaxlen);
-                       char* tempMaxlen = new char[maxlen.length()+1];
-                       *tempMaxlen = '\0'; strncat(tempMaxlen, maxlen.c_str(), maxlen.length());
-                       //strcpy(tempMaxlen, maxlen.c_str());
-                       cPara.push_back(tempMaxlen);
-               }
-               
-               if (ucl) {
-                       char* tempucl = new char[5]; 
-                       strcpy(tempucl, "--ucl"); 
-                       cPara.push_back(tempucl);
-               }
-               
-               if (useQueryfract) {
-                       char* tempqueryfract = new char[13]; 
-                       *tempqueryfract = '\0'; strncat(tempqueryfract, "--queryfract", 12);
-                       //strcpy(tempqueryfract, "--queryfract"); 
-                       cPara.push_back(tempqueryfract);
-                       char* tempQueryfract = new char[queryfract.length()+1];
-                       *tempQueryfract = '\0'; strncat(tempQueryfract, queryfract.c_str(), queryfract.length());
-                       //strcpy(tempQueryfract, queryfract.c_str());
-                       cPara.push_back(tempQueryfract);
-               }
-               
-               
-               char** uchimeParameters;
-               uchimeParameters = new char*[cPara.size()];
-               string commandString = "";
-               for (int i = 0; i < cPara.size(); i++) {  uchimeParameters[i] = cPara[i];  commandString += toString(cPara[i]) + " "; } 
-               //int numArgs = cPara.size();
-               
-               //uchime_main(numArgs, uchimeParameters); 
-               //cout << "commandString = " << commandString << endl;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-               commandString = "\"" + commandString + "\"";
-#endif
-               system(commandString.c_str());
-               
-               //free memory
-               for(int i = 0; i < cPara.size(); i++)  {  delete cPara[i];  }
-               delete[] uchimeParameters; 
-               
-               //remove "" from filenames
-               outputFName = outputFName.substr(1, outputFName.length()-2);
-               filename = filename.substr(1, filename.length()-2);
-               alns = alns.substr(1, alns.length()-2);
-               
-               if (m->control_pressed) { return 0; }
-               
-               //create accnos file from uchime results
-               ifstream in; 
-               m->openInputFile(outputFName, in);
-               
-               ofstream out;
-               m->openOutputFile(accnos, out);
-               
-               int num = 0;
-               numChimeras = 0;
-               while(!in.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       string name = "";
-                       string chimeraFlag = "";
-                       in >> chimeraFlag >> name;
-                       
-                       //fix name if needed
-                       if (templatefile == "self") { 
-                               name = name.substr(0, name.length()-1); //rip off last /
-                               name = name.substr(0, name.find_last_of('/'));
-                       }
-                       
-                       for (int i = 0; i < 15; i++) {  in >> chimeraFlag; }
-                       m->gobble(in);
-                       
-                       if (chimeraFlag == "Y") {  out << name << endl; numChimeras++; }
-                       num++;
-               }
-               in.close();
-               out.close();
-               
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ChimeraUchimeCommand::createProcesses(string outputFileName, string filename, string accnos, string alns, int& numChimeras) {
-       try {
-               
-               processIDS.clear();
-               int process = 1;
-               int num = 0;
-               vector<string> files;
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-               //break up file into multiple files
-               m->divideFile(filename, processors, files);
-               
-               if (m->control_pressed) {  return 0;  }
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(outputFileName + toString(getpid()) + ".temp", files[process], accnos + toString(getpid()) + ".temp", alns + toString(getpid()) + ".temp", numChimeras);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFileName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out << numChimeras << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driver(outputFileName, files[0], accnos, alns, numChimeras);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFileName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { 
-                               int tempNum = 0; 
-                               in >> tempNum; m->gobble(in);
-                               num += tempNum; 
-                               in >> tempNum;
-                               numChimeras += tempNum;
-                       }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the preClusterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               //divide file
-               int count = 0;
-               int spot = 0;
-               map<int, ofstream*> filehandles;
-               map<int, ofstream*>::iterator it3;
-               
-               ofstream* temp;
-               for (int i = 0; i < processors; i++) {
-                       temp = new ofstream;
-                       filehandles[i] = temp;
-                       m->openOutputFile(filename+toString(i)+".temp", *(temp));
-                       files.push_back(filename+toString(i)+".temp");
-               }
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               while(!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { (*(it3->second)).close(); delete it3->second; } return 0; }
-                       
-                       Sequence tempSeq(in); m->gobble(in); 
-                       
-                       if (tempSeq.getName() != "") {
-                               tempSeq.printSequence(*(filehandles[spot])); 
-                               spot++; count++;
-                               if (spot == processors) { spot = 0; }
-                       }
-               }
-               in.close();
-               
-               //delete memory
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       (*(it3->second)).close();
-                       delete it3->second;
-               }
-               
-               //sanity check for number of processors
-               if (count < processors) { processors = count; }
-               
-               vector<uchimeData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               vector<string> dummy; //used so that we can use the same struct for MyUchimeSeqsThreadFunction and MyUchimeThreadFunction
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = toString(i) + ".temp";
-                       
-                       uchimeData* tempUchime = new uchimeData(outputFileName+extension, templatefile, files[i], "", "", "", accnos+extension, alns+extension, dummy, m, 0, 0,  i);
-                       tempUchime->setBooleans(useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract);
-                       tempUchime->setVariables(abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract);
-                       
-                       pDataArray.push_back(tempUchime);
-                       processIDS.push_back(i);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyUchimeSeqsThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-               
-               //using the main process as a worker saves time and memory
-               num = driver(outputFileName, files[0], accnos, alns, numChimeras);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       numChimeras += pDataArray[i]->numChimeras;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif         
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
-                       m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
-                       m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));
-                       
-                       if (chimealns) {
-                               m->appendFiles((alns + toString(processIDS[i]) + ".temp"), alns);
-                               m->mothurRemove((alns + toString(processIDS[i]) + ".temp"));
-                       }
-               }
-               
-               //get rid of the file pieces.
-               for (int i = 0; i < files.size(); i++) { m->mothurRemove(files[i]); }
-               return num;     
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ChimeraUchimeCommand::createProcessesGroups(SequenceParser& parser, string outputFName, string filename, string accnos, string alns, vector<string> groups, string nameFile, string groupFile, string fastaFile) {
-       try {
-               
-               processIDS.clear();
-               int process = 1;
-               int num = 0;
-               
-               //sanity check
-               if (groups.size() < processors) { processors = groups.size(); }
-               
-               //divide the groups between the processors
-               vector<linePair> lines;
-               int numGroupsPerProcessor = groups.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numGroupsPerProcessor;
-                       int endIndex = (i+1) * numGroupsPerProcessor;
-                       if(i == (processors - 1)){      endIndex = groups.size();       }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverGroups(parser, outputFName + toString(getpid()) + ".temp", filename + toString(getpid()) + ".temp", accnos + toString(getpid()) + ".temp", alns + toString(getpid()) + ".temp", lines[process].start, lines[process].end, groups);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputFName + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driverGroups(parser, outputFName, filename, accnos, alns, lines[0].start, lines[0].end, groups);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  outputFName + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-               }
-                               
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the uchimeData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<uchimeData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = toString(i) + ".temp";
-                       
-                       uchimeData* tempUchime = new uchimeData(outputFName+extension, templatefile, filename+extension, fastaFile, nameFile, groupFile, accnos+extension, alns+extension, groups, m, lines[i].start, lines[i].end,  i);
-                       tempUchime->setBooleans(useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract);
-                       tempUchime->setVariables(abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract);
-                       
-                       pDataArray.push_back(tempUchime);
-                       processIDS.push_back(i);
-                       
-                       //MyUchimeThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyUchimeThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-               
-               //using the main process as a worker saves time and memory
-               num = driverGroups(parser, outputFName, filename, accnos, alns, lines[0].start, lines[0].end, groups);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif         
-               
-                               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((outputFName + toString(processIDS[i]) + ".temp"), outputFName);
-                       m->mothurRemove((outputFName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((accnos + toString(processIDS[i]) + ".temp"), accnos);
-                       m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));
-                       
-                       if (chimealns) {
-                               m->appendFiles((alns + toString(processIDS[i]) + ".temp"), alns);
-                               m->mothurRemove((alns + toString(processIDS[i]) + ".temp"));
-                       }
-               }
-               
-               return num;     
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChimeraUchimeCommand", "createProcessesGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
diff --git a/chimerauchimecommand.h b/chimerauchimecommand.h
deleted file mode 100644 (file)
index b7da889..0000000
+++ /dev/null
@@ -1,785 +0,0 @@
-#ifndef CHIMERAUCHIMECOMMAND_H
-#define CHIMERAUCHIMECOMMAND_H
-
-
-/*
- *  chimerauchimecommand.h
- *  Mothur
- *
- *  Created by westcott on 5/13/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "sequenceparser.h"
-
-/***********************************************************/
-
-class ChimeraUchimeCommand : public Command {
-public:
-       ChimeraUchimeCommand(string);
-       ChimeraUchimeCommand();
-       ~ChimeraUchimeCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "chimera.uchime";              }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "uchime by Robert C. Edgar\nhttp://drive5.com/uchime\nThis code is donated to the public domain.\nhttp://www.mothur.org/wiki/Chimera.uchime\nEdgar,R.C., Haas,B.J., Clemente,J.C., Quince,C. and Knight,R. (2011), UCHIME improves sensitivity and speed of chimera detection, Bioinformatics, in press.\n"; }
-       string getDescription()         { return "detect chimeric sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-       
-private:
-       struct linePair {
-               int start;
-               int end;
-               linePair(int i, int j) : start(i), end(j) {}
-       };
-       
-       vector<int> processIDS;   //processid
-       int driver(string, string, string, string, int&);
-       int createProcesses(string, string, string, string, int&);
-               
-       bool abort, useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract;
-       string fastafile, groupfile, templatefile, outputDir, namefile, abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
-       int processors;
-       
-       
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-       vector<string> nameFileNames;
-       vector<string> groupFileNames;
-       
-       string getNamesFile(string&);
-       int readFasta(string, map<string, string>&);
-       int printFile(vector<seqPriorityNode>&, string);
-       int deconvoluteResults(SequenceParser&, string, string, string);
-       int driverGroups(SequenceParser&, string, string, string, string, int, int, vector<string>);
-       int createProcessesGroups(SequenceParser&, string, string, string, string, vector<string>, string, string, string);
-
-
-};
-
-/***********************************************************/
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct uchimeData {
-       string fastafile; 
-       string namefile; 
-       string groupfile;
-       string outputFName;
-       string accnos, alns, filename, templatefile;
-       MothurOut* m;
-       int start;
-       int end;
-       int threadID, count, numChimeras;
-       vector<string> groups;
-       bool useAbskew, chimealns, useMinH, useMindiv, useXn, useDn, useXa, useChunks, useMinchunk, useIdsmoothwindow, useMinsmoothid, useMaxp, skipgaps, skipgaps2, useMinlen, useMaxlen, ucl, useQueryfract;
-       string abskew, minh, mindiv, xn, dn, xa, chunks, minchunk, idsmoothwindow, minsmoothid, maxp, minlen, maxlen, queryfract;
-       
-       uchimeData(){}
-       uchimeData(string o, string t, string file, string f, string n, string g, string ac,  string al, vector<string> gr, MothurOut* mout, int st, int en, int tid) {
-               fastafile = f;
-               namefile = n;
-               groupfile = g;
-               filename = file;
-               outputFName = o;
-               templatefile = t;
-               accnos = ac;
-               alns = al;
-               m = mout;
-               start = st;
-               end = en;
-               threadID = tid;
-               groups = gr;
-               count = 0;
-               numChimeras = 0;
-       }
-       void setBooleans(bool Abskew, bool calns, bool MinH, bool Mindiv, bool Xn, bool Dn, bool Xa, bool Chunks, bool Minchunk, bool Idsmoothwindow, bool Minsmoothid, bool Maxp, bool skipgap, bool skipgap2, bool Minlen, bool Maxlen, bool uc, bool Queryfract) {
-               useAbskew = Abskew;
-               chimealns = calns;
-               useMinH = MinH;
-               useMindiv = Mindiv;
-               useXn = Xn;
-               useDn = Dn;
-               useXa = Xa;
-               useChunks = Chunks;
-               useMinchunk = Minchunk;
-               useIdsmoothwindow = Idsmoothwindow;
-               useMinsmoothid = Minsmoothid;
-               useMaxp = Maxp;
-               skipgaps = skipgap;
-               skipgaps2 = skipgap2;
-               useMinlen = Minlen;
-               useMaxlen = Maxlen;
-               ucl = uc;
-               useQueryfract = Queryfract;
-       }
-       
-       void setVariables(string abske, string min, string mindi, string x, string d, string xa2, string chunk, string minchun, string idsmoothwindo, string minsmoothi, string max, string minle, string maxle, string queryfrac) {
-               abskew = abske;
-               minh = min;
-               mindiv = mindi;
-               xn = x;
-               dn = d;
-               xa = xa2;
-               chunks = chunk;
-               minchunk = minchun;
-               idsmoothwindow = idsmoothwindo;
-               minsmoothid = minsmoothi;
-               maxp = max;
-               minlen = minle;
-               maxlen = maxle;
-               queryfract = queryfrac;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){ 
-       uchimeData* pDataArray;
-       pDataArray = (uchimeData*)lpParam;
-       
-       try {
-               
-               pDataArray->outputFName = pDataArray->m->getFullPathName(pDataArray->outputFName);
-               pDataArray->filename = pDataArray->m->getFullPathName(pDataArray->filename);
-               pDataArray->alns = pDataArray->m->getFullPathName(pDataArray->alns);
-               
-               //clears files
-               ofstream out, out1, out2;
-               pDataArray->m->openOutputFile(pDataArray->outputFName, out); out.close(); 
-               pDataArray->m->openOutputFile(pDataArray->accnos, out1); out1.close();
-               if (pDataArray->chimealns) { pDataArray->m->openOutputFile(pDataArray->alns, out2); out2.close(); }
-               
-               //parse fasta and name file by group
-               SequenceParser* parser;
-               if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile);      }
-               else                                                    { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile);                                            }
-               
-               int totalSeqs = 0;
-               int numChimeras = 0;
-               
-               for (int i = pDataArray->start; i < pDataArray->end; i++) {
-                       int start = time(NULL);  if (pDataArray->m->control_pressed) {  delete parser; return 0; }
-                       
-                       int error = parser->getSeqs(pDataArray->groups[i], pDataArray->filename, true); if ((error == 1) || pDataArray->m->control_pressed) {  delete parser; return 0; }
-                       
-                       //int numSeqs = driver((outputFName + groups[i]), filename, (accnos+ groups[i]), (alns+ groups[i]), numChimeras);
-                       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-                       
-                       //to allow for spaces in the path
-                       string outputFName = "\"" + pDataArray->outputFName+pDataArray->groups[i] + "\"";
-                       string filename = "\"" + pDataArray->filename + "\"";
-                       string alns = "\"" + pDataArray->alns+pDataArray->groups[i] + "\"";
-                       string accnos = pDataArray->accnos+pDataArray->groups[i];
-                       
-                       vector<char*> cPara;
-                       
-                       string path = pDataArray->m->argv;
-                       string tempPath = path;
-                       for (int j = 0; j < path.length(); j++) { tempPath[j] = tolower(path[j]); }
-                       path = path.substr(0, (tempPath.find_last_of('m')));
-                       
-                       string uchimeCommand = path;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       uchimeCommand += "uchime ";
-#else
-                       uchimeCommand += "uchime";
-                       uchimeCommand = "\"" + uchimeCommand + "\"";
-#endif                 
-                       
-                       char* tempUchime;
-                       tempUchime= new char[uchimeCommand.length()+1]; 
-                       *tempUchime = '\0';
-                       strncat(tempUchime, uchimeCommand.c_str(), uchimeCommand.length());
-                       cPara.push_back(tempUchime);
-                       
-                       char* tempIn = new char[8]; 
-                       *tempIn = '\0'; strncat(tempIn, "--input", 7);
-                       //strcpy(tempIn, "--input"); 
-                       cPara.push_back(tempIn);
-                       char* temp = new char[filename.length()+1];
-                       *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
-                       //strcpy(temp, filename.c_str());
-                       cPara.push_back(temp);
-                       
-                       char* tempO = new char[12]; 
-                       *tempO = '\0'; strncat(tempO, "--uchimeout", 11);
-                       //strcpy(tempO, "--uchimeout"); 
-                       cPara.push_back(tempO);
-                       char* tempout = new char[outputFName.length()+1];
-                       //strcpy(tempout, outputFName.c_str());
-                       *tempout = '\0'; strncat(tempout, outputFName.c_str(), outputFName.length());
-                       cPara.push_back(tempout);
-                       
-                       if (pDataArray->chimealns) {
-                               char* tempA = new char[13]; 
-                               *tempA = '\0'; strncat(tempA, "--uchimealns", 12);
-                               //strcpy(tempA, "--uchimealns"); 
-                               cPara.push_back(tempA);
-                               char* tempa = new char[alns.length()+1];
-                               //strcpy(tempa, alns.c_str());
-                               *tempa = '\0'; strncat(tempa, alns.c_str(), alns.length());
-                               cPara.push_back(tempa);
-                       }
-                       
-                       if (pDataArray->useAbskew) {
-                               char* tempskew = new char[9];
-                               *tempskew = '\0'; strncat(tempskew, "--abskew", 8);
-                               //strcpy(tempskew, "--abskew"); 
-                               cPara.push_back(tempskew);
-                               char* tempSkew = new char[pDataArray->abskew.length()+1];
-                               //strcpy(tempSkew, abskew.c_str());
-                               *tempSkew = '\0'; strncat(tempSkew, pDataArray->abskew.c_str(), pDataArray->abskew.length());
-                               cPara.push_back(tempSkew);
-                       }
-                       
-                       if (pDataArray->useMinH) {
-                               char* tempminh = new char[7]; 
-                               *tempminh = '\0'; strncat(tempminh, "--minh", 6);
-                               //strcpy(tempminh, "--minh"); 
-                               cPara.push_back(tempminh);
-                               char* tempMinH = new char[pDataArray->minh.length()+1];
-                               *tempMinH = '\0'; strncat(tempMinH, pDataArray->minh.c_str(), pDataArray->minh.length());
-                               //strcpy(tempMinH, minh.c_str());
-                               cPara.push_back(tempMinH);
-                       }
-                       
-                       if (pDataArray->useMindiv) {
-                               char* tempmindiv = new char[9]; 
-                               *tempmindiv = '\0'; strncat(tempmindiv, "--mindiv", 8);
-                               //strcpy(tempmindiv, "--mindiv"); 
-                               cPara.push_back(tempmindiv);
-                               char* tempMindiv = new char[pDataArray->mindiv.length()+1];
-                               *tempMindiv = '\0'; strncat(tempMindiv, pDataArray->mindiv.c_str(), pDataArray->mindiv.length());
-                               //strcpy(tempMindiv, mindiv.c_str());
-                               cPara.push_back(tempMindiv);
-                       }
-                       
-                       if (pDataArray->useXn) {
-                               char* tempxn = new char[5]; 
-                               //strcpy(tempxn, "--xn"); 
-                               *tempxn = '\0'; strncat(tempxn, "--xn", 4);
-                               cPara.push_back(tempxn);
-                               char* tempXn = new char[pDataArray->xn.length()+1];
-                               //strcpy(tempXn, xn.c_str());
-                               *tempXn = '\0'; strncat(tempXn, pDataArray->xn.c_str(), pDataArray->xn.length());
-                               cPara.push_back(tempXn);
-                       }
-                       
-                       if (pDataArray->useDn) {
-                               char* tempdn = new char[5]; 
-                               //strcpy(tempdn, "--dn"); 
-                               *tempdn = '\0'; strncat(tempdn, "--dn", 4);
-                               cPara.push_back(tempdn);
-                               char* tempDn = new char[pDataArray->dn.length()+1];
-                               *tempDn = '\0'; strncat(tempDn, pDataArray->dn.c_str(), pDataArray->dn.length());
-                               //strcpy(tempDn, dn.c_str());
-                               cPara.push_back(tempDn);
-                       }
-                       
-                       if (pDataArray->useXa) {
-                               char* tempxa = new char[5]; 
-                               //strcpy(tempxa, "--xa"); 
-                               *tempxa = '\0'; strncat(tempxa, "--xa", 4);
-                               cPara.push_back(tempxa);
-                               char* tempXa = new char[pDataArray->xa.length()+1];
-                               *tempXa = '\0'; strncat(tempXa, pDataArray->xa.c_str(), pDataArray->xa.length());
-                               //strcpy(tempXa, xa.c_str());
-                               cPara.push_back(tempXa);
-                       }
-                       
-                       if (pDataArray->useChunks) {
-                               char* tempchunks = new char[9]; 
-                               //strcpy(tempchunks, "--chunks"); 
-                               *tempchunks = '\0'; strncat(tempchunks, "--chunks", 8);
-                               cPara.push_back(tempchunks);
-                               char* tempChunks = new char[pDataArray->chunks.length()+1];
-                               *tempChunks = '\0'; strncat(tempChunks, pDataArray->chunks.c_str(), pDataArray->chunks.length());
-                               //strcpy(tempChunks, chunks.c_str());
-                               cPara.push_back(tempChunks);
-                       }
-                       
-                       if (pDataArray->useMinchunk) {
-                               char* tempminchunk = new char[11]; 
-                               //strcpy(tempminchunk, "--minchunk"); 
-                               *tempminchunk = '\0'; strncat(tempminchunk, "--minchunk", 10);
-                               cPara.push_back(tempminchunk);
-                               char* tempMinchunk = new char[pDataArray->minchunk.length()+1];
-                               *tempMinchunk = '\0'; strncat(tempMinchunk, pDataArray->minchunk.c_str(), pDataArray->minchunk.length());
-                               //strcpy(tempMinchunk, minchunk.c_str());
-                               cPara.push_back(tempMinchunk);
-                       }
-                       
-                       if (pDataArray->useIdsmoothwindow) {
-                               char* tempidsmoothwindow = new char[17]; 
-                               *tempidsmoothwindow = '\0'; strncat(tempidsmoothwindow, "--idsmoothwindow", 16);
-                               //strcpy(tempidsmoothwindow, "--idsmoothwindow"); 
-                               cPara.push_back(tempidsmoothwindow);
-                               char* tempIdsmoothwindow = new char[pDataArray->idsmoothwindow.length()+1];
-                               *tempIdsmoothwindow = '\0'; strncat(tempIdsmoothwindow, pDataArray->idsmoothwindow.c_str(), pDataArray->idsmoothwindow.length());
-                               //strcpy(tempIdsmoothwindow, idsmoothwindow.c_str());
-                               cPara.push_back(tempIdsmoothwindow);
-                       }
-                       
-                       if (pDataArray->useMaxp) {
-                               char* tempmaxp = new char[7]; 
-                               //strcpy(tempmaxp, "--maxp"); 
-                               *tempmaxp = '\0'; strncat(tempmaxp, "--maxp", 6);
-                               cPara.push_back(tempmaxp);
-                               char* tempMaxp = new char[pDataArray->maxp.length()+1];
-                               *tempMaxp = '\0'; strncat(tempMaxp, pDataArray->maxp.c_str(), pDataArray->maxp.length());
-                               //strcpy(tempMaxp, maxp.c_str());
-                               cPara.push_back(tempMaxp);
-                       }
-                       
-                       if (!pDataArray->skipgaps) {
-                               char* tempskipgaps = new char[13]; 
-                               //strcpy(tempskipgaps, "--[no]skipgaps");
-                               *tempskipgaps = '\0'; strncat(tempskipgaps, "--noskipgaps", 12);
-                               cPara.push_back(tempskipgaps);
-                       }
-                       
-                       if (!pDataArray->skipgaps2) {
-                               char* tempskipgaps2 = new char[14]; 
-                               //strcpy(tempskipgaps2, "--[no]skipgaps2"); 
-                               *tempskipgaps2 = '\0'; strncat(tempskipgaps2, "--noskipgaps2", 13);
-                               cPara.push_back(tempskipgaps2);
-                       }
-                       
-                       if (pDataArray->useMinlen) {
-                               char* tempminlen = new char[9]; 
-                               *tempminlen = '\0'; strncat(tempminlen, "--minlen", 8);
-                               //strcpy(tempminlen, "--minlen"); 
-                               cPara.push_back(tempminlen);
-                               char* tempMinlen = new char[pDataArray->minlen.length()+1];
-                               //strcpy(tempMinlen, minlen.c_str());
-                               *tempMinlen = '\0'; strncat(tempMinlen, pDataArray->minlen.c_str(), pDataArray->minlen.length());
-                               cPara.push_back(tempMinlen);
-                       }
-                       
-                       if (pDataArray->useMaxlen) {
-                               char* tempmaxlen = new char[9]; 
-                               //strcpy(tempmaxlen, "--maxlen"); 
-                               *tempmaxlen = '\0'; strncat(tempmaxlen, "--maxlen", 8);
-                               cPara.push_back(tempmaxlen);
-                               char* tempMaxlen = new char[pDataArray->maxlen.length()+1];
-                               *tempMaxlen = '\0'; strncat(tempMaxlen, pDataArray->maxlen.c_str(), pDataArray->maxlen.length());
-                               //strcpy(tempMaxlen, maxlen.c_str());
-                               cPara.push_back(tempMaxlen);
-                       }
-                       
-                       if (pDataArray->ucl) {
-                               char* tempucl = new char[5]; 
-                               strcpy(tempucl, "--ucl"); 
-                               cPara.push_back(tempucl);
-                       }
-                       
-                       if (pDataArray->useQueryfract) {
-                               char* tempqueryfract = new char[13]; 
-                               *tempqueryfract = '\0'; strncat(tempqueryfract, "--queryfract", 12);
-                               //strcpy(tempqueryfract, "--queryfract"); 
-                               cPara.push_back(tempqueryfract);
-                               char* tempQueryfract = new char[pDataArray->queryfract.length()+1];
-                               *tempQueryfract = '\0'; strncat(tempQueryfract, pDataArray->queryfract.c_str(), pDataArray->queryfract.length());
-                               //strcpy(tempQueryfract, queryfract.c_str());
-                               cPara.push_back(tempQueryfract);
-                       }
-                       
-                       
-                       char** uchimeParameters;
-                       uchimeParameters = new char*[cPara.size()];
-                       string commandString = "";
-                       for (int j = 0; j < cPara.size(); j++) {  uchimeParameters[j] = cPara[j];  commandString += toString(cPara[j]) + " "; } 
-                       //int numArgs = cPara.size();
-                       
-                       //uchime_main(numArgs, uchimeParameters); 
-                       //cout << "commandString = " << commandString << endl;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-                       commandString = "\"" + commandString + "\"";
-#endif
-                       system(commandString.c_str());
-                       
-                       //free memory
-                       for(int j = 0; j < cPara.size(); j++)  {  delete cPara[j];  }
-                       delete[] uchimeParameters; 
-                       
-                       //remove "" from filenames
-                       outputFName = outputFName.substr(1, outputFName.length()-2);
-                       filename = filename.substr(1, filename.length()-2);
-                       alns = alns.substr(1, alns.length()-2);
-                       
-                       if (pDataArray->m->control_pressed) { delete parser; return 0; }
-                       
-                       //create accnos file from uchime results
-                       ifstream in; 
-                       pDataArray->m->openInputFile(outputFName, in);
-                       
-                       ofstream out;
-                       pDataArray->m->openOutputFile(accnos, out);
-                       
-                       int num = 0;
-                       numChimeras = 0;
-                       while(!in.eof()) {
-                               
-                               if (pDataArray->m->control_pressed) { break; }
-                               
-                               string name = "";
-                               string chimeraFlag = "";
-                               in >> chimeraFlag >> name;
-                               
-                               //fix name 
-                               name = name.substr(0, name.length()-1); //rip off last /
-                               name = name.substr(0, name.find_last_of('/'));
-                               
-                               for (int j = 0; j < 15; j++) {  in >> chimeraFlag; }
-                               pDataArray->m->gobble(in);
-                               
-                               if (chimeraFlag == "Y") {  out << name << endl; numChimeras++; }
-                               num++;
-                       }
-                       in.close();
-                       out.close();
-                       
-                       
-                       ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-                       totalSeqs += num;
-                       pDataArray->numChimeras += numChimeras;
-                       
-                       if (pDataArray->m->control_pressed) { delete parser; return 0; }
-                       
-                       //remove file made for uchime
-                       pDataArray->m->mothurRemove(filename);
-                       
-                       //append files
-                       pDataArray->m->appendFiles(outputFName, pDataArray->outputFName); pDataArray->m->mothurRemove(outputFName);
-                       pDataArray->m->appendFiles(accnos, pDataArray->accnos); pDataArray->m->mothurRemove(accnos);
-                       if (pDataArray->chimealns) { pDataArray->m->appendFiles(alns, pDataArray->alns); pDataArray->m->mothurRemove(alns); }
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(num) + " sequences from group " + pDataArray->groups[i] + ".");    pDataArray->m->mothurOutEndLine();                                      
-                       
-               }       
-               
-               pDataArray->count = totalSeqs;
-               delete parser;
-               return totalSeqs;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ChimeraUchimeCommand", "MyUchimeThreadFunction");
-               exit(1);
-       }
-} 
-/**************************************************************************************************/
-
-static DWORD WINAPI MyUchimeSeqsThreadFunction(LPVOID lpParam){ 
-       uchimeData* pDataArray;
-       pDataArray = (uchimeData*)lpParam;
-       
-       try {
-               
-               pDataArray->outputFName = pDataArray->m->getFullPathName(pDataArray->outputFName);
-               pDataArray->filename = pDataArray->m->getFullPathName(pDataArray->filename);
-               pDataArray->alns = pDataArray->m->getFullPathName(pDataArray->alns);
-               
-               int totalSeqs = 0;
-               int numChimeras = 0;
-       
-               int start = time(NULL);  if (pDataArray->m->control_pressed) { return 0; }
-                       
-               //to allow for spaces in the path
-               string outputFName = "\"" + pDataArray->outputFName + "\"";
-               string filename = "\"" + pDataArray->filename + "\"";
-               string alns = "\"" + pDataArray->alns+ "\"";
-               string templatefile = "\"" + pDataArray->templatefile + "\"";
-               string accnos = pDataArray->accnos;
-               
-               vector<char*> cPara;
-               
-               char* tempUchime;
-               tempUchime= new char[8]; 
-               *tempUchime = '\0';
-               strncat(tempUchime, "uchime ", 7); 
-               cPara.push_back(tempUchime);
-               
-               char* tempIn = new char[8]; 
-               *tempIn = '\0'; strncat(tempIn, "--input", 7);
-               //strcpy(tempIn, "--input"); 
-               cPara.push_back(tempIn);
-               char* temp = new char[filename.length()+1];
-               *temp = '\0'; strncat(temp, filename.c_str(), filename.length());
-               //strcpy(temp, filename.c_str());
-               cPara.push_back(temp);
-       
-               //add reference file
-               char* tempRef = new char[5]; 
-               //strcpy(tempRef, "--db"); 
-               *tempRef = '\0'; strncat(tempRef, "--db", 4);
-               cPara.push_back(tempRef);  
-               char* tempR = new char[templatefile.length()+1];
-               //strcpy(tempR, templatefile.c_str());
-               *tempR = '\0'; strncat(tempR, templatefile.c_str(), templatefile.length());
-               cPara.push_back(tempR);
-               
-               char* tempO = new char[12]; 
-               *tempO = '\0'; strncat(tempO, "--uchimeout", 11);
-               //strcpy(tempO, "--uchimeout"); 
-               cPara.push_back(tempO);
-               char* tempout = new char[outputFName.length()+1];
-               //strcpy(tempout, outputFName.c_str());
-               *tempout = '\0'; strncat(tempout, outputFName.c_str(), outputFName.length());
-               cPara.push_back(tempout);
-               
-               if (pDataArray->chimealns) {
-                       char* tempA = new char[13]; 
-                       *tempA = '\0'; strncat(tempA, "--uchimealns", 12);
-                       //strcpy(tempA, "--uchimealns"); 
-                       cPara.push_back(tempA);
-                       char* tempa = new char[alns.length()+1];
-                       //strcpy(tempa, alns.c_str());
-                       *tempa = '\0'; strncat(tempa, alns.c_str(), alns.length());
-                       cPara.push_back(tempa);
-               }
-               
-               if (pDataArray->useAbskew) {
-                       char* tempskew = new char[9];
-                       *tempskew = '\0'; strncat(tempskew, "--abskew", 8);
-                       //strcpy(tempskew, "--abskew"); 
-                       cPara.push_back(tempskew);
-                       char* tempSkew = new char[pDataArray->abskew.length()+1];
-                       //strcpy(tempSkew, abskew.c_str());
-                       *tempSkew = '\0'; strncat(tempSkew, pDataArray->abskew.c_str(), pDataArray->abskew.length());
-                       cPara.push_back(tempSkew);
-               }
-               
-               if (pDataArray->useMinH) {
-                       char* tempminh = new char[7]; 
-                       *tempminh = '\0'; strncat(tempminh, "--minh", 6);
-                       //strcpy(tempminh, "--minh"); 
-                       cPara.push_back(tempminh);
-                       char* tempMinH = new char[pDataArray->minh.length()+1];
-                       *tempMinH = '\0'; strncat(tempMinH, pDataArray->minh.c_str(), pDataArray->minh.length());
-                       //strcpy(tempMinH, minh.c_str());
-                       cPara.push_back(tempMinH);
-               }
-               
-               if (pDataArray->useMindiv) {
-                       char* tempmindiv = new char[9]; 
-                       *tempmindiv = '\0'; strncat(tempmindiv, "--mindiv", 8);
-                       //strcpy(tempmindiv, "--mindiv"); 
-                       cPara.push_back(tempmindiv);
-                       char* tempMindiv = new char[pDataArray->mindiv.length()+1];
-                       *tempMindiv = '\0'; strncat(tempMindiv, pDataArray->mindiv.c_str(), pDataArray->mindiv.length());
-                       //strcpy(tempMindiv, mindiv.c_str());
-                       cPara.push_back(tempMindiv);
-               }
-               
-               if (pDataArray->useXn) {
-                       char* tempxn = new char[5]; 
-                       //strcpy(tempxn, "--xn"); 
-                       *tempxn = '\0'; strncat(tempxn, "--xn", 4);
-                       cPara.push_back(tempxn);
-                       char* tempXn = new char[pDataArray->xn.length()+1];
-                       //strcpy(tempXn, xn.c_str());
-                       *tempXn = '\0'; strncat(tempXn, pDataArray->xn.c_str(), pDataArray->xn.length());
-                       cPara.push_back(tempXn);
-               }
-               
-               if (pDataArray->useDn) {
-                       char* tempdn = new char[5]; 
-                       //strcpy(tempdn, "--dn"); 
-                       *tempdn = '\0'; strncat(tempdn, "--dn", 4);
-                       cPara.push_back(tempdn);
-                       char* tempDn = new char[pDataArray->dn.length()+1];
-                       *tempDn = '\0'; strncat(tempDn, pDataArray->dn.c_str(), pDataArray->dn.length());
-                       //strcpy(tempDn, dn.c_str());
-                       cPara.push_back(tempDn);
-               }
-               
-               if (pDataArray->useXa) {
-                       char* tempxa = new char[5]; 
-                       //strcpy(tempxa, "--xa"); 
-                       *tempxa = '\0'; strncat(tempxa, "--xa", 4);
-                       cPara.push_back(tempxa);
-                       char* tempXa = new char[pDataArray->xa.length()+1];
-                       *tempXa = '\0'; strncat(tempXa, pDataArray->xa.c_str(), pDataArray->xa.length());
-                       //strcpy(tempXa, xa.c_str());
-                       cPara.push_back(tempXa);
-               }
-               
-               if (pDataArray->useChunks) {
-                       char* tempchunks = new char[9]; 
-                       //strcpy(tempchunks, "--chunks"); 
-                       *tempchunks = '\0'; strncat(tempchunks, "--chunks", 8);
-                       cPara.push_back(tempchunks);
-                       char* tempChunks = new char[pDataArray->chunks.length()+1];
-                       *tempChunks = '\0'; strncat(tempChunks, pDataArray->chunks.c_str(), pDataArray->chunks.length());
-                       //strcpy(tempChunks, chunks.c_str());
-                       cPara.push_back(tempChunks);
-               }
-               
-               if (pDataArray->useMinchunk) {
-                       char* tempminchunk = new char[11]; 
-                       //strcpy(tempminchunk, "--minchunk"); 
-                       *tempminchunk = '\0'; strncat(tempminchunk, "--minchunk", 10);
-                       cPara.push_back(tempminchunk);
-                       char* tempMinchunk = new char[pDataArray->minchunk.length()+1];
-                       *tempMinchunk = '\0'; strncat(tempMinchunk, pDataArray->minchunk.c_str(), pDataArray->minchunk.length());
-                       //strcpy(tempMinchunk, minchunk.c_str());
-                       cPara.push_back(tempMinchunk);
-               }
-               
-               if (pDataArray->useIdsmoothwindow) {
-                       char* tempidsmoothwindow = new char[17]; 
-                       *tempidsmoothwindow = '\0'; strncat(tempidsmoothwindow, "--idsmoothwindow", 16);
-                       //strcpy(tempidsmoothwindow, "--idsmoothwindow"); 
-                       cPara.push_back(tempidsmoothwindow);
-                       char* tempIdsmoothwindow = new char[pDataArray->idsmoothwindow.length()+1];
-                       *tempIdsmoothwindow = '\0'; strncat(tempIdsmoothwindow, pDataArray->idsmoothwindow.c_str(), pDataArray->idsmoothwindow.length());
-                       //strcpy(tempIdsmoothwindow, idsmoothwindow.c_str());
-                       cPara.push_back(tempIdsmoothwindow);
-               }
-               
-               if (pDataArray->useMaxp) {
-                       char* tempmaxp = new char[7]; 
-                       //strcpy(tempmaxp, "--maxp"); 
-                       *tempmaxp = '\0'; strncat(tempmaxp, "--maxp", 6);
-                       cPara.push_back(tempmaxp);
-                       char* tempMaxp = new char[pDataArray->maxp.length()+1];
-                       *tempMaxp = '\0'; strncat(tempMaxp, pDataArray->maxp.c_str(), pDataArray->maxp.length());
-                       //strcpy(tempMaxp, maxp.c_str());
-                       cPara.push_back(tempMaxp);
-               }
-               
-               if (!pDataArray->skipgaps) {
-                       char* tempskipgaps = new char[13]; 
-                       //strcpy(tempskipgaps, "--[no]skipgaps");
-                       *tempskipgaps = '\0'; strncat(tempskipgaps, "--noskipgaps", 12);
-                       cPara.push_back(tempskipgaps);
-               }
-               
-               if (!pDataArray->skipgaps2) {
-                       char* tempskipgaps2 = new char[14]; 
-                       //strcpy(tempskipgaps2, "--[no]skipgaps2"); 
-                       *tempskipgaps2 = '\0'; strncat(tempskipgaps2, "--noskipgaps2", 13);
-                       cPara.push_back(tempskipgaps2);
-               }
-               
-               if (pDataArray->useMinlen) {
-                       char* tempminlen = new char[9]; 
-                       *tempminlen = '\0'; strncat(tempminlen, "--minlen", 8);
-                       //strcpy(tempminlen, "--minlen"); 
-                       cPara.push_back(tempminlen);
-                       char* tempMinlen = new char[pDataArray->minlen.length()+1];
-                       //strcpy(tempMinlen, minlen.c_str());
-                       *tempMinlen = '\0'; strncat(tempMinlen, pDataArray->minlen.c_str(), pDataArray->minlen.length());
-                       cPara.push_back(tempMinlen);
-               }
-               
-               if (pDataArray->useMaxlen) {
-                       char* tempmaxlen = new char[9]; 
-                       //strcpy(tempmaxlen, "--maxlen"); 
-                       *tempmaxlen = '\0'; strncat(tempmaxlen, "--maxlen", 8);
-                       cPara.push_back(tempmaxlen);
-                       char* tempMaxlen = new char[pDataArray->maxlen.length()+1];
-                       *tempMaxlen = '\0'; strncat(tempMaxlen, pDataArray->maxlen.c_str(), pDataArray->maxlen.length());
-                       //strcpy(tempMaxlen, maxlen.c_str());
-                       cPara.push_back(tempMaxlen);
-               }
-               
-               if (pDataArray->ucl) {
-                       char* tempucl = new char[5]; 
-                       strcpy(tempucl, "--ucl"); 
-                       cPara.push_back(tempucl);
-               }
-               
-               if (pDataArray->useQueryfract) {
-                       char* tempqueryfract = new char[13]; 
-                       *tempqueryfract = '\0'; strncat(tempqueryfract, "--queryfract", 12);
-                       //strcpy(tempqueryfract, "--queryfract"); 
-                       cPara.push_back(tempqueryfract);
-                       char* tempQueryfract = new char[pDataArray->queryfract.length()+1];
-                       *tempQueryfract = '\0'; strncat(tempQueryfract, pDataArray->queryfract.c_str(), pDataArray->queryfract.length());
-                       //strcpy(tempQueryfract, queryfract.c_str());
-                       cPara.push_back(tempQueryfract);
-               }
-               
-               
-               char** uchimeParameters;
-               uchimeParameters = new char*[cPara.size()];
-               string commandString = "";
-               for (int j = 0; j < cPara.size(); j++) {  uchimeParameters[j] = cPara[j];  commandString += toString(cPara[j]) + " "; } 
-               //int numArgs = cPara.size();
-               
-               //uchime_main(numArgs, uchimeParameters); 
-               //cout << "commandString = " << commandString << endl;
-               system(commandString.c_str());
-               
-               //free memory
-               for(int j = 0; j < cPara.size(); j++)  {  delete cPara[j];  }
-               delete[] uchimeParameters; 
-               
-               //remove "" from filenames
-               outputFName = outputFName.substr(1, outputFName.length()-2);
-               filename = filename.substr(1, filename.length()-2);
-               alns = alns.substr(1, alns.length()-2);
-               
-               if (pDataArray->m->control_pressed) { return 0; }
-               
-               //create accnos file from uchime results
-               ifstream in; 
-               pDataArray->m->openInputFile(outputFName, in);
-               
-               ofstream out;
-               pDataArray->m->openOutputFile(accnos, out);
-               
-               numChimeras = 0;
-               while(!in.eof()) {
-                       
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       string name = "";
-                       string chimeraFlag = "";
-                       in >> chimeraFlag >> name;
-                       
-                       for (int j = 0; j < 15; j++) {  in >> chimeraFlag; }
-                       pDataArray->m->gobble(in);
-                       
-                       if (chimeraFlag == "Y") {  out << name << endl; numChimeras++; }
-                       totalSeqs++;
-               }
-               in.close();
-               out.close();
-               
-               if (pDataArray->m->control_pressed) { return 0; }
-               
-               pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(totalSeqs) + " sequences.");       pDataArray->m->mothurOutEndLine();                                      
-       
-               pDataArray->count = totalSeqs;
-               pDataArray->numChimeras = numChimeras;
-               return totalSeqs;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ChimeraUchimeCommand", "MyUchimeSeqsThreadFunction");
-               exit(1);
-       }
-} 
-
-#endif
-
-/**************************************************************************************************/
-
-
-#endif
-
-
diff --git a/chopseqscommand.cpp b/chopseqscommand.cpp
deleted file mode 100644 (file)
index 4e06201..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- *  chopseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "chopseqscommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> ChopSeqsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pnumbases("numbases", "Number", "", "0", "", "", "",false,true); parameters.push_back(pnumbases);
-               CommandParameter pcountgaps("countgaps", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcountgaps);
-               CommandParameter pshort("short", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pshort);
-               CommandParameter pkeep("keep", "Multiple", "front-back", "front", "", "", "",false,false); parameters.push_back(pkeep);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChopSeqsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The chop.seqs command reads a fasta file and outputs a .chop.fasta containing the trimmed sequences. Note: If a sequence is completely 'chopped', an accnos file will be created with the names of the sequences removed. \n";
-               helpString += "The chop.seqs command parameters are fasta, numbases, countgaps and keep. fasta is required unless you have a valid current fasta file. numbases is required.\n";
-               helpString += "The chop.seqs command should be in the following format: chop.seqs(fasta=yourFasta, numbases=yourNum, keep=yourKeep).\n";
-               helpString += "The numbases parameter allows you to specify the number of bases you want to keep.\n";
-               helpString += "The keep parameter allows you to specify whether you want to keep the front or the back of your sequence, default=front.\n";
-               helpString += "The countgaps parameter allows you to specify whether you want to count gaps as bases, default=false.\n";
-               helpString += "The short parameter allows you to specify you want to keep sequences that are too short to chop, default=false.\n";
-               helpString += "For example, if you ran chop.seqs with numbases=200 and short=t, if a sequence had 100 bases mothur would keep the sequence rather than eliminate it.\n";
-               helpString += "Example chop.seqs(fasta=amazon.fasta, numbases=200, keep=front).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ChopSeqsCommand::ChopSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "ChopSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ChopSeqsCommand::ChopSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {                            //if there is a current fasta file, use it
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);      }
-                       
-                       string temp = validParameter.validFile(parameters, "numbases", false);  if (temp == "not found") { temp = "0"; } 
-                       m->mothurConvert(temp, numbases);   
-                       
-                       temp = validParameter.validFile(parameters, "countgaps", false);        if (temp == "not found") { temp = "f"; } 
-                       countGaps = m->isTrue(temp);  
-                       
-                       temp = validParameter.validFile(parameters, "short", false);    if (temp == "not found") { temp = "f"; } 
-                       Short = m->isTrue(temp);   
-               
-                       keep = validParameter.validFile(parameters, "keep", false);             if (keep == "not found") { keep = "front"; } 
-                               
-                       if (numbases == 0)  { m->mothurOut("You must provide the number of bases you want to keep for the chops.seqs command."); m->mothurOutEndLine(); abort = true;  }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "ChopSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ChopSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.fasta";
-               string outputFileNameAccnos = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "chop.accnos";
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ofstream outAcc;
-               m->openOutputFile(outputFileNameAccnos, outAcc);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               bool wroteAccnos = false;
-               
-               while (!in.eof()) {
-                       
-                       Sequence seq(in);
-                       
-                       if (m->control_pressed) { outputTypes.clear(); in.close(); out.close(); outAcc.close(); m->mothurRemove(outputFileName); m->mothurRemove(outputFileNameAccnos); return 0;  }
-                       
-                       if (seq.getName() != "") {
-                               string newSeqString = getChopped(seq);
-                               
-                               //output trimmed sequence
-                               if (newSeqString != "") {
-                                       out << ">" << seq.getName() << endl << newSeqString << endl;
-                               }else{
-                                       outAcc << seq.getName() << endl;
-                                       wroteAccnos = true;
-                               }
-                       }
-               }
-               in.close();
-               out.close();
-               outAcc.close();
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
-               
-               if (wroteAccnos) { m->mothurOut(outputFileNameAccnos); m->mothurOutEndLine(); outputNames.push_back(outputFileNameAccnos); outputTypes["accnos"].push_back(outputFileNameAccnos); }
-               else {  m->mothurRemove(outputFileNameAccnos);  }
-               
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               if (wroteAccnos) { //set accnos file as new current accnosfile
-                       itTypes = outputTypes.find("accnos");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-                       }
-               }
-               
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ChopSeqsCommand::getChopped(Sequence seq) {
-       try {
-               string temp = seq.getAligned();
-               string tempUnaligned = seq.getUnaligned();
-               
-               if (countGaps) {
-                       //if needed trim sequence
-                       if (keep == "front") {//you want to keep the beginning
-                               int tempLength = temp.length();
-
-                               if (tempLength > numbases) { //you have enough bases to remove some
-                               
-                                       int stopSpot = 0;
-                                       int numBasesCounted = 0;
-                                       
-                                       for (int i = 0; i < temp.length(); i++) {
-                                               //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { temp[i] = '.'; }
-                                               
-                                               numBasesCounted++; 
-                                               
-                                               if (numBasesCounted >= numbases) { stopSpot = i; break; }
-                                       }
-                                       
-                                       if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(0, stopSpot+1);  }
-                                                       
-                               }else { 
-                                       if (!Short) { temp = ""; } //sequence too short
-                               }
-                       }else { //you are keeping the back
-                               int tempLength = temp.length();
-                               if (tempLength > numbases) { //you have enough bases to remove some
-                                       
-                                       int stopSpot = 0;
-                                       int numBasesCounted = 0;
-                                       
-                                       for (int i = (temp.length()-1); i >= 0; i--) {
-                                               //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { temp[i] = '.'; }
-                                               
-                                               numBasesCounted++; 
-
-                                               if (numBasesCounted >= numbases) { stopSpot = i; break; }
-                                       }
-                               
-                                       if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(stopSpot+1);  }
-                               }else { 
-                                       if (!Short) { temp = ""; } //sequence too short
-                               }
-                       }
-
-               }else{
-                               
-                       //if needed trim sequence
-                       if (keep == "front") {//you want to keep the beginning
-                               int tempLength = tempUnaligned.length();
-
-                               if (tempLength > numbases) { //you have enough bases to remove some
-                                       
-                                       int stopSpot = 0;
-                                       int numBasesCounted = 0;
-                                       
-                                       for (int i = 0; i < temp.length(); i++) {
-                                               //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { 
-                                                       temp[i] = '.'; 
-                                                       tempLength--;
-                                                       if (tempLength < numbases) { stopSpot = 0; break; }
-                                               }
-                                               
-                                               if(isalpha(temp[i])) { numBasesCounted++; }
-                                               
-                                               if (numBasesCounted >= numbases) { stopSpot = i; break; }
-                                       }
-                                       
-                                       if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(0, stopSpot+1);  }
-                                                       
-                               }else { 
-                                       if (!Short) { temp = ""; } //sequence too short
-                               }                               
-                       }else { //you are keeping the back
-                               int tempLength = tempUnaligned.length();
-                               if (tempLength > numbases) { //you have enough bases to remove some
-                                       
-                                       int stopSpot = 0;
-                                       int numBasesCounted = 0;
-                                       
-                                       for (int i = (temp.length()-1); i >= 0; i--) {
-                                               //eliminate N's
-                                               if (toupper(temp[i]) == 'N') { 
-                                                       temp[i] = '.'; 
-                                                       tempLength--;
-                                                       if (tempLength < numbases) { stopSpot = 0; break; }
-                                               }
-                                               
-                                               if(isalpha(temp[i])) { numBasesCounted++; }
-
-                                               if (numBasesCounted >= numbases) { stopSpot = i; break; }
-                                       }
-                               
-                                       if (stopSpot == 0) { temp = ""; }
-                                       else {  temp = temp.substr(stopSpot);  }
-                               }else { 
-                                       if (!Short) { temp = ""; } //sequence too short
-                               }
-                       }
-               }
-               
-               return temp;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ChopSeqsCommand", "getChopped");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/chopseqscommand.h b/chopseqscommand.h
deleted file mode 100644 (file)
index e73714d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef CHOPSEQSCOMMAND_H
-#define CHOPSEQSCOMMAND_H
-
-/*
- *  chopseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 5/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sequence.hpp"
-
-class ChopSeqsCommand : public Command {
-       
-       public:
-       
-               ChopSeqsCommand(string);
-               ChopSeqsCommand();      
-               ~ChopSeqsCommand(){};
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "chop.seqs";           }
-               string getCommandCategory()             { return "Sequence Processing"; }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Chops.seqs"; }
-               string getDescription()         { return "trim sequence length"; }
-       
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }          
-       
-       private:
-               string fastafile, outputDir, keep;
-               bool abort, countGaps, Short;
-               int numbases;
-               vector<string> outputNames;
-               
-               string getChopped(Sequence);
-};
-
-#endif
-
-
diff --git a/classify.cpp b/classify.cpp
deleted file mode 100644 (file)
index 2d01183..0000000
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- *  classify.cpp
- *  Mothur
- *
- *  Created by westcott on 11/3/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "classify.h"
-#include "sequence.hpp"
-#include "kmerdb.hpp"
-#include "suffixdb.hpp"
-#include "blastdb.hpp"
-#include "distancedb.hpp"
-#include "referencedb.h"
-
-/**************************************************************************************************/
-void Classify::generateDatabaseAndNames(string tfile, string tempFile, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch)  {            
-       try {   
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               
-               if (tfile == "saved") { tfile = rdb->getSavedTaxonomy(); }
-               
-               taxFile = tfile;
-               readTaxonomy(taxFile);  
-               int numSeqs = 0;
-               
-               if (tempFile == "saved") {
-                       int start = time(NULL);
-                       m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + " that are saved in memory.");        m->mothurOutEndLine();
-                       
-                       numSeqs = rdb->referenceSeqs.size();
-                       templateFile = rdb->getSavedReference();
-                       tempFile = rdb->getSavedReference();
-                       
-                       bool needToGenerate = true;
-                       string kmerDBName;
-                       if(method == "kmer")                    {       
-                               database = new KmerDB(tempFile, kmerSize);                      
-                               
-                               kmerDBName = tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               if(kmerFileTest){       
-                                       bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
-                                       if (GoodFile) {  needToGenerate = false;        }
-                               }
-                       }
-                       else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
-                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID);     }
-                       else if(method == "distance")   {       database = new DistanceDB();    }
-                       else {
-                               m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
-                               m->mothurOutEndLine();
-                               database = new KmerDB(tempFile, 8);
-                       }
-                       
-                       if (needToGenerate) {
-                               for (int k = 0; k < rdb->referenceSeqs.size(); k++) {
-                                       Sequence temp(rdb->referenceSeqs[k].getName(), rdb->referenceSeqs[k].getAligned());
-                                       names.push_back(temp.getName());
-                                       database->addSequence(temp);    
-                               }
-                               database->generateDB();
-                       }else if ((method == "kmer") && (!needToGenerate)) {    
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               database->readKmerDB(kmerFileTest);     
-                               
-                               for (int k = 0; k < rdb->referenceSeqs.size(); k++) {
-                                       names.push_back(rdb->referenceSeqs[k].getName());
-                               }                       
-                       }       
-                       
-                       database->setNumSeqs(numSeqs);
-                       
-                       //sanity check
-                       bool okay = phyloTree->ErrorCheck(names);
-                       
-                       if (!okay) { m->control_pressed = true; }
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " to load " + toString(rdb->referenceSeqs.size()) + " sequences and generate the search databases.");m->mothurOutEndLine();  
-                       
-               }else {
-                       
-                       templateFile = tempFile;        
-                       
-                       int start = time(NULL);
-                       
-                       m->mothurOut("Generating search database...    "); cout.flush();
-       #ifdef USE_MPI  
-                               int pid, processors;
-                               vector<unsigned long long> positions;
-                               int tag = 2001;
-                       
-                               MPI_Status status; 
-                               MPI_File inMPI;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-
-                               //char* inFileName = new char[tempFile.length()];
-                               //memcpy(inFileName, tempFile.c_str(), tempFile.length());
-                               
-                               char inFileName[1024];
-                               strcpy(inFileName, tempFile.c_str());
-
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               //delete inFileName;
-
-                               if (pid == 0) { //only one process needs to scan file
-                                       positions = m->setFilePosFasta(tempFile, numSeqs); //fills MPIPos, returns numSeqs
-
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&positions[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                               }else{
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       positions.resize(numSeqs+1);
-                                       MPI_Recv(&positions[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                               }
-                               
-                               //create database
-                               if(method == "kmer")                    {       database = new KmerDB(tempFile, kmerSize);                      }
-                               else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
-                               else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", pid);  }
-                               else if(method == "distance")   {       database = new DistanceDB();    }
-                               else {
-                                       m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8."); m->mothurOutEndLine();
-                                       database = new KmerDB(tempFile, 8);
-                               }
-
-                               //read file 
-                               for(int i=0;i<numSeqs;i++){
-                                       //read next sequence
-                                       int length = positions[i+1] - positions[i];
-                                       char* buf4 = new char[length];
-                                       MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
-                                       
-                                       string tempBuf = buf4;
-                                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                                       delete buf4;
-                                       istringstream iss (tempBuf,istringstream::in);
-                                       
-                                       Sequence temp(iss);  
-                                       if (temp.getName() != "") {
-                                               if (rdb->save) { rdb->referenceSeqs.push_back(temp); }
-                                               names.push_back(temp.getName());
-                                               database->addSequence(temp);    
-                                       }
-                               }
-                               
-                               database->generateDB();
-                               MPI_File_close(&inMPI);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               #else
-                       
-                       //need to know number of template seqs for suffixdb
-                       if (method == "suffix") {
-                               ifstream inFASTA;
-                               m->openInputFile(tempFile, inFASTA);
-                               m->getNumSeqs(inFASTA, numSeqs);
-                               inFASTA.close();
-                       }
-
-                       bool needToGenerate = true;
-                       string kmerDBName;
-                       if(method == "kmer")                    {       
-                               database = new KmerDB(tempFile, kmerSize);                      
-                               
-                               kmerDBName = tempFile.substr(0,tempFile.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               if(kmerFileTest){       
-                                       bool GoodFile = m->checkReleaseVersion(kmerFileTest, m->getVersion());
-                                       if (GoodFile) {  needToGenerate = false;        }
-                               }
-                       }
-                       else if(method == "suffix")             {       database = new SuffixDB(numSeqs);                                                               }
-                       else if(method == "blast")              {       database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID);     }
-                       else if(method == "distance")   {       database = new DistanceDB();    }
-                       else {
-                               m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
-                               m->mothurOutEndLine();
-                               database = new KmerDB(tempFile, 8);
-                       }
-                       
-                       if (needToGenerate) {
-                               ifstream fastaFile;
-                               m->openInputFile(tempFile, fastaFile);
-                               
-                               while (!fastaFile.eof()) {
-                                       Sequence temp(fastaFile);
-                                       m->gobble(fastaFile);
-                                       
-                                       if (rdb->save) { rdb->referenceSeqs.push_back(temp); }
-                                       
-                                       names.push_back(temp.getName());
-                                                               
-                                       database->addSequence(temp);    
-                               }
-                               fastaFile.close();
-
-                               database->generateDB();
-                               
-                       }else if ((method == "kmer") && (!needToGenerate)) {    
-                               ifstream kmerFileTest(kmerDBName.c_str());
-                               database->readKmerDB(kmerFileTest);     
-                       
-                               ifstream fastaFile;
-                               m->openInputFile(tempFile, fastaFile);
-                               
-                               while (!fastaFile.eof()) {
-                                       Sequence temp(fastaFile);
-                                       m->gobble(fastaFile);
-                                       
-                                       if (rdb->save) { rdb->referenceSeqs.push_back(temp); }
-                                       names.push_back(temp.getName());
-                               }
-                               fastaFile.close();
-                       }
-       #endif  
-               
-                       database->setNumSeqs(names.size());
-                       
-                       //sanity check
-                       bool okay = phyloTree->ErrorCheck(names);
-                       
-                       if (!okay) { m->control_pressed = true; }
-                       
-                       m->mothurOut("DONE."); m->mothurOutEndLine();
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " seconds generate search database. "); m->mothurOutEndLine();
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Classify", "generateDatabaseAndNames");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-Classify::Classify() {         m = MothurOut::getInstance();   database = NULL;        flipped=false; }
-/**************************************************************************************************/
-
-int Classify::readTaxonomy(string file) {
-       try {
-               
-               phyloTree = new PhyloTree();
-               string name, taxInfo;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Reading in the " + file + " taxonomy...\t");      cout.flush();
-
-#ifdef USE_MPI 
-               int pid, num, processors;
-               vector<unsigned long long> positions;
-               int tag = 2001;
-               
-               MPI_Status status; 
-               MPI_File inMPI;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-
-               //char* inFileName = new char[file.length()];
-               //memcpy(inFileName, file.c_str(), file.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, file.c_str());
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-               //delete inFileName;
-
-               if (pid == 0) {
-                       positions = m->setFilePosEachLine(file, num);
-                       
-                       //send file positions to all processes
-                       for(int i = 1; i < processors; i++) { 
-                               MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                               MPI_Send(&positions[0], (num+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                       }
-               }else{
-                       MPI_Recv(&num, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                       positions.resize(num+1);
-                       MPI_Recv(&positions[0], (num+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-               }
-       
-               //read file 
-               for(int i=0;i<num;i++){
-                       //read next sequence
-                       int length = positions[i+1] - positions[i];
-                       char* buf4 = new char[length];
-
-                       MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
-
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                       delete buf4;
-
-                       istringstream iss (tempBuf,istringstream::in);
-                       iss >> name; m->gobble(iss);
-            iss >> taxInfo;
-                       taxonomy[name] = taxInfo;
-                       phyloTree->addSeqToTree(name, taxInfo);
-               }
-               
-               MPI_File_close(&inMPI);
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#else                          
-               ifstream inTax;
-               m->openInputFile(file, inTax);
-       
-               //read template seqs and save
-               while (!inTax.eof()) {
-                       inTax >> name; m->gobble(inTax);
-            inTax >> taxInfo;
-               
-                       taxonomy[name] = taxInfo;
-                       
-                       phyloTree->addSeqToTree(name, taxInfo);
-               
-                       m->gobble(inTax);
-               }
-               inTax.close();
-#endif 
-       
-               phyloTree->assignHeirarchyIDs(0);
-               
-               phyloTree->setUp(file);
-       
-               m->mothurOut("DONE.");
-               m->mothurOutEndLine();  cout.flush();
-               
-               return phyloTree->getNumSeqs();
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Classify", "readTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-vector<string> Classify::parseTax(string tax) {
-       try {
-               vector<string> taxons;
-               
-               tax = tax.substr(0, tax.length()-1);  //get rid of last ';'
-       
-               //parse taxonomy
-               string individual;
-               while (tax.find_first_of(';') != -1) {
-                       individual = tax.substr(0,tax.find_first_of(';'));
-                       tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-                       taxons.push_back(individual);
-                       
-               }
-               //get last one
-               taxons.push_back(tax);
-               
-               return taxons;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Classify", "parseTax");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
diff --git a/classify.h b/classify.h
deleted file mode 100644 (file)
index 4e03547..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef CLASSIFY_H
-#define CLASSIFY_H
-
-/*
- *  classify.h
- *  Mothur
- *
- *  Created by westcott on 11/3/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-/* This class is a parent to bayesian, knn.  */
-
-#include "mothur.h"
-#include "database.hpp"
-#include "phylotree.h"
-
-
-class Sequence;
-
-
-/**************************************************************************************************/
-
-class Classify {
-
-public:
-       Classify();
-       virtual ~Classify(){};
-       virtual string getTaxonomy(Sequence*) = 0;
-       virtual string getSimpleTax()  { return simpleTax;      }
-       virtual bool getFlipped()  { return flipped;    }
-       virtual void generateDatabaseAndNames(string, string, string, int, float, float, float, float);
-       virtual void setDistName(string s) {} //for knn, so if distance method is selected with knn you can create the smallest distance file in the right place.
-       
-protected:
-
-       map<string, string> taxonomy;  //name maps to taxonomy
-       //map<string, int> genusCount;  //maps genus to count - in essence a list of how many seqs are in each taxonomy
-       map<string, int>::iterator itTax;
-       map<string, string>::iterator it;
-       Database* database;
-       PhyloTree* phyloTree;
-       
-       string taxFile, templateFile, simpleTax;
-       vector<string> names;
-       int threadID;
-       bool flip, flipped;
-       
-       int readTaxonomy(string);
-       vector<string> parseTax(string);
-       MothurOut* m;
-       
-};
-
-/**************************************************************************************************/
-
-#endif
-
diff --git a/classifyotucommand.cpp b/classifyotucommand.cpp
deleted file mode 100644 (file)
index c889637..0000000
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- *  classifyotucommand.cpp
- *  Mothur
- *
- *  Created by westcott on 6/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "classifyotucommand.h"
-#include "phylotree.h"
-#include "phylosummary.h"
-
-//**********************************************************************************************************************
-vector<string> ClassifyOtuCommand::setParameters(){    
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(preftaxonomy);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pbasis("basis", "Multiple", "otu-sequence", "otu", "", "", "",false,false); parameters.push_back(pbasis);
-               CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pprobs);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClassifyOtuCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The classify.otu command parameters are list, taxonomy, reftaxonomy, name, group, cutoff, label, basis and probs.  The taxonomy and list parameters are required unless you have a valid current file.\n";
-               helpString += "The reftaxonomy parameter allows you give the name of the reference taxonomy file used when you classified your sequences. Providing it will keep the rankIDs in the summary file static.\n";
-               helpString += "The name parameter allows you add a names file with your taxonomy file.\n";
-               helpString += "The group parameter allows you provide a group file to use in creating the summary file breakdown.\n";
-               helpString += "The basis parameter allows you indicate what you want the summary file to represent, options are otu and sequence. Default is otu.\n";
-               helpString += "For example consider the following basis=sequence could give Clostridiales       3       105     16      43      46, where 105 is the total number of sequences whose otu classified to Clostridiales.\n";
-               helpString += "16 is the number of sequences in the otus from groupA, 43 is the number of sequences in the otus from groupB, and 46 is the number of sequences in the otus from groupC.\n";
-               helpString += "Now for basis=otu could give Clostridiales       3       7       6       1       2, where 7 is the number of otus that classified to Clostridiales.\n";
-               helpString += "6 is the number of otus containing sequences from groupA, 1 is the number of otus containing sequences from groupB, and 2 is the number of otus containing sequences from groupC.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like a output files created for, and is separated by dashes.\n";
-               helpString += "The default value for label is all labels in your inputfile.\n";
-               helpString += "The cutoff parameter allows you to specify a consensus confidence threshold for your taxonomy.  The default is 51, meaning 51%. Cutoff cannot be below 51.\n";
-               helpString += "The probs parameter shuts off the outputting of the consensus confidence results. The default is true, meaning you want the confidence to be shown.\n";
-               helpString += "The classify.otu command should be in the following format: classify.otu(taxonomy=yourTaxonomyFile, list=yourListFile, name=yourNamesFile, label=yourLabels).\n";
-               helpString += "Example classify.otu(taxonomy=abrecovery.silva.full.taxonomy, list=abrecovery.fn.list, label=0.10).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClassifyOtuCommand::ClassifyOtuCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["constaxonomy"] = tempOutNames;
-               outputTypes["taxsummary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "ClassifyOtuCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ClassifyOtuCommand::ClassifyOtuCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               labels.clear();
-                               
-               //allow user to run help
-               if (option == "help") { 
-                       help(); abort = true; calledHelp = true;
-               }else if(option == "citation") { citation(); abort = true; calledHelp = true;} 
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["constaxonomy"] = tempOutNames;
-                       outputTypes["taxsummary"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("reftaxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reftaxonomy"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found") {                          
-                               //if there is a current list file, use it
-                               listfile = m->getListFile(); 
-                               if (listfile != "") {  m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current listfile and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listfile == "not open") { abort = true; }      
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not found") {  //if there is a current list file, use it
-                               taxfile = m->getTaxonomyFile(); 
-                               if (taxfile != "") {  m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (taxfile == "not open") { abort = true; }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       refTaxonomy = validParameter.validFile(parameters, "reftaxonomy", true);
-                       if (refTaxonomy == "not found") { refTaxonomy = ""; m->mothurOut("reftaxonomy is not required, but if given will keep the rankIDs in the summary file static."); m->mothurOutEndLine(); }
-                       else if (refTaxonomy == "not open") { abort = true; }
-       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }    
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; allLines = 1;  }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       basis = validParameter.validFile(parameters, "basis", false);
-                       if (basis == "not found") { basis = "otu"; }    
-                       
-                       if ((basis != "otu") && (basis != "sequence")) { m->mothurOut("Invalid option for basis. basis options are otu and sequence, using otu."); m->mothurOutEndLine(); }
-                       
-                       string temp = validParameter.validFile(parameters, "cutoff", false);                    if (temp == "not found") { temp = "51"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       temp = validParameter.validFile(parameters, "probs", false);                                    if (temp == "not found"){       temp = "true";                  }
-                       probs = m->isTrue(temp);
-                       
-                       
-                       if ((cutoff < 51) || (cutoff > 100)) { m->mothurOut("cutoff must be above 50, and no greater than 100."); m->mothurOutEndLine(); abort = true;  }
-                       
-                       if (namefile == ""){
-                               vector<string> files; files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "ClassifyOtuCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ClassifyOtuCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //if user gave a namesfile then use it
-               if (namefile != "") {   readNamesFile();        }
-               
-               //read taxonomy file and save in map for easy access in building bin trees
-               readTaxonomyFile();
-               
-               if (m->control_pressed) { return 0; }
-               
-               input = new InputData(listfile, "list");
-               list = input->getListVector();
-               string lastLabel = list->getLabel();
-
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) { outputTypes.clear(); delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }  return 0; }
-       
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (allLines == 1 || labels.count(list->getLabel()) == 1){
-                       
-                                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                                       process(list);
-                                       if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } delete input; delete list; return 0; }
-                                                                               
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = list->getLabel();
-                                       
-                                       delete list;
-                                       list = input->getListVector(lastLabel);
-                                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                                       process(list);
-                               
-                                       
-                                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } delete input; delete list; return 0; }
-                                                                               
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();
-       
-                       delete list;
-                       list = input->getListVector();
-               }
-               
-               //output error messages about any remaining user labels
-               bool needToRun = false;
-               for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + (*it)); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       list = input->getListVector(lastLabel);
-                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                       
-                       process(list);
-                       delete list;
-                       
-                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } delete input; delete list; return 0; }
-               }
-               
-               delete input;  
-                               
-               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ClassifyOtuCommand::readNamesFile() {
-       try {
-               
-               ifstream inNames;
-               m->openInputFile(namefile, inNames);
-               
-               string name, names;
-       
-               while(!inNames.eof()){
-                       inNames >> name;                        //read from first column  A
-                       inNames >> names;               //read from second column  A,B,C,D
-                       m->gobble(inNames);
-                       
-                       //parse names into vector
-                       vector<string> theseNames;
-                       m->splitAtComma(names, theseNames);
-
-                       for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = name;  }
-                       
-                       if (m->control_pressed) { inNames.close(); nameMap.clear(); return 0; }
-               }
-               inNames.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "readNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ClassifyOtuCommand::readTaxonomyFile() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               
-               string name, tax;
-       
-               while(!in.eof()){
-                       in >> name >> tax;              
-                       m->gobble(in);
-                       
-                       //are there confidence scores, if so remove them
-                       if (tax.find_first_of('(') != -1) {  m->removeConfidences(tax); }
-                       
-                       taxMap[name] = tax;
-                       
-                       if (m->control_pressed) { in.close(); taxMap.clear(); return 0; }
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "readTaxonomyFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> ClassifyOtuCommand::findConsensusTaxonomy(int bin, ListVector* thisList, int& size, string& conTax) {
-       try{
-               conTax = "";
-               vector<string> names;
-               vector<string> allNames;
-               map<string, string>::iterator it;
-               map<string, string>::iterator it2;
-
-               //parse names into vector
-               string binnames = thisList->get(bin);
-               m->splitAtComma(binnames, names);
-
-               //create a tree containing sequences from this bin
-               PhyloTree* phylo = new PhyloTree();
-               
-               size = 0;
-               for (int i = 0; i < names.size(); i++) {
-       
-                       //if namesfile include the names
-                       if (namefile != "") {
-       
-                               //is this sequence in the name file - namemap maps seqName -> repSeqName
-                               it2 = nameMap.find(names[i]);
-                               
-                               if (it2 == nameMap.end()) { //this name is not in name file, skip it
-                                       m->mothurOut(names[i] + " is not in your name file.  I will not include it in the consensus."); m->mothurOutEndLine();
-                               }else{
-                                       
-                                       //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
-                                       it = taxMap.find(it2->second);
-                       
-                                       if (it == taxMap.end()) { //this name is not in taxonomy file, skip it
-                                       
-                                               if (names[i] != it2->second) { m->mothurOut(names[i] + " is represented by " +  it2->second + " and is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
-                                               else {  m->mothurOut(names[i] + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
-                                       }else{
-                               
-                                               //add seq to tree
-                                               phylo->addSeqToTree(names[i], it->second);
-                                               size++;
-                                               allNames.push_back(names[i]);
-                                       }
-                               }
-                               
-                       }else{
-                               //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
-                               it = taxMap.find(names[i]);
-               
-                               if (it == taxMap.end()) { //this name is not in taxonomy file, skip it
-                                       m->mothurOut(names[i] + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine();
-                               }else{
-                                       //add seq to tree
-                                       phylo->addSeqToTree(names[i], it->second);
-                                       size++;
-                                       allNames.push_back(names[i]);
-                               }
-                       }
-
-                       
-                       if (m->control_pressed) { delete phylo; return allNames; }
-                       
-               }
-               
-               //build tree
-               phylo->assignHeirarchyIDs(0);
-               
-               TaxNode currentNode = phylo->get(0);
-               int myLevel = 0;        
-               //at each level
-               while (currentNode.children.size() != 0) { //you still have more to explore
-               
-                       TaxNode bestChild;
-                       int bestChildSize = 0;
-                       
-                       //go through children
-                       for (map<string, int>::iterator itChild = currentNode.children.begin(); itChild != currentNode.children.end(); itChild++) {
-                               
-                               TaxNode temp = phylo->get(itChild->second);
-                               
-                               //select child with largest accesions - most seqs assigned to it
-                               if (temp.accessions.size() > bestChildSize) {
-                                       bestChild = phylo->get(itChild->second);
-                                       bestChildSize = temp.accessions.size();
-                               }
-                               
-                       }
-                               
-                       //is this taxonomy above cutoff
-                       int consensusConfidence = ceil((bestChildSize / (float) size) * 100);
-                       
-                       if (consensusConfidence >= cutoff) { //if yes, add it
-                               if (probs) {
-                                       conTax += bestChild.name + "(" + toString(consensusConfidence) + ");";
-                               }else{
-                                       conTax += bestChild.name + ";";
-                               }
-                               myLevel++;
-                       }else{ //if no, quit
-                               break;
-                       }
-                       
-                       //move down a level
-                       currentNode = bestChild;
-               }
-               
-               if (myLevel != phylo->getMaxLevel()) {
-                       while (myLevel != phylo->getMaxLevel()) {
-                               conTax += "unclassified;";
-                               myLevel++;
-                       }
-               }               
-               if (conTax == "") {  conTax = "no_consensus;";  }
-               
-               delete phylo;   
-               
-               return allNames;
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "findConsensusTaxonomy");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ClassifyOtuCommand::process(ListVector* processList) {
-       try{
-               string conTax;
-               int size;
-               
-               //create output file
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-                               
-               ofstream out;
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".cons.taxonomy";
-               m->openOutputFile(outputFile, out);
-               outputNames.push_back(outputFile); outputTypes["constaxonomy"].push_back(outputFile);
-               
-               ofstream outSum;
-               string outputSumFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".cons.tax.summary";
-               m->openOutputFile(outputSumFile, outSum);
-               outputNames.push_back(outputSumFile); outputTypes["taxsummary"].push_back(outputSumFile);
-               
-               out << "OTU\tSize\tTaxonomy" << endl;
-               
-               PhyloSummary* taxaSum;
-               if (refTaxonomy != "") {
-                       taxaSum = new PhyloSummary(refTaxonomy, groupfile);
-               }else {
-                       taxaSum = new PhyloSummary(groupfile);
-               }
-               
-               //for each bin in the list vector
-               for (int i = 0; i < processList->getNumBins(); i++) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       vector<string> names;
-                       names = findConsensusTaxonomy(i, processList, size, conTax);
-               
-                       if (m->control_pressed) { out.close();  return 0; }
-                       
-                       //output to new names file
-                       out << (i+1) << '\t' << size << '\t' << conTax << endl;
-                       
-                       string noConfidenceConTax = conTax;
-                       m->removeConfidences(noConfidenceConTax);
-                       
-                       //add this bins taxonomy to summary
-                       if (basis == "sequence") {
-                               for(int j = 0; j < names.size(); j++) {  taxaSum->addSeqToTree(names[j], noConfidenceConTax);  }
-                       }else { //otu
-                               taxaSum->addSeqToTree(noConfidenceConTax, names);
-                       }
-               }
-
-               out.close();
-               
-               //print summary file
-               taxaSum->print(outSum);
-               outSum.close();
-               
-               delete taxaSum;
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "process");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string ClassifyOtuCommand::addUnclassifieds(string tax, int maxlevel) {
-       try{
-               string newTax, taxon;
-               int level = 0;
-               
-               //keep what you have counting the levels
-               while (tax.find_first_of(';') != -1) {
-                       //get taxon
-                       taxon = tax.substr(0,tax.find_first_of(';'))+';';
-                       tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-                       newTax += taxon;
-                       level++;
-               }
-               
-               //add "unclassified" until you reach maxLevel
-               while (level < maxlevel) {
-                       newTax += "unclassified;";
-                       level++;
-               }
-               
-               return newTax;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyOtuCommand", "addUnclassifieds");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/classifyotucommand.h b/classifyotucommand.h
deleted file mode 100644 (file)
index a0baf18..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef CLASSIFYOTUSCOMMAND_H
-#define CLASSIFYOTUSCOMMAND_H
-
-/*
- *  classifyotucommand.h
- *  Mothur
- *
- *  Created by westcott on 6/1/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "listvector.hpp"
-#include "inputdata.h"
-
-
-class ClassifyOtuCommand : public Command {
-
-public:
-       ClassifyOtuCommand(string);
-       ClassifyOtuCommand();
-       ~ClassifyOtuCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "classify.otu";                }
-       string getCommandCategory()             { return "Phylotype Analysis";  }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol. \nhttp://www.mothur.org/wiki/Classify.otu"; }
-       string getDescription()         { return "find the concensus taxonomy for each OTU"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-
-private:
-
-       ListVector* list;
-       InputData* input;
-       string listfile, namefile, taxfile, label, outputDir, refTaxonomy, groupfile, basis;
-       bool abort, allLines, probs;
-       int cutoff;
-       set<string> labels; //holds labels to be used
-       vector<string> outputNames;
-       map<string, string> nameMap;
-       map<string, string> taxMap;
-
-       int readNamesFile();
-       int readTaxonomyFile();
-       int process(ListVector*);
-       string addUnclassifieds(string, int);
-       vector<string> findConsensusTaxonomy(int, ListVector*, int&, string&);  // returns the name of the "representative" taxonomy of given bin
-       
-                                                                                               
-};
-
-#endif
-
-
diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp
deleted file mode 100644 (file)
index 0504e66..0000000
+++ /dev/null
@@ -1,1188 +0,0 @@
-/*
- *  classifyseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/2/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "classifyseqscommand.h"
-
-
-
-//**********************************************************************************************************************
-vector<string> ClassifySeqsCommand::setParameters(){   
-       try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter ptemplate("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptemplate);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter psearch("search", "Multiple", "kmer-blast-suffix-distance", "kmer", "", "", "",false,false); parameters.push_back(psearch);
-               CommandParameter pksize("ksize", "Number", "", "8", "", "", "",false,false); parameters.push_back(pksize);
-               CommandParameter pmethod("method", "Multiple", "bayesian-knn", "bayesian", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               //CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pprobs("probs", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pprobs);
-               CommandParameter piters("iters", "Number", "", "100", "", "", "",false,true); parameters.push_back(piters);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               CommandParameter pnumwanted("numwanted", "Number", "", "10", "", "", "",false,true); parameters.push_back(pnumwanted);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClassifySeqsCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The classify.seqs command reads a fasta file containing sequences and creates a .taxonomy file and a .tax.summary file.\n";
-               helpString += "The classify.seqs command parameters are reference, fasta, name, search, ksize, method, taxonomy, processors, match, mismatch, gapopen, gapextend, numwanted and probs.\n";
-               helpString += "The reference, fasta and taxonomy parameters are required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The search parameter allows you to specify the method to find most similar template.  Your options are: suffix, kmer, blast and distance. The default is kmer.\n";
-               helpString += "The name parameter allows you add a names file with your fasta file, if you enter multiple fasta files, you must enter matching names files for them.\n";
-               helpString += "The group parameter allows you add a group file so you can have the summary totals broken up by group.\n";
-               helpString += "The method parameter allows you to specify classification method to use.  Your options are: bayesian and knn. The default is bayesian.\n";
-               helpString += "The ksize parameter allows you to specify the kmer size for finding most similar template to candidate.  The default is 8.\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n";
-               helpString += "The mistmatch parameter allows you to specify the penalty for having different bases.  The default is -1.0.\n";
-               helpString += "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n";
-               helpString += "The gapextend parameter allows you to specify the penalty for extending a gap in an alignment.  The default is -1.0.\n";
-               helpString += "The numwanted parameter allows you to specify the number of sequence matches you want with the knn method.  The default is 10.\n";
-               helpString += "The cutoff parameter allows you to specify a bootstrap confidence threshold for your taxonomy.  The default is 0.\n";
-               helpString += "The probs parameter shuts off the bootstrapping results for the bayesian method. The default is true, meaning you want the bootstrapping to be shown.\n";
-               helpString += "The iters parameter allows you to specify how many iterations to do when calculating the bootstrap confidence score for your taxonomy with the bayesian method.  The default is 100.\n";
-               //helpString += "The flip parameter allows you shut off mothur's   The default is T.\n";
-               helpString += "The classify.seqs command should be in the following format: \n";
-               helpString += "classify.seqs(reference=yourTemplateFile, fasta=yourFastaFile, method=yourClassificationMethod, search=yourSearchmethod, ksize=yourKmerSize, taxonomy=yourTaxonomyFile, processors=yourProcessors) \n";
-               helpString += "Example classify.seqs(fasta=amazon.fasta, reference=core.filtered, method=knn, search=gotoh, ksize=8, processors=2)\n";
-               helpString += "The .taxonomy file consists of 2 columns: 1 = your sequence name, 2 = the taxonomy for your sequence. \n";
-               helpString += "The .tax.summary is a summary of the different taxonomies represented in your fasta file. \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClassifySeqsCommand::ClassifySeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["taxsummary"] = tempOutNames;
-               outputTypes["matchdist"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClassifySeqsCommand::ClassifySeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter("classify.seqs");
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["taxsummary"] = tempOutNames;
-                       outputTypes["matchdist"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("reference");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       fastaFileName = validParameter.validFile(parameters, "fasta", false);
-                       if (fastaFileName == "not found") {                             
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else { 
-                               m->splitAtDash(fastaFileName, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-                                               
-                                               int ableToOpen;
-                                               
-                                               ifstream in;
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                                       
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-
-                       namefile = validParameter.validFile(parameters, "name", false);
-                       if (namefile == "not found") { namefile = "";  }
-
-                       else { 
-                               m->splitAtDash(namefile, namefileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < namefileNames.size(); i++) {
-                                       bool ignore = false;
-                                       if (namefileNames[i] == "current") { 
-                                               namefileNames[i] = m->getNameFile(); 
-                                               if (namefileNames[i] != "") {  m->mothurOut("Using " + namefileNames[i] + " as input file for the name parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current namefile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       namefileNames.erase(namefileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(namefileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       namefileNames[i] = inputDir + namefileNames[i];         }
-                                               }
-                                               int ableToOpen;
-                                               
-                                               ifstream in;
-                                               ableToOpen = m->openInputFile(namefileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(namefileNames[i]);
-                                                               m->mothurOut("Unable to open " + namefileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               namefileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(namefileNames[i]);
-                                                               m->mothurOut("Unable to open " + namefileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               namefileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + namefileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();  abort = true;
-                                                       //erase from file list
-                                                       namefileNames.erase(namefileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setNameFile(namefileNames[i]);
-                                               }
-                                       }
-                               }
-                       }
-
-                       if (namefile != "") {
-                               if (namefileNames.size() != fastaFileNames.size()) { abort = true; m->mothurOut("If you provide a name file, you must have one for each fasta file."); m->mothurOutEndLine(); }
-                       }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", false);
-                       if (groupfile == "not found") { groupfile = "";  }
-                       else { 
-                               m->splitAtDash(groupfile, groupfileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < groupfileNames.size(); i++) {
-                                       if (inputDir != "") {
-                                               string path = m->hasPath(groupfileNames[i]);
-                                               //if the user has not given a path then, add inputdir. else leave path alone.
-                                               if (path == "") {       groupfileNames[i] = inputDir + groupfileNames[i];               }
-                                       }
-                                       int ableToOpen;
-                                       
-                                       ifstream in;
-                                       ableToOpen = m->openInputFile(groupfileNames[i], in, "noerror");
-                               
-                                       //if you can't open it, try default location
-                                       if (ableToOpen == 1) {
-                                               if (m->getDefaultPath() != "") { //default path is set
-                                                       string tryPath = m->getDefaultPath() + m->getSimpleName(groupfileNames[i]);
-                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       groupfileNames[i] = tryPath;
-                                               }
-                                       }
-                                       
-                                       if (ableToOpen == 1) {
-                                               if (m->getOutputDir() != "") { //default path is set
-                                                       string tryPath = m->getOutputDir() + m->getSimpleName(groupfileNames[i]);
-                                                       m->mothurOut("Unable to open " + groupfileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                       ifstream in2;
-                                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                       in2.close();
-                                                       groupfileNames[i] = tryPath;
-                                               }
-                                       }
-                                       
-                                       in.close();
-                                       
-                                       if (ableToOpen == 1) { 
-                                               m->mothurOut("Unable to open " + groupfileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); groupfileNames[i] = "";
-                                               //erase from file list
-                                               groupfileNames.erase(groupfileNames.begin()+i);
-                                               i--;
-                                       }else {
-                                               m->setGroupFile(groupfileNames[i]);
-                                       }
-                               }
-                       }
-
-                       if (groupfile != "") {
-                               if (groupfileNames.size() != fastaFileNames.size()) { abort = true; m->mothurOut("If you provide a group file, you must have one for each fasta file."); m->mothurOutEndLine(); }
-                       }else {
-                               for (int i = 0; i < fastaFileNames.size(); i++) {  groupfileNames.push_back("");  }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "ksize", false);            if (temp == "not found"){       temp = "8";                             }
-                       m->mothurConvert(temp, kmerSize); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       templateFileName = validParameter.validFile(parameters, "reference", true);
-                       if (templateFileName == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       templateFileName = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required for the classify.seqs command."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (templateFileName == "not open") { abort = true; }     
-                       else {  if (save) {     rdb->setSavedReference(templateFileName);       }       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       taxonomyFileName = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxonomyFileName == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->wordGenusProb.size() != 0) {
-                                       taxonomyFileName = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved taxonomy information and the taxonomy parameter is a required for the classify.seqs command."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (taxonomyFileName == "not open") { abort = true; }     
-                       else {  if (save) {     rdb->setSavedTaxonomy(taxonomyFileName);        }       }
-                       
-                       search = validParameter.validFile(parameters, "search", false);         if (search == "not found"){     search = "kmer";                }
-                       
-                       method = validParameter.validFile(parameters, "method", false);         if (method == "not found"){     method = "bayesian";    }
-                       
-                       temp = validParameter.validFile(parameters, "match", false);            if (temp == "not found"){       temp = "1.0";                   }
-                       m->mothurConvert(temp, match);  
-                       
-                       temp = validParameter.validFile(parameters, "mismatch", false);         if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, misMatch);  
-                       
-                       temp = validParameter.validFile(parameters, "gapopen", false);          if (temp == "not found"){       temp = "-2.0";                  }
-                       m->mothurConvert(temp, gapOpen);  
-                       
-                       temp = validParameter.validFile(parameters, "gapextend", false);        if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, gapExtend); 
-                       
-                       temp = validParameter.validFile(parameters, "numwanted", false);        if (temp == "not found"){       temp = "10";                    }
-                       m->mothurConvert(temp, numWanted);
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);           if (temp == "not found"){       temp = "0";                             }
-                       m->mothurConvert(temp, cutoff);
-                       
-                       temp = validParameter.validFile(parameters, "probs", false);            if (temp == "not found"){       temp = "true";                  }
-                       probs = m->isTrue(temp);
-                       
-                       //temp = validParameter.validFile(parameters, "flip", false);                   if (temp == "not found"){       temp = "T";                             }
-                       //flip = m->isTrue(temp); 
-                       flip = true;
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);            if (temp == "not found") { temp = "100";                        }
-                       m->mothurConvert(temp, iters); 
-
-                       
-                       if ((method == "bayesian") && (search != "kmer"))  { 
-                               m->mothurOut("The bayesian method requires the kmer search." + search + "will be disregarded." ); m->mothurOutEndLine();
-                               search = "kmer";
-                       }
-                       
-            if (!abort) {
-                if (namefileNames.size() == 0){
-                    if (fastaFileNames.size() != 0) {
-                        vector<string> files; files.push_back(fastaFileNames[fastaFileNames.size()-1]); 
-                        parser.getNameFile(files);
-                    }
-                }
-            }
-                       
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "ClassifySeqsCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ClassifySeqsCommand::~ClassifySeqsCommand(){   
-       if (abort == false) {
-               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-       }
-}
-//**********************************************************************************************************************
-
-int ClassifySeqsCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if(method == "bayesian"){       classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand(), flip);             }
-               else if(method == "knn"){       classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, rand());                               }
-               else {
-                       m->mothurOut(search + " is not a valid method option. I will run the command using bayesian.");
-                       m->mothurOutEndLine();
-                       classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand(), flip);     
-               }
-               
-               if (m->control_pressed) { delete classify; return 0; }
-                               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-               
-                       m->mothurOut("Classifying sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       string baseTName = taxonomyFileName;
-                       if (taxonomyFileName == "saved") {baseTName = rdb->getSavedTaxonomy();  }
-                       
-                       string RippedTaxName = m->getRootName(m->getSimpleName(baseTName));
-                       RippedTaxName = m->getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1));
-                       if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); }
-                       RippedTaxName +=  "."; 
-               
-                       if (outputDir == "") { outputDir += m->hasPath(fastaFileNames[s]); }
-                       string newTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "taxonomy";
-                       string newaccnosFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "flip.accnos";
-                       string tempTaxonomyFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "taxonomy.temp";
-                       string taxSummary = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + RippedTaxName + "tax.summary";
-                       
-                       if ((method == "knn") && (search == "distance")) { 
-                               string DistName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "match.dist";
-                               classify->setDistName(DistName);  outputNames.push_back(DistName); outputTypes["matchdist"].push_back(DistName);
-                       }
-                       
-                       outputNames.push_back(newTaxonomyFile); outputTypes["taxonomy"].push_back(newTaxonomyFile);
-                       outputNames.push_back(newaccnosFile); outputTypes["accnos"].push_back(newaccnosFile);
-                       outputNames.push_back(taxSummary);      outputTypes["taxsummary"].push_back(taxSummary);
-                       
-                       int start = time(NULL);
-                       int numFastaSeqs = 0;
-                       for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                       
-#ifdef USE_MPI 
-                               int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                               
-                               MPI_Status status; 
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-
-                               MPI_File inMPI;
-                               MPI_File outMPINewTax;
-                               MPI_File outMPITempTax;
-                               MPI_File outMPIAcc;
-                                                       
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                               
-                               char outNewTax[1024];
-                               strcpy(outNewTax, newTaxonomyFile.c_str());
-                               
-                               char outTempTax[1024];
-                               strcpy(outTempTax, tempTaxonomyFile.c_str());
-                       
-                               char outAcc[1024];
-                               strcpy(outAcc, newaccnosFile.c_str());
-                               
-                               char inFileName[1024];
-                               strcpy(inFileName, fastaFileNames[s].c_str());
-
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outNewTax, outMode, MPI_INFO_NULL, &outMPINewTax);
-                               MPI_File_open(MPI_COMM_WORLD, outTempTax, outMode, MPI_INFO_NULL, &outMPITempTax);
-                               MPI_File_open(MPI_COMM_WORLD, outAcc, outMode, MPI_INFO_NULL, &outMPIAcc);
-                               
-                               if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);  MPI_File_close(&outMPIAcc);   MPI_File_close(&outMPITempTax);  delete classify;  return 0;  }
-                               
-                               if (pid == 0) { //you are the root process 
-                                       
-                                       MPIPos = m->setFilePosFasta(fastaFileNames[s], numFastaSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&numFastaSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numFastaSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-                                       
-                               
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPINewTax, outMPITempTax, outMPIAcc, MPIPos);
-                                       
-                                       if (m->control_pressed) {  outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax); MPI_File_close(&outMPIAcc);   MPI_File_close(&outMPITempTax);  for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);        } delete classify; return 0;  }
-                                       
-                                       for (int i = 1; i < processors; i++) {
-                                               int done;
-                                               MPI_Recv(&done, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                       }
-                               }else{ //you are a child process
-                                       MPI_Recv(&numFastaSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numFastaSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numFastaSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-                                       
-                                       
-                                       //align your part
-                                       driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPINewTax, outMPITempTax, outMPIAcc, MPIPos);
-                                       
-                                       if (m->control_pressed) {  outputTypes.clear(); MPI_File_close(&inMPI);  MPI_File_close(&outMPINewTax);  MPI_File_close(&outMPIAcc);  MPI_File_close(&outMPITempTax);  delete classify; return 0;  }
-
-                                       int done = 0;
-                                       MPI_Send(&done, 1, MPI_INT, 0, tag, MPI_COMM_WORLD); 
-                               }
-                               
-                               //close files 
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPINewTax);
-                               MPI_File_close(&outMPITempTax);
-                               MPI_File_close(&outMPIAcc); 
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               
-#else
-               
-                       vector<unsigned long long> positions; 
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       positions = m->divideFile(fastaFileNames[s], processors);
-                       for (int i = 0; i < (positions.size()-1); i++) {        lines.push_back(new linePair(positions[i], positions[(i+1)]));  }
-#else
-                       if (processors == 1) {
-                               lines.push_back(new linePair(0, 1000));
-                       }else {
-                               positions = m->setFilePosFasta(fastaFileNames[s], numFastaSeqs); 
-                if (positions.size() < processors) { processors = positions.size(); }
-                               
-                               //figure out how many sequences you have to process
-                               int numSeqsPerProcessor = numFastaSeqs / processors;
-                               for (int i = 0; i < processors; i++) {
-                                       int startIndex =  i * numSeqsPerProcessor;
-                                       if(i == (processors - 1)){      numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                                       lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
-                               }
-                       }
-#endif
-                       if(processors == 1){
-                               numFastaSeqs = driver(lines[0], newTaxonomyFile, tempTaxonomyFile, newaccnosFile, fastaFileNames[s]);
-                       }else{
-                               numFastaSeqs = createProcesses(newTaxonomyFile, tempTaxonomyFile, newaccnosFile, fastaFileNames[s]); 
-                       }
-#endif
-                       
-                       if (!m->isBlank(newaccnosFile)) { m->mothurOutEndLine(); m->mothurOut("[WARNING]: mothur suspects some of your sequences may be reversed, please check " + newaccnosFile + " for the list of the sequences."); m->mothurOutEndLine(); }
-
-               m->mothurOutEndLine();
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to classify " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               start = time(NULL);
-               
-               
-
-               #ifdef USE_MPI  
-                       if (pid == 0) {  //this part does not need to be paralellized
-                       
-                               if(namefile != "") { m->mothurOut("Reading " + namefileNames[s] + "..."); cout.flush();  MPIReadNamesFile(namefileNames[s]);  m->mothurOut("  Done."); m->mothurOutEndLine(); }
-               #else
-                       //read namefile
-                       if(namefile != "") {
-                       
-                           m->mothurOut("Reading " + namefileNames[s] + "..."); cout.flush();
-                               
-                               nameMap.clear(); //remove old names
-                               
-                               ifstream inNames;
-                               m->openInputFile(namefileNames[s], inNames);
-                               
-                               string firstCol, secondCol;
-                               while(!inNames.eof()) {
-                                       inNames >> firstCol >> secondCol; m->gobble(inNames);
-                                       
-                                       vector<string> temp;
-                                       m->splitAtComma(secondCol, temp);
-                       
-                                       nameMap[firstCol] = temp;  
-                               }
-                               inNames.close();
-                               
-                               m->mothurOut("  Done."); m->mothurOutEndLine();
-                       }
-               #endif
-
-                       string group = "";
-                       if (groupfile != "") {  group = groupfileNames[s]; }
-                       
-                       PhyloSummary taxaSum(baseTName, group);
-                       
-                       if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } delete classify; return 0; }
-               
-                       if (namefile == "") {  taxaSum.summarize(tempTaxonomyFile);  }
-                       else {
-                               ifstream in;
-                               m->openInputFile(tempTaxonomyFile, in);
-                               
-                               //read in users taxonomy file and add sequences to tree
-                               string name, taxon;
-                               
-                               while(!in.eof()){
-                                       in >> name >> taxon; m->gobble(in);
-                                       
-                                       itNames = nameMap.find(name);
-               
-                                       if (itNames == nameMap.end()) { 
-                                               m->mothurOut(name + " is not in your name file please correct."); m->mothurOutEndLine(); exit(1);
-                                       }else{
-                                               for (int i = 0; i < itNames->second.size(); i++) { 
-                                                       taxaSum.addSeqToTree(itNames->second[i], taxon);  //add it as many times as there are identical seqs
-                                               }
-                                               itNames->second.clear();
-                                               nameMap.erase(itNames->first);
-                                       }
-                               }
-                               in.close();
-                       }
-                       m->mothurRemove(tempTaxonomyFile);
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } delete classify; return 0; }
-                       
-                       //print summary file
-                       ofstream outTaxTree;
-                       m->openOutputFile(taxSummary, outTaxTree);
-                       taxaSum.print(outTaxTree);
-                       outTaxTree.close();
-                       
-                       //output taxonomy with the unclassified bins added
-                       ifstream inTax;
-                       m->openInputFile(newTaxonomyFile, inTax);
-                       
-                       ofstream outTax;
-                       string unclass = newTaxonomyFile + ".unclass.temp";
-                       m->openOutputFile(unclass, outTax);
-                       
-                       //get maxLevel from phylotree so you know how many 'unclassified's to add
-                       int maxLevel = taxaSum.getMaxLevel();
-                                                       
-                       //read taxfile - this reading and rewriting is done to preserve the confidence scores.
-                       string name, taxon;
-                       while (!inTax.eof()) {
-                               if (m->control_pressed) { outputTypes.clear();  for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } m->mothurRemove(unclass); delete classify; return 0; }
-
-                               inTax >> name >> taxon; m->gobble(inTax);
-                               
-                               string newTax = addUnclassifieds(taxon, maxLevel);
-                               
-                               outTax << name << '\t' << newTax << endl;
-                       }
-                       inTax.close();  
-                       outTax.close();
-                       
-                       m->mothurRemove(newTaxonomyFile);
-                       rename(unclass.c_str(), newTaxonomyFile.c_str());
-                       
-                       m->mothurOutEndLine();
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to create the summary file for " + toString(numFastaSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       
-                       #ifdef USE_MPI  
-                               }
-                       #endif
-
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-               }
-               
-               //set taxonomy file as new current taxonomyfile
-               string current = "";
-               itTypes = outputTypes.find("taxonomy");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-               }
-               
-               current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               delete classify;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-string ClassifySeqsCommand::addUnclassifieds(string tax, int maxlevel) {
-       try{
-               string newTax, taxon;
-               int level = 0;
-               
-               //keep what you have counting the levels
-               while (tax.find_first_of(';') != -1) {
-                       //get taxon
-                       taxon = tax.substr(0,tax.find_first_of(';'))+';';
-                       tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-                       newTax += taxon;
-                       level++;
-               }
-               
-               //add "unclassified" until you reach maxLevel
-               while (level < maxlevel) {
-                       newTax += "unclassified;";
-                       level++;
-               }
-               
-               return newTax;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "addUnclassifieds");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, string accnos, string filename) {
-       try {
-               
-               int num = 0;
-               processIDS.clear();
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], taxFileName + toString(getpid()) + ".temp", tempTaxFile + toString(getpid()) + ".temp", accnos + toString(getpid()) + ".temp", filename);
-
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = filename + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent does its part
-               num = driver(lines[0], taxFileName, tempTaxFile, accnos, filename);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  filename + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(m->getFullPathName(tempFile));
-               }
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the alignData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<classifyData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
-                       
-                       classifyData* tempclass = new classifyData((accnos + extension), probs, method, templateFileName, taxonomyFileName, (taxFileName + extension), (tempTaxFile + extension), filename, search, kmerSize, iters, numWanted, m, lines[i]->start, lines[i]->end, match, misMatch, gapOpen, gapExtend, cutoff, i, flip);
-                       pDataArray.push_back(tempclass);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MyClassThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);  
-                       
-               }
-               
-               //parent does its part
-               num = driver(lines[processors-1], taxFileName + toString(processors-1) + ".temp", tempTaxFile + toString(processors-1) + ".temp", accnos + toString(processors-1) + ".temp", filename);
-               processIDS.push_back((processors-1));
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-       #endif  
-        vector<string> nonBlankAccnosFiles;
-               if (!(m->isBlank(accnos))) { nonBlankAccnosFiles.push_back(accnos); }
-               else { m->mothurRemove(accnos); } //remove so other files can be renamed to it
-        
-               for(int i=0;i<processIDS.size();i++){
-                       appendTaxFiles((taxFileName + toString(processIDS[i]) + ".temp"), taxFileName);
-                       appendTaxFiles((tempTaxFile + toString(processIDS[i]) + ".temp"), tempTaxFile);
-            if (!(m->isBlank(accnos + toString(processIDS[i]) + ".temp"))) {
-                               nonBlankAccnosFiles.push_back(accnos + toString(processIDS[i]) + ".temp");
-                       }else { m->mothurRemove((accnos + toString(processIDS[i]) + ".temp"));  }
-
-                       m->mothurRemove((m->getFullPathName(taxFileName) + toString(processIDS[i]) + ".temp"));
-                       m->mothurRemove((m->getFullPathName(tempTaxFile) + toString(processIDS[i]) + ".temp"));
-               }
-               
-        //append accnos files
-               if (nonBlankAccnosFiles.size() != 0) { 
-                       rename(nonBlankAccnosFiles[0].c_str(), accnos.c_str());
-                       
-                       for (int h=1; h < nonBlankAccnosFiles.size(); h++) {
-                               appendTaxFiles(nonBlankAccnosFiles[h], accnos);
-                               m->mothurRemove(nonBlankAccnosFiles[h]);
-                       }
-               }else { //recreate the accnosfile if needed
-                       ofstream out;
-                       m->openOutputFile(accnos, out);
-                       out.close();
-               }
-
-               return num;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void ClassifySeqsCommand::appendTaxFiles(string temp, string filename) {
-       try{
-               
-               ofstream output;
-               ifstream input;
-               m->openOutputFileAppend(filename, output);
-               m->openInputFile(temp, input);
-               
-               while(char c = input.get()){
-                       if(input.eof())         {       break;                  }
-                       else                            {       output << c;    }
-               }
-               
-               input.close();
-               output.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "appendTaxFiles");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempTFName, string accnos, string filename){
-       try {
-               ofstream outTax;
-               m->openOutputFile(taxFName, outTax);
-               
-               ofstream outTaxSimple;
-               m->openOutputFile(tempTFName, outTaxSimple);
-               
-               ofstream outAcc;
-               m->openOutputFile(accnos, outAcc);
-       
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-               
-               string taxonomy;
-
-               inFASTA.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-               
-               while (!done) {
-                       if (m->control_pressed) { 
-                               inFASTA.close();
-                               outTax.close();
-                               outTaxSimple.close();
-                               outAcc.close(); return 0; }
-               
-                       Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA);
-                       
-                       if (candidateSeq->getName() != "") {
-                       
-                               taxonomy = classify->getTaxonomy(candidateSeq);
-                               
-                               if (m->control_pressed) { delete candidateSeq; return 0; }
-                               
-                               if (taxonomy == "unknown;") { m->mothurOut("[WARNING]: " + candidateSeq->getName() + " could not be classified. You can use the remove.lineage command with taxon=unknown; to remove such sequences."); m->mothurOutEndLine(); }
-                               
-                               //output confidence scores or not
-                               if (probs) {
-                                       outTax << candidateSeq->getName() << '\t' << taxonomy << endl;
-                               }else{
-                                       outTax << candidateSeq->getName() << '\t' << classify->getSimpleTax() << endl;
-                               }
-                               
-                               if (classify->getFlipped()) { outAcc << candidateSeq->getName() << endl; }
-                               
-                               outTaxSimple << candidateSeq->getName() << '\t' << classify->getSimpleTax() << endl;
-                               
-                               count++;
-                       }
-                       delete candidateSeq;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-                       
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-                       
-               inFASTA.close();
-               outTax.close();
-               outTaxSimple.close();
-               outAcc.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ClassifySeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& newFile, MPI_File& tempFile, MPI_File& accFile, vector<unsigned long long>& MPIPos){
-       try {
-               MPI_Status statusNew; 
-               MPI_Status statusTemp; 
-               MPI_Status statusAcc; 
-               MPI_Status status; 
-               
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-       
-               string taxonomy;
-               string outputString;
-
-               for(int i=0;i<num;i++){
-               
-                       if (m->control_pressed) { return 0; }
-               
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence* candidateSeq = new Sequence(iss);
-                       
-                       if (candidateSeq->getName() != "") {
-                               taxonomy = classify->getTaxonomy(candidateSeq);
-                               
-                               if (taxonomy == "unknown;") { m->mothurOut("[WARNING]: " + candidateSeq->getName() + " could not be classified. You can use the remove.lineage command with taxon=unknown; to remove such sequences."); m->mothurOutEndLine(); }
-                               
-                               //output confidence scores or not
-                               if (probs) {
-                                       outputString =  candidateSeq->getName() + "\t" + taxonomy + "\n";
-                               }else{
-                                       outputString =  candidateSeq->getName() + "\t" + classify->getSimpleTax() + "\n";
-                               }
-                               
-                               int length = outputString.length();
-                               char* buf2 = new char[length];
-                               memcpy(buf2, outputString.c_str(), length);
-                               
-                               MPI_File_write_shared(newFile, buf2, length, MPI_CHAR, &statusNew);
-                               delete buf2;
-                               
-                               outputString =  candidateSeq->getName() + "\t" + classify->getSimpleTax() + "\n";
-                               length = outputString.length();
-                               char* buf = new char[length];
-                               memcpy(buf, outputString.c_str(), length);
-                               
-                               MPI_File_write_shared(tempFile, buf, length, MPI_CHAR, &statusTemp);
-                               delete buf;
-                               
-                               if (classify->getFlipped()) { 
-                                       outputString =  candidateSeq->getName() + "\n";
-                                       length = outputString.length();
-                                       char* buf3 = new char[length];
-                                       memcpy(buf3, outputString.c_str(), length);
-                                       
-                                       MPI_File_write_shared(accFile, buf3, length, MPI_CHAR, &statusAcc);
-                                       delete buf3;
-                               }
-                               
-                       }                               
-                       delete candidateSeq;
-                       
-                       if((i+1) % 100 == 0){   cout << "Classifying sequence " << (i+1) << endl;       }
-               }
-               
-               if(num % 100 != 0){     cout << "Classifying sequence " << (num) << endl;       }
-               
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "driverMPI");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ClassifySeqsCommand::MPIReadNamesFile(string nameFilename){
-       try {
-       
-               nameMap.clear(); //remove old names
-               
-               MPI_File inMPI;
-               MPI_Offset size;
-               MPI_Status status;
-
-               //char* inFileName = new char[nameFilename.length()];
-               //memcpy(inFileName, nameFilename.c_str(), nameFilename.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, nameFilename.c_str());
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
-               MPI_File_get_size(inMPI, &size);
-               //delete inFileName;
-
-               char* buffer = new char[size];
-               MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-
-               string tempBuf = buffer;
-               if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-               istringstream iss (tempBuf,istringstream::in);
-               delete buffer;
-               
-               string firstCol, secondCol;
-               while(!iss.eof()) {
-                       iss >> firstCol >> secondCol; m->gobble(iss);
-                       
-                       vector<string> temp;
-                       m->splitAtComma(secondCol, temp);
-                       
-                       nameMap[firstCol] = temp;  
-               }
-       
-               MPI_File_close(&inMPI);
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifySeqsCommand", "MPIReadNamesFile");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
diff --git a/classifyseqscommand.h b/classifyseqscommand.h
deleted file mode 100644 (file)
index acee70c..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-#ifndef CLASSIFYSEQSCOMMAND_H
-#define CLASSIFYSEQSCOMMAND_H
-
-/*
- *  classifyseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/2/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "classify.h"
-#include "referencedb.h"
-#include "sequence.hpp"
-#include "bayesian.h"
-#include "phylotree.h"
-#include "phylosummary.h"
-#include "knn.h"
-
-
-//KNN and Bayesian methods modeled from algorithms in
-//Naı¨ve Bayesian Classifier for Rapid Assignment of rRNA Sequences 
-//into the New Bacterial Taxonomy􏰎† 
-//Qiong Wang,1 George M. Garrity,1,2 James M. Tiedje,1,2 and James R. Cole1* 
-//Center for Microbial Ecology1 and Department of Microbiology and Molecular Genetics,2 Michigan State University, 
-//East Lansing, Michigan 48824 
-//Received 10 January 2007/Accepted 18 June 2007 
-
-
-
-class ClassifySeqsCommand : public Command {
-       
-public:
-       ClassifySeqsCommand(string);
-       ClassifySeqsCommand();
-       ~ClassifySeqsCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "classify.seqs";               }
-       string getCommandCategory()             { return "Phylotype Analysis";  }
-       string getHelpString(); 
-       string getCitation() { return "Wang Q, Garrity GM, Tiedje JM, Cole JR (2007). Naive Bayesian classifier for rapid assignment of rRNA sequences into the new bacterial taxonomy. Appl Environ Microbiol 73: 5261-7. [ for Bayesian classifier ] \nAltschul SF, Madden TL, Schaffer AA, Zhang J, Zhang Z, Miller W, Lipman DJ (1997). Gapped BLAST and PSI-BLAST: a new generation of protein database search programs. Nucleic Acids Res 25: 3389-402. [ for BLAST ] \nDeSantis TZ, Hugenholtz P, Larsen N, Rojas M, Brodie EL, Keller K, Huber T, Dalevi D, Hu P, Andersen GL (2006). Greengenes, a chimera-checked 16S rRNA gene database and workbench compatible with ARB. Appl Environ Microbiol 72: 5069-72. [ for kmer ] \nhttp://www.mothur.org/wiki/Classify.seqs"; }
-       string getDescription()         { return "classify sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       
-private:
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-       vector<string> fastaFileNames;
-       vector<string> namefileNames;
-       vector<string> groupfileNames;
-       vector<string> outputNames;
-       map<string, vector<string> > nameMap;
-       map<string,  vector<string> >::iterator itNames;
-       
-       Classify* classify;
-       ReferenceDB* rdb;
-       
-       string fastaFileName, templateFileName, distanceFileName, namefile, search, method, taxonomyFileName, outputDir, groupfile;
-       int processors, kmerSize, numWanted, cutoff, iters;
-       float match, misMatch, gapOpen, gapExtend;
-       bool abort, probs, save, flip;
-       
-       int driver(linePair*, string, string, string, string);
-       void appendTaxFiles(string, string);
-       int createProcesses(string, string, string, string); 
-       string addUnclassifieds(string, int);
-       
-       int MPIReadNamesFile(string);
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&);
-       #endif
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct classifyData {
-       string taxFName; 
-       string tempTFName; 
-       string filename;
-       string search, taxonomyFileName, templateFileName, method, accnos;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       float match, misMatch, gapOpen, gapExtend;
-       int count, kmerSize, threadID, cutoff, iters, numWanted;
-       bool probs, flip;
-        
-       classifyData(){}
-       classifyData(string acc, bool p, string me, string te, string tx, string a, string r, string f, string se, int ks, int i, int numW, MothurOut* mout, unsigned long long st, unsigned long long en, float ma, float misMa, float gapO, float gapE, int cut, int tid, bool fli) {
-               accnos = acc;
-               taxonomyFileName = tx;
-               templateFileName = te;
-               taxFName = a;
-               tempTFName = r;
-               filename = f;
-               search = se;
-               method = me;
-               m = mout;
-               start = st;
-               end = en;
-               match = ma; 
-               misMatch = misMa;
-               gapOpen = gapO; 
-               gapExtend = gapE; 
-               kmerSize = ks;
-               cutoff = cut;
-               iters = i;
-               numWanted = numW;
-               threadID = tid;
-               probs = p;
-               count = 0;
-               flip = fli;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ 
-       classifyData* pDataArray;
-       pDataArray = (classifyData*)lpParam;
-       
-       try {
-               ofstream outTax;
-               pDataArray->m->openOutputFile(pDataArray->taxFName, outTax);
-               
-               ofstream outTaxSimple;
-               pDataArray->m->openOutputFile(pDataArray->tempTFName, outTaxSimple);
-               
-               ofstream outAcc;
-               pDataArray->m->openOutputFile(pDataArray->accnos, outAcc);
-               
-               ifstream inFASTA;
-               pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
-               
-               string taxonomy;
-                               
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       inFASTA.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               
-               //make classify
-               Classify* myclassify;
-               if(pDataArray->method == "bayesian"){   myclassify = new Bayesian(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->cutoff, pDataArray->iters, pDataArray->threadID, pDataArray->flip);         }
-               else if(pDataArray->method == "knn"){   myclassify = new Knn(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->numWanted, pDataArray->threadID);                           }
-               else {
-                       pDataArray->m->mothurOut(pDataArray->search + " is not a valid method option. I will run the command using bayesian.");
-                       pDataArray->m->mothurOutEndLine();
-                       myclassify = new Bayesian(pDataArray->taxonomyFileName, pDataArray->templateFileName, pDataArray->search, pDataArray->kmerSize, pDataArray->cutoff, pDataArray->iters, pDataArray->threadID, pDataArray->flip); 
-               }
-               
-               if (pDataArray->m->control_pressed) { delete myclassify; return 0; }
-               
-               int count = 0;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) { delete myclassify; return 0; }
-                       
-                       Sequence* candidateSeq = new Sequence(inFASTA); pDataArray->m->gobble(inFASTA);
-                       
-                       if (candidateSeq->getName() != "") {
-                               
-                               taxonomy = myclassify->getTaxonomy(candidateSeq);
-                               
-                               if (pDataArray->m->control_pressed) { delete candidateSeq; return 0; }
-                               
-                               if (taxonomy == "unknown;") { pDataArray->m->mothurOut("[WARNING]: " + candidateSeq->getName() + " could not be classified. You can use the remove.lineage command with taxon=unknown; to remove such sequences."); pDataArray->m->mothurOutEndLine(); }
-
-                               //output confidence scores or not
-                               if (pDataArray->probs) {
-                                       outTax << candidateSeq->getName() << '\t' << taxonomy << endl;
-                               }else{
-                                       outTax << candidateSeq->getName() << '\t' << myclassify->getSimpleTax() << endl;
-                               }
-                                       
-                               outTaxSimple << candidateSeq->getName() << '\t' << myclassify->getSimpleTax() << endl;
-                                       
-                               if (myclassify->getFlipped()) { outAcc << candidateSeq->getName() << endl; }
-                               
-                               count++;
-                       }
-                       delete candidateSeq;
-                       //report progress
-                       if((count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine();         }
-                       
-               }
-               //report progress
-               if((count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine();         }
-               
-               delete myclassify;
-               inFASTA.close();
-               outTax.close();
-               outTaxSimple.close();
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ClassifySeqsCommand", "MyClassThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-
-
-#endif
-
diff --git a/classifytreecommand.cpp b/classifytreecommand.cpp
deleted file mode 100644 (file)
index bcf2769..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-//
-//  classifytreecommand.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 2/20/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "classifytreecommand.h"
-#include "phylotree.h"
-#include "treereader.h"
-
-//**********************************************************************************************************************
-vector<string> ClassifyTreeCommand::setParameters(){   
-       try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "", "", "none",false,true); parameters.push_back(ptree);
-        CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "", "", "none",false,true); parameters.push_back(ptaxonomy);
-        CommandParameter pname("name", "InputTypes", "", "", "", "", "none",false,false); parameters.push_back(pname);
-        CommandParameter pgroup("group", "InputTypes", "", "", "", "", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter pcutoff("cutoff", "Number", "", "51", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClassifyTreeCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The classify.tree command reads a tree and taxonomy file and output the consensus taxonomy for each node on the tree. \n";
-               helpString += "If you provide a group file, the concensus for each group will also be provided. \n";
-               helpString += "The new tree contains labels at each internal node.  The label is the node number so you can relate the tree to the summary file.\n";
-               helpString += "The summary file lists the concensus taxonomy for the descendants of each node.\n";
-               helpString += "The classify.tree command parameters are tree, group, name and taxonomy. The tree and taxonomy files are required.\n";
-        helpString += "The cutoff parameter allows you to specify a consensus confidence threshold for your taxonomy.  The default is 51, meaning 51%. Cutoff cannot be below 51.\n";
-        helpString += "The classify.tree command should be used in the following format: classify.tree(tree=test.tre, group=test.group, taxonomy=test.taxonomy)\n";
-               helpString += "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n"; 
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ClassifyTreeCommand::ClassifyTreeCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["tree"] = tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "ClassifyTreeCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClassifyTreeCommand::ClassifyTreeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["tree"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-            
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { treefile = ""; abort = true; }
-                       else if (treefile == "not found") { treefile = ""; 
-                treefile = m->getTreeFile(); 
-                if (treefile != "") {  m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                else { m->mothurOut("No valid current files. You must provide a tree file."); m->mothurOutEndLine(); abort = true; }
-            }else { m->setTreeFile(treefile); }        
-            
-            taxonomyfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxonomyfile == "not open") { taxonomyfile = ""; abort = true; }
-                       else if (taxonomyfile == "not found") { taxonomyfile = ""; 
-                taxonomyfile = m->getTaxonomyFile(); 
-                if (taxonomyfile != "") {  m->mothurOut("Using " + taxonomyfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                else { m->mothurOut("No valid current files. You must provide a taxonomy file."); m->mothurOutEndLine(); abort = true; }
-            }else { m->setTaxonomyFile(taxonomyfile); }        
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-            
-            string temp = validParameter.validFile(parameters, "cutoff", false);                       if (temp == "not found") { temp = "51"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       if ((cutoff < 51) || (cutoff > 100)) { m->mothurOut("cutoff must be above 50, and no greater than 100."); m->mothurOutEndLine(); abort = true;  }
-            
-            if (namefile == "") {
-                               vector<string> files; files.push_back(treefile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "ClassifyTreeCommand");           
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ClassifyTreeCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               
-               int start = time(NULL);
-        
-               /***************************************************/
-               //    reading tree info                                                    //
-               /***************************************************/
-        m->setTreeFile(treefile);
-        
-        TreeReader* reader = new TreeReader(treefile, groupfile, namefile);
-        vector<Tree*> T = reader->getTrees();
-        TreeMap* tmap = T[0]->getTreeMap();
-        Tree* outputTree = T[0];
-        delete reader;
-
-        if (namefile != "") { readNamesFile(); }
-                        
-        if (m->control_pressed) { delete tmap;  delete outputTree;  return 0; }
-               
-        readTaxonomyFile();
-        
-        /***************************************************/
-        //             get concensus taxonomies                    //
-        /***************************************************/
-        getClassifications(outputTree);
-        delete outputTree; delete tmap;
-                       
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               //set tree file as new current treefile
-               if (treefile != "") {
-                       string current = "";
-                       itTypes = outputTypes.find("tree");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); }
-                       }
-               }
-               
-               m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to find the concensus taxonomies."); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "execute");       
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//traverse tree finding concensus taxonomy at each node
-//label node with a number to relate to output summary file
-//report all concensus taxonomies to file 
-int ClassifyTreeCommand::getClassifications(Tree*& T){
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(treefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(treefile)) + "taxonomy.summary";
-               outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               //print headings
-               out << "TreeNode\t";
-               if (groupfile != "") { out << "Group\t"; } 
-        out << "NumRep\tTaxonomy" << endl; 
-               
-               string treeOutputDir = outputDir;
-               if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + "taxonomy.tre";
-               
-               //create a map from tree node index to names of descendants, save time later
-               map<int, map<string, set<string> > > nodeToDescendants; //node# -> (groupName -> groupMembers)
-               for (int i = 0; i < T->getNumNodes(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       nodeToDescendants[i] = getDescendantList(T, i, nodeToDescendants);
-               }
-               
-               //for each node
-               for (int i = T->getNumLeaves(); i < T->getNumNodes(); i++) {
-                       
-                       if (m->control_pressed) { out.close(); return 0; }
-            
-                       string tax = "not classifed";
-            int size;
-            if (groupfile != "") {
-                for (map<string, set<string> >::iterator itGroups = nodeToDescendants[i].begin(); itGroups != nodeToDescendants[i].end(); itGroups++) {
-                    if (itGroups->first != "AllGroups") {
-                        tax = getTaxonomy(itGroups->second, size);
-                        out << (i+1) << '\t' << itGroups->first << '\t' << size << '\t' << tax << endl;
-                    }
-                }
-            }else {
-                string group = "AllGroups";
-                tax = getTaxonomy(nodeToDescendants[i][group], size);
-                out << (i+1) << '\t' << size << '\t' << tax << endl;
-            }
-                               
-                       T->tree[i].setLabel((i+1));
-               }
-               out.close();
-        
-               ofstream outTree;
-               m->openOutputFile(outputTreeFileName, outTree);
-               outputNames.push_back(outputTreeFileName); outputTypes["tree"].push_back(outputTreeFileName);
-               T->print(outTree, "both");
-               outTree.close();
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "GetConcensusTaxonomies");        
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClassifyTreeCommand::getTaxonomy(set<string> names, int& size) {
-       try{
-               string conTax = "";
-        size = 0;
-                       
-               //create a tree containing sequences from this bin
-               PhyloTree* phylo = new PhyloTree();
-               
-               for (set<string>::iterator it = names.begin(); it != names.end(); it++) {
-            
-            
-                       //if namesfile include the names
-                       if (namefile != "") {
-                
-                               //is this sequence in the name file - namemap maps seqName -> repSeqName
-                               map<string, string>::iterator it2 = nameMap.find(*it);
-                               
-                               if (it2 == nameMap.end()) { //this name is not in name file, skip it
-                                       m->mothurOut((*it) + " is not in your name file.  I will not include it in the consensus."); m->mothurOutEndLine();
-                               }else{
-                                       
-                                       //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
-                                       map<string, string>::iterator itTax = taxMap.find((it2->second));
-                    
-                                       if (itTax == taxMap.end()) { //this name is not in taxonomy file, skip it
-                        
-                                               if ((*it) != (it2->second)) { m->mothurOut((*it) + " is represented by " +  it2->second + " and is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
-                                               else {  m->mothurOut((*it) + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine(); }
-                                       }else{
-                                               //add seq to tree
-                        int num = nameCount[(*it)]; // we know its there since we found it in nameMap
-                                               for (int i = 0; i < num; i++) {  phylo->addSeqToTree((*it)+toString(i), it2->second);  }
-                        size += num;
-                                       }
-                               }
-                               
-                       }else{
-                               //is this sequence in the taxonomy file - look for repSeqName since we are assuming the taxonomy file is unique
-                               map<string, string>::iterator itTax = taxMap.find((*it));
-                
-                               if (itTax == taxMap.end()) { //this name is not in taxonomy file, skip it
-                                       m->mothurOut((*it) + " is not in your taxonomy file.  I will not include it in the consensus."); m->mothurOutEndLine();
-                               }else{
-                                       //add seq to tree
-                                       phylo->addSeqToTree((*it), itTax->second);
-                    size++;
-                               }
-                       }
-            
-                       if (m->control_pressed) { delete phylo; return conTax; }
-                       
-               }
-               
-               //build tree
-               phylo->assignHeirarchyIDs(0);
-               
-               TaxNode currentNode = phylo->get(0);
-               int myLevel = 0;        
-               //at each level
-               while (currentNode.children.size() != 0) { //you still have more to explore
-            
-                       TaxNode bestChild;
-                       int bestChildSize = 0;
-                       
-                       //go through children
-                       for (map<string, int>::iterator itChild = currentNode.children.begin(); itChild != currentNode.children.end(); itChild++) {
-                               
-                               TaxNode temp = phylo->get(itChild->second);
-                               
-                               //select child with largest accesions - most seqs assigned to it
-                               if (temp.accessions.size() > bestChildSize) {
-                                       bestChild = phylo->get(itChild->second);
-                                       bestChildSize = temp.accessions.size();
-                               }
-                               
-                       }
-            
-                       //is this taxonomy above cutoff
-                       int consensusConfidence = ceil((bestChildSize / (float) size) * 100);
-                       
-                       if (consensusConfidence >= cutoff) { //if yes, add it
-                conTax += bestChild.name + "(" + toString(consensusConfidence) + ");";
-                               myLevel++;
-                       }else{ //if no, quit
-                               break;
-                       }
-                       
-                       //move down a level
-                       currentNode = bestChild;
-               }
-               
-               if (myLevel != phylo->getMaxLevel()) {
-                       while (myLevel != phylo->getMaxLevel()) {
-                               conTax += "unclassified;";
-                               myLevel++;
-                       }
-               }               
-               if (conTax == "") {  conTax = "no_consensus;";  }
-               
-               delete phylo;   
-        
-        return conTax;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "getTaxonomy");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-map<string, set<string> > ClassifyTreeCommand::getDescendantList(Tree*& T, int i, map<int, map<string, set<string> > > descendants){
-       try {
-               map<string ,set<string> > names;
-               
-               map<string ,set<string> >::iterator it;
-        map<string ,set<string> >::iterator it2;
-               
-               int lc = T->tree[i].getLChild();
-               int rc = T->tree[i].getRChild();
-        TreeMap* tmap = T->getTreeMap();
-               
-               if (lc == -1) { //you are a leaf your only descendant is yourself
-            string group = tmap->getGroup(T->tree[i].getName());
-            set<string> mynames; mynames.insert(T->tree[i].getName());
-            names[group] = mynames; //mygroup -> me
-            names["AllGroups"] = mynames;
-               }else{ //your descedants are the combination of your childrens descendants
-                       names = descendants[lc];
-                       for (it = descendants[rc].begin(); it != descendants[rc].end(); it++) {
-                it2 = names.find(it->first); //do we already have this group
-                if (it2 == names.end()) { //nope, so add it
-                    names[it->first] = it->second;
-                }else {
-                    for (set<string>::iterator it3 = (it->second).begin(); it3 != (it->second).end(); it3++) {
-                        names[it->first].insert(*it3);
-                    }
-                }
-                               
-                       }
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "getDescendantList");     
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ClassifyTreeCommand::readTaxonomyFile() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(taxonomyfile, in);
-               
-               string name, tax;
-        
-               while(!in.eof()){
-                       in >> name >> tax;              
-                       m->gobble(in);
-                       
-                       //are there confidence scores, if so remove them
-                       if (tax.find_first_of('(') != -1) {  m->removeConfidences(tax); }
-                       
-                       taxMap[name] = tax;
-                       
-                       if (m->control_pressed) { in.close(); taxMap.clear(); return 0; }
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "readTaxonomyFile");
-               exit(1);
-       }
-}
-
-/*****************************************************************/
-int ClassifyTreeCommand::readNamesFile() {
-       try {
-               ifstream inNames;
-               m->openInputFile(namefile, inNames);
-               
-               string name, names;
-        
-               while(!inNames.eof()){
-                       inNames >> name;                        //read from first column  A
-                       inNames >> names;               //read from second column  A,B,C,D
-                       m->gobble(inNames);
-                       
-                       //parse names into vector
-                       vector<string> theseNames;
-                       m->splitAtComma(names, theseNames);
-            
-                       for (int i = 0; i < theseNames.size(); i++) {  nameMap[theseNames[i]] = name;  }
-            nameCount[name] = theseNames.size();
-                       
-                       if (m->control_pressed) { inNames.close(); nameMap.clear(); return 0; }
-               }
-               inNames.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClassifyTreeCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
-/*****************************************************************/
-
-
diff --git a/classifytreecommand.h b/classifytreecommand.h
deleted file mode 100644 (file)
index 30957af..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef Mothur_classifytreecommand_h
-#define Mothur_classifytreecommand_h
-
-//
-//  classifytreecommand.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 2/20/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "command.hpp"
-#include "readtree.h"
-#include "treemap.h"
-
-class ClassifyTreeCommand : public Command {
-public:
-       ClassifyTreeCommand(string);
-       ClassifyTreeCommand();
-       ~ClassifyTreeCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "classify.tree";                               }
-       string getCommandCategory()             { return "Phylotype Analysis";          }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Classify.tree"; }
-       string getDescription()         { return "Find the consensus taxonomy for the descendant of each tree node"; }
-    
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string treefile, taxonomyfile, groupfile, namefile, outputDir;
-       bool abort;
-       vector<string> outputNames;
-    int numUniquesInName, cutoff;
-    map<string, string> nameMap;
-    map<string, int> nameCount;
-    map<string, string> taxMap;
-       
-       int getClassifications(Tree*&);
-       map<string, set<string> > getDescendantList(Tree*&, int, map<int, map<string, set<string> > >);
-    string getTaxonomy(set<string>, int&);
-    int readNamesFile(); 
-    int readTaxonomyFile();
-       
-};
-
-
-
-#endif
diff --git a/clearcut.cpp b/clearcut.cpp
deleted file mode 100644 (file)
index 5246838..0000000
+++ /dev/null
@@ -1,2159 +0,0 @@
-
-/*
- * clearcut.c
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * An implementation of the Relaxed Neighbor-Joining algorithm 
- *  of Evans, J., Sheneman, L., and Foster, J.
- *
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <math.h>
-#include <time.h>
-#include <sys/time.h>
-#include <float.h>
-
-#include "distclearcut.h"
-#include "dmat.h"
-#include "fasta.h"
-#include "cmdargs.h"
-#include "common.h"
-#include "clearcut.h"
-#include "prng.h"
-
-
-/*
- * main() - 
- *
- * The entry point to the program.
- *
- */
-int clearcut_main(int argc, char *argv[]) {
-
-  DMAT *dmat;         /* The working distance matrix */
-  DMAT *dmat_backup = NULL;/* A backup distance matrix    */
-  NJ_TREE *tree;      /* The phylogenetic tree       */
-  NJ_ARGS *nj_args;   /* Structure for holding command-line arguments */
-  long int i;
-
-  /* some variables for tracking time */
-  struct timeval tv;
-  unsigned long long startUs, endUs;
-  
-
-  /* check and parse supplied command-line arguments */
-  nj_args = NJ_handle_args(argc, argv);
-
-  if(!nj_args) {
-    fprintf(stderr, "Clearcut: Error processing command-line arguments.\n");
-    exit(-1);
-  }
-
-  /* for verbose reporting, print the random number seed to stdout */
-  if(nj_args->verbose_flag) {
-    printf("PRNG SEED: %d\n", nj_args->seed);
-  }
-
-  /* Initialize Mersenne Twister PRNG */
-  init_genrand(nj_args->seed);
-
-
-  switch(nj_args->input_mode) {
-
-    /* If the input type is a distance matrix */
-  case NJ_INPUT_MODE_DISTANCE:
-
-    /* parse the distance matrix */
-    dmat = NJ_parse_distance_matrix(nj_args);
-    if(!dmat) {
-      exit(-1);
-    }
-
-    break;
-
-    /* If the input type is a multiple sequence alignment */
-  case NJ_INPUT_MODE_ALIGNED_SEQUENCES:
-
-    /* build a distance matrix from a multiple sequence alignment */
-    dmat = NJ_build_distance_matrix(nj_args);
-    if(!dmat) {
-      fprintf(stderr, "Clearcut: Failed to build distance matrix from alignment.\n");
-      exit(-1);
-    }
-    
-    break;
-
-  default:
-
-    fprintf(stderr, "Clearcut: Could not determine how to process input\n");
-    exit(-1);
-  }
-
-  /*
-   * Output the computed distance matrix,
-   *  if the user specified one.
-   */
-  if(nj_args->matrixout) {
-    NJ_output_matrix(nj_args, dmat);
-  }
-  
-  /* 
-   * If we are going to generate multiple trees from
-   * the same distance matrix, we need to make a backup 
-   * of the original distance matrix.
-   */
-  if(nj_args->ntrees > 1) {
-    dmat_backup = NJ_dup_dmat(dmat);
-  }
-  
-  /* process n trees */
-  for(i=0;i<nj_args->ntrees;i++) {
-    
-    /* 
-     * If the user has specified matrix shuffling, we need 
-     * to randomize the distance matrix
-     */
-    if(nj_args->shuffle) {
-      NJ_shuffle_distance_matrix(dmat);
-    }
-
-    /* RECORD THE PRECISE TIME OF THE START OF THE NEIGHBOR-JOINING */
-    gettimeofday(&tv, NULL);
-    startUs = ((unsigned long long) tv.tv_sec * 1000000ULL)
-      + ((unsigned long long) tv.tv_usec);
-
-    
-    /* 
-     * Invoke either the Relaxed Neighbor-Joining algorithm (default)
-     * or the "traditional" Neighbor-Joining algorithm 
-     */
-    if(nj_args->neighbor) {
-      tree = NJ_neighbor_joining(nj_args, dmat);
-    } else {
-      tree = NJ_relaxed_nj(nj_args, dmat);
-    }
-  
-    if(!tree) {
-      fprintf(stderr, "Clearcut: Failed to construct tree.\n");
-      exit(0);
-    }
-
-    /* RECORD THE PRECISE TIME OF THE END OF THE NEIGHBOR-JOINING */
-    gettimeofday(&tv, NULL);
-    endUs = ((unsigned long long) tv.tv_sec * 1000000ULL)
-      + ((unsigned long long) tv.tv_usec);
-
-    /* print the time taken to perform the neighbor join */
-    if(nj_args->verbose_flag) {
-      if(nj_args->neighbor) {
-       fprintf(stderr, "NJ tree built in %llu.%06llu secs\n",
-               (endUs - startUs) / 1000000ULL,
-               (endUs - startUs) % 1000000ULL);
-      } else { 
-       fprintf(stderr, "RNJ tree built in %llu.%06llu secs\n",
-               (endUs - startUs) / 1000000ULL,
-               (endUs - startUs) % 1000000ULL);
-      }
-    }
-
-    /* Output the neighbor joining tree here */
-    NJ_output_tree(nj_args, tree, dmat, i);
-    
-    NJ_free_tree(tree);  /* Free the tree */
-    NJ_free_dmat(dmat);  /* Free the working distance matrix */
-
-    /* 
-     * If we need to do another iteration, lets re-initialize 
-     * our working distance matrix.
-     */
-    if(nj_args->ntrees > 1 && i<(nj_args->ntrees-1) ) {
-      dmat = NJ_dup_dmat(dmat_backup);
-    }
-  }
-  
-  /* Free the backup distance matrix */
-  if(nj_args->ntrees > 1) {
-    NJ_free_dmat(dmat_backup);
-  }
-
-  /* If verbosity, describe where the tree output is */
-  if(nj_args->verbose_flag) {
-    if(nj_args->neighbor) {
-      printf("NJ tree(s) in %s\n", nj_args->outfilename);
-    } else {
-      printf("Relaxed NJ tree(s) in %s\n", nj_args->outfilename);
-    }
-  }
-  
-       return 0;
-}
-
-
-
-
-
-/*
- * NJ_find_hmin() - Find minimum transformed values along horizontal
- * 
- * 
- * INPUTS:
- * -------
- *      dmat -- The distance matrix
- *         a -- The index of the specific taxon in the distance matrix
- *
- * RETURNS:
- * --------
- *   <float> -- The value of the selected minimum
- *       min -- Used to transport the index of the minima out 
- *              of the function (by reference)
- * hmincount -- Return the number of minima along the horizontal
- *              (by reference)
- *
- *
- * DESCRIPTION:
- * ------------
- *
- * A fast, inline function to find the smallest transformed value 
- * along the "horizontal" portion of an entry in a distance matrix.
- *
- * Distance matrices are stored internally as continguously-allocated
- * upper-diagonal structures.  With the exception of the taxa at
- * row 0 of this upper-diagonal matrix, all taxa have both a horizontal
- * and vertical component in the distance matrix.  This function
- * scans the horizonal portion of the entry in the distance matrix
- * for the specified taxon and finds the minimum transformed value
- * along that horizontal component.
- *
- * Since multiple minima can exist along the horizontal portion
- * of the entry, I consider all minima and break ties
- * stochastically to help avoid systematic bias.
- *
- * Just searching along the horizontal portion of a row is very fast
- * since the data is stored linearly and contiguously in memory and 
- * cache locality is exploited in the distance matrix representation. 
- *
- * Look at nj.h for more information on how the distance matrix 
- * is architected.
- * 
- */
-static inline
-float
-NJ_find_hmin(DMAT *dmat,
-            long int a,
-            long int *min,
-            long int *hmincount) {
-
-  long int i;     /* index variable for looping                    */
-  int size;       /* current size of distance matrix               */
-  int mindex = 0; /* holds the current index to the chosen minimum */
-  float curval;   /* used to hold current transformed values       */
-  float hmin;     /* the value of the transformed minimum          */
-
-  float *ptr, *r2, *val;  /* pointers used to reduce dereferencing in inner loop */
-
-  /* values used for stochastic selection among multiple minima */
-  float p, x;  
-  long int smallcnt;
-
-  /* initialize the min to something large */
-  hmin = (float)HUGE_VAL;
-
-  /* setup some pointers to limit dereferencing later */
-  r2       = dmat->r2;
-  val      = dmat->val;
-  size     = dmat->size;
-
-  /* initialize values associated with minima tie breaking */
-  p        = 1.0;
-  smallcnt = 0;
-  
-  
-  ptr = &(val[NJ_MAP(a, a+1, size)]);   /* at the start of the horiz. part */
-  for(i=a+1;i<size;i++) {
-
-    curval = *(ptr++) - (r2[a] + r2[i]);  /* compute transformed distance */
-    
-    if(NJ_FLT_EQ(curval, hmin)) {  /* approx. equal */
-      
-      smallcnt++;
-
-      p = 1.0/(float)smallcnt;
-      x = genrand_real2();
-      
-      /* select this minimum in a way which is proportional to 
-        the number of minima found along the row so far */
-      if( x < p ) {
-       mindex = i;
-      }
-
-    } else if (curval < hmin) {
-
-      smallcnt = 1;
-      hmin = curval;
-      mindex = i;
-    }
-  }
-  
-  /* save off the the minimum index to be returned via reference */
-  *min = mindex;
-  
-  /* save off the number of minima */
-  *hmincount = smallcnt;
-  
-  /* return the value of the smallest tranformed distance */
-  return(hmin);
-}
-
-
-
-
-
-
-
-
-/*
- * NJ_find_vmin() - Find minimum transformed distance along vertical
- *
- * 
- * INPUTS:
- * -------
- *      dmat -- The distance matrix
- *         a -- The index of the specific taxon in the distance matrix
- *
- *
- * RETURNS:
- * --------
- *   <float> -- The value of the selected minimum
- *       min -- Used to transport the index of the minima out 
- *              of the function (by reference)
- * vmincount -- The number of minima along the vertical
- *              return by reference.
- *
- * DESCRIPTION:
- * ------------
- *
- * A fast, inline function to find the smallest transformed value 
- * along the "vertical" portion of an entry in a distance matrix.
- *
- * Distance matrices are stored internally as continguously-allocated
- * upper-diagonal matrices.  With the exception of the taxa at
- * row 0 of this upper-diagonal matrix, all taxa have both a horizontal
- * and vertical component in the distance matrix.  This function
- * scans the vertical portion of the entry in the distance matrix
- * for the specified taxon and finds the minimum transformed value
- * along that vertical component.
- *
- * Since multiple minima can exist along the vertical portion
- * of the entry, I consider all minima and break ties
- * stochastically to help avoid systematic bias.
- *
- * Due to cache locality reasons, searching along the vertical
- * component is going to be considerably slower than searching
- * along the horizontal.
- *
- * Look at nj.h for more information on how the distance matrix 
- * is architected.
- * 
- */
-static inline
-float
-NJ_find_vmin(DMAT *dmat,
-            long int a,
-            long int *min,
-            long int *vmincount) {
-
-  long int i;         /* index variable used for looping */
-  long int size;      /* track the size of the matrix    */
-  long int mindex = 0;/* track the index to the minimum  */
-  float curval;       /* track value of current transformed distance  */
-  float vmin;         /* the index to the smallest "vertical" minimum */
-
-  /* pointers which are used to reduce pointer dereferencing in inner loop */
-  float *ptr, *r2, *val;
-
-  /* values used in stochastically breaking ties */
-  float p, x;
-  long int smallcnt;
-
-  /* initialize the vertical min to something really big */
-  vmin = (float)HUGE_VAL;
-
-  /* save off some values to limit dereferencing later */
-  r2       = dmat->r2;
-  val      = dmat->val;
-  size     = dmat->size;
-
-  p        = 1.0;
-  smallcnt = 0;
-
-  /* start on the first row and work down */
-  ptr = &(val[NJ_MAP(0, a, size)]);  
-  for(i=0;i<a;i++) {
-
-    curval = *ptr - (r2[i] + r2[a]);  /* compute transformed distance */
-    
-    if(NJ_FLT_EQ(curval, vmin)) {  /* approx. equal */
-      
-      smallcnt++;
-
-      p = 1.0/(float)smallcnt;
-      x = genrand_real2();
-
-      /* break ties stochastically to avoid systematic bias */
-      if( x < p ) {
-       mindex = i;
-      }
-
-    } else if (curval < vmin) {
-
-      smallcnt = 1;
-      vmin = curval;
-      mindex = i;
-    }
-
-    /* increment our working pointer to the next row down */
-    ptr += size-i-1;
-  }
-
-  /* pass back the index to the minimum found so far (by reference) */
-  *min = mindex;
-  
-  /* pass back the number of minima along the vertical */
-  *vmincount = smallcnt;
-
-  /* return the value of the smallest transformed distance */
-  return(vmin);
-}
-
-
-
-
-/*
- * NJ_permute() - Generate random permutation using the provably unbiased
- *                Fisher-Yates Shuffle.
- *
- * INPUTS:
- * -------
- *   perm -- A pointer to the array of long ints which will be filled.
- *   size -- the length of the permutation vector 
- *
- *
- * OUTPUTS:
- * -------
- *   NONE
- *
- *
- * DESCRIPTION:
- * ------------
- *
- * Return a permuted list of numbers from 0 through size.
- * This is accomplished by initializing the permutation 
- * as an ordered list of integers and then iterating 
- * through and swapping two values selected according to the
- * Fisher-Yates method.
- *
- * This unbiased method for random permutation generation is 
- * discussed in:
- *
- *     Donald E. Knuth, The Art of Computer Programming, 
- *     Addison-Wesley, Volumes 1, 2, and 3, 3rd edition, 1998
- *
- */
-static inline
-void
-NJ_permute(long int *perm,
-          long int size) {
-  
-  long int i;     /* index used for looping */
-  long int swap;  /* we swap values to generate permutation */
-  long int tmp;   /* used for swapping values */
-
-
-  /* check to see if vector of long ints is valid */
-  if(!perm) {
-    fprintf(stderr, "Clearcut: NULL permutation pointer in NJ_permute()\n");
-    exit(-1);
-  }
-  
-  /* init permutation as an ordered list of integers */
-  for(i=0;i<size;i++) {
-    perm[i] = i;
-  }
-
-  /* 
-   * Iterate across the array from i = 0 to size -1, swapping ith element
-   * with a randomly chosen element from a changing range of possible values
-   */
-  for(i=0;i<size;i++) {
-
-    /* choose which element we will swap with */
-    swap = i + NJ_genrand_int31_top(size-i);
-
-    /* swap elements here */
-    if(i != swap) {
-      tmp        = perm[swap];
-      perm[swap] = perm[i];
-      perm[i]    = tmp;
-    }
-  }
-  
-  return;
-}
-
-
-
-
-
-/*
- * NJ_compute_r() - Compute post-join changes to r-vector.  In this
- *                  case, we decrement all of the accumulated distances
- *                  in the r-vector for the two nodes that were
- *                  recently joined (i.e.  x, y)
- *
- * INPUTS:
- * -------
- *   dmat -- The distance matrix 
- *      a -- The index of one of the taxa that were joined
- *      b -- The index of the other taxa that was joined
- *
- * RETURNS:
- * --------
- *   NONE
- * 
- * DESCRIPTION:
- * ------------
- *   
- * This vector of floats is used as a summary of overall distances from
- * each entry in the distance matrix to every other entry.  These values
- * are then used when computing the transformed distances from which
- * decisions concerning joining are made.
- *
- * For speed, we don't recompute r from scratch.  Instead, we decrement
- * all entries in r by the appropriate amount.  That is, r[i] -= dist(i, a)
- * and r[i] -= dist(i, b).
- *
- * As a speed optimization, I process the rows altogether for cache locality
- * purposes, and then process columns.
- *
- * The processing of the scaled r matrix (r2) is handled on-the-fly elsewhere.
- *  
- */
-static inline
-void
-NJ_compute_r(DMAT *dmat,
-            long int a,
-            long int b) {
-  
-  long int i;         /* a variable used in indexing */
-  float *ptrx, *ptry; /* pointers into the distance matrix */
-  
-  /* some variables to limit pointer dereferencing in loop */
-  long int size; 
-  float *r, *val;
-  
-  /* to limit pointer dereferencing */
-  size = dmat->size;
-  val  = dmat->val;
-  r    = dmat->r+a+1;
-
-  /* 
-   * Loop through the rows and decrement the stored r values 
-   * by the distances stored in the rows and columns of the distance 
-   * matrix which are being removed post-join.
-   *
-   * We do the rows altogether in order to benefit from cache locality.
-   */
-  ptrx = &(val[NJ_MAP(a, a+1, size)]); 
-  ptry = &(val[NJ_MAP(b, b+1, size)]); 
-
-  for(i=a+1;i<size;i++) {
-    *r -= *(ptrx++);  
-
-    if(i>b) {
-      *r -= *(ptry++); 
-    }
-
-    r++;
-  }
-
-  /* Similar to the above loop, we now do the columns */
-  ptrx = &(val[NJ_MAP(0, a, size)]);  
-  ptry = &(val[NJ_MAP(0, b, size)]);  
-  r = dmat->r;
-  for(i=0;i<b;i++) {
-    if(i<a) {
-      *r -= *ptrx;
-      ptrx += size-i-1;
-    }
-
-    *r -= *ptry;
-    ptry += size-i-1;
-    r++;
-  }
-
-  return;
-}
-
-
-
-
-
-/*
- * NJ_check_additivity() - Check to make sure that addivity preserved by join
- *
- *
- * INPUTS:
- * -------
- *    dmat -- distance matrix
- *       a -- index into dmat for one of the rows to be joined
- *       b -- index into dmat for another row to be joined
- *
- * OUTPUTS:
- * --------
- *     int    1 if join adheres to additivity constraint
- *            0 if join does breaks additivity
- *
- * DESCRIPTION:
- * ------------
- *
- * Here we perform the check to make sure that by joining a and b we do not 
- * also break consistency (i.e. preserves additivity) with the distances between 
- * the taxa in the new clade and other nodes in the tree.  This is done quite
- * efficiently by looking up the untransformed distance between node b and 
- * some other "target" taxa in the distance matrix (which is not a nor b) and 
- * comparing that distance to the distance computed by finding the distance 
- * from node a to the proposed internal node "x" which joins (a,b).  
- *
- * If dist(x,b) + dist (b, target) == dist(b, target) then additivity is 
- * preserved, otherwise, additivity is not preserved.  If we are in 
- * additivity mode, this join should be rejected.
- *
- */
-static inline
-int
-NJ_check_additivity(DMAT *dmat,
-                   long int a,
-                   long int b) {
-
-  float a2clade, b2clade;
-  float clade_dist;
-  long int target;
-
-
-  /* determine target taxon here */
-  if(b == dmat->size-1) {
-    /* if we can't do a row here, lets do a column */
-    if(a==0) {
-      if(b==1) {
-       target = 2;
-      } else {
-       target = 1;
-      }
-    } else {
-      target = 0;
-    }
-  } else {
-    target = b+1;
-  }
-
-
-  /* distance between a and the root of clade (a,b) */
-  a2clade = 
-    ( (dmat->val[NJ_MAP(a, b, dmat->size)]) + 
-      (dmat->r2[a] - dmat->r2[b]) ) / 2.0;  
-  
-  /* distance between b and the root of clade (a,b) */
-  b2clade = 
-    ( (dmat->val[NJ_MAP(a, b, dmat->size)]) + 
-      (dmat->r2[b] - dmat->r2[a]) ) / 2.0;  
-
-  /* distance between the clade (a,b) and the target taxon */
-  if(b<target) {
-
-    /* compute the distance from the clade root to the target */
-    clade_dist = 
-      ( (dmat->val[NJ_MAP(a, target, dmat->size)] - a2clade) +
-       (dmat->val[NJ_MAP(b, target, dmat->size)] - b2clade) ) / 2.0;
-    
-    /* 
-     * Check to see that distance from clade root to target + distance from 
-     *  b to clade root are equal to the distance from b to the target 
-     */
-    if(NJ_FLT_EQ(dmat->val[NJ_MAP(b, target, dmat->size)], 
-                (clade_dist + b2clade))) {
-      return(1);  /* join is legitimate   */
-    } else {
-      return(0);  /* join is illigitimate */
-    }
-    
-  } else {
-
-    /* compute the distance from the clade root to the target */
-    clade_dist = 
-      ( (dmat->val[NJ_MAP(target, a, dmat->size)] - a2clade) +
-       (dmat->val[NJ_MAP(target, b, dmat->size)] - b2clade) ) / 2.0;
-
-    /* 
-     * Check to see that distance from clade root to target + distance from 
-     *  b to clade root are equal to the distance from b to the target 
-     */
-    if(NJ_FLT_EQ(dmat->val[NJ_MAP(target, b, dmat->size)], 
-                (clade_dist + b2clade))) {
-      return(1);  /* join is legitimate   */
-    } else {
-      return(0);  /* join is illegitimate */
-    }
-  }
-}
-
-
-
-
-
-
-
-/*
- * NJ_check() - Check to see if two taxa can be joined
-
- *
- * INPUTS:
- * -------
- * nj_args    -- Pointer to the data structure holding command-line args
- *    dmat    -- distance matrix
- *       a    -- index into dmat for one of the rows to be joined
- *       b    -- index into dmat for another row to be joined
- *     min    -- the minimum value found
- * additivity -- a flag (0 = not additive mode, 1 = additive mode)
- *
- * OUTPUTS:
- * --------
- *     int    1 if join is okay
- *            0 if join is not okay
- *
- * DESCRIPTION:
- * ------------
- *
- * This function ultimately takes two rows and makes sure that the 
- * intersection of those two rows, which has a transformed distance of
- * "min", is actually the smallest (or equal to the smallest) 
- * transformed distance for both rows (a, b).  If so, it returns
- * 1, else it returns 0.  
- *
- * Basically, we want to join two rows only if the minimum 
- * transformed distance on either row is at the intersection of
- * those two rows.
- *
- */
-static inline
-int 
-NJ_check(NJ_ARGS *nj_args,
-        DMAT *dmat,
-        long int a,
-        long int b,
-        float min,
-        int additivity) {
-
-
-  long int i, size;
-  float *ptr, *val, *r2;
-  
-
-  /* some aliases for speed and readability reasons */
-  val  = dmat->val;
-  r2   = dmat->r2;
-  size = dmat->size;
-
-
-  /* now determine if joining a, b will result in broken distances */
-  if(additivity) {
-    if(!NJ_check_additivity(dmat, a, b)) {
-      return(0);
-    }
-  }
-
-  /* scan the horizontal of row b, punt if anything < min */
-  ptr = &(val[NJ_MAP(b, b+1, size)]);  
-  for(i=b+1;i<size;i++) {
-    if( NJ_FLT_LT( (*ptr - (r2[b] + r2[i])), min) ) {
-      return(0);
-    }
-    ptr++;
-  }
-
-  /* scan the vertical component of row a, punt if anything < min */
-  if(nj_args->norandom) {  /* if we are doing random joins, we checked this */
-    ptr = val + a;
-    for(i=0;i<a;i++) {
-      if( NJ_FLT_LT( (*ptr - (r2[i] + r2[a])), min) ) {
-       return(0);
-      }
-      ptr += size-i-1;
-    }
-  }
-
-  /* scan the vertical component of row b, punt if anything < min */
-  ptr = val + b;
-  for(i=0;i<b;i++) {
-    if( NJ_FLT_LT( (*ptr - (r2[i] + r2[b])), min) && i!=a) {
-      return(0);
-    }
-    ptr += size-i-1;
-  }
-
-  return(1);
-}
-
-
-
-
-
-
-
-/*
- * NJ_collapse() - Collapse the distance matrix by removing 
- *                 rows a and b from the distance matrix and
- *                 replacing them with a single new row which 
- *                 represents the internal node joining a and b
- *
- *
- * INPUTS:
- * -------
- *   dmat -- A pointer to the distance matrix
- * vertex -- A pointer to the vertex vector (vector of tree nodes)
- *           which is used in constructing the tree
- *      a -- An index to a row in the distance matrix from which we
- *           joined.  This row will be collapsed.
- *      b -- An index to a row in the distance matrix from which we
- *           joined.  This row will be collapsed.
- *
- * RETURNS:
- * --------
- *   NONE
- *
- *
- * DESCRIPTION:
- * ------------
- *
- * This function collapses the distance matrix in a way which optimizes
- * cache locality and ultimately gives us a speed improvement due to
- * cache.   At this point, we've decided to join rows a and b from
- * the distance matrix.  We will remove rows a and b from the distance  
- * matrix and replace them with a new row which represents the internal
- * node which joins rows a and b together. 
- * 
- * We always keep the matrix as compact as possible in order to 
- * get good performance from our cache in subsequent operations.  Cache
- * is the key to good performance here.  
- * 
- * Key Steps:
- * ----------
- * 
- *  1)  Fill the "a" row with the new distances of the internal node
- *      joining a and b to all other rows.  
- *  2)  Copy row 0 into what was row b
- *  3)  Increment the pointer to the start of the distance matrix
- *      by one row.
- *  4)  Decrement the size of the matrix by one row.
- *  5)  Do roughly the same thing to the r vector in order to
- *      keep it in sync with the distance matrix.
- *  6)  Compute the scaled r vector (r2) based on the updated
- *      r vector
- *
- * This keeps the distance matrix as compact as possible in memory, and
- * is a relatively fast operation. 
- *
- * This function requires that a < b
- *
- */
-static inline
-void
-NJ_collapse(DMAT *dmat,
-           NJ_VERTEX *vertex,
-           long int a,
-           long int b) {
-
-
-  long int i;     /* index used for looping */
-  long int size;  /* size of dmat --> reduce pointer dereferencing */
-  float a2clade;  /* distance from a to the new node that joins a and b */
-  float b2clade;  /* distance from b to the new node that joins a and b */
-  float cval;     /* stores distance information during loop */
-  float *vptr;    /* pointer to elements in first row of dist matrix */
-  float *ptra;    /* pointer to elements in row a of distance matrix */
-  float *ptrb;    /* pointer to elements in row b of distance matrix */
-
-  float *val, *r, *r2;  /* simply used to limit pointer dereferencing */
-
-
-  /* We must assume that a < b */
-  if(a >= b) {
-    fprintf(stderr, "Clearcut: (a<b) constraint check failed in NJ_collapse()\n");
-    exit(0);
-  }
-
-  /* some shortcuts to help limit dereferencing */
-  val  = dmat->val;
-  r    = dmat->r;
-  r2   = dmat->r2;
-  size = dmat->size;
-
-  /* compute the distance from the clade components (a, b) to the new node */
-  a2clade = 
-    ( (val[NJ_MAP(a, b, size)]) + (dmat->r2[a] - dmat->r2[b]) ) / 2.0;  
-  b2clade = 
-    ( (val[NJ_MAP(a, b, size)]) + (dmat->r2[b] - dmat->r2[a]) ) / 2.0;  
-
-
-  r[a] = 0.0;  /* we are removing row a, so clear dist. in r */
-
-  /* 
-   * Fill the horizontal part of the "a" row and finish computing r and r2 
-   * we handle the horizontal component first to maximize cache locality
-   */
-  ptra = &(val[NJ_MAP(a,   a+1, size)]);   /* start ptra at the horiz. of a  */
-  ptrb = &(val[NJ_MAP(a+1, b,   size)]);   /* start ptrb at comparable place */
-  for(i=a+1;i<size;i++) {
-
-    /* 
-     * Compute distance from new internal node to others in 
-     * the distance matrix.
-     */
-    cval = 
-      ( (*ptra - a2clade) +
-       (*ptrb - b2clade) ) / 2.0;
-
-    /* incr.  row b pointer differently depending on where i is in loop */
-    if(i<b) {
-      ptrb += size-i-1;  /* traverse vertically  by incrementing by row */
-    } else {
-      ptrb++;            /* traverse horiz. by incrementing by column   */
-    }
-
-    /* assign the newly computed distance and increment a ptr by a column */
-    *(ptra++) = cval;  
-
-    /* accumulate the distance onto the r vector */
-    r[a] += cval;
-    r[i] += cval;
-    
-    /* scale r2 on the fly here */
-    r2[i] = r[i]/(float)(size-3);
-  }
-
-  /* fill the vertical part of the "a" column and finish computing r and r2 */ 
-  ptra = val + a;  /* start at the top of the columb for "a" */
-  ptrb = val + b;  /* start at the top of the columb for "b" */
-  for(i=0;i<a;i++) {
-
-    /* 
-     * Compute distance from new internal node to others in 
-     * the distance matrix.
-     */
-    cval = 
-      ( (*ptra - a2clade) + 
-       (*ptrb - b2clade) ) / 2.0;
-    
-    /* assign the newly computed distance and increment a ptr by a column */
-    *ptra = cval;
-
-    /* accumulate the distance onto the r vector */
-    r[a] += cval;
-    r[i] += cval;
-
-    /* scale r2 on the fly here */
-    r2[i] = r[i]/(float)(size-3);
-
-    /* here, always increment by an entire row */
-    ptra += size-i-1;
-    ptrb += size-i-1;
-  }
-
-
-  /* scale r2 on the fly here */
-  r2[a] = r[a]/(float)(size-3);
-
-
-
-  /* 
-   * Copy row 0 into row b.  Again, the code is structured into two 
-   * loops to maximize cache locality for writes along the horizontal
-   * component of row b.
-   */
-  vptr = val;
-  ptrb = val + b;
-  for(i=0;i<b;i++) {
-    *ptrb = *(vptr++);
-    ptrb += size-i-1;
-  }
-  vptr++;  /* skip over the diagonal */
-  ptrb = &(val[NJ_MAP(b, b+1, size)]); 
-  for(i=b+1;i<size;i++) {
-    *(ptrb++) = *(vptr++);
-  }
-
-  /* 
-   * Collapse r here by copying contents of r[0] into r[b] and
-   * incrementing pointer to the beginning of r by one row
-   */
-  r[b]    = r[0];
-  dmat->r = r+1;
-
-
-  /* 
-   * Collapse r2 here by copying contents of r2[0] into r2[b] and
-   * incrementing pointer to the beginning of r2 by one row
-   */
-  r2[b]    = r2[0];
-  dmat->r2 = r2+1;
-
-  /* increment dmat pointer to next row */
-  dmat->val += size;
-  
-  /* decrement the total size of the distance matrix by one row */
-  dmat->size--;
-
-  return;
-}
-
-
-
-
-
-
-
-
-
-/*
- * NJ_neighbor_joining() - Perform a traditional Neighbor-Joining
- *
- *
- * INPUTS:
- * -------
- *  nj_args -- A pointer to a structure containing the command-line arguments
- *     dmat -- A pointer to the distance matrix
- *
- * RETURNS:
- * --------
- *   NJ_TREE * -- A pointer to the Neighbor-Joining tree.
- *
- * DESCRIPTION:
- * ------------
- *
- * This function performs a traditional Neighbor-Joining operation in which
- * the distance matrix is exhaustively searched for the global minimum 
- * transformed distance.  The two nodes which intersect at the global
- * minimum transformed distance are then joined and the distance
- * matrix is collapsed.  This process continues until there are only
- * two nodes left, at which point those nodes are joined.
- *
- */
-NJ_TREE *
-NJ_neighbor_joining(NJ_ARGS *nj_args,
-                   DMAT *dmat) {
-
-  
-  NJ_TREE   *tree = NULL;
-  NJ_VERTEX *vertex = NULL;
-
-  long int a, b;
-  float min;
-    
-
-  /* initialize the r and r2 vectors */
-  NJ_init_r(dmat);
-
-  /* allocate and initialize our vertex vector used for tree construction */
-  vertex = NJ_init_vertex(dmat);
-  if(!vertex) {
-    fprintf(stderr, "Clearcut:  Could not initialize vertex in NJ_neighbor_joining()\n");
-    return(NULL);
-  }
-  
-  /* we iterate until the working distance matrix has only 2 entries */
-  while(vertex->nactive > 2) {
-    /* 
-     * Find the global minimum transformed distance from the distance matrix
-     */
-    min = NJ_min_transform(dmat, &a, &b);
-
-    /* 
-     * Build the tree by removing nodes a and b from the vertex array
-     * and inserting a new internal node which joins a and b.  Collapse
-     * the vertex array similarly to how the distance matrix and r and r2 
-     * are compacted. 
-     */
-    NJ_decompose(dmat, vertex, a, b, 0);
-
-    /* decrement the r and r2 vectors by the distances corresponding to a, b */
-    NJ_compute_r(dmat, a, b);
-
-    /* compact the distance matrix and the r and r2 vectors */
-    NJ_collapse(dmat, vertex, a, b);
-  }
-  
-  /* Properly join the last two nodes on the vertex list */
-  tree = NJ_decompose(dmat, vertex, 0, 1, NJ_LAST);
-
-  /* return the computed tree to the calling function */
-  return(tree);
-}
-
-
-
-
-
-
-
-
-/*
- * NJ_relaxed_nj() -  Construct a tree using the Relaxed Neighbor-Joining
- *
- * INPUTS:
- * -------
- *   nj_args -- A pointer to a data structure containing the command-line args
- *      dmat -- A pointer to the distance matrix
- *
- * RETURNS:
- * --------
- *
- *   NJ_TREE * -- A pointer to a Relaxed Neighbor-Joining tree
- *
- * DESCRIPTION:
- * ------------
- *
- * This function implements the Relaxed Neighbor-Joining algorithm of
- *  Evans, J., Sheneman, L., and Foster, J. 
- *
- * Relaxed Neighbor-Joining works by choosing a local minimum transformed
- * distance when determining when to join two nodes.  (Traditional 
- * Neighbor-Joining chooses a global minimum transformed distance).
- *
- * The algorithm shares the property with traditional NJ that if the 
- * input distances are additive (self-consistent), then the algorithm
- * will manage to construct the true tree consistent with the additive
- * distances.  Additivity state is tracked and every proposed join is checked
- * to make sure it maintains additivity constraints.  If no 
- * additivity-preserving join is possible in a single pass, then the distance 
- * matrix is non-additive, and additivity checking is abandoned.  
- *
- * The algorithm will either attempt joins randomly, or it will perform joins
- * in a particular order.  The default behavior is to perform joins randomly,
- * but this can be switched off with a command-line switch.
- *
- * For randomized joins, all attempts are made to alleviate systematic bias
- * for the choice of rows to joins.  All tie breaking is done in a way which
- * is virtually free of bias.
- *
- * To perform randomized joins, a random permutation is constructed which 
- * specifies the order in which to attempt joins.  I iterate through the 
- * random permutation, and for each row in the random permutation, I find
- * the minimum transformed distance for that row.  If there are multiple 
- * minima, I break ties evenly.  For the row which intersects our 
- * randomly chosen row at the chosen minimum, if we are are still in 
- * additivity mode, I check to see if joining the two rows will break
- * our additivity constraints.  If not, I check to see if there exists 
- * a transformed distance which is smaller than the minimum found on the 
- * original row.  If there is, then we proceed through the random permutation
- * trying additional rows in the random order specified in the permutation.
- * If there is no smaller minimum transformed distance on either of the
- * two rows, then we join them, collapse the distance matrix, and compute
- * a new random permutation. 
- *
- * If the entire random permutation is traversed and no joins are possible
- * due to additivity constraints, then the distance matrix is not
- * additive, and additivity constraint-checking is disabled.
- *
- */
-NJ_TREE *
-NJ_relaxed_nj(NJ_ARGS *nj_args,
-             DMAT *dmat) {
-
-  
-  NJ_TREE *tree;
-  NJ_VERTEX *vertex;
-  long int a, b, t, bh, bv, i;
-  float hmin, vmin, hvmin;
-  float p, q, x;
-  int join_flag;
-  int additivity_mode;
-  long int hmincount, vmincount;
-  long int *permutation = NULL;
-
-
-
-  /* initialize the r and r2 vectors */
-  NJ_init_r(dmat);
-
-  additivity_mode = 1;
-
-  /* allocate the permutation vector, if we are in randomize mode */
-  if(!nj_args->norandom) {
-    permutation = (long int *)calloc(dmat->size, sizeof(long int));
-    if(!permutation) {
-      fprintf(stderr, "Clearcut:  Memory allocation error in NJ_relaxed_nj()\n");
-      return(NULL);
-    }
-  }
-
-  /* allocate and initialize our vertex vector used for tree construction */
-  vertex = NJ_init_vertex(dmat);
-  
-  /* loop until there are only 2 nodes left to join */
-  while(vertex->nactive > 2) {
-
-    switch(nj_args->norandom) {
-
-      /* RANDOMIZED JOINS */
-    case 0:
-
-      join_flag = 0;
-
-      NJ_permute(permutation, dmat->size-1);
-      for(i=0;i<dmat->size-1 && (vertex->nactive>2) ;i++) {
-
-       a = permutation[i];
-
-       /* find min trans dist along horiz. of row a */
-       hmin = NJ_find_hmin(dmat, a, &bh, &hmincount);   
-       if(a) {
-         /* find min trans dist along vert. of row a */
-         vmin = NJ_find_vmin(dmat, a, &bv, &vmincount); 
-       } else {
-         vmin = hmin;
-         bv = bh;
-         vmincount = 0;
-       }
-       
-       if(NJ_FLT_EQ(hmin, vmin)) {
-
-         /* 
-          * The minima along the vertical and horizontal are 
-          * the same.  Compute the proportion of minima along
-          * the horizonal (p) and the proportion of minima 
-          * along the vertical (q).
-          * 
-          * If the same minima exist along the horizonal and
-          * vertical, we break the tie in a way which is
-          * non-biased.  That is, we break the tie based on the
-          * proportion of horiz. minima versus vertical minima.
-          * 
-          */
-         p = (float)hmincount / ((float)hmincount + (float)vmincount);
-         q = 1.0 - p;
-         x = genrand_real2();
-         
-         if(x < p) {
-           hvmin = hmin;
-           b     = bh;
-         } else {
-           hvmin = vmin;
-           b     = bv;
-         }
-       } else if(NJ_FLT_LT(hmin, vmin) ) {
-         hvmin   = hmin;
-         b       = bh;
-       } else {
-         hvmin   = vmin;
-         b       = bv;
-       }
-       
-       if(NJ_check(nj_args, dmat, a, b, hvmin, additivity_mode)) {
-
-         /* swap a and b, if necessary, to make sure a < b */
-         if(b < a) {
-           t = a;
-           a = b;
-           b = t;
-         }
-
-         join_flag = 1;
-       
-         /* join taxa from rows a and b */
-         NJ_decompose(dmat, vertex, a, b, 0);
-
-         /* collapse matrix */
-         NJ_compute_r(dmat, a, b);
-         NJ_collapse(dmat, vertex, a, b);
-         
-         NJ_permute(permutation, dmat->size-1);
-       }
-      }
-      
-      /* turn off additivity if go through an entire cycle without joining */
-      if(!join_flag) {
-       additivity_mode = 0;
-      }
-      
-      break;
-
-
-
-      /* DETERMINISTIC JOINS */
-    case 1:
-      
-      join_flag = 0;
-
-      for(a=0;a<dmat->size-1 && (vertex->nactive > 2) ;) {
-      
-       /* find the min along the horizontal of row a */
-       hmin = NJ_find_hmin(dmat, a, &b, &hmincount);
-      
-       if(NJ_check(nj_args, dmat, a, b, hmin, additivity_mode)) {
-       
-         join_flag = 1;
-       
-         /* join taxa from rows a and b */
-         NJ_decompose(dmat, vertex, a, b, 0);
-
-         /* collapse matrix */
-         NJ_compute_r(dmat, a, b);
-         NJ_collapse(dmat, vertex, a, b);
-
-         if(a) { 
-           a--; 
-         }
-       
-       } else {
-         a++;
-       }
-      }
-    
-      /* turn off additivity if go through an entire cycle without joining */
-      if(!join_flag) {
-       additivity_mode = 0;
-      }
-
-      break;
-    }
-  }  /* WHILE */
-
-  /* Join the last two nodes on the vertex list */
-  tree = NJ_decompose(dmat, vertex, 0, 1, NJ_LAST);
-  
-  if(nj_args->verbose_flag) {
-    if(additivity_mode) {
-      printf("Tree is additive\n");
-    } else {
-      printf("Tree is not additive\n");
-    }
-  }
-  
-  if(vertex) {
-    NJ_free_vertex(vertex);
-  }
-  
-  if(!nj_args->norandom && permutation) {
-    free(permutation);
-  }
-  
-  return(tree);
-}
-
-
-
-
-
-
-/* 
- * NJ_print_distance_matrix() - 
- *
- * Print a distance matrix
- *
- */
-void
-NJ_print_distance_matrix(DMAT *dmat) {
-
-  long int i, j;
-
-  printf("ntaxa: %ld\n", dmat->ntaxa);
-  printf(" size: %ld\n", dmat->size);
-  
-  for(i=0;i<dmat->size;i++) {
-
-    for(j=0;j<dmat->size;j++) {
-      if(j>i) {
-       printf("    %0.4f", dmat->val[NJ_MAP(i, j, dmat->size)]);  
-      } else {
-       printf("         -");
-      }
-    }
-
-
-    if(dmat->r && dmat->r2) {
-      printf("\t\t%0.4f", dmat->r[i]);    
-      printf("\t%0.4f", dmat->r2[i]);
-
-
-    
-      printf("\n");
-
-      for(j=0;j<dmat->size;j++) {
-       if(j>i) {
-         printf("   %0.4f", dmat->val[NJ_MAP(i, j, dmat->size)] - (dmat->r2[i] + dmat->r2[j])); 
-       } else {
-         printf("          ");
-       }
-      }
-      
-      printf("\n");
-    }
-  }
-  
-  printf("\n\n");
-  
-  return;
-}
-
-
-
-
-
-
-
-/*
- * NJ_output_tree() - 
- * 
- * A wrapper for the function that really prints the tree,
- * basically to get a newline in there conveniently.  :-)
- *
- * Print n trees, as specified in command-args
- *  using "count" variable from 0 to (n-1)
- *
- */
-void
-NJ_output_tree(NJ_ARGS *nj_args,
-              NJ_TREE *tree,
-              DMAT *dmat,
-              long int count) {
-
-  FILE *fp;
-
-  if(nj_args->stdout_flag) {
-    fp = stdout;
-  } else {
-
-    if(count == 0) {
-      fp = fopen(nj_args->outfilename, "w");  /* open for writing   */
-    } else {
-      fp = fopen(nj_args->outfilename, "a");  /* open for appending */
-    }
-
-    if(!fp) {
-      fprintf(stderr, "Clearcut: Failed to open outfile %s\n", nj_args->outfilename);
-      exit(-1);
-    }
-  }
-
-  NJ_output_tree2(fp, nj_args, tree, tree, dmat);
-  fprintf(fp, ";\n");
-  
-  if(!nj_args->stdout_flag) {
-    fclose(fp);
-  }
-
-  return;
-}
-
-
-
-
-
-/*
- * NJ_output_tree2() - 
- * 
- *
- */
-void
-NJ_output_tree2(FILE *fp,
-               NJ_ARGS *nj_args,
-               NJ_TREE *tree,
-               NJ_TREE *root,
-               DMAT *dmat) {
-  
-  if(!tree) {
-    return;
-  }
-       
-  if(tree->taxa_index != NJ_INTERNAL_NODE) {
-
-    if(nj_args->expblen) {
-      fprintf(fp, "%s:%e", 
-             dmat->taxaname[tree->taxa_index],
-             tree->dist);
-    } else {
-      fprintf(fp, "%s:%f", 
-             dmat->taxaname[tree->taxa_index],
-             tree->dist);
-    }
-    
-  } else {
-    
-
-    if(tree->left && tree->right) {
-      fprintf(fp, "(");
-    }
-    if(tree->left) {
-      NJ_output_tree2(fp, nj_args, tree->left, root, dmat);
-    }
-
-    if(tree->left && tree->right) {
-      fprintf(fp, ",");
-    }
-    if(tree->right) {
-      NJ_output_tree2(fp, nj_args, tree->right, root, dmat);
-    }
-
-    if(tree != root->left) { 
-      if(tree->left && tree->right) {
-       if(tree != root) {
-         if(nj_args->expblen) {
-           fprintf(fp, "):%e", tree->dist);
-         } else {
-           fprintf(fp, "):%f", tree->dist);
-         }
-       } else {
-         fprintf(fp, ")");
-       }
-      }
-    } else {
-      fprintf(fp, ")");
-    }
-  }
-
-  return;
-}
-
-
-
-
-
-
-
-/*
- * NJ_init_r()
- *
- * This function computes the r column in our matrix
- *
- */
-void
-NJ_init_r(DMAT *dmat) {
-
-  long int i, j, size;
-  long int index;
-  float *r, *r2, *val;
-  long int size1;
-  float size2;
-  
-  r     = dmat->r;
-  r2    = dmat->r2;
-  val   = dmat->val;
-  size  = dmat->size;
-  size1 = size-1;
-  size2 = (float)(size-2);
-
-  index = 0;
-  for(i=0;i<size1;i++) {
-    index++;
-    for(j=i+1;j<size;j++) {
-      r[i] += val[index];
-      r[j] += val[index];
-      index++;
-    }
-
-    r2[i] = r[i]/size2;
-  }
-  
-  return;
-}
-
-
-
-
-
-
-
-
-
-
-
-/*
- * NJ_init_vertex() - 
- *
- * Construct a vertex, which we will use to construct our tree 
- * in a true bottom-up approach.  The vertex construct is 
- * basically the center node in the initial star topology.
- *
- */
-NJ_VERTEX *
-NJ_init_vertex(DMAT *dmat) {
-  
-  long int i;
-  NJ_VERTEX *vertex;
-  
-  /* allocate the vertex here */
-  vertex = (NJ_VERTEX *)calloc(1, sizeof(NJ_VERTEX));
-  
-  /* allocate the nodes in the vertex */
-  vertex->nodes        = (NJ_TREE **)calloc(dmat->ntaxa, sizeof(NJ_TREE *));
-  vertex->nodes_handle = vertex->nodes;
-  
-  /* initialize our size and active variables */
-  vertex->nactive = dmat->ntaxa;
-  vertex->size    = dmat->ntaxa;
-  
-  /* initialize the nodes themselves */
-  for(i=0;i<dmat->ntaxa;i++) {
-    
-    vertex->nodes[i] = (NJ_TREE *)calloc(1, sizeof(NJ_TREE));
-
-    vertex->nodes[i]->left  = NULL;
-    vertex->nodes[i]->right = NULL;
-    
-    vertex->nodes[i]->taxa_index = i;
-  }
-
-  return(vertex);
-}
-
-
-
-
-
-/*
- * NJ_decompose() - 
- *
- * This function decomposes the star by creating new internal nodes
- * and joining two existing tree nodes to it
- *
- */
-NJ_TREE *
-NJ_decompose(DMAT *dmat,
-            NJ_VERTEX *vertex,
-            long int x,
-            long int y,
-            int last_flag) {
-
-  NJ_TREE *new_node;
-  float x2clade, y2clade;
-
-  /* compute the distance from the clade components to the new node */
-  if(last_flag) {
-    x2clade = 
-      (dmat->val[NJ_MAP(x, y, dmat->size)]);  
-  } else {
-    x2clade = 
-      (dmat->val[NJ_MAP(x, y, dmat->size)])/2 +   
-      ((dmat->r2[x] - dmat->r2[y])/2);
-  }
-
-  vertex->nodes[x]->dist = x2clade;
-
-  if(last_flag) {
-    y2clade = 
-      (dmat->val[NJ_MAP(x, y, dmat->size)]);  
-  } else {
-    y2clade = 
-      (dmat->val[NJ_MAP(x, y, dmat->size)])/2 +  
-      ((dmat->r2[y] - dmat->r2[x])/2);
-  }
-
-  vertex->nodes[y]->dist = y2clade;
-
-  /* allocate new node to connect two sub-clades */
-  new_node = (NJ_TREE *)calloc(1, sizeof(NJ_TREE));
-
-  new_node->left  = vertex->nodes[x];
-  new_node->right = vertex->nodes[y];
-  new_node->taxa_index = NJ_INTERNAL_NODE;  /* this is not a terminal node, no taxa index */
-  
-  if(last_flag) {
-    return(new_node);
-  }
-
-  vertex->nodes[x] = new_node;
-  vertex->nodes[y] = vertex->nodes[0];
-  
-  vertex->nodes = &(vertex->nodes[1]);
-  
-  vertex->nactive--;
-
-  return(new_node);
-}
-
-
-
-/*
- * NJ_print_vertex() - 
- *
- * For debugging, print the contents of the vertex
- *
- */
-void
-NJ_print_vertex(NJ_VERTEX *vertex) {
-
-  long int i;
-
-  printf("Number of active nodes: %ld\n", vertex->nactive);
-
-  for(i=0;i<vertex->nactive;i++) {
-    printf("%ld ", vertex->nodes[i]->taxa_index);
-  }
-  printf("\n");
-
-  return;
-}
-
-
-
-
-
-
-
-
-
-/*
- * NJ_print_r() - 
- *
- */
-void
-NJ_print_r(DMAT *dmat) {
-  
-  long int i;
-  
-  printf("\n");
-  for(i=0;i<dmat->size;i++) {
-    printf("r[%ld] = %0.2f\n", i, dmat->r[i]);
-  }
-  printf("\n");
-
-  return;
-}
-
-
-
-
-
-/*
- * NJ_print_taxanames() -
- *
- * Print taxa names here
- *
- */
-void
-NJ_print_taxanames(DMAT *dmat) {
-  
-  long int i;
-  
-  printf("Number of taxa: %ld\n", dmat->ntaxa);
-  
-  for(i=0;i<dmat->ntaxa;i++) {
-    printf("%ld) %s\n", i, dmat->taxaname[i]);
-  }
-  
-  printf("\n");
-
-  return;
-}
-
-
-
-
-/* 
- * NJ_shuffle_distance_matrix() - 
- *
- * Randomize a distance matrix here
- *
- */
-void
-NJ_shuffle_distance_matrix(DMAT *dmat) {
-
-  
-  long int *perm      = NULL;
-  char **tmp_taxaname = NULL;
-  float *tmp_val      = NULL;
-  long int i, j;
-
-  
-  /* alloc the random permutation and a new matrix to hold the shuffled vals */
-  perm         = (long int *)calloc(dmat->size, sizeof(long int));
-  tmp_taxaname = (char **)calloc(dmat->size, sizeof(char *));
-  tmp_val      = (float *)calloc(NJ_NCELLS(dmat->ntaxa), sizeof(float));
-  if(!tmp_taxaname || !perm || !tmp_val) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_shuffle_distance_matrix()\n");
-    exit(-1);
-  }
-
-  /* compute a permutation which will describe how to shuffle the matrix */
-  NJ_permute(perm, dmat->size);
-
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-
-      if(perm[j] < perm[i]) {
-       tmp_val[NJ_MAP(i, j, dmat->size)] = dmat->val[NJ_MAP(perm[j], perm[i], dmat->size)];
-      } else {
-       tmp_val[NJ_MAP(i, j, dmat->size)] = dmat->val[NJ_MAP(perm[i], perm[j], dmat->size)];
-      }
-
-    }
-    
-    tmp_taxaname[i] = dmat->taxaname[perm[i]];
-  }
-
-  /* free our random permutation */
-  if(perm) {
-    free(perm);
-  }
-  
-  /* free the old value matrix */
-  if(dmat->val) {
-    free(dmat->val);
-  }
-
-  /* re-assign the value matrix pointers */
-  dmat->val = tmp_val;
-  dmat->valhandle = dmat->val;
-  
-  /* 
-   * Free our old taxaname with its particular ordering
-   * and re-assign to the new.
-   */
-  if(dmat->taxaname) {
-    free(dmat->taxaname);
-  }
-  dmat->taxaname = tmp_taxaname;
-
-  return;
-}
-
-
-
-/*
- * NJ_free_tree() - 
- *
- * Free a given NJ tree
- */
-void
-NJ_free_tree(NJ_TREE *node) {
-
-  if(!node) {
-    return;
-  }
-  
-  if(node->left) {
-    NJ_free_tree(node->left);
-  }
-  
-  if(node->right) {
-    NJ_free_tree(node->right);
-  }
-  
-  free(node);
-
-  return;
-}
-
-
-
-
-
-
-
-
-
-/*
- * NJ_print_permutation()
- *
- * Print a permutation
- *
- */
-void
-NJ_print_permutation(long int *perm,
-                    long int size) {
-  
-  long int i;
-  
-  for(i=0;i<size-1;i++) {
-    printf("%ld,", perm[i]);
-  }
-  printf("%ld\n", perm[size-1]);
-  
-  return;
-}
-
-
-
-
-/*
- * NJ_dup_dmat() - 
- * 
- * Duplicate a distance matrix
- *
- */
-DMAT *
-NJ_dup_dmat(DMAT *src) {
-  
-  long int i;
-  DMAT *dest;
-  
-  /* allocate the resulting distance matrix */
-  dest = (DMAT *)calloc(1, sizeof(DMAT));
-  if(!dest) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
-    goto XIT_BAD;
-  }
-
-  dest->ntaxa = src->ntaxa;
-  dest->size  = src->size;
-  
-  /* allocate space for array of pointers to taxanames */
-  dest->taxaname = (char **)calloc(dest->ntaxa, sizeof(char *));
-  if(!dest->taxaname) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
-    goto XIT_BAD;
-  }
-
-  /* allocate space for the taxanames themselves */
-  for(i=0;i<src->ntaxa;i++) {
-    dest->taxaname[i] = (char *)calloc(strlen(src->taxaname[i])+1, sizeof(char));
-    if(!dest->taxaname[i]) {
-      fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
-      goto XIT_BAD;
-    }
-  }
-  
-  /* allocate space for the distance values */
-  dest->val = (float *)calloc(NJ_NCELLS(src->ntaxa), sizeof(float));
-  if(!dest->val) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_dup_dmat()\n");
-    goto XIT_BAD;
-  }
-  
-  /* allocate space for the r and r2 vectors */
-  dest->r  = (float *)calloc(src->ntaxa, sizeof(float));
-  dest->r2 = (float *)calloc(src->ntaxa, sizeof(float));
-  
-  /* copy titles */
-  for(i=0;i<src->ntaxa;i++) {
-    strcpy(dest->taxaname[i], src->taxaname[i]);
-  }
-  
-  /* copy values */
-  memcpy(dest->val, src->valhandle, NJ_NCELLS(src->ntaxa)*sizeof(float));
-  
-  /* copy r and r2 */
-  memcpy(dest->r,  src->rhandle,  src->ntaxa*sizeof(float));
-  memcpy(dest->r2, src->r2handle, src->ntaxa*sizeof(float));
-  
-  /* track some memory addresses */
-  dest->valhandle = dest->val;
-  dest->rhandle   = dest->r;
-  dest->r2handle  = dest->r2;
-  
-  return(dest);
-  
- XIT_BAD:
-  
-  /* free what we may have allocated */
-  NJ_free_dmat(dest);
-  
-  return(NULL);
-}
-
-
-
-
-/*
- * NJ_free_dmat() - 
- */
-void
-NJ_free_dmat(DMAT *dmat) {
-  
-  long int i;
-  
-  if(dmat) {
-    
-    if(dmat->taxaname) {
-
-      for(i=0;i<dmat->ntaxa;i++) {
-       if(dmat->taxaname[i]) {
-         free(dmat->taxaname[i]);
-       }
-      }
-
-      free(dmat->taxaname);
-    }
-
-    if(dmat->valhandle) {
-      free(dmat->valhandle);
-    }
-
-    if(dmat->rhandle) {
-      free(dmat->rhandle);
-    }
-
-    if(dmat->r2handle) {
-      free(dmat->r2handle);
-    }
-
-    free(dmat);
-  }
-  
-  return;
-}
-
-
-
-
-
-/*
- * NJ_free_vertex() - 
- *
- * Free the vertex data structure 
- *
- */
-void
-NJ_free_vertex(NJ_VERTEX *vertex) {
-  
-  if(vertex) {
-    if(vertex->nodes_handle) {
-      free(vertex->nodes_handle);
-    }
-    free(vertex);
-  }
-
-  return;
-}
-
-
-
-
-
-
-
-
-
-/*
- *
- * NJ_min_transform() - Find the smallest transformed value to identify 
- *                      which nodes to join.
- *
- * INPUTS:
- * -------
- *  dmat  -- The distance matrix
- *
- * RETURNS:
- * --------
- * <float> -- The minimimum transformed distance
- *   ret_i -- The row of the smallest transformed distance (by reference)
- *   ret_j -- The col of the smallest transformed distance (by reference)
- *
- *
- * DESCRIPTION:
- * ------------
- *
- * Used only with traditional Neighbor-Joining, this function checks the entire
- * working distance matrix and identifies the smallest transformed distance.
- * This requires traversing the entire diagonal matrix, which is itself a 
- * O(N^2) operation.
- *
- */
-float
-NJ_min_transform(DMAT *dmat,
-                long int *ret_i,
-                long int *ret_j) {
-
-  long int i, j;   /* indices used for looping        */
-  long int tmp_i = 0;/* to limit pointer dereferencing  */
-  long int tmp_j = 0;/* to limit pointer dereferencing  */
-  float smallest;  /* track the smallest trans. dist  */
-  float curval;    /* the current trans. dist in loop */
-
-  float *ptr;      /* pointer into distance matrix    */
-  float *r2;       /* pointer to r2 matrix for computing transformed dists */
-  
-  smallest = (float)HUGE_VAL;
-
-  /* track these here to limit pointer dereferencing in inner loop */
-  ptr = dmat->val;
-  r2  = dmat->r2;
-
-  /* for every row */
-  for(i=0;i<dmat->size;i++) {
-    ptr++;  /* skip diagonal */
-    for(j=i+1;j<dmat->size;j++) {   /* for every column */
-
-      /* find transformed distance in matrix at i, j */
-      curval = *(ptr++) - (r2[i] + r2[j]);
-
-      /* if the transformed distanance is less than the known minimum */
-      if(curval < smallest) {
-
-       smallest = curval;
-       tmp_i = i;
-       tmp_j = j;
-      }
-    }
-  }
-  
-  /* pass back (by reference) the coords of the min. transformed distance */
-  *ret_i = tmp_i;
-  *ret_j = tmp_j;
-  
-  return(smallest);  /* return the min transformed distance */
-}
-
-
-
-
-
-
-
diff --git a/clearcut.h b/clearcut.h
deleted file mode 100644 (file)
index f3124e3..0000000
+++ /dev/null
@@ -1,285 +0,0 @@
-
-
-
-/*
- * clearcut.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * AUTHOR:
- *
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_CLEARCUT_H_
-#define _INC_CLEARCUT_H_ 1
-
-extern "C" {
-
-#include "common.h"
-#include "cmdargs.h"
-
-#define NJ_VERSION "1.0.9"
-
-
-#define NJ_INTERNAL_NODE -1
-#define NJ_LAST 101
-
-#define NJ_INPUT_MODE_UNKNOWN             0
-#define NJ_INPUT_MODE_DISTANCE            100
-#define NJ_INPUT_MODE_UNALIGNED_SEQUENCES 101
-#define NJ_INPUT_MODE_ALIGNED_SEQUENCES   102
-
-#define NJ_MODEL_NONE    100
-#define NJ_MODEL_JUKES   101
-#define NJ_MODEL_KIMURA  102
-
-
-
-
-/*
- * DMAT - Distance Matrix
- *
- * This is arguably the most important structure in the
- * program.  This is the distance matrix, and it is used 
- * by many functions throughout the application.
- *
- * The matrix is architected as a contiguously allocated
- * upper-diagonal matrix of floats which include the 
- * diagonal.  
- *
- * Example:
- *
- *      0    1    2    3    4    5
- *   0 0.0  1.0  0.3  0.2  0.1  0.3
- *   1      0.0  0.3  0.2  0.1  0.8
- *   2           0.0  0.1  0.3  0.5 
- *   3                0.0  0.2  0.1
- *   4                     0.0  0.2
- *   5                          0.0
- *
- * The distance matrix shrinks with every join operation,
- * so I track the original and working size of the matrix 
- * inside the matrix.
- *
- * One fast optimization to shrink the distance matrix
- * involves incrementing the "val" pointer.  Thus, in 
- * addition to tracking the pointer to the distances,
- * I also track the original pointer to that I can 
- * free the memory associated with the working distance
- * matrix.
- *
- * This also applies to the r and r2 vectors which are
- * used to compute the transformed distances in the 
- * matrix.
- * 
- */
-
-typedef struct _STRUCT_DMAT {
-
-  long int ntaxa;   /* the original size of the distance matrix */
-  long int size;    /* the current/effective size of the distance matrix */
-
-  char **taxaname;  /* a pointer to an array of taxa name strings */
-
-  float *val;       /* the distances */
-  float *valhandle; /* to track the orig. pointer to free memory */
-
-  float *r, *r2;    /* r and r2 vectors (used to compute transformed dists) */
-  float *rhandle, *r2handle;  /* track orig. pointers to free memory */
-
-} DMAT;
-
-
-
-/*
- * NJ_TREE - The Tree Data Structure 
- *
- *
- * The tree is represented internally as a rooted 
- * binary tree.  Each internal node has a left and a right child.
- * 
- * Additionally, I track the distance between the current node
- * and that node's parent (i.e. the branch length).  
- * 
- * Finally, I track the index of the taxa for leaf nodes.
- *
- */
-typedef struct _STRUCT_NJ_TREE {
-  
-  struct _STRUCT_NJ_TREE *left;  /* left child  */
-  struct _STRUCT_NJ_TREE *right; /* right child */
-  
-  float dist;  /* branch length.  i.e. dist from node to parent */
-  
-  long int taxa_index; /* for terminal nodes, track the taxon index */
-
-} NJ_TREE;
-
-
-
-/*
- * NJ_VERTEX
- *
- * This structure is used for building trees.  It is a vector 
- * which, represents the center of the star when building the RNJ/NJ
- * tree through star-decomposition.
- *
- * It contains a vector of tree (node) pointers.  These pointers
- * get joined together by a new internal node, and the new internal
- * node is placed back into the vector of nodes (which is now smaller).
- *
- * To keep this vector in sync. with the shrinking matrix, parts of
- * the vector are shuffled around, and so a pointer to the originally
- * allocated vector is stored such that it can be freed from memory
- * later.
- *
- * The original and working sizes of the vector are also tracked.
- *
- */
-typedef struct _STRUCT_NJ_VERTEX {
-  
-  NJ_TREE **nodes;
-  NJ_TREE **nodes_handle;  /* original memory handle for freeing */
-
-  long int nactive;  /* number of active nodes in the list */
-  long int size;     /* the total size of the vertex */
-
-} NJ_VERTEX;
-
-
-/* some function prototypes */
-int clearcut_main(int, char**);  
-
-/* core function for performing Relaxed Neighbor Joining */
-NJ_TREE *
-NJ_relaxed_nj(NJ_ARGS *nj_args, DMAT *dmat);
-
-/* function for performing traditional Neighbor-Joining */
-NJ_TREE *
-NJ_neighbor_joining(NJ_ARGS *nj_args, DMAT *dmat);
-
-/* print the distance matrix (for debugging) */
-void
-NJ_print_distance_matrix(DMAT *dmat);
-
-/* output the computed tree to stdout or to the specified file */
-void
-NJ_output_tree(NJ_ARGS *nj_args,
-              NJ_TREE *tree,
-              DMAT *dmat,
-              long int count);
-
-/* the recursive function for outputting trees */
-void
-NJ_output_tree2(FILE *fp,
-               NJ_ARGS *nj_args,
-               NJ_TREE *tree,
-               NJ_TREE *root,
-               DMAT *dmat);
-
-/* initialize vertex */
-NJ_VERTEX *
-NJ_init_vertex(DMAT *dmat);
-
-/* used to decompose the star topology and build the tree */
-NJ_TREE *
-NJ_decompose(DMAT *dmat,
-            NJ_VERTEX *vertex,
-            long int x, 
-            long int y,
-            int last_flag);
-
-/* print the vertex vector (for debugging) */
-void
-NJ_print_vertex(NJ_VERTEX *vertex);
-
-/* print taxa names (for debugging) */
-void
-NJ_print_taxanames(DMAT *dmat);
-
-/* initialize r-vector prior to RNJ/NJ */
-void
-NJ_init_r(DMAT *dmat);
-
-/* print the r-vector (for debugging) */
-void
-NJ_print_r(DMAT *dmat);
-
-/* shuffle the distance matrix, usually after reading in input */
-void
-NJ_shuffle_distance_matrix(DMAT *dmat);
-
-/* free memory from the tree */
-void
-NJ_free_tree(NJ_TREE *node);
-
-/* print permutations (for debugging) */
-void
-NJ_print_permutation(long int *perm,
-                    long int size);
-
-/* duplicate a distance matrix for multiple iterations */
-DMAT *
-NJ_dup_dmat(DMAT *src);
-
-/* free the distance matrix */
-void
-NJ_free_dmat(DMAT *dmat);
-
-/* free the vertex vector */
-void
-NJ_free_vertex(NJ_VERTEX *vertex);
-
-/* for computing the global minimum transformed distance in traditional NJ */
-float
-NJ_min_transform(DMAT *dmat,
-                long int *ret_i,
-                long int *ret_j);
-
-}
-
-#endif /* _INC_CLEARCUT_H_ */
-
-
-
-
-
-
-
diff --git a/clearcutcommand.cpp b/clearcutcommand.cpp
deleted file mode 100644 (file)
index d3c7fa4..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- *  clearcutcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/11/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clearcutcommand.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
-#include "clearcut.h"
-#ifdef __cplusplus
-}
-#endif
-
-//**********************************************************************************************************************
-vector<string> ClearcutCommand::setParameters(){       
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "FastaPhylip", "FastaPhylip", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pverbose("verbose", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pverbose);
-               CommandParameter pquiet("quiet", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pquiet);
-               CommandParameter pversion("version", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pversion);
-               CommandParameter pseed("seed", "String", "", "", "*", "", "",false,false); parameters.push_back(pseed);
-               CommandParameter pnorandom("norandom", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pnorandom);
-               CommandParameter pshuffle("shuffle", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pshuffle);
-               CommandParameter pneighbor("neighbor", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pneighbor);
-               CommandParameter pexpblen("expblen", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpblen);
-               CommandParameter pexpdist("expdist", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pexpdist);
-               CommandParameter pDNA("DNA", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pDNA);
-               CommandParameter pprotein("protein", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pprotein);
-               CommandParameter pjukes("jukes", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pjukes);
-               CommandParameter pkimura("kimura", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkimura);
-               CommandParameter pstdout("stdout", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pstdout);
-               CommandParameter pntrees("ntrees", "Number", "", "1", "", "", "",false,false); parameters.push_back(pntrees);
-               CommandParameter pmatrixout("matrixout", "String", "", "", "", "", "",false,false); parameters.push_back(pmatrixout);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClearcutCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The clearcut command interfaces mothur with the clearcut program written by Initiative for Bioinformatics and Evolutionary Studies (IBEST) at the University of Idaho.\n";
-               helpString += "For more information about clearcut refer to http://bioinformatics.hungry.com/clearcut/ \n";
-               helpString += "The clearcut command parameters are phylip, fasta, version, verbose, quiet, seed, norandom, shuffle, neighbor, expblen, expdist, ntrees, matrixout, stdout, kimura, jukes, protein, DNA. \n";
-               helpString += "The phylip parameter allows you to enter your phylip formatted distance matrix. \n";
-               helpString += "The fasta parameter allows you to enter your aligned fasta file, if you enter a fastafile you specify if the sequences are DNA or protein using the DNA or protein parameters. \n";
-               
-               helpString += "The version parameter prints out the version of clearcut you are using, default=F. \n";
-               helpString += "The verbose parameter prints out more output from clearcut, default=F. \n";
-               helpString += "The quiet parameter turns on silent operation mode, default=F. \n";
-               helpString += "The seed parameter allows you to explicitly set the PRNG seed to a specific value. \n";
-               helpString += "The norandom parameter allows you to attempt joins deterministically, default=F. \n";
-               helpString += "The shuffle parameter allows you to randomly shuffle the distance matrix, default=F. \n";
-               helpString += "The neighbor parameter allows you to use traditional Neighbor-Joining algorithm, default=T. \n";
-               
-               helpString += "The DNA parameter allows you to indicate your fasta file contains DNA sequences, default=F. \n";
-               helpString += "The protein parameter allows you to indicate your fasta file contains protein sequences, default=F. \n";
-               
-               helpString += "The stdout parameter outputs your tree to STDOUT, default=F. \n";
-               helpString += "The matrixout parameter allows you to specify a filename to output a distance matrix to. \n";
-               helpString += "The ntrees parameter allows you to specify the number of output trees, default=1. \n";
-               helpString += "The expblen parameter allows you to use exponential notation for branch lengths, default=F. \n";
-               helpString += "The expdist parameter allows you to use exponential notation for distance outputs, default=F. \n";
-               
-               helpString += "The clearcut command should be in the following format: \n";
-               helpString += "clearcut(phylip=yourDistanceFile) \n";
-               helpString += "Example: clearcut(phylip=abrecovery.phylip.dist) \n";    
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ClearcutCommand::ClearcutCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["tree"] = tempOutNames;
-               outputTypes["matrixout"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "ClearcutCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-ClearcutCommand::ClearcutCommand(string option)  {     
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["tree"] = tempOutNames;
-                       outputTypes["matrixout"] = tempOutNames;
-
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") { fastafile = ""; }  
-                       else { inputFile = fastafile;  m->setFastaFile(fastafile); }
-                       
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { phylipfile = ""; abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }
-                       else { inputFile = phylipfile;  m->setPhylipFile(phylipfile); }
-                               
-                       if ((phylipfile == "") && (fastafile == "")) {  
-                               //is there are current file available for either of these?
-                               //give priority to phylip, then fasta
-                               phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") {  inputFile = phylipfile; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       fastafile = m->getFastaFile(); 
-                                       if (fastafile != "") { inputFile = fastafile;  m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a phylip or fasta file before you can use the clearcut command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       if ((phylipfile != "") && (fastafile != "")) {  m->mothurOut("You must provide either a phylip formatted distance matrix or an aligned fasta file, not BOTH."); m->mothurOutEndLine(); abort=true; }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputFile);      }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "version", false);          if (temp == "not found"){       temp = "F";                     }
-                       version = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "verbose", false);          if (temp == "not found"){       temp = "F";                     }
-                       verbose = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "quiet", false);            if (temp == "not found"){       temp = "F";                     }
-                       quiet = m->isTrue(temp); 
-                       
-                       seed = validParameter.validFile(parameters, "seed", false);                     if (seed == "not found"){       seed = "*";                     }
-                       
-                       temp = validParameter.validFile(parameters, "norandom", false);         if (temp == "not found"){       temp = "F";                     }
-                       norandom = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "shuffle", false);          if (temp == "not found"){       temp = "F";                     }
-                       shuffle = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "neighbor", false);         if (temp == "not found"){       temp = "T";                     }
-                       neighbor = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "DNA", false);                      if (temp == "not found"){       temp = "F";                     }
-                       DNA = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "protein", false);          if (temp == "not found"){       temp = "F";                     }
-                       protein = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "jukes", false);            if (temp == "not found"){       temp = "F";                     }
-                       jukes = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "kimura", false);           if (temp == "not found"){       temp = "F";                     }
-                       kimura = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "stdout", false);           if (temp == "not found"){       temp = "F";                     }
-                       stdoutWanted = m->isTrue(temp); 
-                       
-                       matrixout = validParameter.validFile(parameters, "matrixout", false);   if (matrixout == "not found"){  matrixout = "";         }
-                       
-                       ntrees = validParameter.validFile(parameters, "ntrees", false);         if (ntrees == "not found"){     ntrees = "1";           }
-                       
-                       temp = validParameter.validFile(parameters, "expblen", false);          if (temp == "not found"){       temp = "F";                     }
-                       expblen = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "expdist", false);          if (temp == "not found"){       temp = "F";                     }
-                       expdist = m->isTrue(temp);
-                       
-                       if ((fastafile != "") && ((!DNA) && (!protein))) { m->mothurOut("You must specify the type of sequences you are using: DNA or protein"); m->mothurOutEndLine(); abort=true; }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "ClearcutCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int ClearcutCommand::execute() {       
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //prepare filename
-               string outputName = outputDir + m->getRootName(m->getSimpleName(inputFile)) + "tre";
-               outputNames.push_back(outputName); outputTypes["tree"].push_back(outputName);
-               
-               vector<char*> cPara;
-               
-               char* tempClearcut = new char[8];  
-               strcpy(tempClearcut, "clearcut"); 
-               cPara.push_back(tempClearcut);
-                               
-               //you gave us a distance matrix
-               if (phylipfile != "") {  char* temp = new char[10];  strcpy(temp, "--distance");  cPara.push_back(temp);        }
-               
-               //you gave us a fastafile
-               if (fastafile != "") { char* temp = new char[11];  strcpy(temp, "--alignment");  cPara.push_back(temp);         }
-               
-               if (version)                    {  char* temp = new char[9];  strcpy(temp, "--version");  cPara.push_back(temp);        }
-               if (verbose)                    {  char* temp = new char[9];  strcpy(temp, "--verbose");  cPara.push_back(temp);        }
-               if (quiet)                              {  char* temp = new char[7];  strcpy(temp, "--quiet");  cPara.push_back(temp);  }
-               if (seed != "*")                {  
-                       string tempSeed = "--seed=" + seed;
-                       char* temp = new char[tempSeed.length()];
-                       strcpy(temp, tempSeed.c_str());
-                       cPara.push_back(temp);
-               }
-               if (norandom)                   {  char* temp = new char[10];  strcpy(temp, "--norandom");  cPara.push_back(temp);      }
-               if (shuffle)                    {  char* temp = new char[9];  strcpy(temp, "--shuffle");  cPara.push_back(temp);        }
-               if (neighbor)                   {  char* temp = new char[10];  strcpy(temp, "--neighbor");  cPara.push_back(temp);      }
-               
-               string tempIn = "--in=" + inputFile;  
-               char* tempI = new char[tempIn.length()];
-               strcpy(tempI, tempIn.c_str());
-               cPara.push_back(tempI);
-               
-               if (stdoutWanted)               {  char* temp = new char[8];  strcpy(temp, "--stdout");  cPara.push_back(temp); }
-               else{  
-                       string tempOut = "--out=" + outputName;  
-                       
-                       char* temp = new char[tempOut.length()];
-                       strcpy(temp, tempOut.c_str());
-                       cPara.push_back(temp);
-               }
-                       
-               if (DNA)                                {  char* temp = new char[5];  strcpy(temp, "--DNA");  cPara.push_back(temp);            }
-               if (protein)                    {  char* temp = new char[9];  strcpy(temp, "--protein");  cPara.push_back(temp);        }
-               if (jukes)                              {  char* temp = new char[7];  strcpy(temp, "--jukes");  cPara.push_back(temp);          }
-               if (kimura)                             { char* temp = new char[8];  strcpy(temp, "--kimura");  cPara.push_back(temp);          }
-               if (matrixout != "")    {  
-                       string tempMatrix =  "--matrixout=" + outputDir + matrixout; 
-                       char* temp = new char[tempMatrix.length()];
-                       strcpy(temp, tempMatrix.c_str());
-                       cPara.push_back(temp);
-                       outputNames.push_back((outputDir + matrixout));
-                       outputTypes["matrixout"].push_back((outputDir + matrixout));
-               }
-
-               if (ntrees != "1")              {  
-                       string tempNtrees = "--ntrees=" + ntrees; 
-                       char* temp = new char[tempNtrees.length()];
-                       strcpy(temp, tempNtrees.c_str());
-                       cPara.push_back(temp);
-               }
-
-               if (expblen)                    { char* temp = new char[9];  strcpy(temp, "--expblen");  cPara.push_back(temp);         }
-               if (expdist)                    { char* temp = new char[9];  strcpy(temp, "--expdist");  cPara.push_back(temp); }
-               
-               char** clearcutParameters;
-               clearcutParameters = new char*[cPara.size()];
-               for (int i = 0; i < cPara.size(); i++) {  clearcutParameters[i] = cPara[i];  }
-               int numArgs = cPara.size();
-               
-               clearcut_main(numArgs, clearcutParameters); 
-               
-               //free memory
-               for(int i = 0; i < cPara.size(); i++)  {  delete[] cPara[i];  }
-               delete[] clearcutParameters; 
-               
-               if (!stdoutWanted) {    
-                       
-                       //set first tree file as new current treefile
-                       string currentTree = "";
-                       itTypes = outputTypes.find("tree");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { currentTree = (itTypes->second)[0]; m->setTreeFile(currentTree); }
-                       }
-                       
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearcutCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-
-
-
-
diff --git a/clearcutcommand.h b/clearcutcommand.h
deleted file mode 100644 (file)
index 942953f..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef CLEARCUTCOMMAND_H
-#define CLEARCUTCOMMAND_H
-
-/*
- *  clearcutcommand.h
- *  Mothur
- *
- *  Created by westcott on 5/11/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-/* 
-  Evans, J., L. Sheneman, and J.A. Foster (2006) Relaxed Neighbor-Joining: 
-  A Fast Distance-Based Phylogenetic Tree Construction Method, 
-  J. Mol. Evol., 62, 785-792
- */ 
-
-/****************************************************************************/
-
-class ClearcutCommand : public Command {
-
-public:
-       ClearcutCommand(string);
-       ClearcutCommand();
-       ~ClearcutCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "clearcut";                    }
-       string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getHelpString(); 
-       string getCitation() { return "Sheneman L, Evans J, Foster JA (2006). Clearcut: a fast implementation of relaxed neighbor joining. Bioinformatics 22: 2823-4. \nhttp://www.mothur.org/wiki/Clearcut"; }
-       string getDescription()         { return "create a tree from a fasta or phylip file"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string outputDir, phylipfile, fastafile, matrixout, inputFile, seed, ntrees;
-       bool version, verbose, quiet, norandom, shuffle, neighbor, expblen, expdist, stdoutWanted, kimura, jukes, protein, DNA;
-       bool abort;
-       vector<string> outputNames;
-       
-};
-
-/****************************************************************************/
-
-#endif
-
diff --git a/clearmemorycommand.cpp b/clearmemorycommand.cpp
deleted file mode 100644 (file)
index abdc555..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *  clearmemorycommand.cpp
- *  Mothur
- *
- *  Created by westcott on 7/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clearmemorycommand.h"
-#include "referencedb.h"
-
-//**********************************************************************************************************************
-vector<string> ClearMemoryCommand::setParameters(){    
-       try {
-               vector<string> myArray;
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearMemoryCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClearMemoryCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The clear.memory command removes saved reference data from memory.\n";
-               helpString += "The clear.memory command should be in the following format: clear.memory().\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearMemoryCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-ClearMemoryCommand::ClearMemoryCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearMemoryCommand", "ClearMemoryCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int ClearMemoryCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               ReferenceDB* rdb = ReferenceDB::getInstance();
-               rdb->clearMemory();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClearMemoryCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************/
diff --git a/clearmemorycommand.h b/clearmemorycommand.h
deleted file mode 100644 (file)
index 9017561..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef CLEARMEMORYCOMMAND_H
-#define CLEARMEMORYCOMMAND_H
-
-/*
- *  clearmemorycommand.h
- *  Mothur
- *
- *  Created by westcott on 7/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class ClearMemoryCommand : public Command {
-public:
-       ClearMemoryCommand(string);
-       ClearMemoryCommand(){ abort = true; calledHelp = true; }
-       ~ClearMemoryCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "clear.memory";                        }
-       string getCommandCategory()             { return "General";     }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Clear.memory"; }
-       string getDescription()         { return "remove saved references from memory"; }
-       
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       bool abort;
-       vector<string> outputNames;
-};
-
-#endif
-
diff --git a/cluster.cpp b/cluster.cpp
deleted file mode 100644 (file)
index ac9f448..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- *  cluster.cpp
- *  
- *
- *  Created by Pat Schloss on 8/14/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "cluster.hpp"
-#include "rabundvector.hpp"
-#include "listvector.hpp"
-#include "sparsematrix.hpp"
-
-/***********************************************************************/
-
-Cluster::Cluster(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string f) :
-rabund(rav), list(lv), dMatrix(dm), method(f)
-{
-       try {
-/*
-       cout << "sizeof(MatData): " << sizeof(MatData) << endl;
-       cout << "sizeof(PCell*): " << sizeof(PCell*) << endl;
-
-       int nCells = dMatrix->getNNodes();
-       time_t start = time(NULL);
-
-       MatVec matvec = MatVec(nCells); 
-       int i = 0;
-       for (MatData currentCell = dMatrix->begin(); currentCell != dMatrix->end(); currentCell++) {
-               matvec[i++] = currentCell;
-       }
-       for (i= matvec.size();i>0;i--) {
-               dMatrix->rmCell(matvec[i-1]);
-       }
-       MatData it = dMatrix->begin(); 
-       while (it != dMatrix->end()) { 
-               it = dMatrix->rmCell(it);
-       }
-       cout << "Time to remove " << nCells << " cells: " << time(NULL) - start << " seconds" << endl;
-    exit(0);
-       MatData it = dMatrix->begin();
-       cout << it->row << "/" << it->column << "/" << it->dist << endl;
-       dMatrix->rmCell(dMatrix->begin());
-       cout << it->row << "/" << it->column << "/" << it->dist << endl;
-       exit(0);
-*/
-
-       // Create a data structure to quickly access the PCell information
-       // for a certain sequence. It consists of a vector of lists, where 
-       // a list contains pointers (iterators) to the all distances related
-       // to a certain sequence. The Vector is accessed via the index of a 
-       // sequence in the distance matrix.
-//ofstream outtemp;
-//string temp = "temp";
-//m->openOutputFile(temp, outtemp);    
-//cout << lv->size() << endl;
-       seqVec = vector<MatVec>(lv->size());
-       for (MatData currentCell = dMatrix->begin(); currentCell != dMatrix->end(); currentCell++) {
-//outtemp << currentCell->row << '\t' << currentCell->column  << '\t' << currentCell->dist << endl;
-               seqVec[currentCell->row].push_back(currentCell);
-               seqVec[currentCell->column].push_back(currentCell);
-       }
-//outtemp.close();
-       mapWanted = false;  //set to true by mgcluster to speed up overlap merge
-       
-       //save so you can modify as it changes in average neighbor
-       cutoff = c;
-       m = MothurOut::getInstance();
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "Cluster");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Cluster::getRowColCells() {
-       try {
-               PCell* smallCell = dMatrix->getSmallestCell();  //find the smallest cell - this routine should probably not be in the SpMat class
-       
-               smallRow = smallCell->row;              // get its row
-               smallCol = smallCell->column;   // get its column
-               smallDist = smallCell->dist;    // get the smallest distance
-       //cout << "small row = " << smallRow << "small col = " << smallCol << "small dist = " << smallDist << endl;
-        
-               rowCells = seqVec[smallRow];    // all distances related to the row index
-               colCells = seqVec[smallCol];    // all distances related to the column index
-               nRowCells = rowCells.size();
-               nColCells = colCells.size();
-//cout << "num rows = " << nRowCells << "num col = " << nColCells << endl;
-               
-               //for (int i = 0; i < nColCells; i++) { cout << colCells[i]->row << '\t' << colCells[i]->column << endl;  }
-               //for (int i = 0; i < nRowCells; i++) { cout << rowCells[i]->row << '\t' << rowCells[i]->column << endl;  }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "getRowColCells");
-               exit(1);
-       }
-
-}
-/***********************************************************************/
-// Remove the specified cell from the seqVec and from the sparse
-// matrix
-void Cluster::removeCell(const MatData& cell, int vrow, int vcol, bool rmMatrix){
-       try {
-       
-               ull drow = cell->row;
-                       ull dcol = cell->column;
-                       if (((vrow >=0) && (drow != smallRow)) ||
-                               ((vcol >=0) && (dcol != smallCol))) {
-                               ull dtemp = drow;
-                               drow = dcol;
-                               dcol = dtemp;
-                       }
-
-                       ull crow;
-                       ull ccol;
-                       int nCells;
-                       if (vrow < 0) {
-                               nCells = seqVec[drow].size();
-                               for (vrow=0; vrow<nCells;vrow++) {
-                                       crow = seqVec[drow][vrow]->row;
-                                       ccol = seqVec[drow][vrow]->column;
-                                       if (((crow == drow) && (ccol == dcol)) ||
-                                               ((ccol == drow) && (crow == dcol))) {
-                                               break;
-                                       }
-                               }
-                       }
-
-                       seqVec[drow].erase(seqVec[drow].begin()+vrow);
-                       if (vcol < 0) {
-                               nCells = seqVec[dcol].size();
-                               for (vcol=0; vcol<nCells;vcol++) {
-                                       crow = seqVec[dcol][vcol]->row;
-                                       ccol = seqVec[dcol][vcol]->column;
-                                       if (((crow == drow) && (ccol == dcol)) ||
-                                               ((ccol == drow) && (crow == dcol))) {
-                                               break;
-                                       }
-                               }
-                       }
-               
-                       seqVec[dcol].erase(seqVec[dcol].begin()+vcol);
-               
-                       if (rmMatrix) {
-                       //cout << " removing = " << cell->row << '\t' << cell->column  << '\t' << cell->dist << endl;
-                               dMatrix->rmCell(cell);
-               //      cout << "done" << endl;
-                       }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "removeCell");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void Cluster::clusterBins(){
-       try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol);
-
-               rabund->set(smallCol, rabund->get(smallRow)+rabund->get(smallCol));     
-               rabund->set(smallRow, 0);       
-               rabund->setLabel(toString(smallDist));
-
-       //      cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "clusterBins");
-               exit(1);
-       }
-
-
-}
-
-/***********************************************************************/
-
-void Cluster::clusterNames(){
-       try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(smallRow) << '\t' << list->get(smallCol);
-               if (mapWanted) {  updateMap();  }
-               
-               list->set(smallCol, list->get(smallRow)+','+list->get(smallCol));
-               list->set(smallRow, "");        
-               list->setLabel(toString(smallDist));
-       
-       //      cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "clusterNames");
-               exit(1);
-       }
-
-}
-
-/***********************************************************************/
-//This function clusters based on the method of the derived class
-//At the moment only average and complete linkage are covered, because
-//single linkage uses a different approach.
-void Cluster::update(double& cutOFF){
-       try {
-               getRowColCells();       
-
-               vector<int> foundCol(nColCells, 0);
-
-               int search;
-               bool changed;
-
-               // The vector has to be traversed in reverse order to preserve the index
-               // for faster removal in removeCell()
-               for (int i=nRowCells-1;i>=0;i--) {
-                       //if you are not the smallCell
-                       if (!((rowCells[i]->row == smallRow) && (rowCells[i]->column == smallCol))) {
-                               if (rowCells[i]->row == smallRow) {
-                                       search = rowCells[i]->column;
-                               } else {
-                                       search = rowCells[i]->row;
-                               }
-                               
-                               bool merged = false;
-                               for (int j=0;j<nColCells;j++) {
-                                       if (!((colCells[j]->row == smallRow) && (colCells[j]->column == smallCol))) { //if you are not hte smallest distance
-                                               if (colCells[j]->row == search || colCells[j]->column == search) {
-                                                       foundCol[j] = 1;
-                                                       merged = true;
-                                                       changed = updateDistance(colCells[j], rowCells[i]);
-                                                       // If the cell's distance changed and it had the same distance as 
-                                                       // the smallest distance, invalidate the mins vector in SparseMatrix
-                                                       if (changed) {
-                                                               if (colCells[j]->vectorMap != NULL) {
-                                                                       *(colCells[j]->vectorMap) = NULL;
-                                                                       colCells[j]->vectorMap = NULL;
-                                                               }
-                                                       }
-                                                       break;
-                                               }
-                                       }               
-                               }
-                               //if not merged it you need it for warning 
-                               if ((!merged) && (method == "average" || method == "weighted")) {  
-                                       //m->mothurOut("Warning: trying to merge cell " + toString(rowCells[i]->row+1) + " " + toString(rowCells[i]->column+1) + " distance " + toString(rowCells[i]->dist) + " with value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine(); 
-                                       if (cutOFF > rowCells[i]->dist) {  
-                                               cutOFF = rowCells[i]->dist;  
-                                               //m->mothurOut("changing cutoff to " + toString(cutOFF));  m->mothurOutEndLine(); 
-                                       }
-
-                               }
-                               removeCell(rowCells[i], i , -1);  
-                               
-                       }
-               }
-               clusterBins();
-               clusterNames();
-
-               // Special handling for singlelinkage case, not sure whether this
-               // could be avoided
-               for (int i=nColCells-1;i>=0;i--) {
-                       if (foundCol[i] == 0) {
-                               if (method == "average" || method == "weighted") {
-                                       if (!((colCells[i]->row == smallRow) && (colCells[i]->column == smallCol))) {
-                                               //m->mothurOut("Warning: merging cell " + toString(colCells[i]->row+1) + " " + toString(colCells[i]->column+1) + " distance " + toString(colCells[i]->dist) + " value above cutoff. Results may vary from using cutoff at cluster command instead of read.dist."); m->mothurOutEndLine();
-                                               if (cutOFF > colCells[i]->dist) {  
-                                                       cutOFF = colCells[i]->dist;  
-                                                       //m->mothurOut("changing cutoff to " + toString(cutOFF));  m->mothurOutEndLine(); 
-                                               }
-                                       }
-                               }
-                               removeCell(colCells[i], -1, i);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "update");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void Cluster::setMapWanted(bool f)  {  
-       try {
-               mapWanted = f;
-               
-               //initialize map
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       
-                       //parse bin 
-                       string names = list->get(i);
-                       while (names.find_first_of(',') != -1) { 
-                               //get name from bin
-                               string name = names.substr(0,names.find_first_of(','));
-                               //save name and bin number
-                               seq2Bin[name] = i;
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                       }
-                       
-                       //get last name
-                       seq2Bin[names] = i;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "setMapWanted");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void Cluster::updateMap() {
-try {
-               //update location of seqs in smallRow since they move to smallCol now
-               string names = list->get(smallRow);
-               while (names.find_first_of(',') != -1) { 
-                       //get name from bin
-                       string name = names.substr(0,names.find_first_of(','));
-                       //save name and bin number
-                       seq2Bin[name] = smallCol;
-                       names = names.substr(names.find_first_of(',')+1, names.length());
-               }
-                       
-               //get last name
-               seq2Bin[names] = smallCol;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Cluster", "updateMap");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
-
diff --git a/cluster.hpp b/cluster.hpp
deleted file mode 100644 (file)
index d7c2737..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef CLUSTER_H
-#define CLUSTER_H
-
-
-#include "mothur.h"
-#include "sparsematrix.hpp"
-#include "mothurout.h"
-
-class RAbundVector;
-class ListVector;
-
-typedef vector<MatData> MatVec;
-
-class Cluster {
-       
-public:
-       Cluster(RAbundVector*, ListVector*, SparseMatrix*, float, string);
-    virtual void update(double&);                              
-       virtual string getTag() = 0;
-       virtual void setMapWanted(bool m);  
-       virtual map<string, int> getSeqtoBin()  {  return seq2Bin;      }
-
-protected:     
-       void getRowColCells();
-    void removeCell(const MatData& cell, int vrow, int vcol, bool rmMatrix=true);
-
-       virtual bool updateDistance(MatData& colCell, MatData& rowCell) = 0;
-
-       virtual void clusterBins();
-       virtual void clusterNames();
-       virtual void updateMap();
-       
-       RAbundVector* rabund;
-       ListVector* list;
-       SparseMatrix* dMatrix;  
-       
-       int smallRow;
-       int smallCol;
-       float smallDist;
-       bool mapWanted;
-       float cutoff;
-       map<string, int> seq2Bin;
-       string method;
-       
-       vector<MatVec> seqVec;          // contains vectors of cells related to a certain sequence
-       MatVec rowCells;
-       MatVec colCells;
-       ull nRowCells;
-       ull nColCells;
-       MothurOut* m;
-};
-
-/***********************************************************************/
-
-class CompleteLinkage : public Cluster {
-public:
-       CompleteLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
-       bool updateDistance(MatData& colCell, MatData& rowCell);
-       string getTag();
-       
-private:
-               
-};
-
-/***********************************************************************/
-
-class SingleLinkage : public Cluster {
-public:
-       SingleLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
-    void update(double&);
-       bool updateDistance(MatData& colCell, MatData& rowCell);
-       string getTag();
-       
-private:
-               
-};
-
-/***********************************************************************/
-
-class AverageLinkage : public Cluster {
-public:
-       AverageLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
-       bool updateDistance(MatData& colCell, MatData& rowCell);
-       string getTag();
-       
-private:
-       int saveRow;
-       int saveCol;
-       int rowBin;
-       int colBin;
-       int totalBin;
-
-};
-
-/***********************************************************************/
-
-class WeightedLinkage : public Cluster {
-public:
-       WeightedLinkage(RAbundVector*, ListVector*, SparseMatrix*, float, string);
-       bool updateDistance(MatData& colCell, MatData& rowCell);
-       string getTag();
-       
-private:
-       int saveRow;
-       int saveCol;    
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/clusterclassic.cpp b/clusterclassic.cpp
deleted file mode 100644 (file)
index 1ce81c4..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- *  clusterclassic.cpp
- *  Mothur
- *
- *  Created by westcott on 10/29/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clusterclassic.h"
-#include "progress.hpp"
-
-/***********************************************************************/
-ClusterClassic::ClusterClassic(float c, string f, bool s) : method(f), smallDist(1e6), nseqs(0), sim(s) {
-       try {
-               mapWanted = false;  //set to true by mgcluster to speed up overlap merge
-       
-               //save so you can modify as it changes in average neighbor
-               cutoff = c;
-               aboveCutoff = cutoff + 10000.0;
-               m = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "ClusterClassic");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int ClusterClassic::readPhylipFile(string filename, NameAssignment* nameMap) {
-       try {
-               double distance;
-               int square;
-               string name;
-               vector<string> matrixNames;
-               
-               ifstream fileHandle;
-               m->openInputFile(filename, fileHandle);
-               
-               fileHandle >> nseqs >> name;
-
-               matrixNames.push_back(name);
-
-               if(nameMap == NULL){
-                               list = new ListVector(nseqs);
-                               list->set(0, name);
-               }
-               else{
-                               list = new ListVector(nameMap->getListVector());
-                               if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-               }
-               
-               //initialize distance matrix to cutoff
-               dMatrix.resize(nseqs);
-               //colDist temp(0, 0, aboveCutoff);
-               //rowSmallDists.resize(nseqs, temp);
-               for (int i = 1; i < nseqs; i++) {                       
-                       dMatrix[i].resize(i, aboveCutoff);              
-               }                                                                                               
-                                                                                                               
-               
-               char d;
-               while((d=fileHandle.get()) != EOF){
-
-                               if(isalnum(d)){
-                                               square = 1;
-                                               fileHandle.putback(d);
-                                               for(int i=0;i<nseqs;i++){
-                                                               fileHandle >> distance;
-                                               }
-                                               break;
-                               }
-                               if(d == '\n'){
-                                               square = 0;
-                                               break;
-                               }
-               }
-
-               Progress* reading;
-
-               if(square == 0){
-
-                               reading = new Progress("Reading matrix:     ", nseqs * (nseqs - 1) / 2);
-
-                               int        index = 0;
-
-                               for(int i=1;i<nseqs;i++){
-                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                               
-                                               fileHandle >> name;
-                                               matrixNames.push_back(name);
-               
-
-                                               //there's A LOT of repeated code throughout this method...
-                                               if(nameMap == NULL){
-                                                               list->set(i, name);
-                                               
-                                                               for(int j=0;j<i;j++){
-                                                               
-                                                                               if (m->control_pressed) { delete reading; fileHandle.close(); return 0;  }
-                                                                               
-                                                                               fileHandle >> distance;
-                                                       
-                                                                               if (distance == -1) { distance = 1000000; }
-                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                               
-                                                                               //if(distance < cutoff){
-                                                                                       dMatrix[i][j] = distance;
-                                                                                       if (distance < smallDist) { smallDist = distance; }
-                                                                                       //if (rowSmallDists[i].dist > distance) {  rowSmallDists[i].dist = distance; rowSmallDists[i].col = j; rowSmallDists[i].row = i; }
-                                                                                       //if (rowSmallDists[j].dist > distance) {  rowSmallDists[j].dist = distance; rowSmallDists[j].col = i; rowSmallDists[j].row = j; }
-                                                                               //}
-                                                                               index++;
-                                                                               reading->update(index);
-                                                               }
-                               
-                                               }
-                                               else{
-                                                               if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                               
-                                                               for(int j=0;j<i;j++){
-                                                                               fileHandle >> distance;
-                                                                               
-                                                                               if (m->control_pressed) { delete reading; fileHandle.close(); return 0;  }
-                               
-                                                                               if (distance == -1) { distance = 1000000; }
-                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                                               
-                                                                               //if(distance < cutoff){
-                                                                                       if (distance < smallDist) { smallDist = distance; }
-                                                                                       
-                                                                                       int row = nameMap->get(matrixNames[i]);
-                                                                                       int col = nameMap->get(matrixNames[j]);
-                                                                                       
-                                                                                       if (row < col) {  dMatrix[col][row] = distance; }
-                                                                                       else { dMatrix[row][col] = distance; }
-                                                                                       
-                                                                                       //if (rowSmallDists[row].dist > distance) {  rowSmallDists[row].dist = distance; rowSmallDists[row].col = col; rowSmallDists[row].row = row; }
-                                                                                       //if (rowSmallDists[col].dist > distance) {  rowSmallDists[col].dist = distance; rowSmallDists[col].col = row; rowSmallDists[col].row = col; }
-                                                                               //}
-                                                                               index++;
-                                                                               reading->update(index);
-                                                               }
-                                               }
-                               }
-               }
-               else{
-
-                               reading = new Progress("Reading matrix:     ", nseqs * nseqs);
-               
-                               int index = nseqs;
-
-                               for(int i=1;i<nseqs;i++){
-                                               fileHandle >> name;                
-                                               matrixNames.push_back(name);
-                                               
-                                               if(nameMap == NULL){
-                                                               list->set(i, name);
-                                                               for(int j=0;j<nseqs;j++){
-                                                                               fileHandle >> distance;
-                                                                               
-                                                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                                                               
-                                                                               if (distance == -1) { distance = 1000000; }
-                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                                               
-                                                                               if(j < i){
-                                                                                       if (distance < smallDist) { smallDist = distance; }
-                                                                                       
-                                                                                       dMatrix[i][j] = distance;
-                                                                                       //if (rowSmallDists[i].dist > distance) {  rowSmallDists[i].dist = distance; rowSmallDists[i].col = j; rowSmallDists[i].row = i; }
-                                                                                       //if (rowSmallDists[j].dist > distance) {  rowSmallDists[j].dist = distance; rowSmallDists[j].col = i; rowSmallDists[j].row = j; }
-                                                                               }
-                                                                               index++;
-                                                                               reading->update(index);
-                                                               }
-                                               
-                                               }
-                                               else{
-                                                               if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                               
-                                                               for(int j=0;j<nseqs;j++){
-                                                                               fileHandle >> distance;
-                                                                               
-                                                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                                                               
-                                                                          if (distance == -1) { distance = 1000000; }
-                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.                                                        
-                                                                               
-                                                                               if(j < i){
-                                                                                       if (distance < smallDist) { smallDist = distance; }
-                                                                                       
-                                                                                       int row = nameMap->get(matrixNames[i]);
-                                                                                       int col = nameMap->get(matrixNames[j]);
-                                                                                       
-                                                                                       if (row < col) {  dMatrix[col][row] = distance; }
-                                                                                       else { dMatrix[row][col] = distance; }
-                                                                                       
-                                                                                       //if (rowSmallDists[row].dist > distance) {  rowSmallDists[row].dist = distance; rowSmallDists[row].col = col; rowSmallDists[row].row = row; }
-                                                                                       //if (rowSmallDists[col].dist > distance) {  rowSmallDists[col].dist = distance; rowSmallDists[col].col = row; rowSmallDists[col].row = col; }
-                                                                               }
-                                                                               index++;
-                                                                               reading->update(index);
-                                                               }
-                                               }
-                               }
-               }
-               
-               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-               
-               reading->finish();
-               delete reading;
-
-               list->setLabel("0");
-               rabund = new RAbundVector(list->getRAbundVector());
-               
-               fileHandle.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "readPhylipFile");
-               exit(1);
-       }
-
-}
-/***********************************************************************/
-//sets smallCol and smallRow, returns distance
-double ClusterClassic::getSmallCell() {
-       try {
-                       
-               smallDist = aboveCutoff;
-               smallRow = 1;
-               smallCol = 0;
-               
-               vector<colDist> mins;
-               
-               for(int i=1;i<nseqs;i++){
-                       for(int j=0;j<i;j++){ 
-                               if (dMatrix[i][j] < smallDist) {
-                                       mins.clear();
-                                       colDist temp(i, j, dMatrix[i][j]);
-                                       mins.push_back(temp); 
-                                       smallDist = dMatrix[i][j];
-                               }else if (dMatrix[i][j] == smallDist) {
-                                       colDist temp(i, j, dMatrix[i][j]);
-                                       mins.push_back(temp); 
-
-                               }
-                       }
-               }
-               
-               if (mins.size() > 0) {
-                       int zrand = 0;
-                       if (mins.size() > 1) {
-                               //pick random number between 0 and mins.size()
-                               zrand = (int)((float)(rand()) / (RAND_MAX / (mins.size()-1) + 1));
-                       }
-                       
-                       smallRow = mins[zrand].row;
-                       smallCol = mins[zrand].col;
-               
-               }
-       //cout << smallRow << '\t' << smallCol << '\t' << smallDist << endl;
-               //eliminate smallCell
-               if (smallRow < smallCol) { dMatrix[smallCol][smallRow] = aboveCutoff; }
-               else { dMatrix[smallRow][smallCol] = aboveCutoff; }
-               
-               return smallDist;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "getSmallCell");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::clusterBins(){
-       try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol);
-
-               rabund->set(smallRow, rabund->get(smallRow)+rabund->get(smallCol));     
-               rabund->set(smallCol, 0);       
-               /*for (int i = smallCol+1; i < rabund->size(); i++) {
-                       rabund->set((i-1), rabund->get(i));
-               }
-               rabund->resize((rabund->size()-1));*/
-               rabund->setLabel(toString(smallDist));
-
-       //      cout << '\t' << rabund->get(smallRow) << '\t' << rabund->get(smallCol) << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "clusterBins");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::clusterNames(){
-       try {
-       //      cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(smallRow) << '\t' << list->get(smallCol);
-               if (mapWanted) {  updateMap();  }
-               
-               list->set(smallRow, list->get(smallRow)+','+list->get(smallCol));
-               list->set(smallCol, "");        
-               /*for (int i = smallCol+1; i < list->size(); i++) {
-                       list->set((i-1), list->get(i));
-               }
-               list->resize((list->size()-1));*/
-               list->setLabel(toString(smallDist));
-       
-       //      cout << '\t' << list->get(smallRow) << '\t' << list->get(smallCol) << endl;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "clusterNames");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::update(double& cutOFF){
-       try {
-//print();             
-               getSmallCell();
-               
-               int r, c;
-               r = smallRow; c = smallCol;
-                               
-               for(int i=0;i<nseqs;i++){
-                       if(i != r && i != c){
-                               double distRow, distCol, newDist;
-                               if (i > r) { distRow = dMatrix[i][r]; }
-                               else { distRow =  dMatrix[r][i]; }
-
-                               if (i > c) { distCol = dMatrix[i][c]; dMatrix[i][c] = aboveCutoff; } //like removeCell
-                               else { distCol =  dMatrix[c][i]; dMatrix[c][i] = aboveCutoff; }
-                               
-                               if(method == "furthest"){
-                                       newDist = max(distRow, distCol);
-                               }
-                               else if (method == "average"){
-                                       int rowBin = rabund->get(r);
-                                       int colBin = rabund->get(c);
-                                       newDist = (colBin * distCol + rowBin * distRow) / (rowBin + colBin);
-                               }
-                               else if (method == "weighted"){
-                                       newDist = (distCol + distRow) / 2.0;
-                               }
-                               else if (method == "nearest"){
-                                       newDist = min(distRow, distCol);
-                               }
-                               //cout << "newDist = " << newDist << endl;      
-                               if (i > r) { dMatrix[i][r] = newDist; }
-                               else { dMatrix[r][i] = newDist; }
-                               
-                       }
-               }
-                       
-               clusterBins();
-               clusterNames();
-               
-               //resize each row
-               /*for(int i=0;i<nseqs;i++){
-                       for(int j=c+1;j<dMatrix[i].size();j++){
-                               dMatrix[i][j-1]=dMatrix[i][j];
-                       }
-               }                       
-               
-               //resize each col
-               for(int i=c+1;i<nseqs;i++){
-                       for(int j=0;j < dMatrix[i-1].size();j++){
-                               dMatrix[i-1][j]=dMatrix[i][j];
-                       }
-               }       
-               
-               nseqs--;
-               dMatrix.pop_back();*/
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "update");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::setMapWanted(bool f)  {  
-       try {
-               mapWanted = f;
-               
-               //initialize map
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       
-                       //parse bin 
-                       string names = list->get(i);
-                       while (names.find_first_of(',') != -1) { 
-                               //get name from bin
-                               string name = names.substr(0,names.find_first_of(','));
-                               //save name and bin number
-                               seq2Bin[name] = i;
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                       }
-                       
-                       //get last name
-                       seq2Bin[names] = i;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "setMapWanted");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::updateMap() {
-try {
-               //update location of seqs in smallRow since they move to smallCol now
-               string names = list->get(smallRow);
-               while (names.find_first_of(',') != -1) { 
-                       //get name from bin
-                       string name = names.substr(0,names.find_first_of(','));
-                       //save name and bin number
-                       seq2Bin[name] = smallCol;
-                       names = names.substr(names.find_first_of(',')+1, names.length());
-               }
-                       
-               //get last name
-               seq2Bin[names] = smallCol;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "updateMap");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void ClusterClassic::print() {
-try {
-               //update location of seqs in smallRow since they move to smallCol now
-               for (int i = 0; i < dMatrix.size(); i++) {
-                       m->mothurOut("row = " + toString(i) + "\t");
-                       for (int j = 0; j < dMatrix[i].size(); j++) {
-                               m->mothurOut(toString(dMatrix[i][j]) + "\t");
-                       }
-                       m->mothurOutEndLine();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterClassic", "updateMap");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/clusterclassic.h b/clusterclassic.h
deleted file mode 100644 (file)
index 110c040..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef CLUSTER_H
-#define CLUSTER_H
-
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "listvector.hpp"
-#include "rabundvector.hpp"
-#include "nameassignment.hpp"
-
-/*
- *  clusterclassic.h
- *  Mothur
- *
- *  Created by westcott on 10/29/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-class ClusterClassic {
-       
-public:
-       ClusterClassic(float, string, bool);
-       int readPhylipFile(string, NameAssignment*);
-       void update(double&);
-       double getSmallDist() { return smallDist; }     
-       int getNSeqs() { return nseqs; }        
-       ListVector* getListVector() { return list; }
-       RAbundVector* getRAbundVector() { return rabund; }              
-       string getTag();
-       void setMapWanted(bool m);  
-       map<string, int> getSeqtoBin()  {  return seq2Bin;      }
-
-private:       
-       double getSmallCell();
-       void clusterBins();
-       void clusterNames();
-       void updateMap();
-       void print();
-       
-       struct colDist {
-               int col;
-               int row;
-               double dist;
-               colDist(int r, int c, double d) : row(r), col(c), dist(d) {}
-       };
-       
-       RAbundVector* rabund;
-       ListVector* list;
-       vector< vector<double> > dMatrix;       
-       //vector<colDist> rowSmallDists;
-       
-       int smallRow;
-       int smallCol, nseqs;
-       double smallDist;
-       bool mapWanted, sim;
-       double cutoff, aboveCutoff;
-       map<string, int> seq2Bin;
-       string method;
-       
-       MothurOut* m;
-};
-
-#endif
-
-
diff --git a/clustercommand.cpp b/clustercommand.cpp
deleted file mode 100644 (file)
index 528f71c..0000000
+++ /dev/null
@@ -1,449 +0,0 @@
-/*
- *  clustercommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "clustercommand.h"
-#include "readphylip.h"
-#include "readcolumn.h"
-#include "readmatrix.hpp"
-#include "clusterdoturcommand.h"
-
-//**********************************************************************************************************************
-vector<string> ClusterCommand::setParameters(){        
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);              
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClusterCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The cluster command parameter options are phylip, column, name, method, cuttoff, hard, precision, sim, showabund and timing. Phylip or column and name are required, unless you have a valid current file.\n";
-               helpString += "The cluster command should be in the following format: \n";
-               helpString += "cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n";
-               helpString += "The acceptable cluster methods are furthest, nearest, average and weighted.  If no method is provided then average is assumed.\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterCommand::ClusterCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "ClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-ClusterCommand::ClusterCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
-                                       abort = true;
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-               
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { phylipfile = ""; abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  distfile = phylipfile;  format = "phylip";      m->setPhylipFile(phylipfile); }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { columnfile = ""; abort = true; }        
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  distfile = columnfile; format = "column"; m->setColumnFile(columnfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to column, then phylip
-                               columnfile = m->getColumnFile(); 
-                               if (columnfile != "") {  distfile = columnfile; format = "column"; m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       phylipfile = m->getPhylipFile(); 
-                                       if (phylipfile != "") { distfile = phylipfile;  format = "phylip"; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a phylip or column file before you can use the cluster command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a cluster command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if (columnfile != "") {
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       //get user cutoff and precision or use defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);
-                       if (temp == "not found") { temp = "100"; }
-                       //saves precision legnth for formatting below
-                       length = temp.length();
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
-                       hard = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
-                       sim = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);
-                       if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));  
-                       
-                       method = validParameter.validFile(parameters, "method", false);
-                       if (method == "not found") { method = "average"; }
-                       
-                       if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average, and weighted."); m->mothurOutEndLine(); abort = true; }
-
-                       showabund = validParameter.validFile(parameters, "showabund", false);
-                       if (showabund == "not found") { showabund = "T"; }
-
-                       timing = validParameter.validFile(parameters, "timing", false);
-                       if (timing == "not found") { timing = "F"; }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "ClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterCommand::~ClusterCommand(){}
-//**********************************************************************************************************************
-
-int ClusterCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //phylip file given and cutoff not given - use cluster.classic because it uses less memory and is faster
-               if ((format == "phylip") && (cutoff > 10.0)) {
-                       m->mothurOutEndLine(); m->mothurOut("You are using a phylip file and no cutoff.  I will run cluster.classic to save memory and time."); m->mothurOutEndLine();
-                       
-                       //run unique.seqs for deconvolute results
-                       string inputString = "phylip=" + distfile;
-                       if (namefile != "") { inputString += ", name=" + namefile; }
-                       inputString += ", precision=" + toString(precision);
-                       inputString += ", method=" + method;
-                       if (hard)       { inputString += ", hard=T";    }
-                       else            { inputString += ", hard=F";    }
-                       if (sim)        { inputString += ", sim=T";             }
-                       else            { inputString += ", sim=F";             }
-
-                       
-                       m->mothurOutEndLine(); 
-                       m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine(); 
-                       m->mothurOut("Running command: cluster.classic(" + inputString + ")"); m->mothurOutEndLine(); 
-                       
-                       Command* clusterClassicCommand = new ClusterDoturCommand(inputString);
-                       clusterClassicCommand->execute();
-                       delete clusterClassicCommand;
-                       
-                       m->mothurOut("/------------------------------------------------------------/"); m->mothurOutEndLine();  
-
-                       return 0;
-               }
-               
-               ReadMatrix* read;
-               if (format == "column") { read = new ReadColumnMatrix(columnfile, sim); }       //sim indicates whether its a similarity matrix
-               else if (format == "phylip") { read = new ReadPhylipMatrix(phylipfile, sim); }
-               
-               read->setCutoff(cutoff);
-               
-               NameAssignment* nameMap = NULL;
-               if(namefile != ""){     
-                       nameMap = new NameAssignment(namefile);
-                       nameMap->readMap();
-               }
-               
-               read->read(nameMap);
-               list = read->getListVector();
-               matrix = read->getMatrix();
-               rabund = new RAbundVector(list->getRAbundVector());
-               delete read;
-               
-               if (m->control_pressed) { //clean up
-                       delete list; delete matrix; delete rabund;
-                       sabundFile.close();rabundFile.close();listFile.close();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear();
-                       return 0;
-               }
-               
-               //create cluster
-               if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
-               else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
-               else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff, method);     }
-               else if(method == "weighted"){  cluster = new WeightedLinkage(rabund, list, matrix, cutoff, method);    }
-               tag = cluster->getTag();
-               
-               if (outputDir == "") { outputDir += m->hasPath(distfile); }
-               fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
-               
-               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-               
-               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
-               
-               
-               time_t estart = time(NULL);
-               float previousDist = 0.00000;
-               float rndPreviousDist = 0.00000;
-               oldRAbund = *rabund;
-               oldList = *list;
-
-               print_start = true;
-               start = time(NULL);
-               loops = 0;
-               double saveCutoff = cutoff;
-               
-               while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){
-               
-                       if (m->control_pressed) { //clean up
-                               delete list; delete matrix; delete rabund; delete cluster;
-                               sabundFile.close();rabundFile.close();listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear();
-                               return 0;
-                       }
-               
-                       if (print_start && m->isTrue(timing)) {
-                               m->mothurOut("Clustering (" + tag + ") dist " + toString(matrix->getSmallDist()) + "/" 
-                                       + toString(m->roundDist(matrix->getSmallDist(), precision)) 
-                                       + "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
-                               cout.flush();
-                               print_start = false;
-                       }
-
-                       loops++;
-
-                       cluster->update(cutoff);
-       
-                       float dist = matrix->getSmallDist();
-                       float rndDist;
-                       if (hard) {
-                               rndDist = m->ceilDist(dist, precision); 
-                       }else{
-                               rndDist = m->roundDist(dist, precision); 
-                       }
-
-                       if(previousDist <= 0.0000 && dist != previousDist){
-                               printData("unique");
-                       }
-                       else if(rndDist != rndPreviousDist){
-                               printData(toString(rndPreviousDist,  length-1));
-                       }
-               
-                       previousDist = dist;
-                       rndPreviousDist = rndDist;
-                       oldRAbund = *rabund;
-                       oldList = *list;
-               }
-
-               if (print_start && m->isTrue(timing)) {
-                       m->mothurOut("Clustering (" + tag + ") for distance " + toString(previousDist) + "/" + toString(rndPreviousDist) 
-                                        + "\t(precision: " + toString(precision) + ", Nodes: " + toString(matrix->getNNodes()) + ")");
-                       cout.flush();
-                       print_start = false;
-               }
-               
-               if(previousDist <= 0.0000){
-                       printData("unique");
-               }
-               else if(rndPreviousDist<cutoff){
-                       printData(toString(rndPreviousDist, length-1));
-               }
-               
-               delete matrix;
-               delete list;
-               delete rabund;
-               delete cluster;
-               
-               sabundFile.close();
-               rabundFile.close();
-               listFile.close();
-       
-               if (saveCutoff != cutoff) { 
-                       if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-                       else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-
-                       m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
-               }
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               //if (m->isTrue(timing)) {
-                       m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
-               //}
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void ClusterCommand::printData(string label){
-       try {
-               if (m->isTrue(timing)) {
-                       m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins()) 
-                    + "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
-               }
-               print_start = true;
-               loops = 0;
-               start = time(NULL);
-
-               oldRAbund.setLabel(label);
-               if (m->isTrue(showabund)) {
-                       oldRAbund.getSAbundVector().print(cout);
-               }
-               oldRAbund.print(rabundFile);
-               oldRAbund.getSAbundVector().print(sabundFile);
-       
-               oldList.setLabel(label);
-               oldList.print(listFile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterCommand", "printData");
-               exit(1);
-       }
-
-
-}
-//**********************************************************************************************************************
diff --git a/clustercommand.h b/clustercommand.h
deleted file mode 100644 (file)
index 268ec31..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef CLUSTERCOMMAND_H
-#define CLUSTERCOMMAND_H
-/*
- *  clustercommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "listvector.hpp"
-#include "cluster.hpp"
-#include "sparsematrix.hpp"
-
-/* The cluster() command:
-       The cluster command outputs a .list , .rabund and .sabund files.  
-       The cluster command parameter options are method, cuttoff and precision. No parameters are required.  
-       The cluster command should be in the following format: cluster(method=yourMethod, cutoff=yourCutoff, precision=yourPrecision).  
-       The acceptable methods are furthest, nearest and average.  If you do not provide a method the default algorythm is furthest neighbor.  
-       The cluster() command outputs three files *.list, *.rabund, and *.sabund.   */
-
-
-class ClusterCommand : public Command {
-       
-public:
-       ClusterCommand(string);
-       ClusterCommand();
-       ~ClusterCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "cluster";             }
-       string getCommandCategory()             { return "Clustering";  }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol. \nhttp://www.mothur.org/wiki/Cluster"; }
-       string getDescription()         { return "cluster your sequences into OTUs using a distance matrix"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       Cluster* cluster;
-       SparseMatrix* matrix;
-       ListVector* list;
-       RAbundVector* rabund;
-       RAbundVector oldRAbund;
-       ListVector oldList;
-
-       bool abort, hard, sim;
-
-       string method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, format, distfile;
-       double cutoff;
-       string showabund, timing;
-       int precision, length;
-       ofstream sabundFile, rabundFile, listFile;
-
-       bool print_start;
-       time_t start;
-       unsigned long loops;
-       
-       void printData(string label);
-       vector<string> outputNames;
-};
-
-#endif
diff --git a/clusterdoturcommand.cpp b/clusterdoturcommand.cpp
deleted file mode 100644 (file)
index 603bd73..0000000
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- *  clusterdoturcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clusterdoturcommand.h"
-#include "clusterclassic.h"
-
-//**********************************************************************************************************************
-vector<string> ClusterDoturCommand::setParameters(){   
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClusterDoturCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The cluster.classic command clusters using the algorithm from dotur. \n";
-               helpString += "The cluster.classic command parameter options are phylip, name, method, cuttoff, hard, sim, precision. Phylip is required, unless you have a valid current file.\n";
-               helpString += "The cluster.classic command should be in the following format: \n";
-               helpString += "cluster.classic(phylip=yourDistanceMatrix, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n";
-               helpString += "The acceptable cluster methods are furthest, nearest, weighted and average.  If no method is provided then average is assumed.\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterDoturCommand::ClusterDoturCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "ClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-ClusterDoturCommand::ClusterDoturCommand(string option)  {
-       try{
-               
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
-                                       abort = true;
-                               }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-               
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { 
-                               phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") {  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("You need to provide a phylip file with the cluster.classic command."); m->mothurOutEndLine(); 
-                                       abort = true; 
-                               }       
-                       }else { m->setPhylipFile(phylipfile); } 
-
-               
-                       //check for optional parameter and set defaults
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);
-                       if (temp == "not found") { temp = "100"; }
-                       //saves precision legnth for formatting below
-                       length = temp.length();
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);
-                       if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));  
-                       
-                       temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
-                       hard = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
-                       sim = m->isTrue(temp); 
-                       
-                       method = validParameter.validFile(parameters, "method", false);
-                       if (method == "not found") { method = "average"; }
-                       
-                       if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { 
-                               if (method == "furthest") { tag = "fn"; }
-                               else if (method == "nearest") { tag = "nn"; }
-                               else if (method == "average") { tag = "an"; }
-                               else if (method == "weighted") { tag = "wn"; }
-                       }else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average, weighted."); m->mothurOutEndLine(); abort = true; }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "ClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ClusterDoturCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if(namefile != ""){     
-                       nameMap = new NameAssignment(namefile);
-                       nameMap->readMap();
-               }else{
-                       nameMap = NULL;
-               }
-               
-               //reads phylip file storing data in 2D vector, also fills list and rabund
-               ClusterClassic* cluster = new ClusterClassic(cutoff, method, sim);
-               cluster->readPhylipFile(phylipfile, nameMap);
-               
-               if (m->control_pressed) { delete cluster; delete list; delete rabund; return 0; }
-               
-               list = cluster->getListVector();
-               rabund = cluster->getRAbundVector();
-                                               
-               if (outputDir == "") { outputDir += m->hasPath(phylipfile); }
-               fileroot = outputDir + m->getRootName(m->getSimpleName(phylipfile));
-                       
-               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-                               
-               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
-               
-               float previousDist = 0.00000;
-               float rndPreviousDist = 0.00000;
-               oldRAbund = *rabund;
-               oldList = *list;
-
-               //double saveCutoff = cutoff;
-               
-               int estart = time(NULL);
-       
-               while ((cluster->getSmallDist() < cutoff) && (cluster->getNSeqs() > 1)){
-                       if (m->control_pressed) { delete cluster; delete list; delete rabund; sabundFile.close();rabundFile.close();listFile.close();  for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);        } outputTypes.clear();  return 0;  }
-               
-                       cluster->update(cutoff);
-       
-                       float dist = cluster->getSmallDist();
-                       float rndDist;
-                       if (hard) {
-                               rndDist = m->ceilDist(dist, precision); 
-                       }else{
-                               rndDist = m->roundDist(dist, precision); 
-                       }
-
-                       if(previousDist <= 0.0000 && dist != previousDist){
-                               printData("unique");
-                       }
-                       else if(rndDist != rndPreviousDist){
-                               printData(toString(rndPreviousDist,  length-1));
-                       }
-               
-                       previousDist = dist;
-                       rndPreviousDist = rndDist;
-                       oldRAbund = *rabund;
-                       oldList = *list;
-               }
-       
-               if(previousDist <= 0.0000){
-                       printData("unique");
-               }
-               else if(rndPreviousDist<cutoff){
-                       printData(toString(rndPreviousDist, length-1));
-               }
-                                       
-               sabundFile.close();
-               rabundFile.close();
-               listFile.close();
-               
-               delete cluster; delete nameMap; delete list; delete rabund;
-       
-               //if (saveCutoff != cutoff) { 
-               //      if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-               //      else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-               //      m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
-               //}
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void ClusterDoturCommand::printData(string label){
-       try {
-       
-               oldRAbund.setLabel(label);
-               oldRAbund.print(rabundFile);
-               oldRAbund.getSAbundVector().print(sabundFile);
-               
-               oldRAbund.getSAbundVector().print(cout);
-               
-               oldList.setLabel(label);
-               oldList.print(listFile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterDoturCommand", "printData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/clusterdoturcommand.h b/clusterdoturcommand.h
deleted file mode 100644 (file)
index 643551a..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef CLUSTERDOTURCOMMAND_H
-#define CLUSTERDOTURCOMMAND_H
-
-/*
- *  clusterdoturcommand.h
- *  Mothur
- *
- *  Created by westcott on 10/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "nameassignment.hpp"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "listvector.hpp"
-
-
-class ClusterDoturCommand : public Command {
-       
-public:
-       ClusterDoturCommand(string);
-       ClusterDoturCommand();
-       ~ClusterDoturCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "cluster.classic";             }
-       string getCommandCategory()             { return "Clustering";                  }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Handelsman J (2005). Introducing DOTUR, a computer program for defining operational taxonomic units and estimating species richness. Appl Environ Microbiol 71: 1501-6. \nhttp://www.mothur.org/wiki/Cluster.classic"; }
-       string getDescription()         { return "cluster your sequences into OTUs using DOTUR’s method"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort, hard, sim;
-       string method, fileroot, tag, outputDir, phylipfile, namefile;
-       double cutoff;
-       int precision, length;
-       ofstream sabundFile, rabundFile, listFile;
-       NameAssignment* nameMap;
-       ListVector* list;
-       RAbundVector* rabund;
-       RAbundVector oldRAbund;
-       ListVector oldList;
-       
-       void printData(string label);
-       vector<string> outputNames;
-};
-
-#endif
-
diff --git a/clusterfragmentscommand.cpp b/clusterfragmentscommand.cpp
deleted file mode 100644 (file)
index 772113b..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- *  ryanscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/23/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clusterfragmentscommand.h"
-#include "needlemanoverlap.hpp"
-
-//**********************************************************************************************************************
-//sort by unaligned
-inline bool comparePriority(seqRNode first, seqRNode second) {  
-       bool better = false;
-       
-       if (first.length > second.length) { 
-               better = true;
-       }else if (first.length == second.length) {
-               if (first.numIdentical > second.numIdentical) {
-                       better = true;
-               }
-       }
-       
-       return better; 
-}
-//**********************************************************************************************************************
-vector<string> ClusterFragmentsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pdiffs);
-               CommandParameter ppercent("percent", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppercent);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClusterFragmentsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The cluster.fragments command groups sequences that are part of a larger sequence.\n";
-               helpString += "The cluster.fragments command outputs a new fasta and name file.\n";
-               helpString += "The cluster.fragments command parameters are fasta, name, diffs and percent. The fasta parameter is required, unless you have a valid current file. \n";
-               helpString += "The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n";
-               helpString += "The diffs parameter allows you to set the number of differences allowed, default=0. \n";
-               helpString += "The percent parameter allows you to set percentage of differences allowed, default=0. percent=2 means if the number of difference is less than or equal to two percent of the length of the fragment, then cluster.\n";
-               helpString += "You may use diffs and percent at the same time to say something like: If the number or differences is greater than 1 or more than 2% of the fragment length, don't merge. \n";
-               helpString += "The cluster.fragments command should be in the following format: \n";
-               helpString += "cluster.fragments(fasta=yourFastaFile, names=yourNamesFile) \n";
-               helpString += "Example cluster.fragments(fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterFragmentsCommand::ClusterFragmentsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "ClusterFragmentsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterFragmentsCommand::ClusterFragmentsCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string, string>::iterator it2 = parameters.begin(); it2 != parameters.end(); it2++) { 
-                               if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (fastafile == "not open") { fastafile = ""; abort = true; }     
-                       else { m->setFastaFile(fastafile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);      }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not found") { namefile =  "";  }
-                       else if (namefile == "not open") { namefile = ""; abort = true; }       
-                       else {  readNameFile(); m->setNameFile(namefile); }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "diffs", false);            if (temp == "not found"){       temp = "0";                             }
-                       m->mothurConvert(temp, diffs); 
-                       
-                       temp = validParameter.validFile(parameters, "percent", false);          if (temp == "not found"){       temp = "0";                             }
-                       m->mothurConvert(temp, percent);
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "ClusterFragmentsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ClusterFragmentsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int start = time(NULL);
-               
-               //reads fasta file and return number of seqs
-               int numSeqs = readFASTA(); //fills alignSeqs and makes all seqs active
-               
-               if (m->control_pressed) { return 0; }
-       
-               if (numSeqs == 0) { m->mothurOut("Error reading fasta file...please correct."); m->mothurOutEndLine(); return 0;  }
-               
-               //sort seqs by length of unaligned sequence
-               sort(alignSeqs.begin(), alignSeqs.end(), comparePriority);
-       
-               int count = 0;
-
-               //think about running through twice...
-               for (int i = 0; i < numSeqs; i++) {
-                       
-                       if (alignSeqs[i].active) {  //this sequence has not been merged yet
-                               
-                               string iBases = alignSeqs[i].seq.getUnaligned();
-                               
-                               //try to merge it with all smaller seqs
-                               for (int j = i+1; j < numSeqs; j++) {
-                                       
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       if (alignSeqs[j].active) {  //this sequence has not been merged yet
-                                               
-                                               string jBases = alignSeqs[j].seq.getUnaligned();
-                                                                                                       
-                                               if (isFragment(iBases, jBases)) {
-                                                       //merge
-                                                       alignSeqs[i].names += ',' + alignSeqs[j].names;
-                                                       alignSeqs[i].numIdentical += alignSeqs[j].numIdentical;
-
-                                                       alignSeqs[j].active = 0;
-                                                       alignSeqs[j].numIdentical = 0;
-                                                       count++;
-                                               }
-                                       }//end if j active
-                               }//end if i != j
-                       
-                               //remove from active list 
-                               alignSeqs[i].active = 0;
-                               
-                       }//end if active i
-                       if(i % 100 == 0)        { m->mothurOut(toString(i) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine(); }
-               }
-               
-               if(numSeqs % 100 != 0)  { m->mothurOut(toString(numSeqs) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine();   }
-       
-               
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               
-               string newFastaFile = fileroot + "fragclust.fasta";
-               string newNamesFile = fileroot + "fragclust.names";
-               
-               if (m->control_pressed) { return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Total number of sequences before cluster.fragments was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
-               m->mothurOut("cluster.fragments removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); 
-               
-               printData(newFastaFile, newNamesFile);
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); 
-               
-               if (m->control_pressed) { m->mothurRemove(newFastaFile); m->mothurRemove(newNamesFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(newFastaFile); m->mothurOutEndLine();      
-               m->mothurOut(newNamesFile); m->mothurOutEndLine();      
-               outputNames.push_back(newFastaFile);  outputNames.push_back(newNamesFile); outputTypes["fasta"].push_back(newFastaFile); outputTypes["name"].push_back(newNamesFile);
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "execute");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-bool ClusterFragmentsCommand::isFragment(string seq1, string seq2){
-       try {
-               bool fragment = false;
-               
-               //exact match
-               int pos = seq1.find(seq2);
-               if (pos != string::npos) { return true; }
-               //no match, no diffs wanted
-               else if ((diffs == 0) && (percent == 0)) { return false; }
-               else { //try aligning and see if you can find it
-                       
-                       //find number of acceptable differences for this sequence fragment
-                       int totalDiffs;
-                       if (diffs == 0) { //you didnt set diffs you want a percentage
-                               totalDiffs = floor((seq2.length() * (percent / 100.0)));
-                       }else if (percent == 0) { //you didn't set percent you want diffs
-                               totalDiffs = diffs;
-                       }else if ((percent != 0) && (diffs != 0)) { //you want both, set total diffs to smaller of 2
-                               totalDiffs = diffs;
-                               int percentDiff = floor((seq2.length() * (percent / 100.0)));
-                               if (percentDiff < totalDiffs) { totalDiffs = percentDiff; }
-                       }
-                       
-                       Alignment* alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (seq1.length()+totalDiffs+1));
-                                                       
-                       //use needleman to align 
-                       alignment->align(seq2, seq1);
-                       string tempSeq2 = alignment->getSeqAAln();
-                       string temp = alignment->getSeqBAln();
-                       
-                       delete alignment;
-                       
-                       //chop gap ends
-                       int startPos = 0;
-                       int endPos = tempSeq2.length()-1;
-                       for (int i = 0; i < tempSeq2.length(); i++) {  if (isalpha(tempSeq2[i])) { startPos = i; break; } }
-                       for (int i = tempSeq2.length()-1; i >= 0; i--) {  if (isalpha(tempSeq2[i])) { endPos = i; break; } }
-                       
-                       //count number of diffs
-                       int numDiffs = 0;
-                       for (int i = startPos; i <= endPos; i++) {
-                               if (tempSeq2[i] != temp[i]) { numDiffs++; }
-                       }
-                       
-                       if (numDiffs <= totalDiffs) { fragment = true; }
-                       
-               }
-               
-               return fragment;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "isFragment");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int ClusterFragmentsCommand::readFASTA(){
-       try {
-       
-               ifstream inFasta;
-               m->openInputFile(fastafile, inFasta);
-               
-               while (!inFasta.eof()) {
-                       
-                       if (m->control_pressed) { inFasta.close(); return 0; }
-                       
-                       Sequence seq(inFasta);  m->gobble(inFasta);
-                       
-                       if (seq.getName() != "") {  //can get "" if commented line is at end of fasta file
-                               if (namefile != "") {
-                                       itSize = sizes.find(seq.getName());
-                                       
-                                       if (itSize == sizes.end()) { m->mothurOut(seq.getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); exit(1); }
-                                       else{
-                                               seqRNode tempNode(itSize->second, seq, names[seq.getName()], seq.getUnaligned().length());
-                                               alignSeqs.push_back(tempNode);
-                                       }       
-                               }else { //no names file, you are identical to yourself 
-                                       seqRNode tempNode(1, seq, seq.getName(), seq.getUnaligned().length());
-                                       alignSeqs.push_back(tempNode);
-                               }
-                       }
-               }
-               
-               inFasta.close();
-               return alignSeqs.size();
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "readFASTA");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void ClusterFragmentsCommand::printData(string newfasta, string newname){
-       try {
-               ofstream outFasta;
-               ofstream outNames;
-               
-               m->openOutputFile(newfasta, outFasta);
-               m->openOutputFile(newname, outNames);
-               
-               for (int i = 0; i < alignSeqs.size(); i++) {
-                       if (alignSeqs[i].numIdentical != 0) {
-                               alignSeqs[i].seq.printSequence(outFasta); 
-                               outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
-                       }
-               }
-               
-               outFasta.close();
-               outNames.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "printData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void ClusterFragmentsCommand::readNameFile(){
-       try {
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string firstCol, secondCol;
-                               
-               while (!in.eof()) {
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       names[firstCol] = secondCol;
-                       int size = 1;
-
-                       for(int i=0;i<secondCol.size();i++){
-                               if(secondCol[i] == ','){        size++; }
-                       }
-                       sizes[firstCol] = size;
-               }
-               in.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterFragmentsCommand", "readNameFile");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
diff --git a/clusterfragmentscommand.h b/clusterfragmentscommand.h
deleted file mode 100644 (file)
index c7ea7e0..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef CLUSTERFRAGMENTSCOMMAND_H
-#define CLUSTERFRAGMENTSCOMMAND_H
-
-/*
- *  clusterfragmentscommand.h
- *  Mothur
- *
- *  Created by westcott on 9/23/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sequence.hpp"
-
-/************************************************************/
-struct seqRNode {
-       int numIdentical;
-       int length;
-       Sequence seq;
-       string names;
-       bool active;
-       seqRNode() {}
-       seqRNode(int n, Sequence s, string nm, int l) : numIdentical(n), seq(s), names(nm), active(1), length(l) {}
-       ~seqRNode() {}
-};
-/************************************************************/
-
-class ClusterFragmentsCommand : public Command {
-       
-public:
-       ClusterFragmentsCommand(string);
-       ClusterFragmentsCommand();
-       ~ClusterFragmentsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "cluster.fragments";           }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Cluster.fragments"; }
-       string getDescription()         { return "creates a namesfile with sequences that are a fragment of a larger sequence"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort;
-       string fastafile, namefile, outputDir;
-       int diffs, percent;
-       vector<seqRNode> alignSeqs; 
-       map<string, string> names; //represents the names file first column maps to second column
-       map<string, int> sizes;  //this map a seq name to the number of identical seqs in the names file
-       map<string, int>::iterator itSize; 
-       vector<string> outputNames;
-       
-       int readFASTA();
-       void readNameFile();
-       void printData(string, string); //fasta filename, names file name
-       bool isFragment(string, string);
-       
-};
-
-/************************************************************/
-
-#endif
-
diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp
deleted file mode 100644 (file)
index 8a19f1d..0000000
+++ /dev/null
@@ -1,1220 +0,0 @@
-/*
- *  clustersplitcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "clustersplitcommand.h"
-
-
-
-//**********************************************************************************************************************
-vector<string> ClusterSplitCommand::setParameters(){   
-       try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FastaTaxName",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "FastaTaxName",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName-FastaTaxName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter ptaxlevel("taxlevel", "Number", "", "3", "", "", "",false,false); parameters.push_back(ptaxlevel);
-               CommandParameter psplitmethod("splitmethod", "Multiple", "classify-fasta-distance", "distance", "", "", "",false,false); parameters.push_back(psplitmethod);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.25", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-                       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ClusterSplitCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The cluster.split command parameter options are fasta, phylip, column, name, cutoff, precision, method, splitmethod, taxonomy, taxlevel, showabund, timing, hard, large, processors. Fasta or Phylip or column and name are required.\n";
-               helpString += "The cluster.split command can split your files in 3 ways. Splitting by distance file, by classification, or by classification also using a fasta file. \n";
-               helpString += "For the distance file method, you need only provide your distance file and mothur will split the file into distinct groups. \n";
-               helpString += "For the classification method, you need to provide your distance file and taxonomy file, and set the splitmethod to classify.  \n";
-               helpString += "You will also need to set the taxlevel you want to split by. mothur will split the sequences into distinct taxonomy groups, and split the distance file based on those groups. \n";
-               helpString += "For the classification method using a fasta file, you need to provide your fasta file, names file and taxonomy file.  \n";
-               helpString += "You will also need to set the taxlevel you want to split by. mothur will split the sequence into distinct taxonomy groups, and create distance files for each grouping. \n";
-               helpString += "The phylip and column parameter allow you to enter your distance file. \n";
-               helpString += "The fasta parameter allows you to enter your aligned fasta file. \n";
-               helpString += "The name parameter allows you to enter your name file and is required if your distance file is in column format. \n";
-               helpString += "The cutoff parameter allow you to set the distance you want to cluster to, default is 0.25. \n";
-               helpString += "The precision parameter allows you specify the precision of the precision of the distances outputted, default=100, meaning 2 decimal places. \n";
-               helpString += "The method allows you to specify what clustering algorythm you want to use, default=average, option furthest, nearest, or average. \n";
-               helpString += "The splitmethod parameter allows you to specify how you want to split your distance file before you cluster, default=distance, options distance, classify or fasta. \n";
-               helpString += "The taxonomy parameter allows you to enter the taxonomy file for your sequences, this is only valid if you are using splitmethod=classify. Be sure your taxonomy file does not include the probability scores. \n";
-               helpString += "The taxlevel parameter allows you to specify the taxonomy level you want to use to split the distance file, default=3, meaning use the first taxon in each list. \n";
-               helpString += "The large parameter allows you to indicate that your distance matrix is too large to fit in RAM.  The default value is false.\n";
-#ifdef USE_MPI
-               helpString += "When using MPI, the processors parameter is set to the number of MPI processes running. \n";
-#endif
-               helpString += "The cluster.split command should be in the following format: \n";
-               helpString += "cluster.split(column=youDistanceFile, name=yourNameFile, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision, splitmethod=yourSplitmethod, taxonomy=yourTaxonomyfile, taxlevel=yourtaxlevel) \n";
-               helpString += "Example: cluster.split(column=abrecovery.dist, name=abrecovery.names, method=furthest, cutoff=0.10, precision=1000, splitmethod=classify, taxonomy=abrecovery.silva.slv.taxonomy, taxlevel=5) \n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ClusterSplitCommand::ClusterSplitCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-               outputTypes["column"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-ClusterSplitCommand::ClusterSplitCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-               format = "";
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("cluster.split");
-               
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
-                                       abort = true;
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       outputTypes["column"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                               //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  distfile = phylipfile;  format = "phylip";      m->setPhylipFile(phylipfile); }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { abort = true; } 
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  distfile = columnfile; format = "column";       m->setColumnFile(columnfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = "";  }
-                       else { m->setNameFile(namefile); }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }  
-                       else if (fastafile == "not found") { fastafile = ""; }
-                       else { distfile = fastafile;  splitmethod = "fasta";  m->setFastaFile(fastafile); }
-                       
-                       taxFile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxFile == "not open") { taxFile = ""; abort = true; }      
-                       else if (taxFile == "not found") { taxFile = ""; }
-                       else {  m->setTaxonomyFile(taxFile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "") && (fastafile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to column, then phylip, then fasta
-                               columnfile = m->getColumnFile(); 
-                               if (columnfile != "") {  m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       phylipfile = m->getPhylipFile(); 
-                                       if (phylipfile != "") {  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               fastafile = m->getFastaFile(); 
-                                               if (fastafile != "") {  m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("No valid current files. When executing a cluster.split command you must enter a phylip or a column or fastafile."); m->mothurOutEndLine(); 
-                                                       abort = true; 
-                                               }
-                                       }
-                               }
-                       }
-                       else if ((phylipfile != "") && (columnfile != "") && (fastafile != "")) { m->mothurOut("When executing a cluster.split command you must enter ONLY ONE of the following: fasta, phylip or column."); m->mothurOutEndLine(); abort = true; }
-               
-                       if (columnfile != "") {
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                       
-                       if (fastafile != "") {
-                               if (taxFile == "") { 
-                                       taxFile = m->getTaxonomyFile(); 
-                                       if (taxFile != "") {  m->mothurOut("Using " + taxFile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a taxonomy file if you are if you are using a fasta file to generate the split."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                               
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are if you are using a fasta file to generate the split."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       //get user cutoff and precision or use defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);
-                       if (temp == "not found") { temp = "100"; }
-                       //saves precision legnth for formatting below
-                       length = temp.length();
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
-                       hard = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "large", false);                    if (temp == "not found") { temp = "F"; }
-                       large = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "splitmethod", false);      
-                       if (splitmethod != "fasta") {
-                               if (temp == "not found")  { splitmethod = "distance"; }
-                               else {  splitmethod = temp; }
-                       }
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);           if (temp == "not found")  { temp = "0.25"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));  
-                       
-                       temp = validParameter.validFile(parameters, "taxlevel", false);         if (temp == "not found")  { temp = "3"; }
-                       m->mothurConvert(temp, taxLevelCutoff); 
-                       
-                       method = validParameter.validFile(parameters, "method", false);         if (method == "not found") { method = "average"; }
-                       
-                       if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((splitmethod == "distance") || (splitmethod == "classify") || (splitmethod == "fasta")) { }
-                       else { m->mothurOut(splitmethod + " is not a valid splitting method.  Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((splitmethod == "classify") && (taxFile == "")) {  m->mothurOut("You need to provide a taxonomy file if you are going to use the classify splitmethod."); m->mothurOutEndLine(); abort = true;  }
-
-                       showabund = validParameter.validFile(parameters, "showabund", false);
-                       if (showabund == "not found") { showabund = "T"; }
-
-                       timing = validParameter.validFile(parameters, "timing", false);
-                       if (timing == "not found") { timing = "F"; }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int ClusterSplitCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               time_t estart;
-               vector<string> listFileNames;
-               set<string> labels;
-               string singletonName = "";
-               double saveCutoff = cutoff;
-
-               //****************** file prep work ******************************//
-               #ifdef USE_MPI
-                       int pid;
-                       int tag = 2001;
-                       MPI_Status status; 
-                       MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                       
-                       if (pid == 0) { //only process 0 converts and splits
-                       
-               #endif
-               
-               //if user gave a phylip file convert to column file
-               if (format == "phylip") {
-                       estart = time(NULL);
-                       m->mothurOut("Converting to column format..."); m->mothurOutEndLine();
-                       
-                       ReadCluster* convert = new ReadCluster(distfile, cutoff, outputDir, false);
-                       
-                       NameAssignment* nameMap = NULL;
-                       convert->setFormat("phylip");
-                       convert->read(nameMap);
-                       
-                       if (m->control_pressed) {  delete convert;  return 0;  }
-                       
-                       distfile = convert->getOutputFile();
-               
-                       //if no names file given with phylip file, create it
-                       ListVector* listToMakeNameFile =  convert->getListVector();
-                       if (namefile == "") {  //you need to make a namefile for split matrix
-                               ofstream out;
-                               namefile = phylipfile + ".names";
-                               m->openOutputFile(namefile, out);
-                               for (int i = 0; i < listToMakeNameFile->getNumBins(); i++) {
-                                       string bin = listToMakeNameFile->get(i);
-                                       out << bin << '\t' << bin << endl;
-                               }
-                               out.close();
-                       }
-                       delete listToMakeNameFile;
-                       delete convert;
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to convert the distance file."); m->mothurOutEndLine();
-               }
-               if (m->control_pressed) { return 0; }
-               
-               estart = time(NULL);
-               m->mothurOut("Splitting the file..."); m->mothurOutEndLine();
-               
-               //split matrix into non-overlapping groups
-               SplitMatrix* split;
-               if (splitmethod == "distance")                  {       split = new SplitMatrix(distfile, namefile, taxFile, cutoff, splitmethod, large);                                                       }
-               else if (splitmethod == "classify")             {       split = new SplitMatrix(distfile, namefile, taxFile, taxLevelCutoff, splitmethod, large);                                       }
-               else if (splitmethod == "fasta")                {       split = new SplitMatrix(fastafile, namefile, taxFile, taxLevelCutoff, cutoff, splitmethod, processors, outputDir);      }
-               else { m->mothurOut("Not a valid splitting method.  Valid splitting algorithms are distance, classify or fasta."); m->mothurOutEndLine(); return 0;             }
-               
-               split->split();
-               
-               if (m->control_pressed) { delete split; return 0; }
-               
-               singletonName = split->getSingletonNames();
-               vector< map<string, string> > distName = split->getDistanceFiles();  //returns map of distance files -> namefile sorted by distance file size
-               delete split;
-               
-               //output a merged distance file
-               if (splitmethod == "fasta")             { createMergedDistanceFile(distName); }
-                       
-                               
-               if (m->control_pressed) { return 0; }
-               
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to split the distance file."); m->mothurOutEndLine();
-               estart = time(NULL);
-               
-               //****************** break up files between processes and cluster each file set ******************************//
-       #ifdef USE_MPI
-                       ////you are process 0 from above////
-                       
-                       vector < vector < map<string, string> > > dividedNames; //distNames[1] = vector of filenames for process 1...                           
-                       dividedNames.resize(processors);
-                                       
-                       //for each file group figure out which process will complete it
-                       //want to divide the load intelligently so the big files are spread between processes
-                       for (int i = 0; i < distName.size(); i++) { 
-                               int processToAssign = (i+1) % processors; 
-                               if (processToAssign == 0) { processToAssign = processors; }
-                                               
-                               dividedNames[(processToAssign-1)].push_back(distName[i]);
-                       }
-                                       
-                       //not lets reverse the order of ever other process, so we balance big files running with little ones
-                       for (int i = 0; i < processors; i++) {
-                               int remainder = ((i+1) % processors);
-                               if (remainder) {  reverse(dividedNames[i].begin(), dividedNames[i].end());  }
-                       }
-                       
-                       
-                       //send each child the list of files it needs to process
-                       for(int i = 1; i < processors; i++) { 
-                               //send number of file pairs
-                               int num = dividedNames[i].size();
-                               MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                               
-                               for (int j = 0; j < num; j++) { //send filenames to process i
-                                       char tempDistFileName[1024];
-                                       strcpy(tempDistFileName, (dividedNames[i][j].begin()->first).c_str());
-                                       int lengthDist = (dividedNames[i][j].begin()->first).length();
-                                       
-                                       MPI_Send(&lengthDist, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(tempDistFileName, 1024, MPI_CHAR, i, tag, MPI_COMM_WORLD);
-                                       
-                                       char tempNameFileName[1024];
-                                       strcpy(tempNameFileName, (dividedNames[i][j].begin()->second).c_str());
-                                       int lengthName = (dividedNames[i][j].begin()->second).length();
-
-                                       MPI_Send(&lengthName, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(tempNameFileName, 1024, MPI_CHAR, i, tag, MPI_COMM_WORLD);
-                               }
-                       }
-                       
-                       //process your share
-                       listFileNames = cluster(dividedNames[0], labels);
-                       
-                       //receive the other processes info
-                       for(int i = 1; i < processors; i++) { 
-                               int num = dividedNames[i].size();
-                               
-                               double tempCutoff;
-                               MPI_Recv(&tempCutoff, 1, MPI_DOUBLE, i, tag, MPI_COMM_WORLD, &status);
-                               if (tempCutoff < cutoff) { cutoff = tempCutoff; }
-                               
-                               //send list filenames to root process
-                               for (int j = 0; j < num; j++) {  
-                                       int lengthList = 0;
-                                       char tempListFileName[1024];
-                               
-                                       MPI_Recv(&lengthList, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(tempListFileName, 1024, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
-                               
-                                       string myListFileName = tempListFileName;
-                                       myListFileName = myListFileName.substr(0, lengthList);
-                                       
-                                       listFileNames.push_back(myListFileName);
-                               }
-                               
-                               //send Labels to root process
-                               int numLabels = 0;
-                               MPI_Recv(&numLabels, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                               
-                               for (int j = 0; j < numLabels; j++) {  
-                                       int lengthLabel = 0;
-                                       char tempLabel[100];
-                               
-                                       MPI_Recv(&lengthLabel, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(tempLabel, 100, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
-                               
-                                       string myLabel = tempLabel;
-                                       myLabel = myLabel.substr(0, lengthLabel);
-                       
-                                       if (labels.count(myLabel) == 0) { labels.insert(myLabel); }
-                               }
-                       }
-                       
-               }else { //you are a child process
-                       vector < map<string, string> >  myNames;
-                       
-                       //recieve the files you need to process
-                       //receive number of file pairs
-                       int num = 0;
-                       MPI_Recv(&num, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                       
-                       myNames.resize(num);
-       
-                       for (int j = 0; j < num; j++) { //receive filenames to process 
-                               int lengthDist = 0;
-                               char tempDistFileName[1024];
-                               
-                               MPI_Recv(&lengthDist, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(tempDistFileName, 1024, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status); 
-                               
-                               string myDistFileName = tempDistFileName;
-                               myDistFileName = myDistFileName.substr(0, lengthDist);
-                       
-                               int lengthName = 0;
-                               char tempNameFileName[1024];
-                               
-                               MPI_Recv(&lengthName, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(tempNameFileName, 1024, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status); 
-                               
-                               string myNameFileName = tempNameFileName;
-                               myNameFileName = myNameFileName.substr(0, lengthName);
-                               
-                               //save file name
-                               myNames[j][myDistFileName] = myNameFileName;
-                       }
-       
-                       //process them
-                       listFileNames = cluster(myNames, labels);
-                       
-                       //send cutoff
-                       MPI_Send(&cutoff, 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD);
-                       
-                       //send list filenames to root process
-                       for (int j = 0; j < num; j++) {  
-                               char tempListFileName[1024];
-                               strcpy(tempListFileName, listFileNames[j].c_str());
-                               int lengthList = listFileNames[j].length();
-                                       
-                               MPI_Send(&lengthList, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                               MPI_Send(tempListFileName, 1024, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                       }
-                       
-                       //send Labels to root process
-                       int numLabels = labels.size();
-                       MPI_Send(&numLabels, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                       
-                       for(set<string>::iterator it = labels.begin(); it != labels.end(); ++it) {
-                               char tempLabel[100];
-                               strcpy(tempLabel, (*it).c_str());
-                               int lengthLabel = (*it).length();
-                                       
-                               MPI_Send(&lengthLabel, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                               MPI_Send(tempLabel, 100, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                       }
-               }
-               
-               //make everyone wait
-               MPI_Barrier(MPI_COMM_WORLD);
-               
-       #else
-               ///////////////////// WINDOWS CAN ONLY USE 1 PROCESSORS ACCESS VIOLATION UNRESOLVED ///////////////////////
-               //sanity check
-               if (processors > distName.size()) { processors = distName.size(); }
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               if(processors == 1){
-                                       listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files
-                               }else{
-                                       listFileNames = createProcesses(distName, labels);
-                }
-               #else
-                               listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files
-               #endif
-       #endif  
-               if (m->control_pressed) { for (int i = 0; i < listFileNames.size(); i++) { m->mothurRemove(listFileNames[i]); } return 0; }
-               
-               if (saveCutoff != cutoff) { m->mothurOut("Cutoff was " + toString(saveCutoff) + " changed cutoff to " + toString(cutoff)); m->mothurOutEndLine();  }
-               
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster"); m->mothurOutEndLine();
-               
-               //****************** merge list file and create rabund and sabund files ******************************//
-               estart = time(NULL);
-               m->mothurOut("Merging the clustered files..."); m->mothurOutEndLine();
-               
-               #ifdef USE_MPI
-                       if (pid == 0) { //only process 0 merges
-               #endif
-
-               ListVector* listSingle;
-               map<float, int> labelBins = completeListFile(listFileNames, singletonName, labels, listSingle); //returns map of label to numBins
-               
-               if (m->control_pressed) { if (listSingle != NULL) { delete listSingle; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-               
-               mergeLists(listFileNames, labelBins, listSingle);
-
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-               
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to merge."); m->mothurOutEndLine();
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-                               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               #ifdef USE_MPI
-                       } //only process 0 merges
-                       
-                       //make everyone wait
-                       MPI_Barrier(MPI_COMM_WORLD);
-               #endif
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<float, int> ClusterSplitCommand::completeListFile(vector<string> listNames, string singleton, set<string>& userLabels, ListVector*& listSingle){
-       try {
-                               
-               map<float, int> labelBin;
-               vector<float> orderFloat;
-               int numSingleBins;
-               
-               //read in singletons
-               if (singleton != "none") {
-                       ifstream in;
-                       m->openInputFile(singleton, in);
-                               
-                       string firstCol, secondCol;
-                       listSingle = new ListVector();
-                       while (!in.eof()) {
-                               in >> firstCol >> secondCol; m->gobble(in);
-                               listSingle->push_back(secondCol);
-                       }
-                       in.close();
-                       m->mothurRemove(singleton);
-                       
-                       numSingleBins = listSingle->getNumBins();
-               }else{  listSingle = NULL; numSingleBins = 0;  }
-               
-               //go through users set and make them floats so we can sort them 
-               for(set<string>::iterator it = userLabels.begin(); it != userLabels.end(); ++it) {
-                       float temp = -10.0;
-
-                       if ((*it != "unique") && (convertTestFloat(*it, temp) == true)) {       convert(*it, temp);     }
-                       else if (*it == "unique")                                                                               {       temp = -1.0;            }
-                       
-                       if (temp <= cutoff) {
-                               orderFloat.push_back(temp);
-                               labelBin[temp] = numSingleBins; //initialize numbins 
-                       }
-               }
-       
-               //sort order
-               sort(orderFloat.begin(), orderFloat.end());
-               userLabels.clear();
-                       
-               //get the list info from each file
-               for (int k = 0; k < listNames.size(); k++) {
-       
-                       if (m->control_pressed) {  
-                               if (listSingle != NULL) { delete listSingle; listSingle = NULL; m->mothurRemove(singleton);  }
-                               for (int i = 0; i < listNames.size(); i++) {   m->mothurRemove(listNames[i]);  }
-                               return labelBin;
-                       }
-                       
-                       InputData* input = new InputData(listNames[k], "list");
-                       ListVector* list = input->getListVector();
-                       string lastLabel = list->getLabel();
-                       
-                       string filledInList = listNames[k] + "filledInTemp";
-                       ofstream outFilled;
-                       m->openOutputFile(filledInList, outFilled);
-       
-                       //for each label needed
-                       for(int l = 0; l < orderFloat.size(); l++){
-                       
-                               string thisLabel;
-                               if (orderFloat[l] == -1) { thisLabel = "unique"; }
-                               else { thisLabel = toString(orderFloat[l],  length-1);  } 
-
-                               //this file has reached the end
-                               if (list == NULL) { 
-                                       list = input->getListVector(lastLabel, true); 
-                               }else{  //do you have the distance, or do you need to fill in
-                                               
-                                       float labelFloat;
-                                       if (list->getLabel() == "unique") {  labelFloat = -1.0;  }
-                                       else { convert(list->getLabel(), labelFloat); }
-
-                                       //check for missing labels
-                                       if (labelFloat > orderFloat[l]) { //you are missing the label, get the next smallest one
-                                               //if its bigger get last label, otherwise keep it
-                                               delete list;
-                                               list = input->getListVector(lastLabel, true);  //get last list vector to use, you actually want to move back in the file
-                                       }
-                                       lastLabel = list->getLabel();
-                               }
-                               
-                               //print to new file
-                               list->setLabel(thisLabel);
-                               list->print(outFilled);
-               
-                               //update labelBin
-                               labelBin[orderFloat[l]] += list->getNumBins();
-                                                                       
-                               delete list;
-                                                                       
-                               list = input->getListVector();
-                       }
-                       
-                       if (list != NULL) { delete list; }
-                       delete input;
-                       
-                       outFilled.close();
-                       m->mothurRemove(listNames[k]);
-                       rename(filledInList.c_str(), listNames[k].c_str());
-               }
-               
-               return labelBin;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "completeListFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ClusterSplitCommand::mergeLists(vector<string> listNames, map<float, int> userLabels, ListVector* listSingle){
-       try {
-               if (outputDir == "") { outputDir += m->hasPath(distfile); }
-               fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
-               
-               m->openOutputFile(fileroot+ tag + ".sabund",    outSabund);
-               m->openOutputFile(fileroot+ tag + ".rabund",    outRabund);
-               m->openOutputFile(fileroot+ tag + ".list",              outList);
-                               
-               outputNames.push_back(fileroot+ tag + ".sabund");  outputTypes["list"].push_back(fileroot+ tag + ".list");
-               outputNames.push_back(fileroot+ tag + ".rabund");  outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               outputNames.push_back(fileroot+ tag + ".list");    outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               
-               map<float, int>::iterator itLabel;
-
-               //for each label needed
-               for(itLabel = userLabels.begin(); itLabel != userLabels.end(); itLabel++) {
-                       
-                       string thisLabel;
-                       if (itLabel->first == -1) { thisLabel = "unique"; }
-                       else { thisLabel = toString(itLabel->first,  length-1);  } 
-                       
-                       outList << thisLabel << '\t' << itLabel->second << '\t';
-
-                       RAbundVector* rabund = new RAbundVector();
-                       rabund->setLabel(thisLabel);
-
-                       //add in singletons
-                       if (listSingle != NULL) {
-                               for (int j = 0; j < listSingle->getNumBins(); j++) {
-                                       outList << listSingle->get(j) << '\t';
-                                       rabund->push_back(m->getNumNames(listSingle->get(j)));
-                               }
-                       }
-                       
-                       //get the list info from each file
-                       for (int k = 0; k < listNames.size(); k++) {
-       
-                               if (m->control_pressed) {  if (listSingle != NULL) { delete listSingle;   } for (int i = 0; i < listNames.size(); i++) { m->mothurRemove(listNames[i]);  } delete rabund; return 0; }
-                               
-                               InputData* input = new InputData(listNames[k], "list");
-                               ListVector* list = input->getListVector(thisLabel);
-                               
-                               //this file has reached the end
-                               if (list == NULL) { m->mothurOut("Error merging listvectors in file " + listNames[k]); m->mothurOutEndLine();  }        
-                               else {          
-                                       for (int j = 0; j < list->getNumBins(); j++) {
-                                               outList << list->get(j) << '\t';
-                                               rabund->push_back(m->getNumNames(list->get(j)));
-                                       }
-                                       delete list;
-                               }
-                               delete input;
-                       }
-                       
-                       SAbundVector sabund = rabund->getSAbundVector();
-                       
-                       sabund.print(outSabund);
-                       rabund->print(outRabund);
-                       outList << endl;
-                       
-                       delete rabund;
-               }
-               
-               outList.close();
-               outRabund.close();
-               outSabund.close();
-               
-               if (listSingle != NULL) { delete listSingle;  }
-               
-               for (int i = 0; i < listNames.size(); i++) {  m->mothurRemove(listNames[i]);  }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "mergeLists");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void ClusterSplitCommand::printData(ListVector* oldList){
-       try {
-               string label = oldList->getLabel();
-               RAbundVector oldRAbund = oldList->getRAbundVector();
-               
-               oldRAbund.setLabel(label);
-               if (m->isTrue(showabund)) {
-                       oldRAbund.getSAbundVector().print(cout);
-               }
-               oldRAbund.print(outRabund);
-               oldRAbund.getSAbundVector().print(outSabund);
-       
-               oldList->print(outList);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "printData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string>  ClusterSplitCommand::createProcesses(vector< map<string, string> > distName, set<string>& labels){
-       try {
-        
-        vector<string> listFiles;
-        vector < vector < map<string, string> > > dividedNames; //distNames[1] = vector of filenames for process 1...
-        dividedNames.resize(processors);
-        
-        //for each file group figure out which process will complete it
-        //want to divide the load intelligently so the big files are spread between processes
-        for (int i = 0; i < distName.size(); i++) { 
-            //cout << i << endl;
-            int processToAssign = (i+1) % processors; 
-            if (processToAssign == 0) { processToAssign = processors; }
-            
-            dividedNames[(processToAssign-1)].push_back(distName[i]);
-            if ((processToAssign-1) == 1) { m->mothurOut(distName[i].begin()->first + "\n"); }
-        }
-        
-        //not lets reverse the order of ever other process, so we balance big files running with little ones
-        for (int i = 0; i < processors; i++) {
-            //cout << i << endl;
-            int remainder = ((i+1) % processors);
-            if (remainder) {  reverse(dividedNames[i].begin(), dividedNames[i].end());  }
-        }
-        
-        if (m->control_pressed) { return listFiles; }
-       
-       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               processIDS.clear();
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               set<string> labels;
-                               vector<string> listFileNames = cluster(dividedNames[process], labels);
-                               
-                               //write out names to file
-                               string filename = toString(getpid()) + ".temp";
-                               ofstream out;
-                               m->openOutputFile(filename, out);
-                               out << tag << endl;
-                               for (int j = 0; j < listFileNames.size(); j++) { out << listFileNames[j] << endl;  }
-                               out.close();
-                               
-                               //print out labels
-                               ofstream outLabels;
-                               filename = toString(getpid()) + ".temp.labels";
-                               m->openOutputFile(filename, outLabels);
-                               
-                               outLabels << cutoff << endl;
-                               for (set<string>::iterator it = labels.begin(); it != labels.end(); it++) {
-                                       outLabels << (*it) << endl;
-                               }
-                               outLabels.close();
-
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-        //do your part
-        listFiles = cluster(dividedNames[0], labels);
-        
-               //force parent to wait until all the processes are done
-               for (int i=0;i< processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-        
-        //get list of list file names from each process
-        for(int i=0;i<processIDS.size();i++){
-            string filename = toString(processIDS[i]) + ".temp";
-            ifstream in;
-            m->openInputFile(filename, in);
-            
-            in >> tag; m->gobble(in);
-            
-            while(!in.eof()) {
-                string tempName;
-                in >> tempName; m->gobble(in);
-                listFiles.push_back(tempName);
-            }
-            in.close();
-            m->mothurRemove((toString(processIDS[i]) + ".temp"));
-            
-            //get labels
-            filename = toString(processIDS[i]) + ".temp.labels";
-            ifstream in2;
-            m->openInputFile(filename, in2);
-            
-            float tempCutoff;
-            in2 >> tempCutoff; m->gobble(in2);
-            if (tempCutoff < cutoff) { cutoff = tempCutoff; }
-            
-            while(!in2.eof()) {
-                string tempName;
-                in2 >> tempName; m->gobble(in2);
-                if (labels.count(tempName) == 0) { labels.insert(tempName); }
-            }
-            in2.close();
-            m->mothurRemove((toString(processIDS[i]) + ".temp.labels"));
-        }
-        
-
-    #else
-       
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the clusterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add labels.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<clusterData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       clusterData* tempCluster = new clusterData(dividedNames[i], m, cutoff, method, outputDir, hard, precision, length, i);
-                       pDataArray.push_back(tempCluster);
-                       processIDS.push_back(i);
-            
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyClusterThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);  
-            
-               }
-        
-        //do your part
-        listFiles = cluster(dividedNames[0], labels);
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-            //get tag
-            tag = pDataArray[i]->tag;
-            //get listfiles created
-            for(int j=0; j < pDataArray[i]->listFiles.size(); j++){ listFiles.push_back(pDataArray[i]->listFiles[j]); }
-            //get labels
-            set<string>::iterator it;
-            for(it = pDataArray[i]->labels.begin(); it != pDataArray[i]->labels.end(); it++){ labels.insert(*it); }
-                       //check cutoff
-            if (pDataArray[i]->cutoff < cutoff) { cutoff = pDataArray[i]->cutoff; }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-
-       #endif          
-        
-        return listFiles;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "createProcesses");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-vector<string> ClusterSplitCommand::cluster(vector< map<string, string> > distNames, set<string>& labels){
-       try {
-               
-               vector<string> listFileNames;
-               double smallestCutoff = cutoff;
-               
-               //cluster each distance file
-               for (int i = 0; i < distNames.size(); i++) {
-            
-            Cluster* cluster = NULL;
-            SparseMatrix* matrix = NULL;
-            ListVector* list = NULL;
-            ListVector oldList;
-            RAbundVector* rabund = NULL;
-            
-                       if (m->control_pressed) { return listFileNames; }
-                       
-                       string thisNamefile = distNames[i].begin()->second;
-                       string thisDistFile = distNames[i].begin()->first;
-                                               
-                       #ifdef USE_MPI
-                               int pid;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               
-                               //output your files too
-                               if (pid != 0) {
-                                       cout << endl << "Reading " << thisDistFile << endl;
-                               }
-                       #endif
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Reading " + thisDistFile); m->mothurOutEndLine();
-                       
-                       ReadMatrix* read = new ReadColumnMatrix(thisDistFile);  
-                       read->setCutoff(cutoff);
-
-                       NameAssignment* nameMap = new NameAssignment(thisNamefile);
-                       nameMap->readMap();
-                       read->read(nameMap);
-                       
-                       if (m->control_pressed) {  delete read; delete nameMap; return listFileNames; }
-                       
-                       list = read->getListVector();
-                       oldList = *list;
-                       matrix = read->getMatrix();
-                       
-                       delete read;  read = NULL;
-                       delete nameMap; nameMap = NULL;
-                       
-                       
-                       #ifdef USE_MPI
-                               //output your files too
-                               if (pid != 0) {
-                                       cout << endl << "Clustering " << thisDistFile << endl;
-                               }
-                       #endif
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Clustering " + thisDistFile); m->mothurOutEndLine();
-               
-                       rabund = new RAbundVector(list->getRAbundVector());
-                       
-                       //create cluster
-                       if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, matrix, cutoff, method); }
-                       else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, matrix, cutoff, method); }
-                       else if(method == "average"){   cluster = new AverageLinkage(rabund, list, matrix, cutoff, method);     }
-                       tag = cluster->getTag();
-               
-                       if (outputDir == "") { outputDir += m->hasPath(thisDistFile); }
-                       fileroot = outputDir + m->getRootName(m->getSimpleName(thisDistFile));
-                       
-                       ofstream listFile;
-                       m->openOutputFile(fileroot+ tag + ".list",      listFile);
-               
-                       listFileNames.push_back(fileroot+ tag + ".list");
-                               
-                       float previousDist = 0.00000;
-                       float rndPreviousDist = 0.00000;
-                       
-                       oldList = *list;
-
-                       print_start = true;
-                       start = time(NULL);
-                       double saveCutoff = cutoff;
-               
-                       while (matrix->getSmallDist() < cutoff && matrix->getNNodes() > 0){
-               
-                               if (m->control_pressed) { //clean up
-                                       delete matrix; delete list;     delete cluster; delete rabund;
-                                       listFile.close();
-                                       for (int i = 0; i < listFileNames.size(); i++) {        m->mothurRemove(listFileNames[i]);      }
-                                       listFileNames.clear(); return listFileNames;
-                               }
-               
-                               cluster->update(saveCutoff);
-       
-                               float dist = matrix->getSmallDist();
-                               float rndDist;
-                               if (hard) {
-                                       rndDist = m->ceilDist(dist, precision); 
-                               }else{
-                                       rndDist = m->roundDist(dist, precision); 
-                               }
-
-                               if(previousDist <= 0.0000 && dist != previousDist){
-                                       oldList.setLabel("unique");
-                                       oldList.print(listFile);
-                                       if (labels.count("unique") == 0) {  labels.insert("unique");  }
-                               }
-                               else if(rndDist != rndPreviousDist){
-                                       oldList.setLabel(toString(rndPreviousDist,  length-1));
-                                       oldList.print(listFile);
-                                       if (labels.count(toString(rndPreviousDist,  length-1)) == 0) { labels.insert(toString(rndPreviousDist,  length-1)); }
-                               }
-               
-                               previousDist = dist;
-                               rndPreviousDist = rndDist;
-                               oldList = *list;
-                       }
-
-               
-                       if(previousDist <= 0.0000){
-                               oldList.setLabel("unique");
-                               oldList.print(listFile);
-                               if (labels.count("unique") == 0) { labels.insert("unique"); }
-                       }
-                       else if(rndPreviousDist<cutoff){
-                               oldList.setLabel(toString(rndPreviousDist,  length-1));
-                               oldList.print(listFile);
-                               if (labels.count(toString(rndPreviousDist,  length-1)) == 0) { labels.insert(toString(rndPreviousDist,  length-1)); }
-                       }
-       
-                       delete matrix; delete list;     delete cluster; delete rabund; 
-            matrix = NULL; list = NULL; cluster = NULL; rabund = NULL;
-                       listFile.close();
-                       
-                       if (m->control_pressed) { //clean up
-                               for (int i = 0; i < listFileNames.size(); i++) {        m->mothurRemove(listFileNames[i]);      }
-                               listFileNames.clear(); return listFileNames;
-                       }
-                       
-                       m->mothurRemove(thisDistFile);
-                       m->mothurRemove(thisNamefile);
-                       
-                       if (saveCutoff != cutoff) { 
-                               if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-                               else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-                       
-                               m->mothurOut("Cutoff was " + toString(cutoff) + " changed cutoff to " + toString(saveCutoff)); m->mothurOutEndLine();  
-                       }
-                       
-                       if (saveCutoff < smallestCutoff) { smallestCutoff = saveCutoff;  }
-               }
-               
-               cutoff = smallestCutoff;
-                                       
-               return listFileNames;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "cluster");
-               exit(1);
-       }
-
-
-}
-//**********************************************************************************************************************
-
-int ClusterSplitCommand::createMergedDistanceFile(vector< map<string, string> > distNames) {
-       try{
-               
-#ifdef USE_MPI
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               if (pid != 0) {
-#endif
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") { thisOutputDir = m->hasPath(fastafile); }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist";
-               m->mothurRemove(outputFileName);
-               
-               
-               for (int i = 0; i < distNames.size(); i++) {
-                       if (m->control_pressed) {  return 0; }
-                       
-                       string thisDistFile = distNames[i].begin()->first;
-                       
-                       m->appendFiles(thisDistFile, outputFileName);
-               }       
-                       
-               outputTypes["column"].push_back(outputFileName); outputNames.push_back(outputFileName);
-                       
-#ifdef USE_MPI
-               }
-#endif
-                               
-               return 0;       
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ClusterSplitCommand", "createMergedDistanceFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/clustersplitcommand.h b/clustersplitcommand.h
deleted file mode 100644 (file)
index 0e32ffa..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-#ifndef CLUSTERSPLITCOMMAND_H
-#define CLUSTERSPLITCOMMAND_H
-
-/*
- *  clustersplitcommand.h
- *  Mothur
- *
- *  Created by westcott on 5/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "listvector.hpp"
-#include "cluster.hpp"
-#include "sparsematrix.hpp"
-#include "readcluster.h"
-#include "splitmatrix.h"
-#include "readphylip.h"
-#include "readcolumn.h"
-#include "readmatrix.hpp"
-#include "inputdata.h"
-#include "clustercommand.h"
-
-class ClusterSplitCommand : public Command {
-       
-public:
-       ClusterSplitCommand(string);
-       ClusterSplitCommand();
-       ~ClusterSplitCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "cluster.split";               }
-       string getCommandCategory()             { return "Clustering";                  }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol. \nhttp://www.mothur.org/wiki/Cluster.split"; }
-       string getDescription()         { return "splits your sequences by distance or taxonomy then clusters into OTUs"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-
-private:
-       vector<int> processIDS;   //processid
-       vector<string> outputNames;
-       
-       string method, fileroot, tag, outputDir, phylipfile, columnfile, namefile, distfile, format, showabund, timing, splitmethod, taxFile, fastafile;
-       double cutoff, splitcutoff;
-       int precision, length, processors, taxLevelCutoff;
-       bool print_start, abort, hard, large;
-       time_t start;
-       ofstream outList, outRabund, outSabund;
-       
-       void printData(ListVector*);
-       vector<string> createProcesses(vector< map<string, string> >, set<string>&);
-       vector<string> cluster(vector< map<string, string> >, set<string>&);
-       int mergeLists(vector<string>, map<float, int>, ListVector*);
-       map<float, int> completeListFile(vector<string>, string, set<string>&, ListVector*&);
-       int createMergedDistanceFile(vector< map<string, string> >);
-};
-
-/////////////////not working for Windows////////////////////////////////////////////////////////////
-// getting an access violation error.  This is most likely caused by the 
-// threads stepping on eachother's structures, as I can run the thread function and the cluster fuction 
-// in separately without errors occuring.  I suspect it may be in the use of the
-// static class mothurOut, but I can't pinpoint the problem.  All other objects are made new
-// within the thread.  MothurOut is used by almost all the classes in mothur, so if this was 
-// really the cause I would expect to see all the windows threaded commands to have issues, but not 
-// all do. So far, shhh.flows and trim.flows have similiar problems. Other thoughts, could it have 
-// anything to do with mothur's use of copy constructors in many of our data structures. ie. listvector 
-// is copied by nameassignment and passed to read which passes to the thread?  -westcott 2-8-12
-////////////////////////////////////////////////////////////////////////////////////////////////////
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct clusterData {
-       set<string> labels;
-       vector < map<string, string> > distNames; 
-       string method; 
-    MothurOut* m;
-       double cutoff, precision;
-    string tag, outputDir;
-    vector<string> listFiles;
-    bool hard;
-    int length, threadID;
-       
-       
-       clusterData(){}
-       clusterData(vector < map<string, string> > dv, MothurOut* mout, double cu, string me, string ou, bool hd, double pre, int len, int th) {
-               distNames = dv;
-               m = mout;
-               cutoff = cu;
-        method = me;
-               outputDir = ou;
-        hard = hd;
-        precision = pre;
-        length = len;
-        threadID = th;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyClusterThreadFunction(LPVOID lpParam){ 
-       clusterData* pDataArray;
-       pDataArray = (clusterData*)lpParam;
-       
-       try {
-               cout << "starting " << endl;            
-               
-               double smallestCutoff = pDataArray->cutoff;
-               
-               //cluster each distance file
-               for (int i = 0; i < pDataArray->distNames.size(); i++) {
-            
-            Cluster* mycluster = NULL;
-            SparseMatrix* mymatrix = NULL;
-            ListVector* mylist = NULL;
-            ListVector myoldList;
-            RAbundVector* myrabund = NULL;
-                        
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       string thisNamefile = pDataArray->distNames[i].begin()->second;
-                       string thisDistFile = pDataArray->distNames[i].begin()->first;
-            cout << thisNamefile << '\t' << thisDistFile << endl;      
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Reading " + thisDistFile); pDataArray->m->mothurOutEndLine();
-                       
-                       ReadMatrix* myread = new ReadColumnMatrix(thisDistFile);        
-                       myread->setCutoff(pDataArray->cutoff);
-                       NameAssignment* mynameMap = new NameAssignment(thisNamefile);
-                       mynameMap->readMap();
-            cout << "done reading " << thisNamefile << endl;  
-                       myread->read(mynameMap);
-                       cout << "done reading " << thisDistFile << endl;  
-                       if (pDataArray->m->control_pressed) {  delete myread; delete mynameMap; break; }
-            
-                       mylist = myread->getListVector();
-                       myoldList = *mylist;
-                       mymatrix = myread->getMatrix();
-            cout << "here" << endl;    
-                       delete myread; myread = NULL;
-                       delete mynameMap; mynameMap = NULL;
-                       
-            pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Clustering " + thisDistFile); pDataArray->m->mothurOutEndLine();
-            
-                       myrabund = new RAbundVector(mylist->getRAbundVector());
-                        cout << "here" << endl;        
-                       //create cluster
-                       if (pDataArray->method == "furthest")   {       mycluster = new CompleteLinkage(myrabund, mylist, mymatrix, pDataArray->cutoff, pDataArray->method); }
-                       else if(pDataArray->method == "nearest"){       mycluster = new SingleLinkage(myrabund, mylist, mymatrix, pDataArray->cutoff, pDataArray->method); }
-                       else if(pDataArray->method == "average"){       mycluster = new AverageLinkage(myrabund, mylist, mymatrix, pDataArray->cutoff, pDataArray->method);     }
-                       pDataArray->tag = mycluster->getTag();
-             cout << "here" << endl;   
-                       if (pDataArray->outputDir == "") { pDataArray->outputDir += pDataArray->m->hasPath(thisDistFile); }
-                       string fileroot = pDataArray->outputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(thisDistFile));
-                        cout << "here" << endl;        
-                       ofstream listFile;
-                       pDataArray->m->openOutputFile(fileroot+ pDataArray->tag + ".list",      listFile);
-             cout << "here" << endl;   
-                       pDataArray->listFiles.push_back(fileroot+ pDataArray->tag + ".list");
-            
-                       float previousDist = 0.00000;
-                       float rndPreviousDist = 0.00000;
-                       
-                       myoldList = *mylist;
-        
-                       bool print_start = true;
-                       int start = time(NULL);
-                       double saveCutoff = pDataArray->cutoff;
-            
-                       while (mymatrix->getSmallDist() < pDataArray->cutoff && mymatrix->getNNodes() > 0){
-                
-                               if (pDataArray->m->control_pressed) { //clean up
-                                       delete mymatrix; delete mylist; delete mycluster; delete myrabund;
-                                       listFile.close();
-                                       for (int i = 0; i < pDataArray->listFiles.size(); i++) {        pDataArray->m->mothurRemove(pDataArray->listFiles[i]);  }
-                                       pDataArray->listFiles.clear(); break;
-                               }
-                
-                               mycluster->update(saveCutoff);
-                
-                               float dist = mymatrix->getSmallDist();
-                               float rndDist;
-                               if (pDataArray->hard) {
-                                       rndDist = pDataArray->m->ceilDist(dist, pDataArray->precision); 
-                               }else{
-                                       rndDist = pDataArray->m->roundDist(dist, pDataArray->precision); 
-                               }
-                
-                               if(previousDist <= 0.0000 && dist != previousDist){
-                                       myoldList.setLabel("unique");
-                                       myoldList.print(listFile);
-                                       if (pDataArray->labels.count("unique") == 0) {  pDataArray->labels.insert("unique");  }
-                               }
-                               else if(rndDist != rndPreviousDist){
-                                       myoldList.setLabel(toString(rndPreviousDist,  pDataArray->length-1));
-                                       myoldList.print(listFile);
-                                       if (pDataArray->labels.count(toString(rndPreviousDist,  pDataArray->length-1)) == 0) { pDataArray->labels.insert(toString(rndPreviousDist,  pDataArray->length-1)); }
-                               }
-                       
-                               previousDist = dist;
-                               rndPreviousDist = rndDist;
-                               myoldList = *mylist;
-                       }
-            
-             cout << "here2" << endl;  
-                       if(previousDist <= 0.0000){
-                               myoldList.setLabel("unique");
-                               myoldList.print(listFile);
-                               if (pDataArray->labels.count("unique") == 0) { pDataArray->labels.insert("unique"); }
-                       }
-                       else if(rndPreviousDist<pDataArray->cutoff){
-                               myoldList.setLabel(toString(rndPreviousDist,  pDataArray->length-1));
-                               myoldList.print(listFile);
-                               if (pDataArray->labels.count(toString(rndPreviousDist,  pDataArray->length-1)) == 0) { pDataArray->labels.insert(toString(rndPreviousDist,  pDataArray->length-1)); }
-                       }
-            
-                       delete mymatrix; delete mylist; delete mycluster; delete myrabund; 
-            mymatrix = NULL; mylist = NULL; mycluster = NULL; myrabund = NULL;
-                       listFile.close();
-                       
-                       if (pDataArray->m->control_pressed) { //clean up
-                               for (int i = 0; i < pDataArray->listFiles.size(); i++) {        pDataArray->m->mothurRemove(pDataArray->listFiles[i]);  }
-                               pDataArray->listFiles.clear(); break;
-                       }
-                        cout << "here3" << endl;       
-                       pDataArray->m->mothurRemove(thisDistFile);
-                       pDataArray->m->mothurRemove(thisNamefile);
-                        cout << "here4" << endl;       
-                       if (saveCutoff != pDataArray->cutoff) { 
-                               if (pDataArray->hard)   {  saveCutoff = pDataArray->m->ceilDist(saveCutoff, pDataArray->precision);     }
-                               else            {       saveCutoff = pDataArray->m->roundDist(saveCutoff, pDataArray->precision);  }
-                
-                               pDataArray->m->mothurOut("Cutoff was " + toString(pDataArray->cutoff) + " changed cutoff to " + toString(saveCutoff)); pDataArray->m->mothurOutEndLine();  
-                       }
-                        cout << "here5" << endl;       
-                       if (saveCutoff < smallestCutoff) { smallestCutoff = saveCutoff;  }
-               }
-               
-               pDataArray->cutoff = smallestCutoff;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ClusterSplitCommand", "MyClusterThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-
-
-#endif
-
diff --git a/cmdargs.cpp b/cmdargs.cpp
deleted file mode 100644 (file)
index 929b4aa..0000000
+++ /dev/null
@@ -1,529 +0,0 @@
-/*
- * cmdargs.c
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-
-#ifdef USE_GNU
-#include <getopt.h>
-#else
-#include "getopt_long.h"
-#endif /* USE_GNU*/
-
-
-#include "clearcut.h"
-#include "cmdargs.h"
-
-
-/*
- * NJ_handle_args() - 
- *
- */
-NJ_ARGS *
-NJ_handle_args(int argc,
-              char *argv[]) {
-  
-  static NJ_ARGS nj_args;
-  int option_index, c;
-  
-  optind = 0;  //neccasary to read in arguments if code is run more than once
-
-  struct option NJ_long_options[] = {
-
-    /* These options don't set a flag */
-    {"in",        required_argument, NULL, 'i'},
-    {"out",       required_argument, NULL, 'o'},
-    {"seed",      required_argument, NULL, 's'},
-    {"matrixout", required_argument, NULL, 'm'},
-    {"ntrees",    required_argument, NULL, 'n'},
-
-    /* These options set a flag */
-    {"verbose",      no_argument, &(nj_args.verbose_flag),  1},
-    {"quiet",        no_argument, &(nj_args.quiet_flag),    1},
-    {"distance",     no_argument, &(nj_args.input_mode),    NJ_INPUT_MODE_DISTANCE}, 
-    {"alignment",    no_argument, &(nj_args.input_mode),    NJ_INPUT_MODE_ALIGNED_SEQUENCES},
-    {"help",         no_argument, &(nj_args.help),          1},
-    {"version",      no_argument, &(nj_args.version),       1},
-    {"norandom",     no_argument, &(nj_args.norandom),      1},
-    {"shuffle",      no_argument, &(nj_args.shuffle),       1},
-    {"stdin",        no_argument, &(nj_args.stdin_flag),    1},
-    {"stdout",       no_argument, &(nj_args.stdout_flag),   1},
-    {"dna",          no_argument, &(nj_args.dna_flag),      1},
-    {"DNA",          no_argument, &(nj_args.dna_flag),      1},
-    {"protein",      no_argument, &(nj_args.protein_flag),  1},
-    {"neighbor",     no_argument, &(nj_args.neighbor),      1},
-    {"expblen",      no_argument, &(nj_args.expblen),       1},
-    {"expdist",      no_argument, &(nj_args.expdist),       1}, 
-
-    {"jukes",        no_argument, &(nj_args.jukes_flag),    1},
-    {"kimura",       no_argument, &(nj_args.kimura_flag),   1},
-    
-    {0, 0, 0, 0}
-
-  };
-  
-  /* initializes options to their default */
-  nj_args.infilename       = NULL;
-  nj_args.outfilename      = NULL;
-  nj_args.matrixout        = NULL;
-  nj_args.seed             = time(0);
-  nj_args.verbose_flag     = 0;
-  nj_args.quiet_flag       = 0;
-  nj_args.input_mode       = NJ_INPUT_MODE_DISTANCE;
-  nj_args.help             = 0;
-  nj_args.version          = 0;
-  nj_args.norandom         = 0;
-  nj_args.shuffle          = 0;
-  nj_args.stdin_flag       = 0;
-  nj_args.stdout_flag      = 0;
-  nj_args.dna_flag         = 0;
-  nj_args.protein_flag     = 0;
-  nj_args.correction_model = NJ_MODEL_NONE;
-  nj_args.jukes_flag       = 0;
-  nj_args.kimura_flag      = 0;
-  nj_args.neighbor         = 0;
-  nj_args.ntrees           = 1;
-  nj_args.expblen          = 0;
-  nj_args.expdist          = 0;
-
-  while(1) {
-
-    c = getopt_long(argc,
-                   argv,
-                   "i:o:s:m:n:vqduahVSIOrDPjkNeE",
-                   NJ_long_options,
-                   &option_index);
-    if(c == -1) {
-      break;
-    }
-//printf("%d\t%d\n", option_index, argc);
-//for (int red = 0; red < argc; red++) { printf("%s\n", argv[red]); }
-    switch(c) {
-
-    case 0:
-      if(NJ_long_options[option_index].flag) {
-       break;
-      }
-
-      printf("option %s", NJ_long_options[option_index].name);
-      if(optarg) {
-       printf(" with arg %s", optarg);
-      }
-      printf("\n");
-      break;
-
-    case 'i':
-      nj_args.infilename = optarg;
-      break;
-
-    case 'o':
-      nj_args.outfilename = optarg;
-      break;
-
-    case 's':
-      nj_args.seed = atoi(optarg);
-      break;
-
-    case 'm':
-      nj_args.matrixout = optarg;
-      break;
-
-    case 'n':
-      nj_args.ntrees = atoi(optarg);
-      break;
-
-    case 'v':
-      nj_args.verbose_flag = 1;
-      break; 
-
-    case 'q':
-      nj_args.quiet_flag = 1;
-      break;
-
-    case 'd':
-      nj_args.input_mode = NJ_INPUT_MODE_DISTANCE;
-      break;
-
-    case 'a':
-      nj_args.input_mode = NJ_INPUT_MODE_ALIGNED_SEQUENCES;
-      break;
-
-    case 'h':
-      nj_args.help = 1;
-      break;
-
-    case 'V':
-      nj_args.version = 1;
-      break;
-
-    case 'S':
-      nj_args.shuffle = 1;
-      break;
-      
-    case 'I':
-      nj_args.stdin_flag = 1;
-      break;
-
-    case 'O':
-      nj_args.stdin_flag = 1;
-      break;
-
-    case 'r':
-      nj_args.norandom = 1;
-      break;
-
-    case 'D':
-      nj_args.dna_flag = 1;
-      break;
-
-    case 'P':
-      nj_args.protein_flag = 1;
-      break;
-
-    case 'j':
-      nj_args.jukes_flag = 1;
-      break;
-
-    case 'k':
-      nj_args.kimura_flag = 1;
-      break;
-
-    case 'N':
-      nj_args.neighbor = 1;
-      break;
-
-    case 'e':
-      nj_args.expblen = 1;
-      break;
-
-    case 'E':
-      nj_args.expdist = 1;
-      break;
-
-   default:
-     NJ_usage();
-     exit(-1);
-    }
-  }
-  if(optind < argc) {
-    fprintf(stderr, "Clearcut: Unknown command-line argument:\n  --> %s\n", argv[optind]);
-    NJ_usage();
-    exit(-1);
-  }
-  
-  if(nj_args.version) {
-    printf("Clearcut Version: %s\n", NJ_VERSION);
-   //exit(0);
-  }
-  
-  if(nj_args.help) {
-    NJ_usage();
-    //exit(0);
-  }
-  
-  /* if stdin & explicit filename are specified for input */
-  if(nj_args.stdin_flag) {
-    if(nj_args.infilename) {
-      fprintf(stderr, "Clearcut:  Ambiguous input source specified.  Specify input filename OR stdin.\n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-
-  /* if stdout & explicit filename are specified for output */
-  if(nj_args.stdout_flag) {
-    if(nj_args.outfilename) {
-      fprintf(stderr, "Clearcut:  Ambiguous output specified.  Specify output filename OR stdout.\n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-
-  /* if user did not specify stdin or filename, default to stdin */
-  if(!nj_args.stdin_flag) {
-    if(!nj_args.infilename) {
-
-      fprintf(stderr, "Clearcut: No input file specified.  Using stdin.\n");
-      nj_args.stdin_flag = 1;
-    }
-  }
-  
-  /* if user did not specify stdout or filename, default to stdout */
-  if(!nj_args.stdout_flag) {
-    if(!nj_args.outfilename) {
-      
-      fprintf(stderr, "Clearcut: No output file specified.  Using stdout.\n");
-      nj_args.stdout_flag = 1;
-    }
-  }
-  
-  /* User must specify distance matrix or alignment */
-  if(nj_args.input_mode == NJ_INPUT_MODE_UNKNOWN) {
-    fprintf(stderr, "Clearcut: Must specify input type (--distance | --alignment)\n");
-    NJ_usage();
-    exit(-1);
-  }
-
-  /* do not allow protein or DNA options for distance matrix input */
-  if(nj_args.input_mode == NJ_INPUT_MODE_DISTANCE) {
-    if(nj_args.dna_flag || nj_args.protein_flag) {
-      fprintf(stderr, "Clearcut:  Ambiguous arguments.  (--protein | --DNA) do not apply to distance \n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-  
-  /* make sure different filenames were specified for input and output */
-  if(!nj_args.stdin_flag && !nj_args.stdout_flag) {
-
-    if(!strcmp(nj_args.infilename, nj_args.outfilename)) {
-      fprintf(stderr, "Clearcut: Input filename and output filename must be unique.\n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-
-  /* make sure that user specifies DNA or Protein if dealing with alignment input */
-  if(nj_args.input_mode == NJ_INPUT_MODE_ALIGNED_SEQUENCES) {
-    if(!nj_args.dna_flag && !nj_args.protein_flag) {
-      fprintf(stderr, "Clearcut: Must specify protein or DNA for alignment input.\n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-
-  /* make sure that user does not specify both protein and DNA when dealing with alignment input */
-  if(nj_args.input_mode == NJ_INPUT_MODE_ALIGNED_SEQUENCES) {
-    if(nj_args.dna_flag && nj_args.protein_flag) {
-      fprintf(stderr, "Clearcut: Specifying protein and DNA sequences are mutually exclusive options\n");
-      NJ_usage();
-      exit(-1);
-    }
-  }
-
-  /* make sure verbose and quiet were not specified together */
-  if(nj_args.verbose_flag && nj_args.quiet_flag) {
-    fprintf(stderr, "Clearcut: Verbose and Quiet mode are mutually exclusive.\n");
-    NJ_usage();
-    exit(-1);
-  }
-  
-  /* make sure that a correction model was specified only when providing an alignment */
-  if(nj_args.input_mode == NJ_INPUT_MODE_DISTANCE) {
-    if(nj_args.jukes_flag || nj_args.kimura_flag) {
-      fprintf(stderr, "Clearcut:  Only specify correction model for alignment input.\n");
-      NJ_usage();
-      exit(-1);
-    }
-  } else {
-    if(nj_args.jukes_flag && nj_args.kimura_flag) {
-      fprintf(stderr, "Clearcut:  Only specify one correction model\n");
-      NJ_usage();
-      exit(-1);
-    } else {
-      if(nj_args.jukes_flag && !nj_args.kimura_flag) {
-       nj_args.correction_model = NJ_MODEL_JUKES;
-      } else if(nj_args.kimura_flag && !nj_args.jukes_flag) {
-       nj_args.correction_model = NJ_MODEL_KIMURA;
-      } else {
-       nj_args.correction_model = NJ_MODEL_NONE;  /* DEFAULT */
-      }
-    }
-  }
-  
-  /* make sure that the number of output trees is reasonable */
-  if(nj_args.ntrees <= 0) {
-    fprintf(stderr, "Clearcut: Number of output trees must be a positive integer.\n");
-    NJ_usage();
-    exit(-1);
-  }
-  
-  /* 
-   * make sure that if exponential distances are specified, 
-   * we are dealing with alignment input
-   */
-  if(nj_args.expdist && nj_args.input_mode != NJ_INPUT_MODE_ALIGNED_SEQUENCES) {
-    fprintf(stderr, "Clearcut: Exponential notation for distance matrix output requires that input be an alignment\n");
-    NJ_usage();
-    exit(-1);
-  }
-  
-  return(&nj_args);
-}
-
-
-
-
-
-/*
- * NJ_print_args() - 
- *
- */
-void
-NJ_print_args(NJ_ARGS *nj_args) {
-  
-  char input_mode[32];
-  
-  switch (nj_args->input_mode) {
-  case NJ_INPUT_MODE_DISTANCE:
-    sprintf(input_mode, "Distance Matrix");
-    break;
-  case NJ_INPUT_MODE_UNALIGNED_SEQUENCES:
-    sprintf(input_mode, "Unaligned Sequences");
-    break;
-  case NJ_INPUT_MODE_ALIGNED_SEQUENCES:
-    sprintf(input_mode, "Aligned Sequences");
-    break;
-  default:
-    sprintf(input_mode, "UNKNOWN");
-    break;
-  }
-
-  printf("\n***  Command Line Arguments ***\n");
-  
-  printf("Input Mode: %s\n", input_mode);
-  
-  if(nj_args->stdin_flag) {
-    printf("Input from STDIN\n");
-  } else {
-    printf("Input File: %s\n", nj_args->infilename);
-  }
-
-  if(nj_args->stdout_flag) {
-    printf("Output from STDOUT\n");
-  } else {
-    printf("Output File: %s\n", nj_args->outfilename);
-  }
-  
-  if(nj_args->input_mode != NJ_INPUT_MODE_DISTANCE) {
-    if(nj_args->aligned_flag) {
-      printf("Input Sequences Aligned: YES\n");
-    } else {
-      printf("Input Sequences Aligned:  NO\n");
-    }
-  }
-  
-  if(nj_args->verbose_flag) {
-    printf("Verbose Mode: ON\n");
-  } else {
-    printf("Verbose Mode: OFF\n");
-  }
-  
-  if(nj_args->quiet_flag) {
-    printf("Quiet Mode: ON\n");
-  } else {
-    printf("Quiet Mode: OFF\n");
-  }
-  
-  if(nj_args->seed) {
-    printf("Random Seed: %d\n", nj_args->seed);
-  }
-  
-  printf("\n*******\n");
-  
-  return;
-}
-
-
-
-
-/*
- * NJ_usage() -
- *
- * Print a usage message
- *
- */
-void
-NJ_usage(void) {
-  
-  printf("Usage: clearcut --in=<infilename> --out=<outfilename> [options]...\n");
-  printf("GENERAL OPTIONS:\n");
-  printf("  -h, --help         Display this information.\n");
-  printf("  -V, --version      Print the version of this program.\n");
-  printf("  -v, --verbose      More output. (Default: OFF)\n");
-  printf("  -q, --quiet        Silent operation. (Default: ON)\n");
-  printf("  -s, --seed=<seed>  Explicitly set the PRNG seed to a specific value.\n");
-  printf("  -r, --norandom     Attempt joins deterministically.  (Default: OFF)\n");
-  printf("  -S, --shuffle      Randomly shuffle the distance matrix.  (Default: OFF)\n");
-  printf("  -N, --neighbor     Use traditional Neighbor-Joining algorithm. (Default: OFF)\n");
-
-  printf("\n");
-  printf("INPUT OPTIONS:\n");
-  printf("  -I, --stdin        Read input from STDIN.\n");
-  printf("  -d, --distance     Input file is a distance matrix. (Default: ON)\n");
-  printf("  -a, --alignment    Input file is a set of aligned sequences. (Default: OFF)\n");
-  printf("  -D, --DNA          Input alignment are DNA sequences.\n");
-  printf("  -P, --protein      Input alignment are protein sequences.\n");
-
-  printf("\n");
-  printf("CORRECTION MODEL FOR COMPUTING DISTANCE MATRIX (Default: NO Correction):\n");
-  printf("  -j, --jukes        Use Jukes-Cantor correction for computing distance matrix.\n");
-  printf("  -k, --kimura       Use Kimura correction for distance matrix.\n");
-  
-  printf("\n");
-  printf("OUTPUT OPTIONS:\n");
-  printf("  -O, --stdout           Output tree to STDOUT.\n");
-  printf("  -m, --matrixout=<file> Output distance matrix to specified file.\n");
-  printf("  -n, --ntrees=<n>       Output n trees.  (Default: 1)\n");
-  printf("  -e, --expblen          Exponential notation for branch lengths. (Default: OFF)\n");
-  printf("  -E, --expdist          Exponential notation in distance output. (Default: OFF)\n");
-  
-  printf("\n");
-  printf("EXAMPLES:\n");
-  printf("  Compute tree by supplying distance matrix via stdin:\n");
-  printf("  clearcut --distance < distances.txt > treefile.tre\n");
-  printf("\n");
-  printf("  Compute tree by supplying an alignment of DNA sequences from a file:\n");
-  printf("  clearcut --alignment --DNA --in=alignment.txt --out=treefile.tre\n");
-  
-  return;
-}
-
-
-
diff --git a/cmdargs.h b/cmdargs.h
deleted file mode 100644 (file)
index d44a330..0000000
--- a/cmdargs.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * njdist.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_NJ_CMDARGS_H_
-#define _INC_NJ_CMDARGS_H_ 1
-
-#include "clearcut.h"
-
-
-/* some datatypes */
-typedef struct _STRUCT_NJ_ARGS {
-
-  char *infilename;   /* the name of the input file                  */
-  char *outfilename;  /* the name of the output tree                 */
-  char *matrixout;    /* the name of the distance matrix output file */
-
-  int input_mode;  
-  int aligned_flag;
-  
-  int verbose_flag;
-  int quiet_flag;
-
-  int stdin_flag;
-  int stdout_flag;
-  
-  int help;
-  int version;
-
-  int norandom;
-  int shuffle;
-  
-  int dna_flag;
-  int protein_flag;
-  
-  int seed;
-
-  /* correction models for distance */
-  int correction_model;
-  int jukes_flag;
-  int kimura_flag;
-  
-  /* flag for using traditional neighbor-joining */
-  int neighbor;
-  
-  /* number of trees to output */
-  int ntrees;
-  
-  /* exponential notation output */
-  int expblen;  /* exp notation for tree branch lengths */
-  int expdist;  /* exp notation for distances in matrix output */
-  
-} NJ_ARGS;
-
-
-
-/* some function prototypes */
-
-NJ_ARGS *
-NJ_handle_args(int argc,
-              char *argv[]);
-
-void
-NJ_print_args(NJ_ARGS *nj_args);
-
-void
-NJ_usage(void);
-
-
-#endif /* _INC_NJ_CMDARGS_H_ */
-
diff --git a/collect.cpp b/collect.cpp
deleted file mode 100644 (file)
index 9a89020..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *  collect.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "collect.h"
-
-/***********************************************************************/
-
-int Collect::getCurve(float percentFreq = 0.01){
-        try {
-                RAbundVector* lookup = new RAbundVector(order->getNumBins());
-                SAbundVector* rank        = new SAbundVector(order->getMaxRank()+1);
-
-                CollectorsCurveData* ccd = new CollectorsCurveData();
-        
-                for(int i=0;i<displays.size();i++){
-                        ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
-                        displays[i]->init(label);                   //sets displays label
-                }   
-                               
-                               //convert freq percentage to number
-                               int increment = 1;
-                               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
-                               else { increment = percentFreq;  }
-                                                                                                                                                                                                                                                       
-                for(int i=0;i<numSeqs;i++){
-                                               
-                                               if (m->control_pressed) { delete lookup; delete rank; delete ccd;  return 1;  }
-                                               
-                        int binNumber = order->get(i);
-                        int abundance = lookup->get(binNumber);
-                
-                        rank->set(abundance, rank->get(abundance)-1); 
-                
-                        abundance++;
-                
-                        lookup->set(binNumber, abundance);
-                        rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance)
-
-                        if((i == 0) || (i+1) % increment == 0){
-                                ccd->updateRankData(rank);
-                        }
-                }
-        
-                if(numSeqs % increment != 0){
-                        ccd->updateRankData(rank);
-                }
-        
-                for(int i=0;i<displays.size();i++){
-                        displays[i]->reset();
-                }
-                               
-                               delete lookup;
-                               delete rank;
-                               delete ccd;
-                               
-                               return 0;
-        }
-        catch(exception& e) {
-                       m->errorOut(e, "Collect", "getCurve");
-                       exit(1);
-        }
-}
-
-/***********************************************************************/
-int Collect::getSharedCurve(float percentFreq = 0.01){
-try {
-                vector<SharedRAbundVector*> lookup; 
-                               vector<SharedRAbundVector*> subset;
-
-                //create and initialize vector of sharedvectors, one for each group
-                               vector<string> mGroups = m->getGroups();
-                for (int i = 0; i < mGroups.size(); i++) { 
-                        SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
-                        temp->setLabel(sharedorder->getLabel());
-                        temp->setGroup(mGroups[i]);
-                                               lookup.push_back(temp);
-                }
-       
-                SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData();
-        
-                //initialize labels for output
-                //makes  'uniqueAB         uniqueAC  uniqueBC' if your groups are A, B, C
-                getGroupComb();
-                               
-                for(int i=0;i<displays.size();i++){
-                        ccd->registerDisplay(displays[i]); //adds a display[i] to cdd
-                                               bool hasLciHci = displays[i]->hasLciHci();
-                                               groupLabel = "";
-                                               for (int s = 0; s < groupComb.size(); s++) {
-                                                       if (hasLciHci) {  groupLabel = groupLabel + label + groupComb[s] + "\t" + label + groupComb[s] + "lci\t" + label + groupComb[s] + "hci\t"; }
-                                                       else{  groupLabel = groupLabel + label + groupComb[s] + "\t";  }
-                                               }
-
-                                               string groupLabelAll = groupLabel + label + "all\t"; 
-                                               if ((displays[i]->isCalcMultiple() == true) && (displays[i]->getAll() == true)) {   displays[i]->init(groupLabelAll); }
-                                               else {  displays[i]->init(groupLabel);  }           
-                }
-                
-                               //convert freq percentage to number
-                               int increment = 1;
-                               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
-                               else { increment = percentFreq;  }
-                               
-                //sample all the members
-                for(int i=0;i<numSeqs;i++){
-                               
-                                               if (m->control_pressed) { for (int j = 0; j < lookup.size(); j++) {  delete lookup[j]; } delete ccd;  return 1;  }
-                                               
-                        //get first sample
-                        individual chosen = sharedorder->get(i);
-                        int abundance; 
-                                                    
-                        //set info for sharedvector in chosens group
-                        for (int j = 0; j < lookup.size(); j++) { 
-                                                       if (chosen.group == lookup[j]->getGroup()) {
-                                                               abundance = lookup[j]->getAbundance(chosen.bin);
-                                                               lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
-                                                               break;
-                                                       }
-                        }
-       
-                        //calculate at 0 and the given increment
-                        if((i == 0) || (i+1) % increment == 0){
-
-                                                               //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
-
-                                int n = 1;
-                                                               bool pair = true;
-                                for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
-                                        for (int l = n; l < lookup.size(); l++) {
-                                                                                               subset.clear(); //clear out old pair of sharedrabunds
-                                                                                               //add new pair of sharedrabund vectors
-                                                                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                                                       
-                                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                                                               for (int w = 0; w < lookup.size(); w++) {
-                                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
-                                                                                               }
-                                               
-                                                ccd->updateSharedData(subset, i+1, m->getNumGroups(), pair);
-                                        }
-                                        n++;
-                                }
-                                                       
-                                                               //if this is a calculator that can do multiples then do them
-                                                               pair = false;
-                                                               ccd->updateSharedData(lookup, i+1, m->getNumGroups(), pair); 
-                                                       
-                        }
-                        totalNumSeq = i+1;
-                }
-                
-                //calculate last label if you haven't already
-                if(numSeqs % increment != 0){
-                        //how many comparisons to make i.e. for group a, b, c = ab, ac, bc.
-                        int n = 1;
-                                               bool pair = true;
-                        for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare
-                                for (int l = n; l < lookup.size(); l++) {
-                                                                               subset.clear(); //clear out old pair of sharedrabunds
-                                                                               //add new pair of sharedrabund vectors
-                                                                               subset.push_back(lookup[k]); subset.push_back(lookup[l]);
-                                                                       
-                                                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                                               for (int w = 0; w < lookup.size(); w++) {
-                                                                                       if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
-                                                                               }
-                                                                       
-                                                                               ccd->updateSharedData(subset, totalNumSeq, m->getNumGroups(), pair);
-                                }
-                                n++;
-                        }
-                                               //if this is a calculator that can do multiples then do them
-                                               pair = false;
-                                               ccd->updateSharedData(lookup, totalNumSeq, m->getNumGroups(), pair); 
-                }
-        
-                //resets output files
-                for(int i=0;i<displays.size();i++){
-                        displays[i]->reset();
-                }
-                               
-                               //memory cleanup
-                               delete ccd;
-                               for (int i = 0; i < lookup.size(); i++) {
-                                       delete lookup[i];
-                               }
-                               
-                               return 0;
-
-        }
-        catch(exception& e) {
-                m->errorOut(e, "Collect", "getSharedCurve");
-                               exit(1);
-        }
-}
-
-/**************************************************************************************/
-
-void Collect::getGroupComb() {
-       string group;
-                
-       numGroupComb = 0;
-                
-       int n = 1;
-       vector<string> mGroups = m->getGroups();
-       for (int i = 0; i < (m->getNumGroups() - 1); i++) {
-               for (int l = n; l < m->getNumGroups(); l++) {
-                       group = mGroups[i] + mGroups[l];
-                       groupComb.push_back(group);        
-                       numGroupComb++;
-               }
-               n++;
-       }
-
-}
-
-/**************************************************************************************/
diff --git a/collect.h b/collect.h
deleted file mode 100644 (file)
index 5171233..0000000
--- a/collect.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef COLLECT_H
-#define COLLECT_H
-
-#include "collectorscurvedata.h"
-#include "display.h"
-#include "ordervector.hpp"
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
-#include "sharedordervector.h"
-#include "datavector.hpp"
-#include "mothurout.h"
-
-/***********************************************************************/
-
-class Collect {
-       
-public:
-       Collect(OrderVector* order, vector<Display*> disp) :
-                                       numSeqs(order->getNumSeqs()), order(order), displays(disp), label(order->getLabel())  { m = MothurOut::getInstance(); };
-       Collect(SharedOrderVector* sharedorder, vector<Display*> disp) :
-                                       numSeqs(sharedorder->getNumSeqs()), sharedorder(sharedorder), displays(disp), label(sharedorder->getLabel())  { m = MothurOut::getInstance(); }
-
-       ~Collect(){             };
-       int getCurve(float);
-       int getSharedCurve(float);
-       
-private:
-       SharedOrderVector* sharedorder;
-       OrderVector* order;
-       vector<Display*> displays;
-       int numSeqs, numGroupComb, totalNumSeq;
-       string label, groupLabel;
-       void getGroupComb();
-       vector<string> groupComb;
-       bool validGroup(vector<string>, string);
-       MothurOut* m;
-};
-
-
-#endif
-
diff --git a/collectcommand.cpp b/collectcommand.cpp
deleted file mode 100644 (file)
index 7ad4136..0000000
+++ /dev/null
@@ -1,593 +0,0 @@
-/*
- *  collectcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "collectcommand.h"
-#include "ace.h"
-#include "sobs.h"
-#include "nseqs.h"
-#include "chao1.h"
-#include "bootstrap.h"
-#include "simpson.h"
-#include "simpsoneven.h"
-#include "invsimpson.h"
-#include "npshannon.h"
-#include "shannon.h"
-#include "smithwilson.h"
-#include "heip.h"
-#include "shannoneven.h"
-#include "jackknife.h"
-#include "geom.h"
-#include "qstat.h"
-#include "logsd.h"
-#include "bergerparker.h"
-#include "bstick.h"
-#include "goodscoverage.h"
-#include "efron.h"
-#include "boneh.h"
-#include "solow.h"
-#include "shen.h"
-#include "coverage.h"
-
-
-//**********************************************************************************************************************
-vector<string> CollectCommand::setParameters(){        
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CollectCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The collect.single command parameters are list, sabund, rabund, shared, label, freq, calc and abund.  list, sabund, rabund or shared is required unless you have a valid current file. \n";
-               helpString += "The collect.single command should be in the following format: \n";
-               helpString += "The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n";
-               helpString += "collect.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n";
-               helpString += "Example collect(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-chao-ace-jack).\n";
-               helpString += "The default values for freq is 100, and calc are sobs-chao-ace-jack-shannon-npshannon-simpson.\n";
-               helpString += validCalculator.printCalc("single");
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CollectCommand::CollectCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["sobs"] = tempOutNames;
-               outputTypes["chao"] = tempOutNames;
-               outputTypes["nseqs"] = tempOutNames;
-               outputTypes["coverage"] = tempOutNames;
-               outputTypes["ace"] = tempOutNames;
-               outputTypes["jack"] = tempOutNames;
-               outputTypes["shannon"] = tempOutNames;
-               outputTypes["shannoneven"] = tempOutNames;
-               outputTypes["npshannon"] = tempOutNames;
-               outputTypes["heip"] = tempOutNames;
-               outputTypes["smithwilson"] = tempOutNames;
-               outputTypes["simpson"] = tempOutNames;
-               outputTypes["simpsoneven"] = tempOutNames;
-               outputTypes["invsimpson"] = tempOutNames;
-               outputTypes["bootstrap"] = tempOutNames;
-               outputTypes["geometric"] = tempOutNames;
-               outputTypes["qstat"] = tempOutNames;
-               outputTypes["logseries"] = tempOutNames;
-               outputTypes["bergerparker"] = tempOutNames;
-               outputTypes["bstick"] = tempOutNames;
-               outputTypes["goodscoverage"] = tempOutNames;
-               outputTypes["efron"] = tempOutNames;
-               outputTypes["boneh"] = tempOutNames;
-               outputTypes["solow"] = tempOutNames;
-               outputTypes["shen"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "CollectCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CollectCommand::CollectCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); calledHelp = true; abort = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["sobs"] = tempOutNames;
-                       outputTypes["chao"] = tempOutNames;
-                       outputTypes["nseqs"] = tempOutNames;
-                       outputTypes["coverage"] = tempOutNames;
-                       outputTypes["ace"] = tempOutNames;
-                       outputTypes["jack"] = tempOutNames;
-                       outputTypes["shannon"] = tempOutNames;
-                       outputTypes["shannoneven"] = tempOutNames;
-                       outputTypes["npshannon"] = tempOutNames;
-                       outputTypes["heip"] = tempOutNames;
-                       outputTypes["smithwilson"] = tempOutNames;
-                       outputTypes["simpson"] = tempOutNames;
-                       outputTypes["simpsoneven"] = tempOutNames;
-                       outputTypes["invsimpson"] = tempOutNames;
-                       outputTypes["bootstrap"] = tempOutNames;
-                       outputTypes["geometric"] = tempOutNames;
-                       outputTypes["qstat"] = tempOutNames;
-                       outputTypes["logseries"] = tempOutNames;
-                       outputTypes["bergerparker"] = tempOutNames;
-                       outputTypes["bstick"] = tempOutNames;
-                       outputTypes["goodscoverage"] = tempOutNames;
-                       outputTypes["efron"] = tempOutNames;
-                       outputTypes["boneh"] = tempOutNames;
-                       outputTypes["solow"] = tempOutNames;
-                       outputTypes["shen"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               rabundfile = m->getRabundFile(); 
-                                               if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       sabundfile = m->getSabundFile(); 
-                                                       if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                                       else { 
-                                                               m->mothurOut("No valid current files. You must provide a list, sabund, rabund or shared file before you can use the collect.single command."); m->mothurOutEndLine(); 
-                                                               abort = true;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       //NOTE: if you add new calc options, don't forget to add them to the parameter initialize in setParameters or the gui won't be able to use them
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sobs-chao-ace-jack-shannon-npshannon-simpson";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, freq); 
-                       
-                       temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, abund); 
-                       
-                       temp = validParameter.validFile(parameters, "size", false);                     if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, size); 
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "CollectCommand");
-               exit(1);
-       }                       
-}
-//**********************************************************************************************************************
-
-int CollectCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-       
-               if ((format != "sharedfile")) { inputFileNames.push_back(inputfile);  }
-               else {  inputFileNames = parseSharedFile(sharedfile);  format = "rabund"; }
-       
-               for (int p = 0; p < inputFileNames.size(); p++) {
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  m->clearGroups();  return 0; }
-                       
-                       if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); }
-                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
-                       //globaldata->inputFileName = inputFileNames[p];
-               
-                       if (inputFileNames.size() > 1) {
-                               m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       }
-               
-                       ValidCalculators validCalculator;
-                       
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("single", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "sobs") { 
-                                               cDisplays.push_back(new CollectDisplay(new Sobs(), new OneColumnFile(fileNameRoot+"sobs")));
-                                               outputNames.push_back(fileNameRoot+"sobs"); outputTypes["sobs"].push_back(fileNameRoot+"sobs");
-                                       }else if (Estimators[i] == "chao") { 
-                                               cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao")));
-                                               outputNames.push_back(fileNameRoot+"chao"); outputTypes["chao"].push_back(fileNameRoot+"chao");
-                                       }else if (Estimators[i] == "nseqs") { 
-                                               cDisplays.push_back(new CollectDisplay(new NSeqs(), new OneColumnFile(fileNameRoot+"nseqs")));
-                                               outputNames.push_back(fileNameRoot+"nseqs"); outputTypes["nseqs"].push_back(fileNameRoot+"nseqs");
-                                       }else if (Estimators[i] == "coverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new Coverage(), new OneColumnFile(fileNameRoot+"coverage")));
-                                               outputNames.push_back(fileNameRoot+"coverage"); outputTypes["coverage"].push_back(fileNameRoot+"coverage");
-                                       }else if (Estimators[i] == "ace") { 
-                                               cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace")));
-                                               outputNames.push_back(fileNameRoot+"ace"); outputTypes["ace"].push_back(fileNameRoot+"ace");
-                                       }else if (Estimators[i] == "jack") { 
-                                               cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack")));
-                                               outputNames.push_back(fileNameRoot+"jack"); outputTypes["jack"].push_back(fileNameRoot+"jack");
-                                       }else if (Estimators[i] == "shannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"shannon")));
-                                               outputNames.push_back(fileNameRoot+"shannon"); outputTypes["shannon"].push_back(fileNameRoot+"shannon");
-                                       }else if (Estimators[i] == "shannoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new ShannonEven(), new OneColumnFile(fileNameRoot+"shannoneven")));
-                                               outputNames.push_back(fileNameRoot+"shannoneven"); outputTypes["shannoneven"].push_back(fileNameRoot+"shannoneven");
-                                       }else if (Estimators[i] == "npshannon") { 
-                                               cDisplays.push_back(new CollectDisplay(new NPShannon(), new OneColumnFile(fileNameRoot+"npshannon")));
-                                               outputNames.push_back(fileNameRoot+"npshannon"); outputTypes["npshannon"].push_back(fileNameRoot+"npshannon");
-                                       }else if (Estimators[i] == "heip") { 
-                                               cDisplays.push_back(new CollectDisplay(new Heip(), new OneColumnFile(fileNameRoot+"heip")));
-                                               outputNames.push_back(fileNameRoot+"heip"); outputTypes["heip"].push_back(fileNameRoot+"heip");
-                                       }else if (Estimators[i] == "smithwilson") { 
-                                               cDisplays.push_back(new CollectDisplay(new SmithWilson(), new OneColumnFile(fileNameRoot+"smithwilson")));
-                                               outputNames.push_back(fileNameRoot+"smithwilson"); outputTypes["smithwilson"].push_back(fileNameRoot+"smithwilson");
-                                       }else if (Estimators[i] == "simpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"simpson")));
-                                               outputNames.push_back(fileNameRoot+"simpson"); outputTypes["simpson"].push_back(fileNameRoot+"simpson");
-                                       }else if (Estimators[i] == "simpsoneven") { 
-                                               cDisplays.push_back(new CollectDisplay(new SimpsonEven(), new OneColumnFile(fileNameRoot+"simpsoneven")));
-                                               outputNames.push_back(fileNameRoot+"simpsoneven"); outputTypes["simpsoneven"].push_back(fileNameRoot+"simpsoneven");
-                                       }else if (Estimators[i] == "invsimpson") { 
-                                               cDisplays.push_back(new CollectDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"invsimpson")));
-                                               outputNames.push_back(fileNameRoot+"invsimpson"); outputTypes["invsimpson"].push_back(fileNameRoot+"invsimpson");
-                                       }else if (Estimators[i] == "bootstrap") { 
-                                               cDisplays.push_back(new CollectDisplay(new Bootstrap(), new OneColumnFile(fileNameRoot+"bootstrap")));
-                                               outputNames.push_back(fileNameRoot+"bootstrap"); outputTypes["bootstrap"].push_back(fileNameRoot+"bootstrap");
-                                       }else if (Estimators[i] == "geometric") { 
-                                               cDisplays.push_back(new CollectDisplay(new Geom(), new OneColumnFile(fileNameRoot+"geometric")));
-                                               outputNames.push_back(fileNameRoot+"geometric"); outputTypes["geometric"].push_back(fileNameRoot+"geometric");
-                                       }else if (Estimators[i] == "qstat") { 
-                                               cDisplays.push_back(new CollectDisplay(new QStat(), new OneColumnFile(fileNameRoot+"qstat")));
-                                               outputNames.push_back(fileNameRoot+"qstat"); outputTypes["qstat"].push_back(fileNameRoot+"qstat");
-                                       }else if (Estimators[i] == "logseries") { 
-                                               cDisplays.push_back(new CollectDisplay(new LogSD(), new OneColumnFile(fileNameRoot+"logseries")));
-                                               outputNames.push_back(fileNameRoot+"logseries"); outputTypes["logseries"].push_back(fileNameRoot+"logseries");
-                                       }else if (Estimators[i] == "bergerparker") { 
-                                               cDisplays.push_back(new CollectDisplay(new BergerParker(), new OneColumnFile(fileNameRoot+"bergerparker")));
-                                               outputNames.push_back(fileNameRoot+"bergerparker"); outputTypes["bergerparker"].push_back(fileNameRoot+"bergerparker");
-                                       }else if (Estimators[i] == "bstick") { 
-                                               cDisplays.push_back(new CollectDisplay(new BStick(), new ThreeColumnFile(fileNameRoot+"bstick")));
-                                               outputNames.push_back(fileNameRoot+"bstick"); outputTypes["bstick"].push_back(fileNameRoot+"bstick");
-                                       }else if (Estimators[i] == "goodscoverage") { 
-                                               cDisplays.push_back(new CollectDisplay(new GoodsCoverage(), new OneColumnFile(fileNameRoot+"goodscoverage")));
-                                               outputNames.push_back(fileNameRoot+"goodscoverage"); outputTypes["goodscoverage"].push_back(fileNameRoot+"goodscoverage");
-                                       }else if (Estimators[i] == "efron") {
-                                               cDisplays.push_back(new CollectDisplay(new Efron(size), new OneColumnFile(fileNameRoot+"efron")));
-                                               outputNames.push_back(fileNameRoot+"efron"); outputTypes["efron"].push_back(fileNameRoot+"efron");
-                                       }else if (Estimators[i] == "boneh") {
-                                               cDisplays.push_back(new CollectDisplay(new Boneh(size), new OneColumnFile(fileNameRoot+"boneh")));
-                                               outputNames.push_back(fileNameRoot+"boneh"); outputTypes["boneh"].push_back(fileNameRoot+"boneh");
-                                       }else if (Estimators[i] == "solow") {
-                                               cDisplays.push_back(new CollectDisplay(new Solow(size), new OneColumnFile(fileNameRoot+"solow")));
-                                               outputNames.push_back(fileNameRoot+"solow"); outputTypes["solow"].push_back(fileNameRoot+"solow");
-                                       }else if (Estimators[i] == "shen") {
-                                               cDisplays.push_back(new CollectDisplay(new Shen(size, abund), new OneColumnFile(fileNameRoot+"shen")));
-                                               outputNames.push_back(fileNameRoot+"shen"); outputTypes["shen"].push_back(fileNameRoot+"shen");
-                                       }
-                               }
-                       }
-               
-                       //if the users entered no valid calculators don't execute command
-                       if (cDisplays.size() == 0) { return 0; }
-                       
-                       input = new InputData(inputFileNames[p], format);
-                       order = input->getOrderVector();
-                       string lastLabel = order->getLabel();
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       if (m->control_pressed) {  
-                               for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear(); 
-                               delete input;  
-                               delete order; 
-                               m->clearGroups();
-                               return 0;
-                       }
-
-
-                       while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                               if (m->control_pressed) { 
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear(); 
-                                       delete input;  
-                                       delete order; 
-                                       m->clearGroups();
-                                       return 0;
-                               }
-
-                               
-                               if(allLines == 1 || labels.count(order->getLabel()) == 1){
-                               
-                                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                                       cCurve = new Collect(order, cDisplays);
-                                       cCurve->getCurve(freq);
-                                       delete cCurve;
-                                       
-                                       processedLabels.insert(order->getLabel());
-                                       userLabels.erase(order->getLabel());
-                                       
-                                       
-                               }
-                               //you have a label the user want that is smaller than this label and the last label has not already been processed 
-                               if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = order->getLabel();
-                                       
-                                       delete order;
-                                       order = (input->getOrderVector(lastLabel));
-                                       
-                                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                                       cCurve = new Collect(order, cDisplays);
-                                       cCurve->getCurve(freq);
-                                       delete cCurve;
-                                       
-                                       
-                                       processedLabels.insert(order->getLabel());
-                                       userLabels.erase(order->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       order->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = order->getLabel();  
-                               
-                               delete order;           
-                               order = (input->getOrderVector());
-                       }
-                       
-                       
-                       if (m->control_pressed) { 
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear(); 
-                                       delete input;  
-                                       m->clearGroups();
-                                       return 0;
-                       }
-                               
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (order != NULL) {    delete order;   }
-                               order = (input->getOrderVector(lastLabel));
-                               
-                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                               
-                               cCurve = new Collect(order, cDisplays);
-                               cCurve->getCurve(freq);
-                               delete cCurve;
-                               
-                               if (m->control_pressed) { 
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        } outputTypes.clear(); 
-                                       delete input;  
-                                       delete order;
-                                       m->clearGroups();
-                                       return 0;
-                               }
-                               delete order;
-                       }
-                       
-                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                       cDisplays.clear();
-                       delete input;  
-               }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-                               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-vector<string> CollectCommand::parseSharedFile(string filename) {
-       try {
-               vector<string> filenames;
-               
-               map<string, ofstream*> filehandles;
-               map<string, ofstream*>::iterator it3;
-                                       
-               input = new InputData(filename, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               
-               string sharedFileRoot = m->getRootName(filename);
-               
-               //clears file before we start to write to it below
-               for (int i=0; i<lookup.size(); i++) {
-                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-                       filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-               }
-               
-               ofstream* temp;
-               for (int i=0; i<lookup.size(); i++) {
-                       temp = new ofstream;
-                       filehandles[lookup[i]->getGroup()] = temp;
-                       groups.push_back(lookup[i]->getGroup());
-               }
-
-               while(lookup[0] != NULL) {
-               
-                       for (int i = 0; i < lookup.size(); i++) {
-                               RAbundVector rav = lookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
-                               rav.print(*(filehandles[lookup[i]->getGroup()]));
-                               (*(filehandles[lookup[i]->getGroup()])).close();
-                       }
-               
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               //free memory
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       delete it3->second;
-               }
-               
-               delete input;
-
-               return filenames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectCommand", "parseSharedFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/collectcommand.h b/collectcommand.h
deleted file mode 100644 (file)
index b882013..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef COLLECTCOMMAND_H
-#define COLLECTCOMMAND_H
-/*
- *  collectcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "ordervector.hpp"
-#include "inputdata.h"
-#include "collect.h"
-#include "display.h"
-#include "validcalculator.h"
-
-/*The collect() command:
-       The collect command generates a collector's curve from the given file.  
-       The collect command outputs a file for each estimator you choose to use.  The collect command parameters are label, freq, single, abund.  
-       No parameters are required.  
-       The collect command should be in the following format: collect(label=yourLabel, freq=yourFreq, single=yourEstimators, abund=yourAbund). 
-       example collect(label=unique-.01-.03, freq=10, single=collect-chao-ace-jack).  
-       The default values for  freq is 100, for abund is 10, and single are collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson.  
-       The valid single estimators are: collect-chao-ace-jack-bootstrap-shannon-npshannon-simpson. 
-       The label parameter is used to analyze specific labels in your input. */
-
-
-class CollectCommand : public Command {
-       
-public:
-       CollectCommand(string); 
-       CollectCommand();
-       ~CollectCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "collect.single";                      }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getCitation() { return "Schloss PD, Handelsman J (2006). Introducing SONS, A tool that compares the membership of microbial communities. Appl Environ Microbiol 72: 6773-9. \nhttp://www.mothur.org/wiki/Collect.single"; }
-       string getHelpString(); 
-       string getDescription()         { return "generates collector's curves using calculators, that describe the richness, diversity, and other features of individual samples"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       OrderVector* order;
-       InputData* input;
-       Collect* cCurve;
-       vector<Display*> cDisplays;
-       int abund, size;
-       float freq;
-       vector<string> outputNames;
-
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string label, calc, outputDir, sharedfile, listfile, rabundfile, sabundfile, format, inputfile;
-       vector<string>  Estimators;
-       vector<string> inputFileNames;
-       vector<string> groups;
-       
-       vector<string> parseSharedFile(string);
-
-
-};
-
-#endif
diff --git a/collectdisplay.h b/collectdisplay.h
deleted file mode 100644 (file)
index 781cea1..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#ifndef COLLECTDISPLAY_H
-#define COLLECTDISPLAY_H
-
-#include "sabundvector.hpp"
-#include "sharedsabundvector.h"
-#include "calculator.h"
-#include "fileoutput.h"
-#include "display.h"
-
-
-/***********************************************************************/
-
-class CollectDisplay : public Display {
-       
-public:
-       CollectDisplay(Calculator* calc, FileOutput* file) : estimate(calc), output(file) {timesCalled = 0;};
-       ~CollectDisplay()       {       delete estimate; delete output;         }
-       
-       
-       void update(SAbundVector* rank){
-               nSeqs=rank->getNumSeqs();
-               data = estimate->getValues(rank);
-               output->output(nSeqs, data);    
-       };
-       
-       void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroups){
-               timesCalled++;
-               data = estimate->getValues(shared);  //passes estimators a shared vector from each group to be compared
-               
-               //figure out what groups are being compared in getValues
-               //because we randomizes the order we need to put the results in the correct column in the output file
-               int group1Index, group2Index, pos;
-               
-               vector<string> mGroups = m->getGroups();
-               for (int i = 0; i < mGroups.size(); i++) {
-                       if (shared[0]->getGroup() == mGroups[i]) { group1Index = i; }
-                       if (shared[1]->getGroup() == mGroups[i]) { group2Index = i; }
-               }
-               
-               numGroupComb = 0;
-               int n = 1;
-               for (int i = 0; i < (numGroups - 1); i++) {
-                       for (int l = n; l < numGroups; l++) {
-                               if ((group1Index == i) && (group2Index == l)) {
-                                       pos = numGroupComb;  //pos tells you which column in the output file you are in
-                               }else if ((group1Index == l) && (group2Index == i)) {
-                                       pos = numGroupComb;
-                               }
-                               numGroupComb++;
-                       }
-                       n++;
-               }
-                       
-               if ((estimate->getMultiple() == true) && all) { 
-                       numGroupComb++; 
-                       groupData.resize((numGroupComb*data.size()), 0);
-                       //is this the time its called with all values
-                       if  ((timesCalled % numGroupComb) == 0) { 
-                               //last spot
-                               pos = ((groupData.size()-1) * data.size());
-                       }
-                       //fills groupdata with datas info
-                       for (int i = 0; i < data.size(); i++) {
-                               groupData[pos+i] = data[i];
-                       }
-               }else {
-                       groupData.resize((numGroupComb*data.size()), 0);
-                       //fills groupdata with datas info
-                       for (int i = 0; i < data.size(); i++) {
-                               groupData[pos+i] = data[i];
-                       }
-               }
-               
-               //when you get all your groups info then output
-               if ((timesCalled % numGroupComb) == 0) {
-                       output->output(numSeqs, groupData);     
-               }
-       };
-                                                                       
-       void init(string s)             {       output->initFile(s);    };
-       void reset()                    {       output->resetFile();    };
-       void close()                    {       output->resetFile();    };
-       void setAll(bool a)             {       all = a;                                }
-       bool getAll()                   {       return all;                             }
-       
-       
-       bool isCalcMultiple()   { return estimate->getMultiple(); }
-       bool calcNeedsAll()     { return estimate->getNeedsAll(); }
-       bool hasLciHci()        {
-               if (estimate->getCols() == 3) { return true; } 
-               else{ return false; } 
-       }
-       
-       string getName()        {  return estimate->getName();  }
-       
-       
-private:
-       
-       Calculator* estimate;
-       FileOutput* output;
-       int nSeqs, timesCalled, numGroupComb;
-       vector<double> data;
-       vector<double> groupData;
-       bool all;
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/collectorscurvedata.h b/collectorscurvedata.h
deleted file mode 100644 (file)
index d32a9e0..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef COLLECTORSCURVEDATA_H
-#define COLLECTORSCURVEDATA_H
-
-#include "sabundvector.hpp"
-#include "sharedrabundvector.h"
-#include "display.h"
-#include "observable.h"
-
-
-/***********************************************************************/
-
-class CollectorsCurveData : public Observable {
-       
-public:
-       CollectorsCurveData() : rank(0) {};
-       
-       void registerDisplay(Display* o)                {       displays.insert(o);                             };
-       void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
-       SAbundVector* getRankData()                             {       return rank;                                    };
-       void rankDataChanged()                                  {       notifyDisplays();                               };
-       void updateRankData(SAbundVector* rv)   {       rank = rv; rankDataChanged();   };
-
-       void notifyDisplays(){  
-               for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                       (*pos)->update(rank);
-               }       
-       };
-       
-private:
-       set<Display*> displays;
-       SAbundVector* rank;
-       
-};
-
-/***********************************************************************/
-
-
-class SharedCollectorsCurveData : public Observable {
-       
-public:
-       SharedCollectorsCurveData() { }; //: shared1(0), shared2(0)
-       
-       void registerDisplay(Display* o)                {       displays.insert(o);                     };
-       void removeDisplay(Display* o)                  {       displays.erase(o);      delete o;       };
-       void SharedDataChanged()                                {       notifyDisplays();                               };
-       void updateSharedData(vector<SharedRAbundVector*> s, int numSeqs, int numGroupComb, bool p)     {       pairs = p; shared = s; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged();     };
-       
-       void notifyDisplays(){  
-               for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                       
-                       if ((*pos)->calcNeedsAll() == true) {
-                               (*pos)->update(shared, NumSeqs, NumGroupComb);
-                       }else{
-                               
-                               if ( ((*pos)->isCalcMultiple() == true) && ((*pos)->getAll() == true) && (!pairs) ) {
-                                       (*pos)->update(shared, NumSeqs, NumGroupComb);
-                               }else {
-                                       vector<SharedRAbundVector*> temp; temp.push_back(shared[0]); temp.push_back(shared[1]);
-                                       shared = temp; 
-                                       
-                                       (*pos)->update(shared, NumSeqs, NumGroupComb);
-                               }
-                       }
-               }       
-       };
-       
-private:
-       set<Display*> displays;
-       vector<Display*> multiDisplays;
-       vector<SharedRAbundVector*> shared;
-       int NumSeqs, NumGroupComb;
-       bool pairs;
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp
deleted file mode 100644 (file)
index f3a320b..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-/*
- *  collectsharedcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "collectsharedcommand.h"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedkstest.h"
-#include "whittaker.h"
-#include "sharednseqs.h"
-#include "sharedochiai.h"
-#include "sharedanderbergs.h"
-#include "sharedkulczynski.h"
-#include "sharedkulczynskicody.h"
-#include "sharedlennon.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-#include "sharedjackknife.h"
-#include "whittaker.h"
-#include "odum.h"
-#include "canberra.h"
-#include "structeuclidean.h"
-#include "structchord.h"
-#include "hellinger.h"
-#include "manhattan.h"
-#include "structpearson.h"
-#include "soergel.h"
-#include "spearman.h"
-#include "structkulczynski.h"
-#include "structchi2.h"
-#include "speciesprofile.h"
-#include "hamming.h"
-#include "gower.h"
-#include "memchi2.h"
-#include "memchord.h"
-#include "memeuclidean.h"
-#include "mempearson.h"
-
-
-//**********************************************************************************************************************
-vector<string> CollectSharedCommand::setParameters(){  
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CollectSharedCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The collect.shared command parameters are shared, label, freq, calc and groups.  shared is required if there is no current sharedfile. \n";
-               helpString += "The collect.shared command should be in the following format: \n";
-               helpString += "collect.shared(label=yourLabel, freq=yourFreq, calc=yourEstimators, groups=yourGroups).\n";
-               helpString += "Example collect.shared(label=unique-.01-.03, freq=10, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n";
-               helpString += "The default values for freq is 100 and calc are sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan.\n";
-               helpString += "The default value for groups is all the groups in your groupfile.\n";
-               helpString += "The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n";
-               helpString += validCalculator.printCalc("shared");
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n";
-               helpString += "If you use sharedchao and run into memory issues, set all to false. \n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CollectSharedCommand::CollectSharedCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["sharedchao"] = tempOutNames;
-               outputTypes["sharedsobs"] = tempOutNames;
-               outputTypes["sharedace"] = tempOutNames;
-               outputTypes["jabund"] = tempOutNames;
-               outputTypes["sorabund"] = tempOutNames;
-               outputTypes["jclass"] = tempOutNames;
-               outputTypes["sorclass"] = tempOutNames;
-               outputTypes["jest"] = tempOutNames;
-               outputTypes["sorest"] = tempOutNames;
-               outputTypes["thetayc"] = tempOutNames;
-               outputTypes["thetan"] = tempOutNames;
-               outputTypes["kstest"] = tempOutNames;
-               outputTypes["whittaker"] = tempOutNames;
-               outputTypes["sharednseqs"] = tempOutNames;
-               outputTypes["ochiai"] = tempOutNames;
-               outputTypes["anderberg"] = tempOutNames;
-               outputTypes["kulczynski"] = tempOutNames;
-               outputTypes["kulczynskicody"] = tempOutNames;
-               outputTypes["lennon"] = tempOutNames;
-               outputTypes["morisitahorn"] = tempOutNames;
-               outputTypes["braycurtis"] = tempOutNames;
-               outputTypes["odum"] = tempOutNames;
-               outputTypes["canberra"] = tempOutNames;
-               outputTypes["structeuclidean"] = tempOutNames;
-               outputTypes["structchord"] = tempOutNames;
-               outputTypes["hellinger"] = tempOutNames;
-               outputTypes["manhattan"] = tempOutNames;
-               outputTypes["structpearson"] = tempOutNames;
-               outputTypes["soergel"] = tempOutNames;
-               outputTypes["spearman"] = tempOutNames;
-               outputTypes["structkulczynski"] = tempOutNames;
-               outputTypes["structchi2"] = tempOutNames;
-               outputTypes["speciesprofile"] = tempOutNames;
-               outputTypes["hamming"] = tempOutNames;
-               outputTypes["gower"] = tempOutNames;
-               outputTypes["memchi2"] = tempOutNames;
-               outputTypes["memchord"] = tempOutNames;
-               outputTypes["memeuclidean"] = tempOutNames;
-               outputTypes["mempearson"] = tempOutNames;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CollectSharedCommand::CollectSharedCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters=parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["sharedchao"] = tempOutNames;
-                       outputTypes["sharedsobs"] = tempOutNames;
-                       outputTypes["sharedace"] = tempOutNames;
-                       outputTypes["jabund"] = tempOutNames;
-                       outputTypes["sorabund"] = tempOutNames;
-                       outputTypes["jclass"] = tempOutNames;
-                       outputTypes["sorclass"] = tempOutNames;
-                       outputTypes["jest"] = tempOutNames;
-                       outputTypes["sorest"] = tempOutNames;
-                       outputTypes["thetayc"] = tempOutNames;
-                       outputTypes["thetan"] = tempOutNames;
-                       outputTypes["kstest"] = tempOutNames;
-                       outputTypes["whittaker"] = tempOutNames;
-                       outputTypes["sharednseqs"] = tempOutNames;
-                       outputTypes["ochiai"] = tempOutNames;
-                       outputTypes["anderberg"] = tempOutNames;
-                       outputTypes["kulczynski"] = tempOutNames;
-                       outputTypes["kulczynskicody"] = tempOutNames;
-                       outputTypes["lennon"] = tempOutNames;
-                       outputTypes["morisitahorn"] = tempOutNames;
-                       outputTypes["braycurtis"] = tempOutNames;
-                       outputTypes["odum"] = tempOutNames;
-                       outputTypes["canberra"] = tempOutNames;
-                       outputTypes["structeuclidean"] = tempOutNames;
-                       outputTypes["structchord"] = tempOutNames;
-                       outputTypes["hellinger"] = tempOutNames;
-                       outputTypes["manhattan"] = tempOutNames;
-                       outputTypes["structpearson"] = tempOutNames;
-                       outputTypes["soergel"] = tempOutNames;
-                       outputTypes["spearman"] = tempOutNames;
-                       outputTypes["structkulczynski"] = tempOutNames;
-                       outputTypes["speciesprofile"] = tempOutNames;
-                       outputTypes["structchi2"] = tempOutNames;
-                       outputTypes["hamming"] = tempOutNames;
-                       outputTypes["gower"] = tempOutNames;
-                       outputTypes["memchi2"] = tempOutNames;
-                       outputTypes["memchord"] = tempOutNames;
-                       outputTypes["memeuclidean"] = tempOutNames;
-                       outputTypes["mempearson"] = tempOutNames;
-                       
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking..
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                       }
-                       m->setGroups(Groups);
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, freq); 
-                       
-                       temp = validParameter.validFile(parameters, "all", false);                              if (temp == "not found") { temp = "false"; }
-                       all = m->isTrue(temp);
-                                               
-                       if (abort == false) {
-                               
-                               string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(sharedfile));
-                               
-                               ValidCalculators validCalculator;
-                               
-                               for (int i=0; i<Estimators.size(); i++) {
-                                       if (validCalculator.isValidCalculator("shared", Estimators[i]) == true) { 
-                                               if (Estimators[i] == "sharedchao") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedChao1(), new SharedOneColumnFile(fileNameRoot+"shared.chao")));
-                                                       outputNames.push_back(fileNameRoot+"shared.chao"); outputTypes["sharedchao"].push_back(fileNameRoot+"shared.chao");
-                                               }else if (Estimators[i] == "sharedsobs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedSobsCS(), new SharedOneColumnFile(fileNameRoot+"shared.sobs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.sobs"); outputTypes["sharedsobs"].push_back(fileNameRoot+"shared.sobs");
-                                               }else if (Estimators[i] == "sharedace") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedAce(), new SharedOneColumnFile(fileNameRoot+"shared.ace")));
-                                                       outputNames.push_back(fileNameRoot+"shared.ace"); outputTypes["sharedace"].push_back(fileNameRoot+"shared.ace");
-                                               }else if (Estimators[i] == "jabund") {  
-                                                       cDisplays.push_back(new CollectDisplay(new JAbund(), new SharedOneColumnFile(fileNameRoot+"jabund")));
-                                                       outputNames.push_back(fileNameRoot+"jabund"); outputTypes["jabund"].push_back(fileNameRoot+"jabund");
-                                               }else if (Estimators[i] == "sorabund") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorAbund(), new SharedOneColumnFile(fileNameRoot+"sorabund")));
-                                                       outputNames.push_back(fileNameRoot+"sorabund"); outputTypes["sorabund"].push_back(fileNameRoot+"sorabund");
-                                               }else if (Estimators[i] == "jclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jclass(), new SharedOneColumnFile(fileNameRoot+"jclass")));
-                                                       outputNames.push_back(fileNameRoot+"jclass"); outputTypes["jclass"].push_back(fileNameRoot+"jclass");
-                                               }else if (Estimators[i] == "sorclass") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorClass(), new SharedOneColumnFile(fileNameRoot+"sorclass")));
-                                                       outputNames.push_back(fileNameRoot+"sorclass"); outputTypes["sorclass"].push_back(fileNameRoot+"sorclass");
-                                               }else if (Estimators[i] == "jest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Jest(), new SharedOneColumnFile(fileNameRoot+"jest")));
-                                                       outputNames.push_back(fileNameRoot+"jest"); outputTypes["jest"].push_back(fileNameRoot+"jest");
-                                               }else if (Estimators[i] == "sorest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SorEst(), new SharedOneColumnFile(fileNameRoot+"sorest")));
-                                                       outputNames.push_back(fileNameRoot+"sorest"); outputTypes["sorest"].push_back(fileNameRoot+"sorest");
-                                               }else if (Estimators[i] == "thetayc") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaYC(), new SharedOneColumnFile(fileNameRoot+"thetayc")));
-                                                       outputNames.push_back(fileNameRoot+"thetayc"); outputTypes["thetayc"].push_back(fileNameRoot+"thetayc");
-                                               }else if (Estimators[i] == "thetan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new ThetaN(), new SharedOneColumnFile(fileNameRoot+"thetan")));
-                                                       outputNames.push_back(fileNameRoot+"thetan"); outputTypes["thetan"].push_back(fileNameRoot+"thetan");
-                                               }else if (Estimators[i] == "kstest") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KSTest(), new SharedOneColumnFile(fileNameRoot+"kstest")));
-                                                       outputNames.push_back(fileNameRoot+"kstest"); outputTypes["kstest"].push_back(fileNameRoot+"kstest");
-                                               }else if (Estimators[i] == "whittaker") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Whittaker(), new SharedOneColumnFile(fileNameRoot+"whittaker")));
-                                                       outputNames.push_back(fileNameRoot+"whittaker"); outputTypes["whittaker"].push_back(fileNameRoot+"whittaker");
-                                               }else if (Estimators[i] == "sharednseqs") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SharedNSeqs(), new SharedOneColumnFile(fileNameRoot+"shared.nseqs")));
-                                                       outputNames.push_back(fileNameRoot+"shared.nseqs"); outputTypes["shared.nseqs"].push_back(fileNameRoot+"shared.nseqs");
-                                               }else if (Estimators[i] == "ochiai") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Ochiai(), new SharedOneColumnFile(fileNameRoot+"ochiai")));
-                                                       outputNames.push_back(fileNameRoot+"ochiai"); outputTypes["ochiai"].push_back(fileNameRoot+"ochiai");
-                                               }else if (Estimators[i] == "anderberg") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Anderberg(), new SharedOneColumnFile(fileNameRoot+"anderberg")));
-                                                       outputNames.push_back(fileNameRoot+"anderberg"); outputTypes["anderberg"].push_back(fileNameRoot+"anderberg");
-                                               }else if (Estimators[i] == "kulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Kulczynski(), new SharedOneColumnFile(fileNameRoot+"kulczynski")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynski"); outputTypes["kulczynski"].push_back(fileNameRoot+"kulczynski");
-                                               }else if (Estimators[i] == "kulczynskicody") { 
-                                                       cDisplays.push_back(new CollectDisplay(new KulczynskiCody(), new SharedOneColumnFile(fileNameRoot+"kulczynskicody")));
-                                                       outputNames.push_back(fileNameRoot+"kulczynskicody"); outputTypes["kulczynskicody"].push_back(fileNameRoot+"kulczynskicody");
-                                               }else if (Estimators[i] == "lennon") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Lennon(), new SharedOneColumnFile(fileNameRoot+"lennon")));
-                                                       outputNames.push_back(fileNameRoot+"lennon"); outputTypes["lennon"].push_back(fileNameRoot+"lennon");
-                                               }else if (Estimators[i] == "morisitahorn") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MorHorn(), new SharedOneColumnFile(fileNameRoot+"morisitahorn")));
-                                                       outputNames.push_back(fileNameRoot+"morisitahorn"); outputTypes["morisitahorn"].push_back(fileNameRoot+"morisitahorn");
-                                               }else if (Estimators[i] == "braycurtis") { 
-                                                       cDisplays.push_back(new CollectDisplay(new BrayCurtis(), new SharedOneColumnFile(fileNameRoot+"braycurtis")));
-                                                       outputNames.push_back(fileNameRoot+"braycurtis"); outputTypes["braycurtis"].push_back(fileNameRoot+"braycurtis");
-                                               }else if (Estimators[i] == "odum") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Odum(), new SharedOneColumnFile(fileNameRoot+"odum")));
-                                                       outputNames.push_back(fileNameRoot+"odum"); outputTypes["odum"].push_back(fileNameRoot+"odum");
-                                               }else if (Estimators[i] == "canberra") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Canberra(), new SharedOneColumnFile(fileNameRoot+"canberra")));
-                                                       outputNames.push_back(fileNameRoot+"canberra"); outputTypes["canberra"].push_back(fileNameRoot+"canberra");
-                                               }else if (Estimators[i] == "structeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructEuclidean(), new SharedOneColumnFile(fileNameRoot+"structeuclidean")));
-                                                       outputNames.push_back(fileNameRoot+"structeuclidean"); outputTypes["structeuclidean"].push_back(fileNameRoot+"structeuclidean");
-                                               }else if (Estimators[i] == "structchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChord(), new SharedOneColumnFile(fileNameRoot+"structchord")));
-                                                       outputNames.push_back(fileNameRoot+"structchord"); outputTypes["structchord"].push_back(fileNameRoot+"structchord");
-                                               }else if (Estimators[i] == "hellinger") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hellinger(), new SharedOneColumnFile(fileNameRoot+"hellinger")));
-                                                       outputNames.push_back(fileNameRoot+"hellinger"); outputTypes["hellinger"].push_back(fileNameRoot+"hellinger");
-                                               }else if (Estimators[i] == "manhattan") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Manhattan(), new SharedOneColumnFile(fileNameRoot+"manhattan")));
-                                                       outputNames.push_back(fileNameRoot+"manhattan"); outputTypes["manhattan"].push_back(fileNameRoot+"manhattan");
-                                               }else if (Estimators[i] == "structpearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructPearson(), new SharedOneColumnFile(fileNameRoot+"structpearson")));
-                                                       outputNames.push_back(fileNameRoot+"structpearson"); outputTypes["structpearson"].push_back(fileNameRoot+"structpearson");
-                                               }else if (Estimators[i] == "soergel") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Soergel(), new SharedOneColumnFile(fileNameRoot+"soergel")));
-                                                       outputNames.push_back(fileNameRoot+"soergel"); outputTypes["soergel"].push_back(fileNameRoot+"soergel");
-                                               }else if (Estimators[i] == "spearman") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Spearman(), new SharedOneColumnFile(fileNameRoot+"spearman")));
-                                                       outputNames.push_back(fileNameRoot+"spearman"); outputTypes["spearman"].push_back(fileNameRoot+"spearman");
-                                               }else if (Estimators[i] == "structkulczynski") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructKulczynski(), new SharedOneColumnFile(fileNameRoot+"structkulczynski")));
-                                                       outputNames.push_back(fileNameRoot+"structkulczynski"); outputTypes["structkulczynski"].push_back(fileNameRoot+"structkulczynski");
-                                               }else if (Estimators[i] == "speciesprofile") { 
-                                                       cDisplays.push_back(new CollectDisplay(new SpeciesProfile(), new SharedOneColumnFile(fileNameRoot+"speciesprofile")));
-                                                       outputNames.push_back(fileNameRoot+"speciesprofile"); outputTypes["speciesprofile"].push_back(fileNameRoot+"speciesprofile");
-                                               }else if (Estimators[i] == "hamming") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Hamming(), new SharedOneColumnFile(fileNameRoot+"hamming")));
-                                                       outputNames.push_back(fileNameRoot+"hamming"); outputTypes["hamming"].push_back(fileNameRoot+"hamming");
-                                               }else if (Estimators[i] == "structchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new StructChi2(), new SharedOneColumnFile(fileNameRoot+"structchi2")));
-                                                       outputNames.push_back(fileNameRoot+"structchi2"); outputTypes["structchi2"].push_back(fileNameRoot+"structchi2");
-                                               }else if (Estimators[i] == "gower") { 
-                                                       cDisplays.push_back(new CollectDisplay(new Gower(), new SharedOneColumnFile(fileNameRoot+"gower")));
-                                                       outputNames.push_back(fileNameRoot+"gower"); outputTypes["gower"].push_back(fileNameRoot+"gower");
-                                               }else if (Estimators[i] == "memchi2") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChi2(), new SharedOneColumnFile(fileNameRoot+"memchi2")));
-                                                       outputNames.push_back(fileNameRoot+"memchi2"); outputTypes["memchi2"].push_back(fileNameRoot+"memchi2");
-                                               }else if (Estimators[i] == "memchord") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemChord(), new SharedOneColumnFile(fileNameRoot+"memchord")));
-                                                       outputNames.push_back(fileNameRoot+"memchord"); outputTypes["memchord"].push_back(fileNameRoot+"memchord");
-                                               }else if (Estimators[i] == "memeuclidean") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemEuclidean(), new SharedOneColumnFile(fileNameRoot+"memeuclidean")));
-                                                       outputNames.push_back(fileNameRoot+"memeuclidean"); outputTypes["memeuclidean"].push_back(fileNameRoot+"memeuclidean");
-                                               }else if (Estimators[i] == "mempearson") { 
-                                                       cDisplays.push_back(new CollectDisplay(new MemPearson(), new SharedOneColumnFile(fileNameRoot+"mempearson")));
-                                                       outputNames.push_back(fileNameRoot+"mempearson"); outputTypes["mempearson"].push_back(fileNameRoot+"mempearson");
-                                               }
-                                               
-                                       }
-                               }       
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "CollectSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CollectSharedCommand::~CollectSharedCommand(){}
-//**********************************************************************************************************************
-
-int CollectSharedCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //if the users entered no valid calculators don't execute command
-               if (cDisplays.size() == 0) { return 0; }
-               for(int i=0;i<cDisplays.size();i++){    cDisplays[i]->setAll(all);      }       
-       
-               input = new InputData(sharedfile, "sharedfile");
-               order = input->getSharedOrderVector();
-               string lastLabel = order->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-                       
-               //set users groups
-               SharedUtil* util = new SharedUtil();
-               Groups = m->getGroups();
-               vector<string> allGroups = m->getAllGroups();
-               util->setGroups(Groups, allGroups, "collect");
-               m->setGroups(Groups);
-               m->setAllGroups(allGroups);
-               delete util;
-
-               while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  outputTypes.clear();
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       delete order; delete input;
-                                       m->clearGroups();
-                                       return 0;
-                       }
-
-                       if(allLines == 1 || labels.count(order->getLabel()) == 1){
-                       
-                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                               //create collectors curve
-                               cCurve = new Collect(order, cDisplays);
-                               cCurve->getSharedCurve(freq);
-                               delete cCurve;
-                       
-                               processedLabels.insert(order->getLabel());
-                               userLabels.erase(order->getLabel());
-                       }
-                       
-                       //you have a label the user want that is smaller than this label and the last label has not already been processed
-                       if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = order->getLabel();
-                               
-                               delete order;
-                               order = input->getSharedOrderVector(lastLabel);
-                               
-                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                               //create collectors curve
-                               cCurve = new Collect(order, cDisplays);
-                               cCurve->getSharedCurve(freq);
-                               delete cCurve;
-                               
-                               processedLabels.insert(order->getLabel());
-                               userLabels.erase(order->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               order->setLabel(saveLabel);
-                       }
-                       
-                       
-                       lastLabel = order->getLabel();                  
-                       
-                       //get next line to process
-                       delete order;
-                       order = input->getSharedOrderVector();
-               }
-               
-               if (m->control_pressed) { 
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }   outputTypes.clear();
-                                       for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                                       m->clearGroups();
-                                       delete input;
-                                       return 0;
-               }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (order != NULL) {  delete order;  }
-                       order = input->getSharedOrderVector(lastLabel);
-                       
-                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                       cCurve = new Collect(order, cDisplays);
-                       cCurve->getSharedCurve(freq);
-                       delete cCurve;
-                       
-                       if (m->control_pressed) { 
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  outputTypes.clear();
-                               for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }
-                               delete order; 
-                               delete input;
-                               m->clearGroups();
-                               return 0;
-                       }
-
-                       delete order;
-               }
-               
-               for(int i=0;i<cDisplays.size();i++){    delete cDisplays[i];    }       
-               
-               //reset groups parameter
-               m->clearGroups(); 
-               delete input;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CollectSharedCommand", "execute");
-               exit(1);
-       }
-}
-
-/***********************************************************/
diff --git a/collectsharedcommand.h b/collectsharedcommand.h
deleted file mode 100644 (file)
index 71c11d6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef COLLECTSHAREDCOMMAND_H
-#define COLLECTSHAREDCOMMAND_H
-/*
- *  collectsharedcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sharedordervector.h"
-#include "inputdata.h"
-#include "collect.h"
-#include "display.h"
-#include "validcalculator.h"
-#include "sharedutilities.h"
-
-
-class CollectSharedCommand : public Command {
-       
-public:
-       CollectSharedCommand(string);   
-       CollectSharedCommand(); 
-       ~CollectSharedCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "collect.shared";                      }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Handelsman J (2006). Introducing SONS, A tool that compares the membership of microbial communities. Appl Environ Microbiol 72: 6773-9. \nhttp://www.mothur.org/wiki/Collect.shared"; }
-       string getDescription()         { return "generates collector's curves for calculators, which describe the similarity between communities or their shared richness"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       SharedOrderVector* order;
-       InputData* input;
-       Collect* cCurve;
-       vector<Display*> cDisplays;
-       float freq;
-
-       bool abort, allLines, all;
-       set<string> labels; //holds labels to be used
-       string label, calc, groups, outputDir, sharedfile;
-       vector<string>  Estimators, Groups, outputNames;
-};
-
-#endif
diff --git a/command.hpp b/command.hpp
deleted file mode 100644 (file)
index 22f1181..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef COMMAND_HPP
-#define COMMAND_HPP
-//test2
-/*
- *  command.h
- *  
- *
- *  Created by Pat Schloss on 10/23/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-/*This class is a parent to all the command classes.  */
-
-
-#include "mothur.h"
-#include "optionparser.h"
-#include "validparameter.h"
-#include "mothurout.h"
-#include "commandparameter.h"
-
-
-class Command {
-       
-       public:
-               Command() {  m = MothurOut::getInstance();   } 
-               
-               //needed by gui
-               virtual string getCommandName() = 0;
-               virtual string getCommandCategory() = 0;
-               virtual string getHelpString() = 0;
-               virtual string getCitation() = 0;
-               virtual string getDescription() = 0;
-               
-               virtual map<string, vector<string> > getOutputFiles() { return outputTypes; }
-               virtual vector<string> setParameters() = 0; //to fill parameters
-               virtual vector<CommandParameter> getParameters() { return parameters; }
-       
-               virtual int execute() = 0;
-               virtual void help() = 0;
-               void citation() { m->mothurOutEndLine(); m->mothurOut(getCitation()); m->mothurOutEndLine(); }
-               virtual ~Command() { }
-       
-       protected:
-               MothurOut* m;
-               bool calledHelp;
-                       
-               map<string, vector<string> > outputTypes;
-               vector<CommandParameter> parameters;
-       
-               map<string, vector<string> >::iterator itTypes;
-};
-
-#endif
diff --git a/commandfactory.cpp b/commandfactory.cpp
deleted file mode 100644 (file)
index 527f7bf..0000000
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- *  commandfactory.cpp
- *  
- *
- *  Created by Pat Schloss on 10/25/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readdistcommand.h"
-#include "readtreecommand.h"
-#include "readotucommand.h"
-#include "clustercommand.h"
-#include "collectcommand.h"
-#include "collectsharedcommand.h"
-#include "getgroupcommand.h"
-#include "getlabelcommand.h"
-#include "rarefactcommand.h"
-#include "summarycommand.h"
-#include "summarysharedcommand.h"
-#include "rarefactsharedcommand.h"
-#include "quitcommand.h"
-#include "helpcommand.h"
-#include "commandfactory.hpp"
-#include "deconvolutecommand.h"
-#include "parsimonycommand.h"
-#include "unifracunweightedcommand.h"
-#include "unifracweightedcommand.h"
-#include "libshuffcommand.h"
-#include "heatmapcommand.h"
-#include "heatmapsimcommand.h"
-#include "filterseqscommand.h"
-#include "venncommand.h"
-#include "nocommands.h"
-#include "binsequencecommand.h"
-#include "getoturepcommand.h"
-#include "treegroupscommand.h"
-#include "distancecommand.h"
-#include "aligncommand.h"
-#include "matrixoutputcommand.h"
-#include "getsabundcommand.h"
-#include "getrabundcommand.h"
-#include "seqsummarycommand.h"
-#include "screenseqscommand.h"
-#include "reversecommand.h"
-#include "trimseqscommand.h"
-#include "mergefilecommand.h"
-#include "listseqscommand.h"
-#include "getseqscommand.h"
-#include "removeseqscommand.h"
-#include "systemcommand.h"
-#include "secondarystructurecommand.h"
-#include "getsharedotucommand.h"
-#include "getlistcountcommand.h"
-#include "hclustercommand.h"
-#include "classifyseqscommand.h"
-#include "phylotypecommand.h"
-#include "mgclustercommand.h"
-#include "preclustercommand.h"
-#include "pcoacommand.h"
-#include "otuhierarchycommand.h"
-#include "setdircommand.h"
-#include "parselistscommand.h"
-#include "chimeraccodecommand.h"
-#include "chimeracheckcommand.h"
-#include "chimeraslayercommand.h"
-#include "chimerapintailcommand.h"
-#include "chimerabellerophoncommand.h"
-#include "chimerauchimecommand.h"
-#include "setlogfilecommand.h"
-#include "phylodiversitycommand.h"
-#include "makegroupcommand.h"
-#include "chopseqscommand.h"
-#include "clearcutcommand.h"
-#include "catchallcommand.h"
-#include "splitabundcommand.h"
-#include "clustersplitcommand.h"
-#include "classifyotucommand.h"
-#include "degapseqscommand.h"
-#include "getrelabundcommand.h"
-#include "sensspeccommand.h"
-#include "sffinfocommand.h"
-#include "seqerrorcommand.h"
-#include "normalizesharedcommand.h"
-#include "metastatscommand.h"
-#include "splitgroupscommand.h"
-#include "clusterfragmentscommand.h"
-#include "getlineagecommand.h"
-#include "removelineagecommand.h"
-#include "parsefastaqcommand.h"
-#include "pipelinepdscommand.h"
-#include "deuniqueseqscommand.h"
-#include "pairwiseseqscommand.h"
-#include "clusterdoturcommand.h"
-#include "subsamplecommand.h"
-#include "removegroupscommand.h"
-#include "getgroupscommand.h"
-#include "getotuscommand.h"
-#include "removeotuscommand.h"
-#include "indicatorcommand.h"
-#include "consensusseqscommand.h"
-#include "trimflowscommand.h"
-#include "corraxescommand.h"
-#include "shhhercommand.h"
-#include "pcacommand.h"
-#include "nmdscommand.h"
-#include "removerarecommand.h"
-#include "mergegroupscommand.h"
-#include "amovacommand.h"
-#include "homovacommand.h"
-#include "mantelcommand.h"
-#include "makefastqcommand.h"
-#include "anosimcommand.h"
-#include "getcurrentcommand.h"
-#include "setcurrentcommand.h"
-#include "sharedcommand.h"
-#include "getcommandinfocommand.h"
-#include "deuniquetreecommand.h"
-#include "countseqscommand.h"
-#include "countgroupscommand.h"
-#include "clearmemorycommand.h"
-#include "summarytaxcommand.h"
-#include "chimeraperseuscommand.h"
-#include "shhhseqscommand.h"
-#include "summaryqualcommand.h"
-#include "otuassociationcommand.h"
-#include "sortseqscommand.h"
-#include "classifytreecommand.h"
-#include "cooccurrencecommand.h"
-#include "pcrseqscommand.h"
-#include "createdatabasecommand.h"
-#include "makebiomcommand.h"
-
-/*******************************************************/
-
-/******************************************************/
-CommandFactory* CommandFactory::getInstance() {
-       if( _uniqueInstance == 0) {
-               _uniqueInstance = new CommandFactory();
-       }
-       return _uniqueInstance;
-}
-/***********************************************************/
-
-/***********************************************************/
-//note: This class is resposible for knowing which commands are mpiEnabled,
-//If a command is not enabled only process 0 will execute the command. 
-//This avoids redundant outputs on pieces of code we have not paralellized. 
-//If you add mpi code to a existing command you need to modify the list below or the code will hang on MPI blocking commands like FIle_open. 
-//example:  commands["dist.seqs"] = "MPIEnabled";
-
-CommandFactory::CommandFactory(){
-       string s = "";
-       m = MothurOut::getInstance();
-       
-       command = new NoCommand(s);
-       shellcommand = new NoCommand(s);
-       pipecommand = new NoCommand(s);
-       
-       outputDir = ""; inputDir = "";
-       logFileName = "";
-       append = false;
-       
-       //initialize list of valid commands
-       commands["read.dist"]                   = "read.dist"; 
-       commands["read.otu"]                    = "read.otu";
-       commands["read.tree"]                   = "read.tree"; 
-       commands["make.shared"]                 = "make.shared"; 
-       commands["bin.seqs"]                    = "bin.seqs"; 
-       commands["get.oturep"]                  = "get.oturep";
-       commands["cluster"]                             = "cluster"; 
-       commands["unique.seqs"]                 = "unique.seqs"; 
-       commands["dist.shared"]                 = "dist.shared";
-       commands["collect.single"]              = "collect.single"; 
-       commands["collect.shared"]              = "collect.shared"; 
-       commands["rarefaction.single"]  = "rarefaction.single"; 
-       commands["rarefaction.shared"]  = "rarefaction.shared"; 
-       commands["summary.single"]              = "summary.single"; 
-       commands["summary.shared"]              = "summary.shared"; 
-       commands["parsimony"]                   = "parsimony";
-       commands["unifrac.weighted"]    = "unifrac.weighted"; 
-       commands["unifrac.unweighted"]  = "unifrac.unweighted"; 
-       commands["libshuff"]                    = "libshuff";
-       commands["tree.shared"]                 = "tree.shared";
-       commands["heatmap.bin"]                 = "heatmap.bin";
-       commands["heatmap.sim"]                 = "heatmap.sim";
-       commands["venn"]                                = "venn";
-       commands["get.group"]           = "get.group";
-       commands["get.label"]           = "get.label";
-       commands["get.sabund"]          = "get.sabund";
-       commands["get.rabund"]          = "get.rabund";
-       commands["help"]                                = "help";
-       commands["reverse.seqs"]                = "reverse.seqs";
-       commands["trim.seqs"]                   = "trim.seqs";
-       commands["trim.flows"]                  = "trim.flows";
-       commands["list.seqs"]                   = "list.seqs";
-       commands["get.seqs"]                    = "get.seqs";
-       commands["remove.seqs"]                 = "remove.seqs";
-       commands["system"]                              = "system";
-       commands["align.check"]                 = "align.check";
-       commands["get.sharedseqs"]              = "get.sharedseqs";
-       commands["get.otulist"]                 = "get.otulist";
-       commands["hcluster"]                    = "hcluster"; 
-       commands["phylotype"]                   = "phylotype";
-       commands["mgcluster"]                   = "mgcluster";
-       commands["pre.cluster"]                 = "pre.cluster";
-       commands["pcoa"]                                = "pcoa";
-       commands["otu.hierarchy"]               = "otu.hierarchy";
-       commands["set.dir"]                             = "MPIEnabled";
-       commands["merge.files"]                 = "merge.files";
-       commands["parse.list"]                  = "parse.list";
-       commands["set.logfile"]                 = "set.logfile";
-       commands["phylo.diversity"]             = "phylo.diversity";
-       commands["make.group"]                  = "make.group";
-       commands["chop.seqs"]                   = "chop.seqs";
-       commands["clearcut"]                    = "clearcut";
-       commands["catchall"]                    = "catchall";
-       commands["split.abund"]                 = "split.abund";
-       commands["classify.otu"]                = "classify.otu";
-       commands["degap.seqs"]                  = "degap.seqs";
-       commands["get.relabund"]                = "get.relabund";
-       commands["sffinfo"]                             = "sffinfo";
-       commands["normalize.shared"]    = "normalize.shared";
-       commands["metastats"]                   = "metastats";
-       commands["split.groups"]                = "split.groups";
-       commands["cluster.fragments"]   = "cluster.fragments";
-       commands["get.lineage"]                 = "get.lineage";
-       commands["remove.lineage"]              = "remove.lineage";
-       commands["fastq.info"]                  = "fastq.info";
-       commands["deunique.seqs"]               = "deunique.seqs";
-       commands["cluster.classic"]             = "cluster.classic";
-       commands["sub.sample"]                  = "sub.sample";
-       commands["remove.groups"]               = "remove.groups";
-       commands["get.groups"]                  = "get.groups";
-       commands["get.otus"]                    = "get.otus";
-       commands["remove.otus"]                 = "remove.otus";
-       commands["indicator"]                   = "indicator";
-       commands["consensus.seqs"]              = "consensus.seqs";
-       commands["corr.axes"]                   = "corr.axes";
-       commands["pca"]                                 = "pca";
-       commands["nmds"]                                = "nmds";
-       commands["remove.rare"]                 = "remove.rare";
-       commands["amova"]                               = "amova";
-       commands["homova"]                              = "homova";
-       commands["mantel"]                              = "mantel";
-       commands["anosim"]                              = "anosim";
-       commands["make.fastq"]                  = "make.fastq";
-       commands["merge.groups"]                = "merge.groups";
-       commands["get.current"]                 = "MPIEnabled";
-       commands["set.current"]                 = "MPIEnabled";
-       commands["get.commandinfo"]             = "get.commandinfo";
-       commands["deunique.tree"]               = "deunique.tree";
-       commands["count.seqs"]                  = "count.seqs";
-       commands["count.groups"]                = "count.groups";
-       commands["clear.memory"]                = "clear.memory";
-       commands["pairwise.seqs"]               = "MPIEnabled";
-       commands["pipeline.pds"]                = "MPIEnabled";
-       commands["classify.seqs"]               = "MPIEnabled"; 
-       commands["dist.seqs"]                   = "MPIEnabled";
-       commands["filter.seqs"]                 = "MPIEnabled";
-       commands["align.seqs"]                  = "MPIEnabled";
-       commands["chimera.ccode"]               = "MPIEnabled";
-       commands["chimera.check"]               = "MPIEnabled";
-       commands["chimera.slayer"]              = "MPIEnabled";
-       commands["chimera.uchime"]              = "chimera.uchime";
-       commands["chimera.perseus"]             = "chimera.perseus";
-       commands["chimera.pintail"]             = "MPIEnabled";
-       commands["chimera.bellerophon"] = "MPIEnabled";
-       commands["screen.seqs"]                 = "MPIEnabled";
-       commands["summary.seqs"]                = "MPIEnabled";
-       commands["cluster.split"]               = "MPIEnabled";
-       commands["shhh.flows"]                  = "MPIEnabled";
-       commands["sens.spec"]                   = "sens.spec";
-       commands["seq.error"]                   = "seq.error";
-       commands["summary.tax"]                 = "summary.tax";
-       commands["summary.qual"]                = "summary.qual";
-       commands["shhh.seqs"]                   = "shhh.seqs";
-       commands["otu.association"]             = "otu.association";
-    commands["sort.seqs"]           = "sort.seqs";
-    commands["classify.tree"]       = "classify.tree";
-    commands["cooccurrence"]        = "cooccurrence";
-    commands["pcr.seqs"]            = "pcr.seqs";
-    commands["create.database"]     = "create.database";
-    commands["make.biom"]           = "make.biom";
-       commands["quit"]                                = "MPIEnabled"; 
-
-}
-/***********************************************************/
-
-/***********************************************************/
-bool CommandFactory::MPIEnabled(string commandName) {
-       bool mpi = false;
-       it = commands.find(commandName);
-       if (it != commands.end()) { 
-               if (it->second == "MPIEnabled") { return true; }
-       }
-       return mpi;
-}
-/***********************************************************/
-
-/***********************************************************/
-CommandFactory::~CommandFactory(){
-       _uniqueInstance = 0;
-       delete command;
-       delete shellcommand;
-       delete pipecommand;
-}
-/***********************************************************/
-
-/***********************************************************/
-int CommandFactory::checkForRedirects(string optionString) {
-    try {
-        
-        int pos = optionString.find("outputdir");
-        if (pos != string::npos) { //user has set outputdir in command option string
-            string outputOption = "";
-            bool foundEquals = false;
-            for(int i=pos;i<optionString.length();i++){
-                if(optionString[i] == ',')       { break;               }              
-                else if(optionString[i] == '=')  { foundEquals = true; }
-                if (foundEquals)       {   outputOption += optionString[i]; }
-            }
-            if(m->dirCheck(outputOption)){ 
-                setOutputDirectory(outputOption); 
-                m->mothurOut("Setting output directory to: " + outputOption); m->mothurOutEndLine();
-            }
-        }
-        
-        pos = optionString.find("inputdir");
-        if (pos != string::npos) { //user has set inputdir in command option string
-            string intputOption = "";
-            bool foundEquals = false;
-            for(int i=pos;i<optionString.length();i++){
-                if(optionString[i] == ',')       { break;               }              
-                else if(optionString[i] == '=')  { foundEquals = true; }
-                if (foundEquals)       {   intputOption += optionString[i]; }
-            }
-            if(m->dirCheck(intputOption)){ 
-                setInputDirectory(intputOption); 
-                m->mothurOut("Setting input directory to: " + intputOption); m->mothurOutEndLine();
-            }
-        }
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "getCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-/***********************************************************/
-//This function calls the appropriate command fucntions based on user input.
-Command* CommandFactory::getCommand(string commandName, string optionString){
-       try {
-        
-               delete command;   //delete the old command
-        
-        checkForRedirects(optionString);
-                       
-               //user has opted to redirect output from dir where input files are located to some other place
-               if (outputDir != "") { 
-                       if (optionString != "") { optionString += ", outputdir=" + outputDir; }
-                       else { optionString += "outputdir=" + outputDir; }
-               }
-               
-               //user has opted to redirect input from dir where mothur.exe is located to some other place
-               if (inputDir != "") { 
-                       if (optionString != "") { optionString += ", inputdir=" + inputDir; }
-                       else { optionString += "inputdir=" + inputDir; }
-               }
-               
-               if(commandName == "read.dist")                                  {       command = new ReadDistCommand(optionString);                            }
-               else if(commandName == "read.otu")                              {       command = new ReadOtuCommand(optionString);                                     }
-               else if(commandName == "read.tree")                             {       command = new ReadTreeCommand(optionString);                            }
-               else if(commandName == "cluster")                               {       command = new ClusterCommand(optionString);                                     }
-               else if(commandName == "unique.seqs")                   {       command = new DeconvoluteCommand(optionString);                         }
-               else if(commandName == "parsimony")                             {       command = new ParsimonyCommand(optionString);                           }
-               else if(commandName == "help")                                  {       command = new HelpCommand(optionString);                                        }
-               else if(commandName == "quit")                                  {       command = new QuitCommand(optionString);                                        }
-               else if(commandName == "collect.single")                {       command = new CollectCommand(optionString);                                     }
-               else if(commandName == "collect.shared")                {       command = new CollectSharedCommand(optionString);                       }
-               else if(commandName == "rarefaction.single")    {       command = new RareFactCommand(optionString);                            }
-               else if(commandName == "rarefaction.shared")    {       command = new RareFactSharedCommand(optionString);                      }
-               else if(commandName == "summary.single")                {       command = new SummaryCommand(optionString);                                     }
-               else if(commandName == "summary.shared")                {       command = new SummarySharedCommand(optionString);                       }
-               else if(commandName == "unifrac.weighted")              {       command = new UnifracWeightedCommand(optionString);                     }
-               else if(commandName == "unifrac.unweighted")    {       command = new UnifracUnweightedCommand(optionString);           }
-               else if(commandName == "get.group")             {   command = new GetgroupCommand(optionString);                                }
-               else if(commandName == "get.label")             {   command = new GetlabelCommand(optionString);                                }
-               else if(commandName == "get.sabund")            {   command = new GetSAbundCommand(optionString);                               }
-               else if(commandName == "get.rabund")            {   command = new GetRAbundCommand(optionString);                               }
-               else if(commandName == "libshuff")              {   command = new LibShuffCommand(optionString);                                }
-               else if(commandName == "heatmap.bin")                   {   command = new HeatMapCommand(optionString);                                 }
-               else if(commandName == "heatmap.sim")                   {   command = new HeatMapSimCommand(optionString);                              }
-               else if(commandName == "filter.seqs")                   {   command = new FilterSeqsCommand(optionString);                              }
-               else if(commandName == "venn")                                  {   command = new VennCommand(optionString);                                    }
-               else if(commandName == "bin.seqs")                              {   command = new BinSeqCommand(optionString);                                  }
-               else if(commandName == "get.oturep")                    {   command = new GetOTURepCommand(optionString);                               }
-               else if(commandName == "tree.shared")                   {   command = new TreeGroupCommand(optionString);                               }
-               else if(commandName == "dist.shared")                   {   command = new MatrixOutputCommand(optionString);                    }
-               else if(commandName == "dist.seqs")                             {   command = new DistanceCommand(optionString);                                }
-               else if(commandName == "align.seqs")                    {   command = new AlignCommand(optionString);                                   }
-               else if(commandName == "summary.seqs")                  {       command = new SeqSummaryCommand(optionString);                          }
-               else if(commandName == "screen.seqs")                   {       command = new ScreenSeqsCommand(optionString);                          }
-               else if(commandName == "reverse.seqs")                  {       command = new ReverseSeqsCommand(optionString);                         }
-               else if(commandName == "trim.seqs")                             {       command = new TrimSeqsCommand(optionString);                            }
-               else if(commandName == "trim.flows")                    {       command = new TrimFlowsCommand(optionString);                           }
-               else if(commandName == "shhh.flows")                    {       command = new ShhherCommand(optionString);                                      }
-               else if(commandName == "list.seqs")                             {       command = new ListSeqsCommand(optionString);                            }
-               else if(commandName == "get.seqs")                              {       command = new GetSeqsCommand(optionString);                                     }
-               else if(commandName == "remove.seqs")                   {       command = new RemoveSeqsCommand(optionString);                          }
-               else if(commandName == "merge.files")                   {       command = new MergeFileCommand(optionString);                           }
-               else if(commandName == "system")                                {       command = new SystemCommand(optionString);                                      }
-               else if(commandName == "align.check")                   {       command = new AlignCheckCommand(optionString);                          }
-               else if(commandName == "get.sharedseqs")                {       command = new GetSharedOTUCommand(optionString);                        }
-               else if(commandName == "get.otulist")                   {       command = new GetListCountCommand(optionString);                        }
-               else if(commandName == "hcluster")                              {       command = new HClusterCommand(optionString);                            }
-               else if(commandName == "classify.seqs")                 {       command = new ClassifySeqsCommand(optionString);                        }
-               else if(commandName == "chimera.ccode")                 {       command = new ChimeraCcodeCommand(optionString);                        }
-               else if(commandName == "chimera.check")                 {       command = new ChimeraCheckCommand(optionString);                        }
-               else if(commandName == "chimera.slayer")                {       command = new ChimeraSlayerCommand(optionString);                       }
-               else if(commandName == "chimera.uchime")                {       command = new ChimeraUchimeCommand(optionString);                       }
-               else if(commandName == "chimera.pintail")               {       command = new ChimeraPintailCommand(optionString);                      }
-               else if(commandName == "chimera.bellerophon")   {       command = new ChimeraBellerophonCommand(optionString);          }
-               else if(commandName == "phylotype")                             {       command = new PhylotypeCommand(optionString);                           }
-               else if(commandName == "mgcluster")                             {       command = new MGClusterCommand(optionString);                           }
-               else if(commandName == "pre.cluster")                   {       command = new PreClusterCommand(optionString);                          }
-               else if(commandName == "pcoa")                                  {       command = new PCOACommand(optionString);                                        }
-               else if(commandName == "pca")                                   {       command = new PCACommand(optionString);                                         }
-               else if(commandName == "nmds")                                  {       command = new NMDSCommand(optionString);                                        }
-               else if(commandName == "otu.hierarchy")                 {       command = new OtuHierarchyCommand(optionString);                        }
-               else if(commandName == "set.dir")                               {       command = new SetDirectoryCommand(optionString);                        }
-               else if(commandName == "set.logfile")                   {       command = new SetLogFileCommand(optionString);                          }
-               else if(commandName == "parse.list")                    {       command = new ParseListCommand(optionString);                           }
-               else if(commandName == "phylo.diversity")               {       command = new PhyloDiversityCommand(optionString);                      }
-               else if(commandName == "make.group")                    {       command = new MakeGroupCommand(optionString);                           }
-               else if(commandName == "chop.seqs")                             {       command = new ChopSeqsCommand(optionString);                            }
-               else if(commandName == "clearcut")                              {       command = new ClearcutCommand(optionString);                            }
-               else if(commandName == "catchall")                              {       command = new CatchAllCommand(optionString);                            }
-               else if(commandName == "split.abund")                   {       command = new SplitAbundCommand(optionString);                          }
-               else if(commandName == "cluster.split")                 {       command = new ClusterSplitCommand(optionString);                        }
-               else if(commandName == "classify.otu")                  {       command = new ClassifyOtuCommand(optionString);                         }
-               else if(commandName == "degap.seqs")                    {       command = new DegapSeqsCommand(optionString);                           }
-               else if(commandName == "get.relabund")                  {       command = new GetRelAbundCommand(optionString);                         }
-               else if(commandName == "sens.spec")                             {       command = new SensSpecCommand(optionString);                            }
-               else if(commandName == "seq.error")                             {       command = new SeqErrorCommand(optionString);                            }
-               else if(commandName == "sffinfo")                               {       command = new SffInfoCommand(optionString);                                     }
-               else if(commandName == "normalize.shared")              {       command = new NormalizeSharedCommand(optionString);                     }
-               else if(commandName == "metastats")                             {       command = new MetaStatsCommand(optionString);                           }
-               else if(commandName == "split.groups")                  {       command = new SplitGroupCommand(optionString);                          }
-               else if(commandName == "cluster.fragments")             {       command = new ClusterFragmentsCommand(optionString);            }
-               else if(commandName == "get.lineage")                   {       command = new GetLineageCommand(optionString);                          }
-               else if(commandName == "remove.lineage")                {       command = new RemoveLineageCommand(optionString);                       }
-               else if(commandName == "get.groups")                    {       command = new GetGroupsCommand(optionString);                           }
-               else if(commandName == "remove.groups")                 {       command = new RemoveGroupsCommand(optionString);                        }
-               else if(commandName == "get.otus")                              {       command = new GetOtusCommand(optionString);                                     }
-               else if(commandName == "remove.otus")                   {       command = new RemoveOtusCommand(optionString);                          }
-               else if(commandName == "fastq.info")                    {       command = new ParseFastaQCommand(optionString);                         }
-               else if(commandName == "pipeline.pds")                  {       command = new PipelineCommand(optionString);                            }
-               else if(commandName == "deunique.seqs")                 {       command = new DeUniqueSeqsCommand(optionString);                        }
-               else if(commandName == "pairwise.seqs")                 {       command = new PairwiseSeqsCommand(optionString);                        }
-               else if(commandName == "cluster.classic")               {       command = new ClusterDoturCommand(optionString);                        }
-               else if(commandName == "sub.sample")                    {       command = new SubSampleCommand(optionString);                           }
-               else if(commandName == "indicator")                             {       command = new IndicatorCommand(optionString);                           }
-               else if(commandName == "consensus.seqs")                {       command = new ConsensusSeqsCommand(optionString);                       }
-               else if(commandName == "corr.axes")                             {       command = new CorrAxesCommand(optionString);                            }
-               else if(commandName == "remove.rare")                   {       command = new RemoveRareCommand(optionString);                          }
-               else if(commandName == "merge.groups")                  {       command = new MergeGroupsCommand(optionString);                         }
-               else if(commandName == "amova")                                 {       command = new AmovaCommand(optionString);                                       }
-               else if(commandName == "homova")                                {       command = new HomovaCommand(optionString);                                      }
-               else if(commandName == "mantel")                                {       command = new MantelCommand(optionString);                                      }
-               else if(commandName == "make.fastq")                    {       command = new MakeFastQCommand(optionString);                           }
-               else if(commandName == "get.current")                   {       command = new GetCurrentCommand(optionString);                          }
-               else if(commandName == "set.current")                   {       command = new SetCurrentCommand(optionString);                          }
-               else if(commandName == "anosim")                                {       command = new AnosimCommand(optionString);                                      }
-               else if(commandName == "make.shared")                   {       command = new SharedCommand(optionString);                                      }
-               else if(commandName == "get.commandinfo")               {       command = new GetCommandInfoCommand(optionString);                      }
-               else if(commandName == "deunique.tree")                 {       command = new DeuniqueTreeCommand(optionString);                        }
-               else if(commandName == "count.seqs")                    {       command = new CountSeqsCommand(optionString);                           }
-               else if(commandName == "count.groups")                  {       command = new CountGroupsCommand(optionString);                         }
-               else if(commandName == "clear.memory")                  {       command = new ClearMemoryCommand(optionString);                         }
-               else if(commandName == "summary.tax")                   {       command = new SummaryTaxCommand(optionString);                          }
-               else if(commandName == "summary.qual")                  {       command = new SummaryQualCommand(optionString);                         }
-               else if(commandName == "chimera.perseus")               {       command = new ChimeraPerseusCommand(optionString);                      }
-               else if(commandName == "shhh.seqs")                             {       command = new ShhhSeqsCommand(optionString);                            }
-               else if(commandName == "otu.association")               {       command = new OTUAssociationCommand(optionString);                      }
-        else if(commandName == "sort.seqs")             {      command = new SortSeqsCommand(optionString);                }
-        else if(commandName == "classify.tree")         {      command = new ClassifyTreeCommand(optionString);            }
-        else if(commandName == "cooccurrence")          {      command = new CooccurrenceCommand(optionString);            }
-        else if(commandName == "pcr.seqs")              {      command = new PcrSeqsCommand(optionString);                 }
-        else if(commandName == "create.database")       {      command = new CreateDatabaseCommand(optionString);          }
-        else if(commandName == "make.biom")             {      command = new MakeBiomCommand(optionString);                }
-               else                                                                                    {       command = new NoCommand(optionString);                                          }
-
-               return command;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "getCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-/***********************************************************/
-//This function calls the appropriate command fucntions based on user input.
-Command* CommandFactory::getCommand(string commandName, string optionString, string mode){
-       try {
-               delete pipecommand;   //delete the old command
-               
-        checkForRedirects(optionString);
-        
-               //user has opted to redirect output from dir where input files are located to some other place
-               if (outputDir != "") { 
-                       if (optionString != "") { optionString += ", outputdir=" + outputDir; }
-                       else { optionString += "outputdir=" + outputDir; }
-               }
-               
-               //user has opted to redirect input from dir where mothur.exe is located to some other place
-               if (inputDir != "") { 
-                       if (optionString != "") { optionString += ", inputdir=" + inputDir; }
-                       else { optionString += "inputdir=" + inputDir; }
-               }
-               
-               if(commandName == "read.dist")                                  {       pipecommand = new ReadDistCommand(optionString);                                }
-               else if(commandName == "read.otu")                              {       pipecommand = new ReadOtuCommand(optionString);                                 }
-               else if(commandName == "read.tree")                             {       pipecommand = new ReadTreeCommand(optionString);                                }
-               else if(commandName == "cluster")                               {       pipecommand = new ClusterCommand(optionString);                                 }
-               else if(commandName == "unique.seqs")                   {       pipecommand = new DeconvoluteCommand(optionString);                             }
-               else if(commandName == "parsimony")                             {       pipecommand = new ParsimonyCommand(optionString);                               }
-               else if(commandName == "help")                                  {       pipecommand = new HelpCommand(optionString);                                    }
-               else if(commandName == "quit")                                  {       pipecommand = new QuitCommand(optionString);                                    }
-               else if(commandName == "collect.single")                {       pipecommand = new CollectCommand(optionString);                                 }
-               else if(commandName == "collect.shared")                {       pipecommand = new CollectSharedCommand(optionString);                   }
-               else if(commandName == "rarefaction.single")    {       pipecommand = new RareFactCommand(optionString);                                }
-               else if(commandName == "rarefaction.shared")    {       pipecommand = new RareFactSharedCommand(optionString);                  }
-               else if(commandName == "summary.single")                {       pipecommand = new SummaryCommand(optionString);                                 }
-               else if(commandName == "summary.shared")                {       pipecommand = new SummarySharedCommand(optionString);                   }
-               else if(commandName == "unifrac.weighted")              {       pipecommand = new UnifracWeightedCommand(optionString);                 }
-               else if(commandName == "unifrac.unweighted")    {       pipecommand = new UnifracUnweightedCommand(optionString);               }
-               else if(commandName == "get.group")             {   pipecommand = new GetgroupCommand(optionString);                            }
-               else if(commandName == "get.label")             {   pipecommand = new GetlabelCommand(optionString);                            }
-               else if(commandName == "get.sabund")            {   pipecommand = new GetSAbundCommand(optionString);                           }
-               else if(commandName == "get.rabund")            {   pipecommand = new GetRAbundCommand(optionString);                           }
-               else if(commandName == "libshuff")              {   pipecommand = new LibShuffCommand(optionString);                            }
-               else if(commandName == "heatmap.bin")                   {   pipecommand = new HeatMapCommand(optionString);                                     }
-               else if(commandName == "heatmap.sim")                   {   pipecommand = new HeatMapSimCommand(optionString);                          }
-               else if(commandName == "filter.seqs")                   {   pipecommand = new FilterSeqsCommand(optionString);                          }
-               else if(commandName == "venn")                                  {   pipecommand = new VennCommand(optionString);                                        }
-               else if(commandName == "bin.seqs")                              {   pipecommand = new BinSeqCommand(optionString);                                      }
-               else if(commandName == "get.oturep")                    {   pipecommand = new GetOTURepCommand(optionString);                           }
-               else if(commandName == "tree.shared")                   {   pipecommand = new TreeGroupCommand(optionString);                           }
-               else if(commandName == "dist.shared")                   {   pipecommand = new MatrixOutputCommand(optionString);                        }
-               else if(commandName == "dist.seqs")                             {   pipecommand = new DistanceCommand(optionString);                            }
-               else if(commandName == "align.seqs")                    {   pipecommand = new AlignCommand(optionString);                                       }
-               else if(commandName == "summary.seqs")                  {       pipecommand = new SeqSummaryCommand(optionString);                              }
-               else if(commandName == "screen.seqs")                   {       pipecommand = new ScreenSeqsCommand(optionString);                              }
-               else if(commandName == "reverse.seqs")                  {       pipecommand = new ReverseSeqsCommand(optionString);                             }
-               else if(commandName == "trim.seqs")                             {       pipecommand = new TrimSeqsCommand(optionString);                                }
-               else if(commandName == "trim.flows")                    {       pipecommand = new TrimFlowsCommand(optionString);                               }
-               else if(commandName == "shhh.flows")                    {       pipecommand = new ShhherCommand(optionString);                                  }
-               else if(commandName == "list.seqs")                             {       pipecommand = new ListSeqsCommand(optionString);                                }
-               else if(commandName == "get.seqs")                              {       pipecommand = new GetSeqsCommand(optionString);                                 }
-               else if(commandName == "remove.seqs")                   {       pipecommand = new RemoveSeqsCommand(optionString);                              }
-               else if(commandName == "merge.files")                   {       pipecommand = new MergeFileCommand(optionString);                               }
-               else if(commandName == "system")                                {       pipecommand = new SystemCommand(optionString);                                  }
-               else if(commandName == "align.check")                   {       pipecommand = new AlignCheckCommand(optionString);                              }
-               else if(commandName == "get.sharedseqs")                {       pipecommand = new GetSharedOTUCommand(optionString);                    }
-               else if(commandName == "get.otulist")                   {       pipecommand = new GetListCountCommand(optionString);                    }
-               else if(commandName == "hcluster")                              {       pipecommand = new HClusterCommand(optionString);                                }
-               else if(commandName == "classify.seqs")                 {       pipecommand = new ClassifySeqsCommand(optionString);                    }
-               else if(commandName == "chimera.ccode")                 {       pipecommand = new ChimeraCcodeCommand(optionString);                    }
-               else if(commandName == "chimera.check")                 {       pipecommand = new ChimeraCheckCommand(optionString);                    }
-               else if(commandName == "chimera.uchime")                {       pipecommand = new ChimeraUchimeCommand(optionString);                   }
-               else if(commandName == "chimera.slayer")                {       pipecommand = new ChimeraSlayerCommand(optionString);                   }
-               else if(commandName == "chimera.pintail")               {       pipecommand = new ChimeraPintailCommand(optionString);                  }
-               else if(commandName == "chimera.bellerophon")   {       pipecommand = new ChimeraBellerophonCommand(optionString);              }
-               else if(commandName == "phylotype")                             {       pipecommand = new PhylotypeCommand(optionString);                               }
-               else if(commandName == "mgcluster")                             {       pipecommand = new MGClusterCommand(optionString);                               }
-               else if(commandName == "pre.cluster")                   {       pipecommand = new PreClusterCommand(optionString);                              }
-               else if(commandName == "pcoa")                                  {       pipecommand = new PCOACommand(optionString);                                    }
-               else if(commandName == "pca")                                   {       pipecommand = new PCACommand(optionString);                                             }
-               else if(commandName == "nmds")                                  {       pipecommand = new NMDSCommand(optionString);                                    }
-               else if(commandName == "otu.hierarchy")                 {       pipecommand = new OtuHierarchyCommand(optionString);                    }
-               else if(commandName == "set.dir")                               {       pipecommand = new SetDirectoryCommand(optionString);                    }
-               else if(commandName == "set.logfile")                   {       pipecommand = new SetLogFileCommand(optionString);                              }
-               else if(commandName == "parse.list")                    {       pipecommand = new ParseListCommand(optionString);                               }
-               else if(commandName == "phylo.diversity")               {       pipecommand = new PhyloDiversityCommand(optionString);                  }
-               else if(commandName == "make.group")                    {       pipecommand = new MakeGroupCommand(optionString);                               }
-               else if(commandName == "chop.seqs")                             {       pipecommand = new ChopSeqsCommand(optionString);                                }
-               else if(commandName == "clearcut")                              {       pipecommand = new ClearcutCommand(optionString);                                }
-               else if(commandName == "catchall")                              {       pipecommand = new CatchAllCommand(optionString);                                }
-               else if(commandName == "split.abund")                   {       pipecommand = new SplitAbundCommand(optionString);                              }
-               else if(commandName == "cluster.split")                 {       pipecommand = new ClusterSplitCommand(optionString);                    }
-               else if(commandName == "classify.otu")                  {       pipecommand = new ClassifyOtuCommand(optionString);                             }
-               else if(commandName == "degap.seqs")                    {       pipecommand = new DegapSeqsCommand(optionString);                               }
-               else if(commandName == "get.relabund")                  {       pipecommand = new GetRelAbundCommand(optionString);                             }
-               else if(commandName == "sens.spec")                             {       pipecommand = new SensSpecCommand(optionString);                                }
-               else if(commandName == "seq.error")                             {       pipecommand = new SeqErrorCommand(optionString);                                }
-               else if(commandName == "sffinfo")                               {       pipecommand = new SffInfoCommand(optionString);                                 }
-               else if(commandName == "normalize.shared")              {       pipecommand = new NormalizeSharedCommand(optionString);                 }
-               else if(commandName == "metastats")                             {       pipecommand = new MetaStatsCommand(optionString);                               }
-               else if(commandName == "split.groups")                  {       pipecommand = new SplitGroupCommand(optionString);                              }
-               else if(commandName == "cluster.fragments")             {       pipecommand = new ClusterFragmentsCommand(optionString);                }
-               else if(commandName == "get.lineage")                   {       pipecommand = new GetLineageCommand(optionString);                              }
-               else if(commandName == "get.groups")                    {       pipecommand = new GetGroupsCommand(optionString);                               }
-               else if(commandName == "remove.lineage")                {       pipecommand = new RemoveLineageCommand(optionString);                   }
-               else if(commandName == "remove.groups")                 {       pipecommand = new RemoveGroupsCommand(optionString);                    }
-               else if(commandName == "get.otus")                              {       pipecommand = new GetOtusCommand(optionString);                                 }
-               else if(commandName == "remove.otus")                   {       pipecommand = new RemoveOtusCommand(optionString);                              }
-               else if(commandName == "fastq.info")                    {       pipecommand = new ParseFastaQCommand(optionString);                             }
-               else if(commandName == "deunique.seqs")                 {       pipecommand = new DeUniqueSeqsCommand(optionString);                    }
-               else if(commandName == "pairwise.seqs")                 {       pipecommand = new PairwiseSeqsCommand(optionString);                    }
-               else if(commandName == "cluster.classic")               {       pipecommand = new ClusterDoturCommand(optionString);                    }
-               else if(commandName == "sub.sample")                    {       pipecommand = new SubSampleCommand(optionString);                               }
-               else if(commandName == "indicator")                             {       pipecommand = new IndicatorCommand(optionString);                               }
-               else if(commandName == "consensus.seqs")                {       pipecommand = new ConsensusSeqsCommand(optionString);                   }
-               else if(commandName == "corr.axes")                             {       pipecommand = new CorrAxesCommand(optionString);                                }
-               else if(commandName == "remove.rare")                   {       pipecommand = new RemoveRareCommand(optionString);                              }
-               else if(commandName == "merge.groups")                  {       pipecommand = new MergeGroupsCommand(optionString);                             }
-               else if(commandName == "amova")                                 {       pipecommand = new AmovaCommand(optionString);                                   }
-               else if(commandName == "homova")                                {       pipecommand = new HomovaCommand(optionString);                                  }
-               else if(commandName == "mantel")                                {       pipecommand = new MantelCommand(optionString);                                  }
-               else if(commandName == "anosim")                                {       pipecommand = new AnosimCommand(optionString);                                  }
-               else if(commandName == "make.fastq")                    {       pipecommand = new MakeFastQCommand(optionString);                               }
-               else if(commandName == "get.current")                   {       pipecommand = new GetCurrentCommand(optionString);                              }
-               else if(commandName == "set.current")                   {       pipecommand = new SetCurrentCommand(optionString);                              }
-               else if(commandName == "make.shared")                   {       pipecommand = new SharedCommand(optionString);                                  }
-               else if(commandName == "get.commandinfo")               {       pipecommand = new GetCommandInfoCommand(optionString);                  }
-               else if(commandName == "deunique.tree")                 {       pipecommand = new DeuniqueTreeCommand(optionString);                    }
-               else if(commandName == "count.seqs")                    {       pipecommand = new CountSeqsCommand(optionString);                               }
-               else if(commandName == "count.groups")                  {       pipecommand = new CountGroupsCommand(optionString);                             }
-               else if(commandName == "clear.memory")                  {       pipecommand = new ClearMemoryCommand(optionString);                             }
-               else if(commandName == "summary.tax")                   {       pipecommand = new SummaryTaxCommand(optionString);                              }
-               else if(commandName == "summary.qual")                  {       pipecommand = new SummaryQualCommand(optionString);                             }
-               else if(commandName == "chimera.perseus")               {       pipecommand = new ChimeraPerseusCommand(optionString);                  }
-               else if(commandName == "shhh.seqs")                             {       pipecommand = new ShhhSeqsCommand(optionString);                                }
-               else if(commandName == "otu.association")               {       pipecommand = new OTUAssociationCommand(optionString);                  }
-        else if(commandName == "sort.seqs")             {      pipecommand = new SortSeqsCommand(optionString);                }
-        else if(commandName == "classify.tree")         {      pipecommand = new ClassifyTreeCommand(optionString);            }
-        else if(commandName == "cooccurrence")          {      pipecommand = new CooccurrenceCommand(optionString);            }
-        else if(commandName == "pcr.seqs")              {      pipecommand = new PcrSeqsCommand(optionString);                 }
-        else if(commandName == "create.database")       {      pipecommand = new CreateDatabaseCommand(optionString);          }
-        else if(commandName == "make.biom")             {      pipecommand = new MakeBiomCommand(optionString);                }
-               else                                                                                    {       pipecommand = new NoCommand(optionString);                                              }
-
-               return pipecommand;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "getCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-/***********************************************************/
-//This function calls the appropriate command fucntions based on user input, this is used by the pipeline command to check a users piepline for errors before running
-Command* CommandFactory::getCommand(string commandName){
-       try {
-               delete shellcommand;   //delete the old command
-               
-               if(commandName == "read.dist")                                  {       shellcommand = new ReadDistCommand();                           }
-               else if(commandName == "read.otu")                              {       shellcommand = new ReadOtuCommand();                            }
-               else if(commandName == "read.tree")                             {       shellcommand = new ReadTreeCommand();                           }
-               else if(commandName == "cluster")                               {       shellcommand = new ClusterCommand();                            }
-               else if(commandName == "unique.seqs")                   {       shellcommand = new DeconvoluteCommand();                        }
-               else if(commandName == "parsimony")                             {       shellcommand = new ParsimonyCommand();                          }
-               else if(commandName == "help")                                  {       shellcommand = new HelpCommand();                                       }
-               else if(commandName == "quit")                                  {       shellcommand = new QuitCommand();                                       }
-               else if(commandName == "collect.single")                {       shellcommand = new CollectCommand();                            }
-               else if(commandName == "collect.shared")                {       shellcommand = new CollectSharedCommand();                      }
-               else if(commandName == "rarefaction.single")    {       shellcommand = new RareFactCommand();                           }
-               else if(commandName == "rarefaction.shared")    {       shellcommand = new RareFactSharedCommand();                     }
-               else if(commandName == "summary.single")                {       shellcommand = new SummaryCommand();                            }
-               else if(commandName == "summary.shared")                {       shellcommand = new SummarySharedCommand();                      }
-               else if(commandName == "unifrac.weighted")              {       shellcommand = new UnifracWeightedCommand();            }
-               else if(commandName == "unifrac.unweighted")    {       shellcommand = new UnifracUnweightedCommand();          }
-               else if(commandName == "get.group")             {   shellcommand = new GetgroupCommand();                               }
-               else if(commandName == "get.label")             {   shellcommand = new GetlabelCommand();                               }
-               else if(commandName == "get.sabund")            {   shellcommand = new GetSAbundCommand();                              }
-               else if(commandName == "get.rabund")            {   shellcommand = new GetRAbundCommand();                              }
-               else if(commandName == "libshuff")              {   shellcommand = new LibShuffCommand();                               }
-               else if(commandName == "heatmap.bin")                   {   shellcommand = new HeatMapCommand();                                }
-               else if(commandName == "heatmap.sim")                   {   shellcommand = new HeatMapSimCommand();                             }
-               else if(commandName == "filter.seqs")                   {   shellcommand = new FilterSeqsCommand();                             }
-               else if(commandName == "venn")                                  {   shellcommand = new VennCommand();                                   }
-               else if(commandName == "bin.seqs")                              {   shellcommand = new BinSeqCommand();                                 }
-               else if(commandName == "get.oturep")                    {   shellcommand = new GetOTURepCommand();                              }
-               else if(commandName == "tree.shared")                   {   shellcommand = new TreeGroupCommand();                              }
-               else if(commandName == "dist.shared")                   {   shellcommand = new MatrixOutputCommand();                   }
-               else if(commandName == "dist.seqs")                             {   shellcommand = new DistanceCommand();                               }
-               else if(commandName == "align.seqs")                    {   shellcommand = new AlignCommand();                                  }
-               else if(commandName == "summary.seqs")                  {       shellcommand = new SeqSummaryCommand();                         }
-               else if(commandName == "screen.seqs")                   {       shellcommand = new ScreenSeqsCommand();                         }
-               else if(commandName == "reverse.seqs")                  {       shellcommand = new ReverseSeqsCommand();                        }
-               else if(commandName == "trim.seqs")                             {       shellcommand = new TrimSeqsCommand();                           }
-               else if(commandName == "trim.flows")                    {       shellcommand = new TrimFlowsCommand();                          }
-               else if(commandName == "shhh.flows")                    {       shellcommand = new ShhherCommand();                                     }
-               else if(commandName == "list.seqs")                             {       shellcommand = new ListSeqsCommand();                           }
-               else if(commandName == "get.seqs")                              {       shellcommand = new GetSeqsCommand();                            }
-               else if(commandName == "remove.seqs")                   {       shellcommand = new RemoveSeqsCommand();                         }
-               else if(commandName == "merge.files")                   {       shellcommand = new MergeFileCommand();                          }
-               else if(commandName == "system")                                {       shellcommand = new SystemCommand();                                     }
-               else if(commandName == "align.check")                   {       shellcommand = new AlignCheckCommand();                         }
-               else if(commandName == "get.sharedseqs")                {       shellcommand = new GetSharedOTUCommand();                       }
-               else if(commandName == "get.otulist")                   {       shellcommand = new GetListCountCommand();                       }
-               else if(commandName == "hcluster")                              {       shellcommand = new HClusterCommand();                           }
-               else if(commandName == "classify.seqs")                 {       shellcommand = new ClassifySeqsCommand();                       }
-               else if(commandName == "chimera.ccode")                 {       shellcommand = new ChimeraCcodeCommand();                       }
-               else if(commandName == "chimera.check")                 {       shellcommand = new ChimeraCheckCommand();                       }
-               else if(commandName == "chimera.slayer")                {       shellcommand = new ChimeraSlayerCommand();                      }
-               else if(commandName == "chimera.uchime")                {       shellcommand = new ChimeraUchimeCommand();                      }
-               else if(commandName == "chimera.pintail")               {       shellcommand = new ChimeraPintailCommand();                     }
-               else if(commandName == "chimera.bellerophon")   {       shellcommand = new ChimeraBellerophonCommand();         }
-               else if(commandName == "phylotype")                             {       shellcommand = new PhylotypeCommand();                          }
-               else if(commandName == "mgcluster")                             {       shellcommand = new MGClusterCommand();                          }
-               else if(commandName == "pre.cluster")                   {       shellcommand = new PreClusterCommand();                         }
-               else if(commandName == "pcoa")                                  {       shellcommand = new PCOACommand();                                       }
-               else if(commandName == "pca")                                   {       shellcommand = new PCACommand();                                        }
-               else if(commandName == "nmds")                                  {       shellcommand = new NMDSCommand();                                       }
-               else if(commandName == "otu.hierarchy")                 {       shellcommand = new OtuHierarchyCommand();                       }
-               else if(commandName == "set.dir")                               {       shellcommand = new SetDirectoryCommand();                       }
-               else if(commandName == "set.logfile")                   {       shellcommand = new SetLogFileCommand();                         }
-               else if(commandName == "parse.list")                    {       shellcommand = new ParseListCommand();                          }
-               else if(commandName == "phylo.diversity")               {       shellcommand = new PhyloDiversityCommand();                     }
-               else if(commandName == "make.group")                    {       shellcommand = new MakeGroupCommand();                          }
-               else if(commandName == "chop.seqs")                             {       shellcommand = new ChopSeqsCommand();                           }
-               else if(commandName == "clearcut")                              {       shellcommand = new ClearcutCommand();                           }
-               else if(commandName == "catchall")                              {       shellcommand = new CatchAllCommand();                           }
-               else if(commandName == "split.abund")                   {       shellcommand = new SplitAbundCommand();                         }
-               else if(commandName == "cluster.split")                 {       shellcommand = new ClusterSplitCommand();                       }
-               else if(commandName == "classify.otu")                  {       shellcommand = new ClassifyOtuCommand();                        }
-               else if(commandName == "degap.seqs")                    {       shellcommand = new DegapSeqsCommand();                          }
-               else if(commandName == "get.relabund")                  {       shellcommand = new GetRelAbundCommand();                        }
-               else if(commandName == "sens.spec")                             {       shellcommand = new SensSpecCommand();                           }
-               else if(commandName == "seq.error")                             {       shellcommand = new SeqErrorCommand();                           }
-               else if(commandName == "sffinfo")                               {       shellcommand = new SffInfoCommand();                            }
-               else if(commandName == "normalize.shared")              {       shellcommand = new NormalizeSharedCommand();            }
-               else if(commandName == "metastats")                             {       shellcommand = new MetaStatsCommand();                          }
-               else if(commandName == "split.groups")                  {       shellcommand = new SplitGroupCommand();                         }
-               else if(commandName == "cluster.fragments")             {       shellcommand = new ClusterFragmentsCommand();           }
-               else if(commandName == "get.lineage")                   {       shellcommand = new GetLineageCommand();                         }
-               else if(commandName == "remove.lineage")                {       shellcommand = new RemoveLineageCommand();                      }
-               else if(commandName == "get.groups")                    {       shellcommand = new GetGroupsCommand();                          }
-               else if(commandName == "remove.groups")                 {       shellcommand = new RemoveGroupsCommand();                       }
-               else if(commandName == "get.otus")                              {       shellcommand = new GetOtusCommand();                            }
-               else if(commandName == "remove.otus")                   {       shellcommand = new RemoveOtusCommand();                         }
-               else if(commandName == "fastq.info")                    {       shellcommand = new ParseFastaQCommand();                        }
-               else if(commandName == "deunique.seqs")                 {       shellcommand = new DeUniqueSeqsCommand();                       }
-               else if(commandName == "pairwise.seqs")                 {       shellcommand = new PairwiseSeqsCommand();                       }
-               else if(commandName == "cluster.classic")               {       shellcommand = new ClusterDoturCommand();                       }
-               else if(commandName == "sub.sample")                    {       shellcommand = new SubSampleCommand();                          }
-               else if(commandName == "indicator")                             {       shellcommand = new IndicatorCommand();                          }
-               else if(commandName == "consensus.seqs")                {       shellcommand = new ConsensusSeqsCommand();                      }
-               else if(commandName == "corr.axes")                             {       shellcommand = new CorrAxesCommand();                           }
-               else if(commandName == "remove.rare")                   {       shellcommand = new RemoveRareCommand();                         }
-               else if(commandName == "merge.groups")                  {       shellcommand = new MergeGroupsCommand();                        }
-               else if(commandName == "amova")                                 {       shellcommand = new AmovaCommand();                                      }
-               else if(commandName == "homova")                                {       shellcommand = new HomovaCommand();                                     }
-               else if(commandName == "mantel")                                {       shellcommand = new MantelCommand();                                     }
-               else if(commandName == "anosim")                                {       shellcommand = new AnosimCommand();                                     }
-               else if(commandName == "make.fastq")                    {       shellcommand = new MakeFastQCommand();                          }
-               else if(commandName == "get.current")                   {       shellcommand = new GetCurrentCommand();                         }
-               else if(commandName == "set.current")                   {       shellcommand = new SetCurrentCommand();                         }
-               else if(commandName == "make.shared")                   {       shellcommand = new SharedCommand();                                     }
-               else if(commandName == "get.commandinfo")               {       shellcommand = new GetCommandInfoCommand();                     }
-               else if(commandName == "deunique.tree")                 {       shellcommand = new DeuniqueTreeCommand();                       }
-               else if(commandName == "count.seqs")                    {       shellcommand = new CountSeqsCommand();                          }
-               else if(commandName == "count.groups")                  {       shellcommand = new CountGroupsCommand();                        }
-               else if(commandName == "clear.memory")                  {       shellcommand = new ClearMemoryCommand();                        }
-               else if(commandName == "summary.tax")                   {       shellcommand = new SummaryTaxCommand();                         }
-               else if(commandName == "summary.qual")                  {       shellcommand = new SummaryQualCommand();                        }
-               else if(commandName == "chimera.perseus")               {       shellcommand = new ChimeraPerseusCommand();                     }
-               else if(commandName == "shhh.seqs")                             {       shellcommand = new ShhhSeqsCommand();                           }
-               else if(commandName == "otu.association")               {       shellcommand = new OTUAssociationCommand();                     }
-        else if(commandName == "sort.seqs")             {      shellcommand = new SortSeqsCommand();               }
-        else if(commandName == "classify.tree")         {      shellcommand = new ClassifyTreeCommand();           }
-        else if(commandName == "cooccurrence")          {      shellcommand = new CooccurrenceCommand();           }
-        else if(commandName == "pcr.seqs")              {      shellcommand = new PcrSeqsCommand();                }
-        else if(commandName == "create.database")       {      shellcommand = new CreateDatabaseCommand();         }
-        else if(commandName == "make.biom")             {      shellcommand = new MakeBiomCommand();               }
-               else                                                                                    {       shellcommand = new NoCommand();                                         }
-
-               return shellcommand;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "getCommand");
-               exit(1);
-       }
-}
-/***********************************************************
-//This function is used to interrupt a command
-Command* CommandFactory::getCommand(){
-       try {
-               delete command;   //delete the old command
-
-               string s = "";
-           command = new NoCommand(s);
-       
-               return command;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "getCommand");
-               exit(1);
-       }
-}
-***********************************************************************/
-bool CommandFactory::isValidCommand(string command) {
-       try {   
-       
-               //is the command in the map
-               if ((commands.find(command)) != (commands.end())) {
-                       return true;
-               }else{
-                       m->mothurOut(command + " is not a valid command in Mothur.  Valid commands are ");
-                       for (it = commands.begin(); it != commands.end(); it++) {
-                               m->mothurOut(it->first + ", ");
-                       }
-                       m->mothurOutEndLine();
-                       return false;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "isValidCommand");
-               exit(1);
-       }
-}
-/***********************************************************************/
-bool CommandFactory::isValidCommand(string command, string noError) {
-       try {   
-       
-               //is the command in the map
-               if ((commands.find(command)) != (commands.end())) {
-                       return true;
-               }else{
-                       return false;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "isValidCommand");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void CommandFactory::printCommands(ostream& out) {
-       try {   
-               out << "Valid commands are: ";
-               for (it = commands.begin(); it != commands.end(); it++) {
-                       out << it->first << ",";
-               }
-               out << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CommandFactory", "printCommands");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
-
-
diff --git a/commandfactory.hpp b/commandfactory.hpp
deleted file mode 100644 (file)
index e95db80..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef COMMANDFACTORY_HPP\r
-#define COMMANDFACTORY_HPP\r
-\r
-/*\r
- *  commandfactory.h\r
- *  \r
- *\r
- *  Created by Pat Schloss on 10/25/08.\r
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.\r
- *\r
- */\r
-\r
-#include "mothur.h"\r
-#include "mothurout.h"\r
-#include "currentfile.h"\r
-\r
-class Command;\r
-\r
-class CommandFactory {\r
-public:\r
-       static CommandFactory* getInstance();\r
-       Command* getCommand(string, string, string);\r
-       Command* getCommand(string, string);\r
-       Command* getCommand(string);\r
-       //Command* getCommand();\r
-       bool isValidCommand(string);\r
-       bool isValidCommand(string, string);\r
-       void printCommands(ostream&);\r
-       void setOutputDirectory(string o)               {       outputDir = o;  m->setOutputDir(o);     }\r
-       void setInputDirectory(string i)                {       inputDir = i;           }\r
-       void setLogfileName(string n, bool a)   {       logFileName = n;  append = a;           }\r
-       string getLogfileName()                                 {       return logFileName;     }\r
-       bool getAppend()                                                {       return append;                  }\r
-       string getOutputDir()                                   {       return outputDir;               }\r
-       bool MPIEnabled(string);\r
-       map<string, string> getListCommands()   {       return commands;                }\r
-       \r
-private:\r
-       Command* command;\r
-       Command* shellcommand;\r
-       Command* pipecommand;\r
-       \r
-       MothurOut* m;\r
-       CurrentFile* currentFile;\r
-       \r
-       map<string, string> commands;\r
-       map<string, string>::iterator it;\r
-       string outputDir, inputDir, logFileName;\r
-       bool append;\r
-       \r
-    int checkForRedirects(string);\r
-    \r
-       static CommandFactory* _uniqueInstance;\r
-       CommandFactory( const CommandFactory& ); // Disable copy constructor\r
-       void operator=( const CommandFactory& ); // Disable assignment operator\r
-       CommandFactory();\r
-       ~CommandFactory();\r
-\r
-};\r
-\r
-#endif\r
diff --git a/commandoptionparser.cpp b/commandoptionparser.cpp
deleted file mode 100644 (file)
index dfad533..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *  commandoptionparser.cpp
- *  
- *
- *  Created by Pat Schloss on 10/23/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "commandoptionparser.hpp"
-
-
-//**********************************************************************************************************************
-//This Function parses through the command line and pulls out the command then sends the options to  the parseGlobalData
-CommandOptionParser::CommandOptionParser(string input){
-       try {
-               m = MothurOut::getInstance();
-               
-               int openParen = input.find_first_of('(');
-               int closeParen = input.find_last_of(')');
-               optionString = "";
-               commandString = "";
-
-               if(openParen != -1 && closeParen != -1){        
-            //gobble extra spaces
-            int spot = 0;
-            for (int i = 0; i < input.length(); i++) {  if (!(isspace(input[i]))) { spot = i; break; } }
-            if (spot > openParen) { spot = 0; }
-                       commandString = input.substr(spot, openParen-spot);   //commandString contains everything before "("
-                       optionString = input.substr((openParen+1), (closeParen-openParen-1)); //optionString contains everything between "(" and ")".
-               }
-               else if (openParen == -1) { m->mothurOut("[ERROR]: You are missing ("); m->mothurOutEndLine(); }
-               else if (closeParen == -1) { m->mothurOut("[ERROR]:You are missing )"); m->mothurOutEndLine(); }
-    }
-       catch(exception& e) {
-               m->errorOut(e, "CommandOptionParser", "CommandOptionParser");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-string CommandOptionParser::getCommandString() {       return commandString;   }
-
-//**********************************************************************************************************************
-
-string CommandOptionParser::getOptionString()  {       return optionString;    }
-
-//**********************************************************************************************************************
diff --git a/commandoptionparser.hpp b/commandoptionparser.hpp
deleted file mode 100644 (file)
index 0c3a6f3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef COMMANDOPTIONPARSER_HPP
-#define COMMANDOPTIONPARSER_HPP
-
-#include "mothur.h"
-#include "mothurout.h"
-
-//**********************************************************************************************************************
-
-class CommandOptionParser {
-public:
-       CommandOptionParser(string);
-       string getCommandString();
-       string getOptionString();
-       
-private:
-       string commandString, optionString;
-       MothurOut* m;
-};
-
-//**********************************************************************************************************************
-
-#endif
diff --git a/commandparameter.h b/commandparameter.h
deleted file mode 100644 (file)
index 9dda0a1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef COMMANDPARAMETER_H
-#define COMMANDPARAMETER_H
-
-
-/*
- *  commandparameter.h
- *  Mothur
- *
- *  Created by westcott on 3/23/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "mothur.h"
-
-//**********************************************************************************************************************
-
-class CommandParameter {
-       
-       public:
-               CommandParameter() { name = ""; type = ""; options = ""; optionsDefault = ""; chooseOnlyOneGroup = ""; chooseAtLeastOneGroup = ""; linkedGroup = ""; multipleSelectionAllowed = false; required = false; }
-               CommandParameter(string n, string t, string o, string d, string only, string atLeast, string linked, bool m, bool r) : name(n), type(t), options(o), optionsDefault(d), 
-                               chooseOnlyOneGroup(only), chooseAtLeastOneGroup(atLeast), linkedGroup(linked), multipleSelectionAllowed(m), required(r) {}
-               ~CommandParameter() {}
-       
-               string name;            //something like fasta, processors, method
-               string type;  //must be set to "Boolean", "Multiple", "Number", "String", "InputTypes" - InputTypes is for file inputs
-               string options; //if the parameter has specific options allowed, used for parameters of type "Multiple", something like "furthest-nearest-average", or "sobs-chao...", leave blank for command that do not required specific options
-               string optionsDefault;   //the default for this parameter, could be something like "F" for a boolean or "100" for a number or "sobs-chao" for multiple
-               
-       
-               //for chooseOnlyOneGroup, chooseAtLeastOneGroup and linkedGroup if no group is needed set to "none".
-               string chooseOnlyOneGroup; //for file inputs: if a command has several options for input files but you can only choose one then put them in a group
-                                                                       //for instance in the read.dist command you can use a phylip or column file but not both so set chooseOnlyOneGroup for both parameters to something like "DistanceFileGroup"
-               string chooseAtLeastOneGroup; //for file inputs: if a command has several options for input files and you want to make sure one is choosen then put them in a group
-                                                                       //for instance in the read.dist command you must provide a phylip or column file so set chooseAtLeastOneGroup for both parameters to something like "DistanceFileGroup"
-               string linkedGroup; //for file inputs: if a command has a file option were if you provide one you must provide another you can put them in a group
-                                                                               //for instance in the read.dist command if you provide a column file you must provide a name file so set linkedGroup for both parameters to something like "ColumnNameGroup"
-
-               bool multipleSelectionAllowed; //for "Multiple" type to say whether you can select multiple options, for instance for calc parameter set to true, but for method set to false
-               bool required; //is this parameter required
-       
-               
-       private:
-};
-
-//**********************************************************************************************************************
-
-#endif
diff --git a/common.h b/common.h
deleted file mode 100644 (file)
index 573d78c..0000000
--- a/common.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * common.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * A header file filled with common definitions and simple inline functions
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_NJ_COMMON_H_
-#define _INC_NJ_COMMON_H_ 1
-
-#include <math.h>
-#include <float.h>
-
-
-#define NJ_AMBIGUITY_CHAR    63  /* ? character */
-
-
-/*
- * this macro defines the number of cells in the diagonal matrix 
- * based on the number of taxa involved
- *
- */
-#define NJ_NCELLS(a)       ( ((a)*(a+1))/2 )
-
-
-
-
-/*
- * NJ_MAP() - 
- *
- * Thus function maps i, j coordinates to the correct offset into 
- * the distance matrix
- *
- */
-static inline
-long int 
-NJ_MAP(long int i,
-       long int j,
-       long int ntaxa) {
-  
-  return((i*(2*ntaxa-i-1))/2 + j);
-}
-
-
-static inline
-int
-NJ_FLT_EQ(float x,
-         float y) {
-  
-  if(fabs(x - y)<FLT_EPSILON) {
-    return(1);
-  } else {
-    return(0);
-  }
-}
-
-
-
-static inline
-int
-NJ_FLT_LT(float x,
-         float y) {
-  
-  if(NJ_FLT_EQ(x, y)) {
-    return(0);
-  } else {
-    if(x < y) {
-      return(1);
-    } else {
-      return(0);
-    }
-  }
-}
-
-
-static inline
-int
-NJ_FLT_GT(float x,
-         float y) {
-  
-  if(NJ_FLT_EQ(x, y)) {
-    return(0);
-  } else {
-    if(x > y) {
-      return(1);
-    } else {
-      return(0);
-    }
-  }
-}
-
-
-
-
-#endif /* _INC_NJ_COMMON_H_ */
-
-
-
diff --git a/completelinkage.cpp b/completelinkage.cpp
deleted file mode 100644 (file)
index 86e9054..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-
-#include "cluster.hpp"
-
-/***********************************************************************/
-
-CompleteLinkage::CompleteLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
-       Cluster(rav, lv, dm, c, s)
-{}
-
-/***********************************************************************/
-//This function returns the tag of the method.
-string CompleteLinkage::getTag() {
-       return("fn");
-}
-
-
-/***********************************************************************/
-//This function updates the distance based on the furthest neighbor method.
-bool CompleteLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
-       try {
-               bool changed = false;
-               if (colCell->dist < rowCell->dist) {
-                       colCell->dist = rowCell->dist;
-                       changed = true;
-               }       
-               return(changed);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CompleteLinkage", "updateDistance");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/consensus.cpp b/consensus.cpp
deleted file mode 100644 (file)
index 1be052f..0000000
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- *  consensuscommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/29/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-
-#include "consensus.h"
-
-//**********************************************************************************************************************
-Tree* Consensus::getTree(vector<Tree*>& t){
-       try {
-               numNodes = t[0]->getNumNodes();
-               numLeaves = t[0]->getNumLeaves();
-        numTrees = t.size();
-               
-               //get the possible pairings
-               getSets(t);     
-               
-               if (m->control_pressed) { return 0; }
-               
-               consensusTree = new Tree(t[0]->getTreeMap());
-               
-               it2 = nodePairs.find(treeSet);
-               
-               nodePairsInTree[treeSet] = it2->second; 
-               
-               //erase treeset because you are adding it
-               nodePairs.erase(treeSet);
-               
-               //set count to numLeaves;
-               count = numLeaves;
-               
-               buildConsensusTree(treeSet);
-               
-               if (m->control_pressed) {  delete consensusTree; return 0; }
-               
-        map<string, string> empty;
-               consensusTree->assembleTree(empty);
-               
-               if (m->control_pressed) {  delete consensusTree; return 0; }
-                               
-               return consensusTree; 
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int Consensus::printSetsInfo() {
-       try {
-        //open file for pairing not included in the tree
-               string notIncluded = "cons.pairs";  
-               ofstream out2;
-        m->openOutputFile(notIncluded, out2);
-
-        //output species in order
-               out2 << "Species in Order: " << endl << endl;
-               for (int i = 0; i < treeSet.size(); i++) {  out2 << i+1 << ".  " << treeSet[i] << endl; }
-               
-               //output sets included
-               out2 << endl << "Sets included in the consensus tree:" << endl << endl;
-               
-               if (m->control_pressed) {  return 0; }
-               
-               vector<string> temp;
-               for (it2 = nodePairsInTree.begin(); it2 != nodePairsInTree.end(); it2++) {
-            
-                       if (m->control_pressed) {  return 0; }
-                       
-                       //only output pairs not leaves
-                       if (it2->first.size() > 1) { 
-                               temp.clear();
-                               //initialize temp to all "."
-                               temp.resize(treeSet.size(), ".");
-                               
-                               //set the spot in temp that represents it2->first[i] to a "*" 
-                               for (int i = 0; i < it2->first.size(); i++) {
-                                       //find spot 
-                                       int index = findSpot(it2->first[i]);
-                                       temp[index] = "*";
-                                       //temp[index] = it2->first[i] + "  ";
-                               }
-                               
-                               //output temp
-                               for (int j = 0; j < temp.size(); j++) { 
-                                       out2 << temp[j];
-                               }
-                               out2 << '\t' << it2->second << endl;
-                       }
-               }
-               
-               //output sets not included
-               out2 << endl << "Sets NOT included in the consensus tree:" << endl << endl;
-               for (it2 = nodePairs.begin(); it2 != nodePairs.end(); it2++) {
-            
-                       if (m->control_pressed) { return 0; }
-                       
-                       temp.clear();
-                       //initialize temp to all "."
-                       temp.resize(treeSet.size(), ".");
-            
-                       //set the spot in temp that represents it2->first[i] to a "*" 
-                       for (int i = 0; i < it2->first.size(); i++) {
-                               //find spot 
-                               int index = findSpot(it2->first[i]);
-                               temp[index] = "*";
-                       }
-            
-                       //output temp
-                       for (int j = 0; j < temp.size(); j++) { 
-                               out2 << temp[j];
-                       }
-                       out2 << '\t' << it2->second << endl;
-               }
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "printSetsInfo");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int Consensus::buildConsensusTree(vector<string> nodeSet) {
-       try {
-               vector<string> leftChildSet;
-               vector<string> rightChildSet;
-               
-               if (m->control_pressed) { return 1; }
-               
-               //if you are at a leaf
-               if (nodeSet.size() == 1) {
-                       //return the vector index of the leaf you are at
-                       return consensusTree->getIndex(nodeSet[0]);
-               //terminate recursion
-               }else if (count == numNodes) { return 0; }
-               else {
-                       //finds best child pair
-                       leftChildSet = getNextAvailableSet(nodeSet, rightChildSet);
-                       int left = buildConsensusTree(leftChildSet);
-                       int right = buildConsensusTree(rightChildSet);
-                       consensusTree->tree[count].setChildren(left, right);
-                       consensusTree->tree[count].setLabel((nodePairsInTree[nodeSet]/(float)numTrees)); 
-                       consensusTree->tree[left].setParent(count);
-                       consensusTree->tree[right].setParent(count);
-                       count++;
-                       return (count-1);
-               }
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "buildConcensusTree");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int Consensus::getSets(vector<Tree*>& t) {
-       try {
-               vector<string> temp;
-               treeSet.clear();
-               
-               //for each tree add the possible pairs you find
-               for (int i = 0; i < t.size(); i++) {
-                       
-                       //for each non-leaf node get descendant info.
-                       for (int j = numLeaves; j < numNodes; j++) {
-                               
-                               if (m->control_pressed) { return 1; }
-                               
-                               temp.clear();
-                               //go through pcounts and pull out descendants
-                               for (it = t[i]->tree[j].pcount.begin(); it != t[i]->tree[j].pcount.end(); it++) {
-                                       temp.push_back(it->first);
-                               }
-                               
-                               //sort temp
-                               sort(temp.begin(), temp.end());
-                               
-                               it2 = nodePairs.find(temp);
-                               if (it2 != nodePairs.end()) {
-                                       nodePairs[temp]++;
-                               }else{
-                                       nodePairs[temp] = 1;
-                               }
-                       }
-               }
-               
-               
-               //add each leaf to terminate recursion in consensus
-               //you want the leaves in there but with insignifigant sightings value so it is added last
-               //for each leaf node get descendant info.
-               for (int j = 0; j < numLeaves; j++) {
-               
-                       if (m->control_pressed) { return 1; }
-            
-                       //only need the first one since leaves have no descendants but themselves
-                       it = t[0]->tree[j].pcount.begin(); 
-                       temp.clear();  temp.push_back(it->first);
-                       
-                       //fill treeSet
-                       treeSet.push_back(it->first);
-                       
-                       //add leaf to list but with sighting value less then all non leaf pairs 
-                       nodePairs[temp] = 0;
-               }
-
-               sort(treeSet.begin(), treeSet.end());
-               
-               
-               map< vector<string>, int> nodePairsCopy = nodePairs;
-               
-               
-               //set initial rating on pairs to sightings + subgroup sightings
-               while (nodePairsCopy.size() != 0) {
-                       if (m->control_pressed) { return 1; }
-               
-                       vector<string> smallOne = getSmallest(nodePairsCopy);
-                       
-                       int subgrouprate = getSubgroupRating(smallOne);
-               
-                       nodePairsInitialRate[smallOne] = nodePairs[smallOne] + subgrouprate;
-                       
-                       nodePairsCopy.erase(smallOne);
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "getSets");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> Consensus::getSmallest(map< vector<string>, int> nodes) {
-       try{
-               vector<string> smallest = nodes.begin()->first;
-               int smallsize = smallest.size();
-               
-               for(it2 = nodes.begin(); it2 != nodes.end(); it2++) {
-                       if(it2->first.size() < smallsize) { smallsize = it2->first.size();  smallest = it2->first;  }
-               }
-               
-               return smallest;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "getSmallest");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-vector<string> Consensus::getNextAvailableSet(vector<string> bigset, vector<string>& rest) {
-       try {
-//cout << "new call " << endl << endl << endl;
-               vector<string> largest; largest.clear();
-               rest.clear();
-               
-               //if you are just 2 groups
-               if (bigset.size() == 2)  {   
-                       rest.push_back(bigset[0]);
-                       largest.push_back(bigset[1]);
-               }else{
-                       rest = bestSplit[bigset][0];
-                       largest = bestSplit[bigset][1];
-               }
-               
-               
-               //save for printing out later and for branch lengths
-               nodePairsInTree[rest] = nodePairs[rest];
-               
-               //delete whatever set you return because it is no longer available
-               nodePairs.erase(rest);
-
-               //save for printing out later and for branch lengths
-               nodePairsInTree[largest] = nodePairs[largest];
-               
-               //delete whatever set you return because it is no longer available
-               nodePairs.erase(largest);
-               
-               return largest;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "getNextAvailableSet");
-               exit(1);
-       }
-}
-
-/**********************************************************************************************************************/
-int Consensus::getSubgroupRating(vector<string> group) {
-       try {
-               map< vector<string>, int>::iterator ittemp;
-               map< vector< vector<string> > , int >::iterator it3;
-               int rate = 0;
-               
-               // ***********************************************************************************//
-               //1. this function must be called passing it littlest sets to biggest 
-               //              since it the rating is made from your sighting plus you best splits rating
-               //2. it saves the top pair to use later
-               // ***********************************************************************************//
-
-               
-               if (group.size() < 3) {  return rate;  }
-               
-               map< vector<string>, int> possiblePairing;  //this is all the subsets of group
-               
-               //go through the sets
-               for (it2 = nodePairs.begin(); it2 != nodePairs.end(); it2++) {
-                       //are you a subset of bigset, then save in possiblePairings
-                       if (isSubset(group, it2->first) == true) {  possiblePairing[it2->first] = it2->second;  }
-               }               
-       
-               map< vector< vector<string> > , int > rating;
-               
-               while (possiblePairing.size() != 0) {
-               
-                       it2 = possiblePairing.begin(); 
-                       vector<string> temprest = getRestSet(group, it2->first);
-                       
-                       //is the rest a set available in possiblePairings
-                       ittemp = possiblePairing.find(temprest);
-                       if (ittemp != possiblePairing.end()) {  //if the rest is in the possible pairings then add this pair to rating map
-                               vector< vector<string> > temprate;
-                               temprate.push_back(it2->first);  temprate.push_back(temprest);
-                               
-                               rating[temprate] = (nodePairsInitialRate[it2->first] + nodePairsInitialRate[temprest]);
-                               
-                               //erase so you dont add 1,2 and 2,1.
-                               possiblePairing.erase(temprest);
-                       }
-                       
-                       possiblePairing.erase(it2);
-               }
-
-
-               it3 = rating.begin();
-               rate = it3->second;
-               vector< vector<string> > topPair = it3->first;
-               
-               //choose the split with the best rating
-               for (it3 = rating.begin(); it3 != rating.end(); it3++) {
-                       
-                       if (it3->second > rate) {  rate = it3->second;  topPair = it3->first;  }
-               }
-               
-               bestSplit[group] = topPair;
-               
-               return rate;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "getSubgroupRating");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-vector<string> Consensus::getRestSet(vector<string> bigset, vector<string> subset) {
-       try {
-               vector<string> rest;
-               
-               for (int i = 0; i < bigset.size(); i++) {
-                       bool inSubset = false;
-                       for (int j = 0; j < subset.size(); j++) {
-                               if (bigset[i] == subset[j]) { inSubset = true; break; }
-                       }
-                       
-                       //its not in the subset so put it in the rest
-                       if (inSubset == false) { rest.push_back(bigset[i]); }
-               }
-
-               return rest;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "getRestSet");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-bool Consensus::isSubset(vector<string> bigset, vector<string> subset) {
-       try {
-               
-       
-               if (subset.size() > bigset.size()) { return false;  }
-               
-               //check if each guy in suset is also in bigset
-               for (int i = 0; i < subset.size(); i++) {
-                       bool match = false;
-                       for (int j = 0; j < bigset.size(); j++) {
-                               if (subset[i] == bigset[j]) { match = true; break; }
-                       }
-                       
-                       //you have a guy in subset that had no match in bigset
-                       if (match == false) { return false; }
-               }
-               
-               return true;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "isSubset");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int Consensus::findSpot(string node) {
-       try {
-               int spot;
-               
-               //check if each guy in suset is also in bigset
-               for (int i = 0; i < treeSet.size(); i++) {
-                       if (treeSet[i] == node) { spot = i; break; }
-               }
-               
-               return spot;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Consensus", "findSpot");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
diff --git a/consensus.h b/consensus.h
deleted file mode 100644 (file)
index faa4e42..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef CONCENSUS_H
-#define CONCENSUS_H
-/*
- *  consensus.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/29/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-
-
-#include "tree.h"
-#include "treemap.h"
-
-//NOTE: This class assumes all leaf nodes have 1 member.  
-//      Mothur does allow for names files with trees which would make a tree with multiple members at one leaf.  
-//      This class is currently only called internally by commands that have leaf node containing only 1 member.
-//      But if in the future, this changes things will need to be reworked in getSets and buildConsensus.
-
-
-class Consensus {
-       
-public:
-       Consensus() { m = MothurOut::getInstance(); }   
-       ~Consensus() {}
-       
-    Tree* getTree(vector<Tree*>&);
-               
-private:
-    MothurOut* m;
-    Tree* consensusTree;
-    
-    vector<string> treeSet;            //set containing all members of the tree to start recursion.  filled in getSets().
-       map< vector<string>, int > nodePairs;  //<map of possible combinations these combos are the pcounts or descendants info, to how many times they occured
-                                                                               // ie. combos FI and EGK would create nodePairs[vector containing F and I] = 1; nodePairs[vector containing E, G and K] = 1
-                                                                               // if you saw the combo FI again in another tree you would then update nodePairs[vector containing F and I] = 2;
-                                                                               // requires vectors to be sorted to find key.
-       map< vector<string>, vector< vector<string> > > bestSplit;  //maps a group to its best split
-       map< vector<string>, int > nodePairsInitialRate;
-       map< vector<string>, int > nodePairsInTree;
-       map<string, int>::iterator it;
-       map< vector<string>, int>::iterator it2;
-       string outputFile, notIncluded, filename;
-       int numNodes, numLeaves, count, numTrees;  //count is the next available spot in the tree vector
-       vector<string> outputNames;
-                                                                               
-       int getSets(vector<Tree*>&);
-       int getSubgroupRating(vector<string>);
-       vector<string> getSmallest(map< vector<string>, int>);
-       vector<string> getNextAvailableSet(vector<string>, vector<string>&);  
-       vector<string> getRestSet(vector<string>, vector<string>);
-       bool isSubset(vector<string>, vector<string>); 
-       int findSpot(string); 
-       int buildConsensusTree(vector<string>);
-    int printSetsInfo();
-       
-};
-
-#endif
-
diff --git a/consensusseqscommand.cpp b/consensusseqscommand.cpp
deleted file mode 100644 (file)
index 223e5db..0000000
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- *  consensusseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/23/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "consensusseqscommand.h"
-#include "sequence.hpp"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> ConsensusSeqsCommand::setParameters(){  
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "100", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ConsensusSeqsCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "The consensus.seqs command can be used in 2 ways: create a consensus sequence from a fastafile, or with a listfile create a consensus sequence for each otu. Sequences must be aligned.\n";
-               helpString += "The consensus.seqs command parameters are fasta, list, name, cutoff and label.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your sequences, and is required, unless you have a valid current fasta file. \n";
-               helpString += "The list parameter allows you to enter a your list file. \n";
-               helpString += "The name parameter allows you to enter a names file associated with the fasta file. \n";
-               helpString += "The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n";
-               helpString += "The cutoff parameter allows you set a percentage of sequences that support the base. For example: cutoff=97 would only return a sequence that only showed ambiguities for bases that were not supported by at least 97% of sequences.\n";
-               helpString += "The consensus.seqs command should be in the following format: \n";
-               helpString += "consensus.seqs(fasta=yourFastaFile, list=yourListFile) \n";      
-               helpString += "Example: consensus.seqs(fasta=abrecovery.align, list=abrecovery.fn.list) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ConsensusSeqsCommand::ConsensusSeqsCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "ConsensusSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-ConsensusSeqsCommand::ConsensusSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);      
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       
-                       //check for parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {                    
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { listfile = "";  }   
-                       else { m->setListFile(listfile); }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "cutoff", false);  if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);      }
-                       
-                       if (namefile == ""){
-                               vector<string> files; files.push_back(fastafile); 
-                               parser.getNameFile(files);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "ConsensusSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ConsensusSeqsCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               readFasta();
-               
-               if (m->control_pressed) { return 0; }
-               
-               if (namefile != "") { readNames(); }
-               
-               if (m->control_pressed) { return 0; }
-               
-                               
-               if (listfile == "") {
-                       
-                       ofstream outSummary;
-                       string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.summary";
-                       m->openOutputFile(outputSummaryFile, outSummary);
-                       outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
-                       outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
-                       
-                       outSummary << "PositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
-                       
-                       ofstream outFasta;
-                       string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "cons.fasta";
-                       m->openOutputFile(outputFastaFile, outFasta);
-                       outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
-                       
-                       vector<string> seqs;
-                       int seqLength = 0;
-                       for (map<string, string>::iterator it = nameMap.begin(); it != nameMap.end(); it++) {
-                               
-                               if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0; }
-                               
-                               string seq = fastaMap[it->second];
-                               seqs.push_back(seq);
-                               
-                               if (seqLength == 0) { seqLength = seq.length(); }
-                               else if (seqLength != seq.length()) { m->mothurOut("[ERROR]: sequence are not the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-
-                       }
-                       
-                       vector< vector<float> > percentages; percentages.resize(5);
-                       for (int j = 0; j < percentages.size(); j++) { percentages[j].resize(seqLength, 0.0); }
-                       
-                       string consSeq = "";
-                       //get counts
-                       for (int j = 0; j < seqLength; j++) {
-                               
-                               if (m->control_pressed) { outSummary.close(); outFasta.close(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0; }
-                               
-                               vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
-                               int numDots = 0;
-                               
-                               for (int i = 0; i < seqs.size(); i++) {
-                                       
-                                       if (seqs[i][j] == '.') { numDots++; }
-                                       
-                                       char base = toupper(seqs[i][j]);
-                                       if (base == 'A') { counts[0]++; }
-                                       else if (base == 'T') { counts[1]++; }
-                                       else if (base == 'G') { counts[2]++; }
-                                       else if (base == 'C') { counts[3]++; }
-                                       else { counts[4]++; }
-                               }
-                               
-                               char conBase = '.';
-                               if (numDots != seqs.size()) { conBase = getBase(counts, seqs.size()); }
-                               
-                               consSeq += conBase;
-                               
-                               percentages[0][j] = counts[0] / (float) seqs.size();
-                               percentages[1][j] = counts[1] / (float) seqs.size();
-                               percentages[2][j] = counts[2] / (float) seqs.size();
-                               percentages[3][j] = counts[3] / (float) seqs.size();
-                               percentages[4][j] = counts[4] / (float) seqs.size();
-                               
-                       }
-                       
-                       for (int j = 0; j < seqLength; j++) { 
-                               outSummary << (j+1) << '\t' << percentages[0][j] << '\t'<< percentages[1][j] << '\t'<< percentages[2][j] << '\t' << percentages[3][j] << '\t' << percentages[4][j] << '\t' << seqs.size() << '\t' << consSeq[j] << endl;
-                       }
-                       
-                               
-                       outFasta << ">conseq" << endl << consSeq << endl;
-                       
-                       outSummary.close(); outFasta.close();
-                       
-               
-               }else {
-                       
-                                               
-                       InputData* input = new InputData(listfile, "list");
-                       ListVector* list = input->getListVector();
-                       
-                       string lastLabel = list->getLabel();
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } delete list; delete input;  return 0;  }
-                               
-                               if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
-                                       
-                                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                       
-                                       processList(list);
-                                       
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = list->getLabel();
-                                       
-                                       delete list; 
-                                       
-                                       list = input->getListVector(lastLabel);
-                                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                       
-                                       processList(list);
-                                       
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       list->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = list->getLabel();
-                               
-                               delete list; list = NULL;
-                               
-                               //get next line to process
-                               list = input->getListVector();                          
-                       }
-                       
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } if (list != NULL) { delete list; } delete input; return 0;  }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (list != NULL) { delete list; }
-                               
-                               list = input->getListVector(lastLabel);
-                               
-                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                               
-                               processList(list);
-                               
-                               delete list; list = NULL;
-                       }
-                       
-                       if (list != NULL) { delete list; }
-                       delete input;
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "execute");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ConsensusSeqsCommand::processList(ListVector*& list){
-       try{
-               
-               ofstream outSummary;
-               string outputSummaryFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.summary";
-               m->openOutputFile(outputSummaryFile, outSummary);
-               outSummary.setf(ios::fixed, ios::floatfield); outSummary.setf(ios::showpoint);
-               outputNames.push_back(outputSummaryFile); outputTypes["summary"].push_back(outputSummaryFile);
-               
-               ofstream outName;
-               string outputNameFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.names";
-               m->openOutputFile(outputNameFile, outName);
-               outputNames.push_back(outputNameFile); outputTypes["name"].push_back(outputNameFile);
-               
-               ofstream outFasta;
-               string outputFastaFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + list->getLabel() + ".cons.fasta";
-               m->openOutputFile(outputFastaFile, outFasta);
-               outputNames.push_back(outputFastaFile); outputTypes["fasta"].push_back(outputFastaFile);
-               
-               outSummary << "OTU#\tPositioninAlignment\tA\tT\tG\tC\tGap\tNumberofSeqs\tConsensusBase" << endl;
-               
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       
-                       if (m->control_pressed) { outSummary.close(); outName.close(); outFasta.close(); return 0; }
-                       
-                       string bin = list->get(i);
-                       
-                       string newName = "";
-                       string consSeq = getConsSeq(bin, outSummary, newName, i);
-                       
-                       outFasta << ">seq" << (i+1) << endl << consSeq << endl;
-                       outName << "seq" << (i+1) << '\t' << "seq" << (i+1) << "," << newName << endl;
-               }
-               
-               outSummary.close(); outName.close(); outFasta.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "processList");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-//made this smart enough to owrk with unique or non unique list file
-string ConsensusSeqsCommand::getConsSeq(string bin, ofstream& outSummary, string& name, int binNumber){
-       try{
-               
-               string consSeq = "";
-               bool error = false;
-               
-               //the whole bin is the second column if no names file, otherwise build it
-               name = bin;
-               if (namefile != "") { name = ""; }
-               
-               vector<string> binNames;
-               m->splitAtComma(bin, binNames);
-               
-               //get sequence strings for each name in the bin
-               vector<string> seqs;
-               
-               set<string> addedAlready;
-               int seqLength = 0;
-               for (int i = 0; i < binNames.size(); i++) {
-                       
-                       map<string, string>::iterator it;
-                       
-                       it = nameMap.find(binNames[i]);
-                       if (it == nameMap.end()) { 
-                               if (namefile == "") { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta file, please correct."); m->mothurOutEndLine(); error = true; }
-                               else { m->mothurOut("[ERROR]: " + binNames[i] + " is not in your fasta or name file, please correct."); m->mothurOutEndLine(); error = true; }
-                               break;
-                       }else {
-                               
-                               //add sequence string to seqs vector to process below
-                               string seq = fastaMap[it->second];
-                               seqs.push_back(seq);
-                               
-                               if (seqLength == 0) { seqLength = seq.length(); }
-                               else if (seqLength != seq.length()) { m->mothurOut("[ERROR]: sequence are not the same length, please correct."); m->mothurOutEndLine(); error = true; break; }
-                               
-                               if (namefile != "") { 
-                                       //did we add this line from name file already?
-                                       if (addedAlready.count(it->second) == 0) {
-                                               name += "," + nameFileMap[it->second];
-                                               addedAlready.insert(it->second);
-                                       }
-                               }
-                               
-                       }
-               }
-               
-               if (error) { m->control_pressed = true; return consSeq; }
-               
-               if (namefile != "") { name = name.substr(1); }
-               
-               vector< vector<float> > percentages; percentages.resize(5);
-               for (int j = 0; j < percentages.size(); j++) { percentages[j].resize(seqLength, 0.0); }
-               
-               //get counts
-               for (int j = 0; j < seqLength; j++) {
-                       
-                       if (m->control_pressed) { return consSeq; }
-                       
-                       vector<int> counts; counts.resize(5, 0); //A,T,G,C,Gap
-                       int numDots = 0;
-                       
-                       for (int i = 0; i < seqs.size(); i++) {
-                               
-                               if (seqs[i][j] == '.') { numDots++; }
-                               
-                               char base = toupper(seqs[i][j]);
-                               if (base == 'A') { counts[0]++; }
-                               else if (base == 'T') { counts[1]++; }
-                               else if (base == 'G') { counts[2]++; }
-                               else if (base == 'C') { counts[3]++; }
-                               else { counts[4]++; }
-                       }
-                       
-                       char conBase = '.';
-                       if (numDots != seqs.size()) { conBase = getBase(counts, seqs.size()); }
-                       
-                       consSeq += conBase;
-                       
-                       percentages[0][j] = counts[0] / (float) seqs.size();
-                       percentages[1][j] = counts[1] / (float) seqs.size();
-                       percentages[2][j] = counts[2] / (float) seqs.size();
-                       percentages[3][j] = counts[3] / (float) seqs.size();
-                       percentages[4][j] = counts[4] / (float) seqs.size();
-                       
-               }
-               
-               for (int j = 0; j < seqLength; j++) { 
-                       outSummary << (binNumber + 1) << '\t' << (j+1) << '\t' << percentages[0][j] << '\t'<< percentages[1][j] << '\t'<< percentages[2][j] << '\t' << percentages[3][j] << '\t' << percentages[4][j] << '\t' << seqs.size() << '\t' << consSeq[j] << endl;
-               }
-               
-               return consSeq;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "getConsSeq");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-char ConsensusSeqsCommand::getBase(vector<int> counts, int size){  //A,T,G,C,Gap
-       try{
-               /* A = adenine
-               * C = cytosine
-               * G = guanine
-               * T = thymine
-               * R = G A (purine)
-               * Y = T C (pyrimidine)
-               * K = G T (keto)
-               * M = A C (amino)
-               * S = G C (strong bonds)
-               * W = A T (weak bonds)
-               * B = G T C (all but A)
-               * D = G A T (all but C)
-               * H = A C T (all but G)
-               * V = G C A (all but T)
-               * N = A G C T (any) */
-               
-               char conBase = 'N';
-               
-               //zero out counts that don't make the cutoff
-               float percentage = (100.0 - cutoff) / 100.0;
-               int zeroCutoff = percentage * size;
-               
-               for (int i = 0; i < counts.size(); i++) {
-                       if (counts[i] < zeroCutoff) { counts[i] = 0; }
-               }
-               
-               //any
-               if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'n'; }
-               //any no gap
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'N'; }
-               //all but T
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'v'; }  
-               //all but T no gap
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'V'; }  
-               //all but G
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'h'; }  
-               //all but G no gap
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'H'; }  
-               //all but C
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'd'; }  
-               //all but C no gap
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'D'; }  
-               //all but A
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'b'; }  
-               //all but A no gap
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'B'; }  
-               //W = A T (weak bonds)
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'w'; }  
-               //W = A T (weak bonds) no gap
-               else if ((counts[0] != 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'W'; }  
-               //S = G C (strong bonds)
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 's'; }  
-               //S = G C (strong bonds) no gap
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'S'; }  
-               //M = A C (amino)
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'm'; }  
-               //M = A C (amino) no gap
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'M'; }  
-               //K = G T (keto)
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'k'; }  
-               //K = G T (keto) no gap
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'K'; }  
-               //Y = T C (pyrimidine)
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'y'; }  
-               //Y = T C (pyrimidine) no gap
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'Y'; }  
-               //R = G A (purine)
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'r'; }  
-               //R = G A (purine) no gap
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'R'; }  
-               //only A
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'a'; }  
-               //only A no gap
-               else if ((counts[0] != 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'A'; }  
-               //only T
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 't'; }  
-               //only T no gap
-               else if ((counts[0] == 0) && (counts[1] != 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'T'; }  
-               //only G
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = 'g'; }  
-               //only G no gap
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] != 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'G'; }  
-               //only C
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] != 0)) {  conBase = 'c'; }  
-               //only C no gap
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] != 0) && (counts[4] == 0)) {  conBase = 'C'; }  
-               //only gap
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] != 0)) {  conBase = '-'; }
-               //cutoff removed all counts
-               else if ((counts[0] == 0) && (counts[1] == 0) && (counts[2] == 0) && (counts[3] == 0) && (counts[4] == 0)) {  conBase = 'N'; }
-               else{ m->mothurOut("[ERROR]: cannot find consensus base."); m->mothurOutEndLine(); }
-               
-               return conBase;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "getBase");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int ConsensusSeqsCommand::readFasta(){
-       try{
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       string name = seq.getName();
-                       
-                       if (name != "") {
-                               fastaMap[name] = seq.getAligned();
-                               nameMap[name] = name; //set nameMap incase no names file
-                               nameFileMap[name] = name;
-                       }
-               }
-               
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ConsensusSeqsCommand", "readFasta");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ConsensusSeqsCommand::readNames(){
-        try{
-                
-                ifstream in;
-                m->openInputFile(namefile, in);
-                
-                string thisname, repnames;
-                map<string, string>::iterator it;
-                
-                bool error = false;
-                
-                while(!in.eof()){
-                        
-                        if (m->control_pressed) { break; }
-                        
-                        in >> thisname;                m->gobble(in);          //read from first column
-                        in >> repnames;                        //read from second column
-                        
-                        it = nameMap.find(thisname);
-                        if (it != nameMap.end()) { //then this sequence was in the fastafile
-                                
-                                vector<string> splitRepNames;
-                                m->splitAtComma(repnames, splitRepNames);
-                                
-                                nameFileMap[thisname] = repnames;      //for later when outputting the new namesFile if the list file is unique
-                                for (int i = 0; i < splitRepNames.size(); i++) { nameMap[splitRepNames[i]] = thisname; }
-                                
-                        }else{ m->mothurOut("[ERROR]: " + thisname + " is not in the fasta file, please correct."); m->mothurOutEndLine(); error = true; }
-                        
-                        m->gobble(in);
-                }
-                
-                in.close();
-                
-                if (error) { m->control_pressed = true; }
-                return 0;
-       }
-        catch(exception& e) {
-                m->errorOut(e, "ConsensusSeqsCommand", "readNames");
-                exit(1);
-        }
- }
-//***************************************************************************************************************
-
-
diff --git a/consensusseqscommand.h b/consensusseqscommand.h
deleted file mode 100644 (file)
index 423c4e4..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef CONSENSUSSEQSCOMMAND_H
-#define CONSENSUSSEQSCOMMAND_H
-//test
-/*
- *  consensusseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/23/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "listvector.hpp"
-
-class ConsensusSeqsCommand : public Command {
-public:
-       ConsensusSeqsCommand(string);
-       ConsensusSeqsCommand();
-       ~ConsensusSeqsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "consensus.seqs";              }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Consensus.seqs"; }
-       string getDescription()         { return "create a consensus sequence for each OTU or for a fasta file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       bool abort, allLines;
-       string fastafile, listfile, namefile, label, outputDir;
-       set<string> labels;
-       vector<string> outputNames;
-       map<string, string> fastaMap;
-       map<string, string> nameMap;
-       map<string, string> nameFileMap;
-       int cutoff;
-       
-       int readFasta();
-       int readNames();
-       int processList(ListVector*&);
-       string getConsSeq(string, ofstream&, string&, int);
-       char getBase(vector<int>, int);
-};
-
-#endif
-
-
-
-
diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp
deleted file mode 100644 (file)
index 75b87fa..0000000
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- *  cooccurrencecommand.cpp
- *  Mothur
- *
- *  Created by kiverson on 1/2/12.
- *  Copyright 2012 Schloss Lab. All rights reserved.
- *
- */
-
-#include "cooccurrencecommand.h"
-
-//**********************************************************************************************************************
-vector<string> CooccurrenceCommand::setParameters() {  
-       try { 
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);             
-               CommandParameter pmetric("metric", "Multiple", "cscore-checker-combo-vratio", "cscore", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter pmatrix("matrixmodel", "Multiple", "sim1-sim2-sim3-sim4-sim5-sim6-sim7-sim8-sim9", "sim2", "", "", "",false,false); parameters.push_back(pmatrix);
-        CommandParameter pruns("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pruns);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-        CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CooccurrenceCommand::getHelpString(){   
-       try {
-               string helpString = "The cooccurrence command calculates four metrics and tests their significance to assess whether presence-absence patterns are different than what one would expect by chance.";
-        helpString += "The cooccurrence command parameters are shared, metric, matrixmodel, iters, label and groups.";
-        helpString += "The matrixmodel parameter options are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8 and sim9. Default=sim2";
-        helpString += "The metric parameter options are cscore, checker, combo and vratio. Default=cscore";
-        helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "The groups parameter allows you to specify which of the groups you would like analyzed.\n";
-        helpString += "The cooccurrence command should be in the following format: \n";
-               helpString += "cooccurrence(shared=yourSharedFile) \n";
-               helpString += "Example cooccurrence(shared=final.an.shared).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourShared).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CooccurrenceCommand::CooccurrenceCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-        vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "CooccurrenceCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CooccurrenceCommand::CooccurrenceCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-               
-            vector<string> tempOutNames;
-            outputTypes["summary"] = tempOutNames;
-               
-               //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-
-                       
-                       metric = validParameter.validFile(parameters, "metric", false);                         if (metric == "not found") { metric = "cscore"; }
-                       
-                       if ((metric != "cscore") && (metric != "checker") && (metric != "combo") && (metric != "vratio")) {
-                               m->mothurOut("[ERROR]: " + metric + " is not a valid metric option for the cooccurrence command. Choices are cscore, checker, combo, vratio."); m->mothurOutEndLine(); abort = true; 
-                       }
-                       
-                       matrix = validParameter.validFile(parameters, "matrixmodel", false);                            if (matrix == "not found") { matrix = "sim2"; }
-                       
-                       if ((matrix != "sim1") && (matrix != "sim2") && (matrix != "sim3") && (matrix != "sim4") && (matrix != "sim5" ) && (matrix != "sim6" ) && (matrix != "sim7" ) && (matrix != "sim8" ) && (matrix != "sim9" )) {
-                               m->mothurOut("[ERROR]: " + matrix + " is not a valid matrix option for the cooccurrence command. Choices are sim1, sim2, sim3, sim4, sim5, sim6, sim7, sim8, sim9."); m->mothurOutEndLine(); abort = true; 
-                       }
-            
-            groups = validParameter.validFile(parameters, "groups", false);                    
-                       if (groups == "not found") { groups = "";   }
-                       else { 
-                               m->splitAtDash(groups, Groups); 
-                       }                       
-                       m->setGroups(Groups);
-            
-            string temp = validParameter.validFile(parameters, "iters", false);                        if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, runs); 
-
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "CooccurrenceCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int CooccurrenceCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               InputData* input = new InputData(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-        ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "cooccurence.summary";
-        m->openOutputFile(outputFileName, out);
-        outputNames.push_back(outputFileName);  outputTypes["summary"].push_back(outputFileName);
-        out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-        out << "metric\tlabel\tScore\tpValue\n";
-
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
-       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               getCooccurrence(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                       
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               getCooccurrence(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
-
-                       //get next line to process
-                       lookup = input->getSharedRAbundVectors();                               
-               }
-               
-               if (m->control_pressed) { delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-       
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       
-                       getCooccurrence(lookup, out);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-       
-        out.close(); 
-        
-               //reset groups parameter 
-               delete input; 
-        m->clearGroups(); 
-
-        m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               m->mothurOutEndLine();
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CooccurrenceCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp, ofstream& out){
-    try {
-        int numOTUS = thisLookUp[0]->getNumBins();
-        vector< vector<int> > co_matrix; co_matrix.resize(thisLookUp[0]->getNumBins());
-        for (int i = 0; i < thisLookUp[0]->getNumBins(); i++) { co_matrix[i].resize((thisLookUp.size()), 0); }
-        vector<int> columntotal; columntotal.resize(thisLookUp.size(), 0);
-        vector<int> rowtotal; rowtotal.resize(numOTUS, 0);
-        
-        for (int i = 0; i < thisLookUp.size(); i++) { //nrows in the shared file
-            for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) { //cols of original shared file
-                if (m->control_pressed) { return 0; }
-                int abund = thisLookUp[i]->getAbundance(j);
-                
-                if(abund > 0) {
-                    co_matrix[j][i] = 1;
-                    rowtotal[j]++;
-                    columntotal[i]++;
-                }
-            }
-        }
-        
-        //nrows is ncols of inital matrix. All the functions need this value. They assume the transposition has already taken place and nrows and ncols refer to that matrix.
-        //comatrix and initmatrix are still vectors of vectors of ints as in the original script. The abundancevector is only what was read in ie not a co-occurrence matrix!
-        int nrows = numOTUS;//rows of inital matrix
-        int ncols = thisLookUp.size();//groups
-        double initscore = 0.0;
-        
-        vector<double> stats;
-        double probabilityMatrix[ncols * nrows];
-        vector<vector<int> > nullmatrix(nrows, vector<int>(ncols, 0));
-        
-        TrialSwap2 trial;
-        
-        int n = accumulate( columntotal.begin(), columntotal.end(), 0 );
-        
-        //============================================================
-        
-        //generate a probability matrix. Only do this once.
-        float start = 0.0;
-        
-        if (matrix == "sim1") {
-            for(int i=0;i<nrows;i++) {
-                for(int j=0;j<ncols;j++) {
-                    probabilityMatrix[ncols * i + j] = start + 1/double(nrows*ncols);
-                    start = start + 1/double(nrows*ncols);
-                }
-            }
-        }
-        //don't need a prob matrix because we just shuffle the rows, may use this in the future
-        else if (matrix == "sim2") { }
-//            for(int i=0;i<nrows;i++) {
-//                start = 0.0;
-//                for(int j=0;j<ncols;j++) {
-//                    probabilityMatrix[ncols * i + j] = start + 1/double(ncols);
-//                    start = start + 1/double(ncols);
-//                }
-//            }
-//        }
-        
-        else if (matrix == "sim3") {
-            for(int j=0;j<ncols;j++) {
-                start = 0.0;
-                for(int i=0;i<nrows;i++) {
-                    probabilityMatrix[ncols * i + j] = start + 1/double(nrows);
-                    start = start + 1/double(nrows);
-                }
-            }
-        }
-        
-        else if (matrix == "sim4") {
-            for(int i=0;i<nrows;i++) {
-                start = 0.0;
-                for(int j=0;j<ncols;j++) {
-                    probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n);
-                    start = start + columntotal[j]/double(n);
-                }
-            }
-        }
-        
-        else if (matrix == "sim5") {
-            for(int j=0;j<ncols;j++) {
-                start = 0.0;
-                for(int i=0;i<nrows;i++) {
-                    probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n);
-                    start = start + rowtotal[i]/double(n);
-                }
-            }
-        }
-        
-        else if (matrix == "sim6") {
-            for(int i=0;i<nrows;i++) {
-                for(int j=0;j<ncols;j++) {
-                    probabilityMatrix[ncols * i + j] = start + columntotal[j]/double(n*nrows);
-                    start = start + columntotal[j]/double(n*nrows);
-                }
-            }
-        }
-        
-        
-        else if (matrix == "sim7") {
-            for(int i=0;i<nrows;i++) {
-                for(int j=0;j<ncols;j++) {
-                    probabilityMatrix[ncols * i + j] = start + rowtotal[i]/double(n*ncols);
-                    start = start + rowtotal[i]/double(n*ncols);
-                }
-            }
-        }
-        
-        else if (matrix == "sim8") {
-            for(int i=0;i<nrows;i++) {
-                for(int j=0;j<ncols;j++) {
-                    probabilityMatrix[ncols * i + j] = start + (rowtotal[i]*columntotal[j])/double(n*n);
-                    start = start + (rowtotal[i]*columntotal[j])/double(n*n);
-                }
-            }
-        }
-        else if (matrix == "sim9" || matrix == "sim2") { }
-        else {
-            m->mothurOut("[ERROR]: No model selected! \n");
-            m->control_pressed = true;
-        }
-        
-        
-        //co_matrix is the transposed shared file, initmatrix is the original shared file
-        if (metric == "cscore") { initscore = trial.calc_c_score(co_matrix, rowtotal, ncols, nrows); }
-        else if (metric == "checker") { initscore = trial.calc_checker(co_matrix, rowtotal, ncols, nrows); }
-        else if (metric == "vratio") { initscore = trial.calc_vratio(nrows, ncols, rowtotal, columntotal); }
-        else if (metric == "combo") { initscore = trial.calc_combo(nrows, ncols, co_matrix); }
-        else { m->mothurOut("[ERROR]: No metric selected!\n"); m->control_pressed = true; return 1; }
-        
-        m->mothurOut("Initial c score: " + toString(initscore)); m->mothurOutEndLine();
-        
-        double previous;
-        double current;
-        double randnum;
-        int count;
-
-        //burn-in for sim9    
-        if(matrix == "sim9") {
-            for(int i=0;i<10000;i++) trial.swap_checkerboards (co_matrix, ncols, nrows);
-        }
-
-        //populate null matrix from probability matrix, do this a lot.
-        for(int k=0;k<runs;k++){
-            nullmatrix.clear();
-            //zero-fill the null matrix
-            nullmatrix.assign(nrows, vector<int>(ncols, 0));
-            
-            if(matrix == "sim1" || matrix == "sim6" || matrix == "sim8" || matrix == "sim7") {
-                count = 0;
-                while(count < n) {
-                    if (m->control_pressed) { return 0; }
-                nextnum2:
-                    previous = 0.0;
-                    randnum = rand() / double(RAND_MAX);
-                    for(int i=0;i<nrows;i++) {
-                        for(int j=0;j<ncols;j++) {
-                            current = probabilityMatrix[ncols * i + j];
-                            if(randnum <= current && randnum > previous) {
-                                nullmatrix[i][j] = 1;
-                                count++;
-                                if (count > n) break;
-                                else
-                                    goto nextnum2;
-                            }
-                            previous = current;
-                        }
-                    }
-                }
-            }
-            
-            else if (matrix == "sim2") {
-                for(int i=0;i<nrows;i++) {
-                    random_shuffle( co_matrix[i].begin(), co_matrix[i].end() ); 
-                }
-                //do this for the scoring since those all have nullmatrix as a parameter
-                //nullmatrix gets cleared at the begining of each run
-                nullmatrix = co_matrix;
-            }
-            
-            else if(matrix == "sim4") {
-                for(int i=0;i<nrows;i++) {
-                    count = 0;
-                    while(count < rowtotal[i]) {
-                        previous = 0.0;
-                        if (m->control_pressed) { return 0; }
-                        randnum = rand() / double(RAND_MAX);
-                        for(int j=0;j<ncols;j++) {
-                            current = probabilityMatrix[ncols * i + j];
-                            if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
-                                nullmatrix[i][j] = 1;
-                                count++;
-                                previous = 0.0;
-                                break;
-                            }
-                            previous = current;
-                        }
-                    }
-                }
-            }
-            
-            else if(matrix == "sim3" || matrix == "sim5") {
-                //columns
-                for(int j=0;j<ncols;j++) {
-                    count = 0;
-                    while(count < columntotal[j]) {
-                        if (m->control_pressed) { return 0; }
-                        randnum = rand() / double(RAND_MAX);
-                        for(int i=0;i<nrows;i++) {
-                            current = probabilityMatrix[ncols * i + j];
-                            if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
-                                nullmatrix[i][j] = 1;
-                                count++;
-                                previous = 0.0;
-                                break;
-                            }
-                            previous = current;
-                        }
-                    }
-                }
-            }
-            
-            //swap_checkerboards takes the original matrix and swaps checkerboards
-            else if(matrix == "sim9") {
-                trial.swap_checkerboards (co_matrix, ncols, nrows);
-                nullmatrix = co_matrix;
-            }
-            else {
-                m->mothurOut("[ERROR]: No null model selected!\n\n"); m->control_pressed = true;
-                return 1;
-            }
-            
-            //run metric on null matrix and add score to the stats vector
-            if (metric == "cscore"){
-                stats.push_back(trial.calc_c_score(nullmatrix, rowtotal, ncols, nrows));
-            }
-            else if (metric == "checker") {
-                stats.push_back(trial.calc_checker(nullmatrix, rowtotal, ncols, nrows));
-            }
-            else if (metric == "vratio") {
-                stats.push_back(trial.calc_vratio(nrows, ncols, rowtotal, columntotal));
-            }
-            else if (metric == "combo") {
-                stats.push_back(trial.calc_combo(nrows, ncols, nullmatrix));
-            }
-            else {
-                m->mothurOut("[ERROR]: No metric selected!\n\n"); m->control_pressed = true;
-                return 1;
-            }
-            
-        }
-        
-        
-        
-        double total = 0.0;
-        for (int i=0; i<stats.size();i++) { total+=stats[i]; }
-        
-        double nullMean = double (total/(double)stats.size());
-        
-        m->mothurOutEndLine(); m->mothurOut("average metric score: " + toString(nullMean)); m->mothurOutEndLine();
-        
-        double pvalue = 0.0;
-        if (metric == "cscore" || metric == "checker") { pvalue = trial.calc_pvalue_greaterthan (stats, initscore); }
-        else{ pvalue = trial.calc_pvalue_lessthan (stats, initscore); }
-        
-        m->mothurOut("pvalue: " + toString(pvalue)); m->mothurOutEndLine();
-        out << metric << '\t' << thisLookUp[0]->getLabel() << '\t' << nullMean << '\t' << pvalue << endl;
-        
-        return 0;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "CooccurrenceCommand", "Cooccurrence");
-        exit(1);
-    }
-}
-//**********************************************************************************************************************
-
-
diff --git a/cooccurrencecommand.h b/cooccurrencecommand.h
deleted file mode 100644 (file)
index 8f60e08..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef COOCCURRENCECOMMAND_H
-#define COOCCURRENCECOMMAND_H
-
-/*
- *  COOCCURRENCE.h
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "trialswap2.h"
-#include "inputdata.h"
-#include "sharedrabundvector.h"
-
-
-class CooccurrenceCommand : public Command {
-       
-public:
-       
-       CooccurrenceCommand(string);    
-       CooccurrenceCommand();
-       ~CooccurrenceCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "Cooccurrence";                        }
-       string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Cooccurrence"; }
-       string getDescription()         { return "calculates four metrics and tests their significance to assess whether presence-absence patterns are different than what one would expect by chance."; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-    string metric, matrix, outputDir;
-    string label, sharedfile, groups;
-    bool abort, allLines;
-    set<string> labels;
-    vector<string> outputNames, Groups;
-    int runs;
-    
-    int getCooccurrence(vector<SharedRAbundVector*>&, ofstream&);
-       
-};
-
-#endif
-
-
diff --git a/corraxescommand.cpp b/corraxescommand.cpp
deleted file mode 100644 (file)
index c27eb4b..0000000
+++ /dev/null
@@ -1,977 +0,0 @@
-/*
- *  corraxescommand.cpp
- *  Mothur
- *
- *  Created by westcott on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "corraxescommand.h"
-#include "sharedutilities.h"
-#include "linearalgebra.h"
-
-//**********************************************************************************************************************
-vector<string> CorrAxesCommand::setParameters(){       
-       try {
-               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paxes);
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pmetadata("metadata", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pmetadata);
-               CommandParameter pnumaxes("numaxes", "Number", "", "3", "", "", "",false,false); parameters.push_back(pnumaxes);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CorrAxesCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The corr.axes command reads a shared, relabund or metadata file as well as an axes file and calculates the correlation coefficient.\n";
-               helpString += "The corr.axes command parameters are shared, relabund, axes, metadata, groups, method, numaxes and label.  The shared, relabund or metadata and axes parameters are required.  If shared is given the relative abundance is calculated.\n";
-               helpString += "The groups parameter allows you to specify which of the groups you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance level you would like used, if none is given the first distance is used.\n";
-               helpString += "The method parameter allows you to select what method you would like to use. Options are pearson, spearman and kendall. Default=pearson.\n";
-               helpString += "The numaxes parameter allows you to select the number of axes you would like to use. Default=3.\n";
-               helpString += "The corr.axes command should be in the following format: corr.axes(axes=yourPcoaFile, shared=yourSharedFile, method=yourMethod).\n";
-               helpString += "Example corr.axes(axes=genus.pool.thetayc.genus.lt.pcoa, shared=genus.pool.shared, method=kendall).\n";
-               helpString += "The corr.axes command outputs a .corr.axes file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CorrAxesCommand::CorrAxesCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["corr.axes"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "CorrAxesCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CorrAxesCommand::CorrAxesCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["corr.axes"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("axes");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["axes"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("metadata");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["metadata"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       axesfile = validParameter.validFile(parameters, "axes", true);
-                       if (axesfile == "not open") { abort = true; }
-                       else if (axesfile == "not found") { axesfile = ""; m->mothurOut("axes is a required parameter for the corr.axes command."); m->mothurOutEndLine(); abort = true;  }     
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; }
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else { inputFileName = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { abort = true; }
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else { inputFileName = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       metadatafile = validParameter.validFile(parameters, "metadata", true);
-                       if (metadatafile == "not open") { abort = true; }
-                       else if (metadatafile == "not found") { metadatafile = ""; }
-                       else { inputFileName = metadatafile; }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "";  pickedGroups = false;  }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups); 
-                       }                       
-                       m->setGroups(Groups);
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputFileName);  }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }  
-                       
-                       if ((relabundfile == "") && (sharedfile == "") && (metadatafile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then relabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputFileName = sharedfile; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       relabundfile = m->getRelAbundFile(); 
-                                       if (relabundfile != "") { inputFileName = relabundfile;  m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You must provide either a shared, relabund, or metadata file."); m->mothurOutEndLine(); abort = true; 
-                                       }
-                               }
-                       }       
-                       
-                       if (metadatafile != "") {
-                               if ((relabundfile != "") || (sharedfile != "")) { m->mothurOut("You may only use one of the following : shared, relabund or metadata file."); m->mothurOutEndLine(); abort = true;  }
-                       }else {
-                               if ((relabundfile != "") && (sharedfile != "")) { m->mothurOut("You may only use one of the following : shared, relabund or metadata file."); m->mothurOutEndLine(); abort = true;  }
-                       }
-                       string temp;
-                       temp = validParameter.validFile(parameters, "numaxes", false);          if (temp == "not found"){       temp = "3";                             }
-                       m->mothurConvert(temp, numaxes); 
-                       
-                       method = validParameter.validFile(parameters, "method", false);         if (method == "not found"){     method = "pearson";             }
-                       
-                       if ((method != "pearson") && (method != "spearman") && (method != "kendall")) { m->mothurOut(method + " is not a valid method. Valid methods are pearson, spearman, and kendall."); m->mothurOutEndLine(); abort = true; }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "CorrAxesCommand");           
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int CorrAxesCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               /*************************************************************************************/
-               // use smart distancing to get right sharedRabund and convert to relabund if needed  //
-               /************************************************************************************/
-               if (sharedfile != "") {  
-                       InputData* input = new InputData(sharedfile, "sharedfile");
-                       getSharedFloat(input); 
-                       delete input;
-                       
-                       if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-                       if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading relabund file."); m->mothurOutEndLine(); return 0; }
-                       
-               }else if (relabundfile != "") { 
-                       InputData* input = new InputData(relabundfile, "relabund");
-                       getSharedFloat(input); 
-                       delete input;
-                       
-                       if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-                       if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading relabund file."); m->mothurOutEndLine(); return 0; }
-                       
-               }else if (metadatafile != "") { 
-                       getMetadata();  //reads metadata file and store in lookupFloat, saves column headings in metadataLabels for later
-                       if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-                       if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading metadata file."); m->mothurOutEndLine(); return 0; }
-                       
-                       if (pickedGroups) { eliminateZeroOTUS(lookupFloat); }
-                       
-               }else { m->mothurOut("[ERROR]: no file given."); m->mothurOutEndLine(); return 0; }
-               
-               if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-               
-               //this is for a sanity check to make sure the axes file and shared file match
-               for (int i = 0; i < lookupFloat.size(); i++) { names.insert(lookupFloat[i]->getGroup()); }
-               
-               /*************************************************************************************/
-               // read axes file and check for file mismatches with shared or relabund file         //
-               /************************************************************************************/
-               
-               //read axes file
-               map<string, vector<float> > axes = readAxes();
-               
-               if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-               
-               //sanity check, the read only adds groups that are in the shared or relabund file, but we want to make sure the axes file isn't missing anyone
-               if (axes.size() != lookupFloat.size()) { 
-                       map<string, vector<float> >::iterator it;
-                       for (int i = 0; i < lookupFloat.size(); i++) {
-                               it = axes.find(lookupFloat[i]->getGroup());
-                               if (it == axes.end()) { m->mothurOut(lookupFloat[i]->getGroup() + " is in your shared of relabund file but not in your axes file, please correct."); m->mothurOutEndLine(); }
-                       }
-                       m->control_pressed = true;
-               }
-               
-               if (m->control_pressed) {  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-               
-               /*************************************************************************************/
-               // calc the r values                                                                                                                            //
-               /************************************************************************************/
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + method + ".corr.axes";
-               outputNames.push_back(outputFileName); outputTypes["corr.axes"].push_back(outputFileName);      
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               //output headings
-               if (metadatafile == "") {  out << "OTU";        }
-               else {  out << "Feature";                                               }
-
-               for (int i = 0; i < numaxes; i++) { out << '\t' << "axis" << (i+1) << "\tp-value"; }
-               out << "\tlength" << endl;
-               
-               if (method == "pearson")                {  calcPearson(axes, out);      }
-               else if (method == "spearman")  {  calcSpearman(axes, out); }
-               else if (method == "kendall")   {  calcKendall(axes, out);      }
-               else { m->mothurOut("[ERROR]: Invalid method."); m->mothurOutEndLine(); }
-               
-               out.close();
-               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
-               
-               if (m->control_pressed) {  return 0; }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "execute");   
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CorrAxesCommand::calcPearson(map<string, vector<float> >& axes, ofstream& out) {
-   try {
-          
-       LinearAlgebra linear;
-       
-          //find average of each axis - X
-          vector<float> averageAxes; averageAxes.resize(numaxes, 0.0);
-          for (map<string, vector<float> >::iterator it = axes.begin(); it != axes.end(); it++) {
-                  vector<float> temp = it->second;
-                  for (int i = 0; i < temp.size(); i++) {
-                          averageAxes[i] += temp[i];  
-                  }
-          }
-          
-          for (int i = 0; i < averageAxes.size(); i++) {  averageAxes[i] = averageAxes[i] / (float) axes.size(); }
-          
-          //for each otu
-          for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
-                  
-                  if (metadatafile == "") {  out << m->currentBinLabels[i];    }
-                  else {  out << metadataLabels[i];            }
-                                  
-                  //find the averages this otu - Y
-                  float sumOtu = 0.0;
-                  for (int j = 0; j < lookupFloat.size(); j++) {
-                          sumOtu += lookupFloat[j]->getAbundance(i);
-                  }
-                  float Ybar = sumOtu / (float) lookupFloat.size();
-                  
-                  vector<float> rValues(averageAxes.size());
-
-                  //find r value for each axis
-                  for (int k = 0; k < averageAxes.size(); k++) {
-                          
-                          double r = 0.0;
-                          double numerator = 0.0;
-                          double denomTerm1 = 0.0;
-                          double denomTerm2 = 0.0;
-                          for (int j = 0; j < lookupFloat.size(); j++) {
-                                  float Yi = lookupFloat[j]->getAbundance(i);
-                                  float Xi = axes[lookupFloat[j]->getGroup()][k];
-                                  
-                                  numerator += ((Xi - averageAxes[k]) * (Yi - Ybar));
-                                  denomTerm1 += ((Xi - averageAxes[k]) * (Xi - averageAxes[k]));
-                                  denomTerm2 += ((Yi - Ybar) * (Yi - Ybar));
-                          }
-                          
-                          double denom = (sqrt(denomTerm1) * sqrt(denomTerm2));
-                          
-                          r = numerator / denom;
-               
-               if (isnan(r) || isinf(r)) { r = 0.0; }
-               
-                          rValues[k] = r;
-                          out << '\t' << r; 
-               
-               double sig = linear.calcPearsonSig(lookupFloat.size(), r);
-               
-               out << '\t' << sig;
-                  }
-                  
-                  double sum = 0;
-                  for(int k=0;k<rValues.size();k++){
-                          sum += rValues[k] * rValues[k];
-                  }
-                  out << '\t' << sqrt(sum) << endl;
-          }
-                  
-          return 0;
-   }
-   catch(exception& e) {
-          m->errorOut(e, "CorrAxesCommand", "calcPearson");
-          exit(1);
-   }
-}
-//**********************************************************************************************************************
-int CorrAxesCommand::calcSpearman(map<string, vector<float> >& axes, ofstream& out) {
-       try {
-               
-        LinearAlgebra linear;
-        vector<double> sf; 
-        
-               //format data
-               vector< map<float, int> > tableX; tableX.resize(numaxes);
-               map<float, int>::iterator itTable;
-               vector< vector<spearmanRank> > scores; scores.resize(numaxes);
-               for (map<string, vector<float> >::iterator it = axes.begin(); it != axes.end(); it++) {
-                       vector<float> temp = it->second;
-                       for (int i = 0; i < temp.size(); i++) {
-                               spearmanRank member(it->first, temp[i]);
-                               scores[i].push_back(member);  
-                               
-                               //count number of repeats
-                               itTable = tableX[i].find(temp[i]);
-                               if (itTable == tableX[i].end()) { 
-                                       tableX[i][temp[i]] = 1;
-                               }else {
-                                       tableX[i][temp[i]]++;
-                               }
-                       }
-               }
-               
-               //calc LX
-               //for each axis
-               vector<double> Lx; Lx.resize(numaxes, 0.0);
-               for (int i = 0; i < numaxes; i++) {
-                       for (itTable = tableX[i].begin(); itTable != tableX[i].end(); itTable++) {
-                               double tx = (double) itTable->second;
-                               Lx[i] += ((pow(tx, 3.0) - tx) / 12.0);
-                       }
-               }
-               
-               //sort each axis
-               for (int i = 0; i < numaxes; i++) {  sort(scores[i].begin(), scores[i].end(), compareSpearman); }
-               
-               //find ranks of xi in each axis
-               map<string, vector<float> > rankAxes;
-               for (int i = 0; i < numaxes; i++) {
-                       
-                       vector<spearmanRank> ties;
-                       int rankTotal = 0;
-            double sfTemp = 0.0;
-                       for (int j = 0; j < scores[i].size(); j++) {
-                               rankTotal += (j+1);
-                               ties.push_back(scores[i][j]);
-                               
-                               if (j != (scores[i].size()-1)) { // you are not the last so you can look ahead
-                                       if (scores[i][j].score != scores[i][j+1].score) { // you are done with ties, rank them and continue
-
-                                               for (int k = 0; k < ties.size(); k++) {
-                                                       float thisrank = rankTotal / (float) ties.size();
-                                                       rankAxes[ties[k].name].push_back(thisrank);
-                                               }
-                        int t = ties.size();
-                        sfTemp += (t*t*t-t);
-                                               ties.clear();
-                                               rankTotal = 0;
-                                       }
-                               }else { // you are the last one
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankAxes[ties[k].name].push_back(thisrank);
-                                               
-                                       }
-                               }
-                       }
-            sf.push_back(sfTemp);
-               }
-               
-                               
-               //for each otu
-               for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
-                       
-                       if (metadatafile == "") {  out << m->currentBinLabels[i];       }
-                       else {  out << metadataLabels[i];               }
-                       
-                       //find the ranks of this otu - Y
-                       vector<spearmanRank> otuScores;
-                       map<float, int> tableY;
-                       for (int j = 0; j < lookupFloat.size(); j++) {
-                               spearmanRank member(lookupFloat[j]->getGroup(), lookupFloat[j]->getAbundance(i));
-                               otuScores.push_back(member);
-                               
-                               itTable = tableY.find(member.score);
-                               if (itTable == tableY.end()) { 
-                                       tableY[member.score] = 1;
-                               }else {
-                                       tableY[member.score]++;
-                               }
-                               
-                       }
-                       
-                       //calc Ly
-                       double Ly = 0.0;
-                       for (itTable = tableY.begin(); itTable != tableY.end(); itTable++) {
-                               double ty = (double) itTable->second;
-                               Ly += ((pow(ty, 3.0) - ty) / 12.0);
-                       }
-                       
-                       sort(otuScores.begin(), otuScores.end(), compareSpearman);
-                       
-            double sg = 0.0;
-                       map<string, float> rankOtus;
-                       vector<spearmanRank> ties;
-                       int rankTotal = 0;
-                       for (int j = 0; j < otuScores.size(); j++) {
-                               rankTotal += (j+1);
-                               ties.push_back(otuScores[j]);
-                               
-                               if (j != (otuScores.size()-1)) { // you are not the last so you can look ahead
-                                       if (otuScores[j].score != otuScores[j+1].score) { // you are done with ties, rank them and continue
-                                               
-                                               for (int k = 0; k < ties.size(); k++) {
-                                                       float thisrank = rankTotal / (float) ties.size();
-                                                       rankOtus[ties[k].name] = thisrank;
-                                               }
-                        int t = ties.size();
-                        sg += (t*t*t-t);
-                                               ties.clear();
-                                               rankTotal = 0;
-                                       }
-                               }else { // you are the last one
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankOtus[ties[k].name] = thisrank;
-                                       }
-                               }
-                       }
-                       vector<double> pValues(numaxes);        
-
-                       //calc spearman ranks for each axis for this otu
-                       for (int j = 0; j < numaxes; j++) {
-                               
-                               double di = 0.0;
-                               for (int k = 0; k < lookupFloat.size(); k++) {
-                                       
-                                       float xi = rankAxes[lookupFloat[k]->getGroup()][j];
-                                       float yi = rankOtus[lookupFloat[k]->getGroup()];
-                                       
-                                       di += ((xi - yi) * (xi - yi));
-                               }
-                               
-                               double p = 0.0;
-                               
-                               double n = (double) lookupFloat.size();
-                               
-                               double SX2 = ((pow(n, 3.0) - n) / 12.0) - Lx[j];
-                               double SY2 = ((pow(n, 3.0) - n) / 12.0) - Ly;
-                               
-                               p = (SX2 + SY2 - di) / (2.0 * sqrt((SX2*SY2)));
-                               
-                if (isnan(p) || isinf(p)) { p = 0.0; }
-                
-                               out  << '\t' << p;
-                               
-                               pValues[j] = p;
-                
-                double sig = linear.calcSpearmanSig(n, sf[j], sg, di);            
-                out  << '\t' << sig;
-                
-                       }
-
-                       double sum = 0;
-                       for(int k=0;k<numaxes;k++){
-                               sum += pValues[k] * pValues[k];
-                       }
-                       out << '\t' << sqrt(sum) << endl;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "calcSpearman");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CorrAxesCommand::calcKendall(map<string, vector<float> >& axes, ofstream& out) {
-       try {
-               
-        LinearAlgebra linear;
-        
-               //format data
-               vector< vector<spearmanRank> > scores; scores.resize(numaxes);
-               for (map<string, vector<float> >::iterator it = axes.begin(); it != axes.end(); it++) {
-                       vector<float> temp = it->second;
-                       for (int i = 0; i < temp.size(); i++) {
-                               spearmanRank member(it->first, temp[i]);
-                               scores[i].push_back(member);  
-                       }
-               }
-               
-               //sort each axis
-               for (int i = 0; i < numaxes; i++) {  sort(scores[i].begin(), scores[i].end(), compareSpearman); }
-               
-               //convert scores to ranks of xi in each axis
-               for (int i = 0; i < numaxes; i++) {
-                       
-                       vector<spearmanRank*> ties;
-                       int rankTotal = 0;
-                       for (int j = 0; j < scores[i].size(); j++) {
-                               rankTotal += (j+1);
-                               ties.push_back(&(scores[i][j]));
-                               
-                               if (j != scores[i].size()-1) { // you are not the last so you can look ahead
-                                       if (scores[i][j].score != scores[i][j+1].score) { // you are done with ties, rank them and continue
-                                               for (int k = 0; k < ties.size(); k++) {
-                                                       float thisrank = rankTotal / (float) ties.size();
-                                                       (*ties[k]).score = thisrank;
-                                               }
-                                               ties.clear();
-                                               rankTotal = 0;
-                                       }
-                               }else { // you are the last one
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               (*ties[k]).score = thisrank;
-                                       }
-                               }
-                       }
-               }
-               
-               //for each otu
-               for (int i = 0; i < lookupFloat[0]->getNumBins(); i++) {
-               
-                       if (metadatafile == "") {  out << m->currentBinLabels[i];       }
-                       else {  out << metadataLabels[i];               }
-                       
-                       //find the ranks of this otu - Y
-                       vector<spearmanRank> otuScores;
-                       for (int j = 0; j < lookupFloat.size(); j++) {
-                               spearmanRank member(lookupFloat[j]->getGroup(), lookupFloat[j]->getAbundance(i));
-                               otuScores.push_back(member);
-                       }
-                                               
-                       sort(otuScores.begin(), otuScores.end(), compareSpearman);
-                       
-                       map<string, float> rankOtus;
-                       vector<spearmanRank> ties;
-                       int rankTotal = 0;
-                       for (int j = 0; j < otuScores.size(); j++) {
-                               rankTotal += (j+1);
-                               ties.push_back(otuScores[j]);
-                               
-                               if (j != otuScores.size()-1) { // you are not the last so you can look ahead
-                                       if (otuScores[j].score != otuScores[j+1].score) { // you are done with ties, rank them and continue
-                                               for (int k = 0; k < ties.size(); k++) {
-                                                       float thisrank = rankTotal / (float) ties.size();
-                                                       rankOtus[ties[k].name] = thisrank;
-                                               }
-                                               ties.clear();
-                                               rankTotal = 0;
-                                       }
-                               }else { // you are the last one
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankOtus[ties[k].name] = thisrank;
-                                       }
-                               }
-                       }
-                       
-                       
-                       vector<double> pValues(numaxes);
-                       
-                       //calc spearman ranks for each axis for this otu
-                       for (int j = 0; j < numaxes; j++) {
-                       
-                               int numCoor = 0;
-                               int numDisCoor = 0;
-                               
-                               vector<spearmanRank> otus; 
-                               vector<spearmanRank> otusTemp;
-                               for (int l = 0; l < scores[j].size(); l++) {   
-                                       spearmanRank member(scores[j][l].name, rankOtus[scores[j][l].name]);
-                                       otus.push_back(member);
-                               }
-                               
-                               int count = 0;
-                               for (int l = 0; l < scores[j].size(); l++) {
-                                       
-                                       int numWithHigherRank = 0;
-                                       int numWithLowerRank = 0;
-                                       float thisrank = otus[l].score;
-                                       
-                                       for (int u = l+1; u < scores[j].size(); u++) {
-                                               if (otus[u].score > thisrank) { numWithHigherRank++; }
-                                               else if (otus[u].score < thisrank) { numWithLowerRank++; }
-                                               count++;
-                                       }
-                                       
-                                       numCoor += numWithHigherRank;
-                                       numDisCoor += numWithLowerRank;
-                               }
-                               
-                               double p = (numCoor - numDisCoor) / (float) count;
-                 if (isnan(p) || isinf(p)) { p = 0.0; }
-                
-                               out << '\t' << p;
-                               pValues[j] = p;
-                
-                double sig = linear.calcKendallSig(scores[j].size(), p);
-                
-                out << '\t' << sig;
-                       }
-                       
-                       double sum = 0;
-                       for(int k=0;k<numaxes;k++){
-                               sum += pValues[k] * pValues[k];
-                       }
-                       out << '\t' << sqrt(sum) << endl;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "calcKendall");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CorrAxesCommand::getSharedFloat(InputData* input){
-       try {
-               lookupFloat = input->getSharedRAbundFloatVectors();
-               string lastLabel = lookupFloat[0]->getLabel();
-               
-               if (label == "") { label = lastLabel;  return 0; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookupFloat[0] != NULL) && (userLabels.size() != 0)) {
-                       
-                       if (m->control_pressed) {  return 0;  }
-                       
-                       if(labels.count(lookupFloat[0]->getLabel()) == 1){
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               break;
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookupFloat[0]->getLabel();
-                               
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } 
-                               lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookupFloat[0]->setLabel(saveLabel);
-                               break;
-                       }
-                       
-                       lastLabel = lookupFloat[0]->getLabel();                 
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } 
-                       lookupFloat = input->getSharedRAbundFloatVectors();
-               }
-               
-               
-               if (m->control_pressed) { return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookupFloat.size(); i++) {  if (lookupFloat[i] != NULL) {   delete lookupFloat[i];  } } 
-                       lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-               }       
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "getSharedFloat");    
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CorrAxesCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>& thislookup) {
-       try {
-               
-               vector<SharedRAbundFloatVector*> newLookup;
-               for (int i = 0; i < thislookup.size(); i++) {
-                       SharedRAbundFloatVector* temp = new SharedRAbundFloatVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookup.push_back(temp);
-               }
-               
-               //for each bin
-               vector<string> newBinLabels;
-               string snumBins = toString(thislookup[0]->getNumBins());
-               for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                       if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                       
-                       //look at each sharedRabund and make sure they are not all zero
-                       bool allZero = true;
-                       for (int j = 0; j < thislookup.size(); j++) {
-                               if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                       }
-                       
-                       //if they are not all zero add this bin
-                       if (!allZero) {
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                               }
-                               
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               newBinLabels.push_back(binLabel);
-                       }
-               }
-               
-               for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-               
-               thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "eliminateZeroOTUS");
-               exit(1);
-       }
-}
-/*****************************************************************/
-map<string, vector<float> > CorrAxesCommand::readAxes(){
-       try {
-               map<string, vector<float> > axes;
-               
-               ifstream in;
-               m->openInputFile(axesfile, in);
-               
-               string headerLine = m->getline(in); m->gobble(in);
-               
-               //count the number of axis you are reading
-               bool done = false;
-               int count = 0;
-               while (!done) {
-                       int pos = headerLine.find("axis");
-                       if (pos != string::npos) {
-                               count++;
-                               headerLine = headerLine.substr(pos+4);
-                       }else { done = true; }
-               }
-               
-               if (numaxes > count) { m->mothurOut("You requested " + toString(numaxes) + " axes, but your file only includes " + toString(count) + ". Using " + toString(count) + "."); m->mothurOutEndLine(); numaxes = count; }
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return axes; }
-                       
-                       string group = "";
-                       in >> group; m->gobble(in);
-                       
-                       vector<float> thisGroupsAxes;
-                       for (int i = 0; i < count; i++) {
-                               float temp = 0.0;
-                               in >> temp; 
-                               
-                               //only save the axis we want
-                               if (i < numaxes) {  thisGroupsAxes.push_back(temp); }
-                       }
-                       
-                       //save group if its one the user selected
-                       if (names.count(group) != 0) {
-                               map<string, vector<float> >::iterator it = axes.find(group);
-                               
-                               if (it == axes.end()) {
-                                       axes[group] = thisGroupsAxes;
-                               }else {
-                                       m->mothurOut(group + " is already in your axes file, using first definition."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               
-               return axes;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "readAxes");  
-               exit(1);
-       }
-}
-/*****************************************************************/
-int CorrAxesCommand::getMetadata(){
-       try {
-               vector<string> groupNames;
-               
-               ifstream in;
-               m->openInputFile(metadatafile, in);
-               
-               string headerLine = m->getline(in); m->gobble(in);
-               istringstream iss (headerLine,istringstream::in);
-               
-               //read the first label, because it refers to the groups
-               string columnLabel;
-               iss >> columnLabel; m->gobble(iss); 
-               
-               //save names of columns you are reading
-               while (!iss.eof()) {
-                       iss >> columnLabel; m->gobble(iss);
-                       metadataLabels.push_back(columnLabel);
-               }
-               int count = metadataLabels.size();
-                       
-               //read rest of file
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       string group = "";
-                       in >> group; m->gobble(in);
-                       groupNames.push_back(group);
-                               
-                       SharedRAbundFloatVector* tempLookup = new SharedRAbundFloatVector();
-                       tempLookup->setGroup(group);
-                       tempLookup->setLabel("1");
-                       
-                       for (int i = 0; i < count; i++) {
-                               float temp = 0.0;
-                               in >> temp; 
-                               tempLookup->push_back(temp, group);
-                       }
-                       
-                       lookupFloat.push_back(tempLookup);
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               
-               //remove any groups the user does not want, and set globaldata->groups with only valid groups
-               SharedUtil* util;
-               util = new SharedUtil();
-               Groups = m->getGroups();
-               util->setGroups(Groups, groupNames);
-               m->setGroups(Groups);
-               
-               for (int i = 0; i < lookupFloat.size(); i++) {
-                       //if this sharedrabund is not from a group the user wants then delete it.
-                       if (util->isValidGroup(lookupFloat[i]->getGroup(), m->getGroups()) == false) { 
-                               delete lookupFloat[i]; lookupFloat[i] = NULL;
-                               lookupFloat.erase(lookupFloat.begin()+i); 
-                               i--; 
-                       }
-               }
-               
-               delete util;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CorrAxesCommand", "getMetadata");       
-               exit(1);
-       }
-}
-/*****************************************************************/
-
-
-
-
-
-
diff --git a/corraxescommand.h b/corraxescommand.h
deleted file mode 100644 (file)
index 2aa7ae0..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef CORRAXESCOMMAND_H
-#define CORRAXESCOMMAND_H
-
-/*
- *  corraxescommand.h
- *  Mothur
- *
- *  Created by westcott on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "sharedrabundfloatvector.h"
-#include "inputdata.h"
-
-
-class CorrAxesCommand : public Command {
-public:
-       CorrAxesCommand(string);
-       CorrAxesCommand();
-       ~CorrAxesCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "corr.axes";                           }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Corr.axes"; }
-       string getDescription()         { return "calculate the correlation coefficient for each column in a shared/relabund file to the axes displayed in a pcoa file"; }
-       
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-private:
-
-       string axesfile, sharedfile, relabundfile, metadatafile, groups, label, inputFileName, outputDir, method;
-       bool abort, pickedGroups;
-       int numaxes;
-       set<string> names;
-       
-       vector<string> outputNames, Groups;
-       vector<SharedRAbundFloatVector*> lookupFloat;
-       vector<string> metadataLabels;
-       
-       int getSharedFloat(InputData*);
-       int getMetadata();
-       int eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&);
-       map<string, vector<float> > readAxes();
-       int calcPearson(map<string, vector<float> >&, ofstream&);
-       int calcSpearman(map<string, vector<float> >&, ofstream&);
-       int calcKendall(map<string, vector<float> >&, ofstream&);
-       
-};
-
-
-#endif
-
-
diff --git a/countgroupscommand.cpp b/countgroupscommand.cpp
deleted file mode 100644 (file)
index 0c03882..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *  countgroupscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 8/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "countgroupscommand.h"
-#include "sharedutilities.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> CountGroupsCommand::setParameters(){    
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "sharedGroup", "sharedGroup", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CountGroupsCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The count.groups command counts sequences from a specific group or set of groups from the following file types: group or shared file.\n";
-               helpString += "The count.groups command parameters are accnos, group, shared and groups. You must provide a group or shared file.\n";
-               helpString += "The accnos parameter allows you to provide a file containing the list of groups.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like.  You can separate group names with dashes.\n";
-               helpString += "The count.groups command should be in the following format: count.groups(accnos=yourAccnos, group=yourGroupFile).\n";
-               helpString += "Example count.groups(accnos=amazon.accnos, group=amazon.groups).\n";
-               helpString += "or count.groups(groups=pasture, group=amazon.groups).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. group), '=' and parameters (i.e.yourGroupFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CountGroupsCommand::CountGroupsCommand(){      
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "CountGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CountGroupsCommand::CountGroupsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = ""; }
-                       else { m->setAccnosFile(accnosfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else {
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }
-                       else if (sharedfile == "not found") {  sharedfile = "";  }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") {    groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }    
-                       
-                       if ((sharedfile == "") && (groupfile == "")) { 
-                               //give priority to shared, then group
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") {  m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       groupfile = m->getGroupFile(); 
-                                       if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
-                                       }
-                               }
-                       }
-                       
-                       if ((accnosfile == "") && (Groups.size() == 0)) { Groups.push_back("all"); m->setGroups(Groups); }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "CountGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int CountGroupsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
-               
-               if (groupfile != "") {
-                       GroupMap groupMap(groupfile);
-                       groupMap.readMap();
-                       
-                       //make sure groups are valid
-                       //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil util;
-                       vector<string> nameGroups = groupMap.getNamesOfGroups();
-                       util.setGroups(Groups, nameGroups);
-                       
-                       for (int i = 0; i < Groups.size(); i++) {
-                               m->mothurOut(Groups[i] + " contains " + toString(groupMap.getNumSeqs(Groups[i])) + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) { return 0; }
-               
-               if (sharedfile != "")           {               
-                       InputData input(sharedfile, "sharedfile");
-                       vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
-                       
-                       for (int i = 0; i < lookup.size(); i++) {
-                               m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + "."); m->mothurOutEndLine();
-                               delete lookup[i];
-                       }                       
-               }
-                               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void CountGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/countgroupscommand.h b/countgroupscommand.h
deleted file mode 100644 (file)
index 2532a80..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef COUNTGROUPSCOMMAND_H
-#define COUNTGROUPSCOMMAND_H
-
-/*
- *  countgroupscommand.h
- *  Mothur
- *
- *  Created by westcott on 8/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class CountGroupsCommand : public Command {
-       
-public:
-       
-       CountGroupsCommand(string);
-       CountGroupsCommand();   
-       ~CountGroupsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "count.groups";                        }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Count.groups"; }
-       string getDescription()         { return "counts the number of sequences in each group"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       string sharedfile, groupfile, outputDir, groups, accnosfile;
-       bool abort;
-       vector<string> Groups;
-       
-       void readAccnos();
-};
-
-#endif
diff --git a/countseqscommand.cpp b/countseqscommand.cpp
deleted file mode 100644 (file)
index e83c603..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- *  countseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 6/1/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "countseqscommand.h"
-#include "groupmap.h"
-#include "sharedutilities.h"
-
-//**********************************************************************************************************************
-vector<string> CountSeqsCommand::setParameters(){      
-       try {
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CountSeqsCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The count.seqs command reads a name file and outputs a .seq.count file.  You may also provide a group file to get the counts broken down by group.\n";
-               helpString += "The groups parameter allows you to indicate which groups you want to include in the counts, by default all groups in your groupfile are used.\n";
-               helpString += "When you use the groups parameter and a sequence does not represent any sequences from the groups you specify it is not included in the .count.summary file.\n";
-               helpString += "The count.seqs command should be in the following format: count.seqs(name=yourNameFile).\n";
-               helpString += "Example count.seqs(name=amazon.names).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourNameFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-CountSeqsCommand::CountSeqsCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "CountSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-CountSeqsCommand::CountSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found"){                                      
-                               namefile = m->getNameFile(); 
-                               if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current namefile and the name parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "all"; }
-                       m->splitAtDash(groups, Groups);
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(namefile);               }
-
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "CountSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int CountSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(namefile)) + "seq.count";
-               m->openOutputFile(outputFileName, out); outputTypes["summary"].push_back(outputFileName);
-               out << "Representative_Sequence\ttotal\t";
-               
-               GroupMap* groupMap;
-               if (groupfile != "") { 
-                       groupMap = new GroupMap(groupfile); groupMap->readMap(); 
-                       
-                       //make sure groups are valid. takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
-                       vector<string> nameGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, nameGroups);
-                       delete util;
-                       
-                       //sort groupNames so that the group title match the counts below, this is needed because the map object automatically sorts
-                       sort(Groups.begin(), Groups.end());
-                       
-                       //print groupNames
-                       for (int i = 0; i < Groups.size(); i++) {
-                               out << Groups[i] << '\t';
-                       }
-               }
-               out << endl;
-               
-               //open input file
-               ifstream in;
-               m->openInputFile(namefile, in);
-        
-               int total = 0;
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       
-                       vector<string> names;
-                       m->splitAtChar(secondCol, names, ',');
-                       
-                       if (groupfile != "") {
-                               //set to 0
-                               map<string, int> groupCounts;
-                               int total = 0;
-                               for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
-                               
-                               //get counts for each of the users groups
-                               for (int i = 0; i < names.size(); i++) {
-                                       string group = groupMap->getGroup(names[i]);
-                                       
-                                       if (group == "not found") { m->mothurOut("[ERROR]: " + names[i] + " is not in your groupfile, please correct."); m->mothurOutEndLine(); }
-                                       else {
-                                               map<string, int>::iterator it = groupCounts.find(group);
-                                               
-                                               //if not found, then this sequence is not from a group we care about
-                                               if (it != groupCounts.end()) {
-                                                       it->second++;
-                                                       total++;
-                                               }
-                                       }
-                               }
-                               
-                               if (total != 0) {
-                                       out << firstCol << '\t' << total << '\t';
-                                       for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
-                                               out << it->second << '\t';
-                                       }
-                                       out << endl;
-                               }
-                       }else {
-                               out << firstCol << '\t' << names.size() << endl;
-                       }
-                       
-                       total += names.size();
-               }
-               in.close();
-               
-               if (groupfile != "") { delete groupMap; }
-               
-               if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; }
-               
-        m->mothurOutEndLine();
-               m->mothurOut("Total number of sequences: " + toString(total)); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               m->mothurOutEndLine();
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "CountSeqsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/countseqscommand.h b/countseqscommand.h
deleted file mode 100644 (file)
index 89549a9..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef COuNTSEQSCOMMAND_H
-#define COuNTSEQSCOMMAND_H
-
-/*
- *  countseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 6/1/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class CountSeqsCommand : public Command {
-       
-public:
-       
-       CountSeqsCommand(string);
-       CountSeqsCommand();     
-       ~CountSeqsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "count.seqs";                          }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Count.seqs"; }
-       string getDescription()         { return "counts the number of sequences represented by each unique sequence in a namesfile"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       string namefile, groupfile, outputDir, groups;
-       bool abort;
-       vector<string> Groups;
-};
-
-#endif
-
-
diff --git a/coverage.cpp b/coverage.cpp
deleted file mode 100644 (file)
index aebe66f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *  coverage.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 4/22/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "coverage.h"
-
-/***********************************************************************/
-EstOutput Coverage::getValues(SAbundVector* rank){
-
-       try {
-               data.resize(1,0);
-
-               data[0] = 1. - rank->get(1) / (double)rank->getNumSeqs();
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Coverage", "getValues");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
diff --git a/coverage.h b/coverage.h
deleted file mode 100644 (file)
index 8d6fead..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef COVERAGE_H
-#define COVERAGE_H
-
-/*
- *  coverage.h
- *  Mothur
- *
- *  Created by Pat Schloss on 4/22/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the coverage estimator on single group. 
- It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Coverage : public Calculator  {
-       
-public: 
-       Coverage() : Calculator("coverage", 1, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Coverage"; }
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/createdatabasecommand.cpp b/createdatabasecommand.cpp
deleted file mode 100644 (file)
index 1da67e6..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-//
-//  createdatabasecommand.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 3/28/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "createdatabasecommand.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> CreateDatabaseCommand::setParameters(){ 
-       try {
-               CommandParameter pfasta("repfasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("repname", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pcontaxonomy);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string CreateDatabaseCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The create.database command reads a listfile, *.cons.taxonomy, *.rep.fasta, *.rep.names and optional groupfile, and creates a database file.\n";
-               helpString += "The create.database command parameters are repfasta, list, repname, contaxonomy, group and label. List, repfasta, repnames, and contaxonomy are required.\n";
-        helpString += "The repfasta file is fasta file outputted by get.oturep(fasta=yourFastaFile, list=yourListfile, column=yourDistFile, name=yourNameFile).\n";
-        helpString += "The repname file is the name file outputted by get.oturep(fasta=yourFastaFile, list=yourListfile, column=yourDistFile, name=yourNameFile).\n";
-        helpString += "The contaxonomy file is the taxonomy file outputted by classify.otu(list=yourListfile, taxonomy=yourTaxonomyFile).\n";
-        helpString += "The group file is optional and will just give you the abundance breakdown by group.\n";
-        helpString += "The label parameter allows you to specify a label to be used from your listfile.\n";
-        helpString += "NOTE: Make SURE the repfasta, repnames and contaxonomy are for the same label as the listfile.\n";
-        helpString += "The create.database command should be in the following format: \n";
-               helpString += "create.database(repfasta=yourFastaFileFromGetOTURep, repname=yourNameFileFromGetOTURep, contaxonomy=yourConTaxFileFromClassifyOTU, list=yourListFile) \n";       
-               helpString += "Example: create.database(repfasta=final.an.0.03.rep.fasta, name=final.an.0.03.rep.names, list=fina.an.list, label=0.03, contaxonomy=final.an.0.03.cons.taxonomy) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. repfasta), '=' and parameters (i.e.yourFastaFileFromGetOTURep).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-CreateDatabaseCommand::CreateDatabaseCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["database"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "CreateDatabaseCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-CreateDatabaseCommand::CreateDatabaseCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-        
-               //allow user to run help
-               if (option == "help") { 
-                       help(); abort = true; calledHelp = true;
-               }else if(option == "citation") { citation(); abort = true; calledHelp = true;} 
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-            
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["database"] = tempOutNames;
-            
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("repname");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["repname"] = inputDir + it->second;          }
-                               }
-                               
-                               it = parameters.find("contaxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["contaxonomy"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("repfasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["repfasta"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-            
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found") {                          
-                               //if there is a current list file, use it
-                               listfile = m->getListFile(); 
-                               if (listfile != "") {  m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current listfile and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listfile == "not open") { abort = true; }      
-                       else { m->setListFile(listfile); }
-                       
-                       contaxonomyfile = validParameter.validFile(parameters, "contaxonomy", true);
-                       if (contaxonomyfile == "not found") {  //if there is a current list file, use it
-               contaxonomyfile = "";  m->mothurOut("The contaxonomy parameter is required, aborting."); m->mothurOutEndLine(); abort = true; 
-                       }
-                       else if (contaxonomyfile == "not open") { contaxonomyfile = ""; abort = true; }
-
-            repfastafile = validParameter.validFile(parameters, "repfasta", true);
-                       if (repfastafile == "not found") {  //if there is a current list file, use it
-                repfastafile = "";  m->mothurOut("The repfasta parameter is required, aborting."); m->mothurOutEndLine(); abort = true; 
-                       }
-                       else if (repfastafile == "not open") { repfastafile = ""; abort = true; }
-
-            repnamesfile = validParameter.validFile(parameters, "repname", true);
-                       if (repnamesfile == "not found") {  //if there is a current list file, use it
-                repnamesfile = "";  m->mothurOut("The repnames parameter is required, aborting."); m->mothurOutEndLine(); abort = true; 
-                       }
-                       else if (repnamesfile == "not open") { repnamesfile = ""; abort = true; }
-
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-            label = validParameter.validFile(parameters, "label", false);                      
-                       if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your listfile.\n");}
-        }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "CreateDatabaseCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int CreateDatabaseCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-        
-        //taxonomies holds the taxonomy info for each Otu
-        //classifyOtuSizes holds the size info of each Otu to help with error checking
-        vector<string> taxonomies;
-        vector<int> classifyOtuSizes = readTax(taxonomies);
-        
-        if (m->control_pressed) { return 0; }
-        
-        vector<Sequence> seqs;
-        vector<int> repOtusSizes = readFasta(seqs);
-        
-        if (m->control_pressed) { return 0; }
-        
-        //names redundants to uniques. backwards to how we normally do it, but each bin is the list file will be a key entry in the map.
-        map<string, string> repNames;
-        int numUniqueNamesFile = readNames(repNames);
-        
-        //are there the same number of otus in the fasta and name files
-        if (repOtusSizes.size() != numUniqueNamesFile) { m->mothurOut("[ERROR]: you have " + toString(numUniqueNamesFile) + " unique seqs in your repname file, but " + toString(repOtusSizes.size()) + " seqs in your repfasta file.  These should match.\n"); m->control_pressed = true; }
-        
-        if (m->control_pressed) { return 0; }
-        
-        //are there the same number of OTUs in the tax and fasta file
-        if (classifyOtuSizes.size() != repOtusSizes.size()) { m->mothurOut("[ERROR]: you have " + toString(classifyOtuSizes.size()) + " taxonomies in your contaxonomy file, but " + toString(repOtusSizes.size()) + " seqs in your repfasta file.  These should match.\n"); m->control_pressed = true; }
-
-        if (m->control_pressed) { return 0; }
-        
-        //at this point we have the same number of OTUs. Are the sizes we have found so far accurate?
-        for (int i = 0; i < classifyOtuSizes.size(); i++) {
-            if (classifyOtuSizes[i] != repOtusSizes[i]) {
-               m->mothurOut("[ERROR]: OTU size info does not match for bin " + toString(i+1) + ". The contaxonomy file indicated the OTU represented " + toString(classifyOtuSizes[i]) + " sequences, but the repfasta file had " + toString(repOtusSizes[i]) + ".  These should match. Make sure you are using files for the same distance.\n"); m->control_pressed = true; 
-            }
-        }
-        
-        if (m->control_pressed) { return 0; }
-        
-        //at this point we are fairly sure the repfasta, repnames and contaxonomy files match so lets proceed with the listfile
-        ListVector* list = getList();
-        
-        if (m->control_pressed) { delete list; return 0; }
-        
-        GroupMap* groupmap = NULL;
-        if (groupfile != "") {
-                       groupmap = new GroupMap(groupfile);
-                       groupmap->readMap();
-               }
-        
-        if (m->control_pressed) { delete list; if (groupfile != "") { delete groupmap; } return 0; }
-        
-        if (outputDir == "") { outputDir += m->hasPath(listfile); }
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + "database";
-        outputNames.push_back(outputFileName); outputTypes["database"].push_back(outputFileName);
-        
-        ofstream out;
-        m->openOutputFile(outputFileName, out);
-        
-        string header = "OTUNumber\tAbundance\t";
-        if (groupfile != "") { 
-            header = "OTUNumber\t";
-            for (int i = 0; i < groupmap->getNamesOfGroups().size(); i++) { header += (groupmap->getNamesOfGroups())[i] + '\t'; }
-        }
-        header += "repSeqName\trepSeq\tOTUConTaxonomy";
-        out << header << endl;
-        
-        for (int i = 0; i < list->getNumBins(); i++) {
-            
-            if (m->control_pressed) { break; }
-            
-            out << (i+1) << '\t';
-            
-            vector<string> binNames;
-            string bin = list->get(i);
-            
-            map<string, string>::iterator it = repNames.find(bin);
-            if (it == repNames.end()) {
-                m->mothurOut("[ERROR: OTU " + toString(i+1) + " is not in the repnames file. Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
-            }
-            
-            m->splitAtComma(bin, binNames);
-            
-            //sanity check
-            if (binNames.size() != classifyOtuSizes[i]) {
-                 m->mothurOut("[ERROR: OTU " + toString(i+1) + " contains " + toString(binNames.size()) + " sequence, but the rep and taxonomy files indicated this OTU should have " + toString(classifyOtuSizes[i]) + ". Make sure you are using files for the same distance.\n"); m->control_pressed = true;   break;
-            }
-            
-            //output abundances
-            if (groupfile != "") {
-                string groupAbunds = "";
-                map<string, int> counts;
-                //initialize counts to 0
-                for (int j = 0; j < groupmap->getNamesOfGroups().size(); j++) { counts[(groupmap->getNamesOfGroups())[j]] = 0; }
-                
-                //find abundances by group
-                bool error = false;
-                for (int j = 0; j < binNames.size(); j++) {
-                    string group = groupmap->getGroup(binNames[j]);
-                    if (group == "not found") {
-                        m->mothurOut("[ERROR]: " + binNames[j] + " is not in your groupfile, please correct.\n");
-                        error = true;
-                    }else { counts[group]++; }
-                }
-                
-                //output counts
-                for (int j = 0; j < groupmap->getNamesOfGroups().size(); j++) { out << counts[(groupmap->getNamesOfGroups())[j]] << '\t';  }
-                
-                if (error) { m->control_pressed = true; }
-            }else { out << binNames.size() << '\t'; }
-            
-            //output repSeq
-            out << it->second << '\t' << seqs[i].getAligned() << '\t' << taxonomies[i] << endl;
-        }
-        out.close();
-        
-        delete list;
-        if (groupfile != "") { delete groupmap; }
-        
-        if (m->control_pressed) { m->mothurRemove(outputFileName); return 0; }
-        
-        m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               m->mothurOutEndLine();
-        
-        return 0;
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<int> CreateDatabaseCommand::readTax(vector<string>& taxonomies){
-       try {
-               
-        vector<int> sizes; 
-        
-        ifstream in;
-        m->openInputFile(contaxonomyfile, in);
-        
-        //read headers
-        m->getline(in);
-        
-        while (!in.eof()) {
-            
-            if (m->control_pressed) { break; }
-            
-            string otu = ""; string tax = "unknown";
-            int size = 0;
-            
-            in >> otu >> size >> tax; m->gobble(in);
-            
-            sizes.push_back(size);
-            taxonomies.push_back(tax);
-        }
-        in.close();
-        
-        return sizes;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<int> CreateDatabaseCommand::readFasta(vector<Sequence>& seqs){
-       try {
-               
-        vector<int> sizes; 
-        
-        ifstream in;
-        m->openInputFile(repfastafile, in);
-        
-        while (!in.eof()) {
-            
-            if (m->control_pressed) { break; }
-            
-            string binInfo;
-            Sequence seq(in, binInfo, true);  m->gobble(in);
-            
-            //the binInfo should look like - binNumber|size ie. 1|200 if it is binNumber|size|group then the user gave us the wrong repfasta file
-            vector<string> info;
-            m->splitAtChar(binInfo, info, '|');
-            if (info.size() != 2) { m->mothurOut("[ERROR]: your repfasta file is not the right format.  The create database command is designed to be used with the output from get.oturep.  When running get.oturep you can not use a group file, because mothur is only expecting one representative sequence per OTU and when you use a group file with get.oturep a representative is found for each group.\n");  m->control_pressed = true; break;}
-            
-            int size = 0;
-            m->mothurConvert(info[1], size);
-            
-            sizes.push_back(size);
-            seqs.push_back(seq);
-        }
-        in.close();
-        
-        return sizes;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "readFasta");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int CreateDatabaseCommand::readNames(map<string, string>& nameMap) { 
-       try {
-               
-               //open input file
-               ifstream in;
-               m->openInputFile(repnamesfile, in);
-               
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       
-                       nameMap[secondCol] = firstCol;
-               }
-               in.close();
-               
-               return nameMap.size();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "readNames");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ListVector* CreateDatabaseCommand::getList(){
-       try {
-               InputData* input = new InputData(listfile, "list");
-               ListVector* list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               if (label == "") { label = lastLabel; delete input; return list; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((list != NULL) && (userLabels.size() != 0)) {
-                       if (m->control_pressed) {  delete input; return list;  }
-                       
-                       if(labels.count(list->getLabel()) == 1){
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               break;
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list;
-                               list = input->getListVector(lastLabel);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                               break;
-                       }
-                       
-                       lastLabel = list->getLabel();                   
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       delete list; 
-                       list = input->getListVector();
-               }
-               
-               
-               if (m->control_pressed) { delete input; return list;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       delete list;
-                       list = input->getListVector(lastLabel);
-               }       
-               
-               delete input;
-
-        return list;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "CreateDatabaseCommand", "getList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/createdatabasecommand.h b/createdatabasecommand.h
deleted file mode 100644 (file)
index 643ff6e..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef Mothur_createdatabasecommand_h
-#define Mothur_createdatabasecommand_h
-
-//
-//  createdatabasecommand.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 3/28/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "command.hpp"
-#include "listvector.hpp"
-#include "sequence.hpp"
-
-class CreateDatabaseCommand : public Command {
-public:
-       CreateDatabaseCommand(string);
-       CreateDatabaseCommand();
-       ~CreateDatabaseCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "create.database";             }
-       string getCommandCategory()             { return "OTU-Based Approaches"; }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Create.database"; }
-       string getDescription()         { return "creates database file that includes, abundances across groups, representative sequences, and taxonomy for each OTU"; }
-    
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       bool abort;
-       string listfile, groupfile, repfastafile, repnamesfile, contaxonomyfile, label, outputDir;
-       
-       vector<string> outputNames;
-               
-       vector<int> readFasta(vector<Sequence>&);
-    vector<int> readTax(vector<string>&);
-    int readNames(map<string, string>&); 
-       ListVector* getList();
-       
-};
-
-
-
-
-#endif
diff --git a/currentfile.h b/currentfile.h
deleted file mode 100644 (file)
index 8f2ea48..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef CURRENTFILE_H
-#define CURRENTFILE_H
-
-/*
- *  currentfile.h
- *  Mothur
- *
- *  Created by westcott on 3/15/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-#include "mothur.h"
-
-/***********************************************/
-
-class CurrentFile {
-       
-       public:
-               static CurrentFile* getInstance() {
-                       if(instance == 0) {     instance = new CurrentFile();   }
-                       return instance;
-               }
-               
-               string getPhylipFile()          { return phylipfile;            }
-               string getColumnFile()          { return columnfile;            }
-               string getListFile()            { return listfile;                      }
-               string getRabundFile()          { return rabundfile;            }
-               string getSabundFile()          { return sabundfile;            }
-               string getNameFile()            { return namefile;                      }       
-               string getGroupFile()           { return groupfile;                     }       
-               string getOrderFile()           { return orderfile;                     }
-               string getOrderGroupFile()      { return ordergroupfile;        }
-               string getTreeFile()            { return treefile;                      }
-               string getSharedFile()          { return sharedfile;            }
-               string getRelAbundFile()        { return relabundfile;          }
-               string getDesignFile()          { return designfile;            }
-               string getFastaFile()           { return fastafile;                     }
-               string getSFFFile()                     { return sfffile;                       }
-               string getQualFile()            { return qualfile;                      }
-               string getOligosFile()          { return oligosfile;            }
-               
-               
-               void setListFile(string f)                      { listfile = m->getFullPathName(f);                             }
-               void setTreeFile(string f)                      { treefile = m->getFullPathName(f);                             }
-               void setGroupFile(string f)                     { groupfile = m->getFullPathName(f);                    }               
-               void setPhylipFile(string f)            { phylipfile = m->getFullPathName(f);                   }
-               void setColumnFile(string f)            { columnfile = m->getFullPathName(f);                   }
-               void setNameFile(string f)                      { namefile = m->getFullPathName(f);                             }       
-               void setRabundFile(string f)            { rabundfile = m->getFullPathName(f);                   }
-               void setSabundFile(string f)            { sabundfile = m->getFullPathName(f);                   }
-               void setSharedFile(string f)            { sharedfile = m->getFullPathName(f);                   }
-               void setRelAbundFile(string f)          { relabundfile = m->getFullPathName(f);                 }
-               void setOrderFile(string f)                     { orderfile = m->getFullPathName(f);                    }
-               void setOrderGroupFile(string f)        { ordergroupfile = m->getFullPathName(f);               }
-               void setDesignFile(string f)            { designfile = m->getFullPathName(f);                   }
-               void setFastaFile(string f)                     { fastafile = m->getFullPathName(f);                    }
-               void setSFFFile(string f)                       { sfffile = m->getFullPathName(f);                              }
-               void setQualFile(string f)                      { qualfile = m->getFullPathName(f);                             }
-               void setOligosFile(string f)            { oligosfile = m->getFullPathName(f);                   }
-       
-       private:
-               MothurOut* m;
-               string phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile;
-               string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile;
-               
-               static CurrentFile* instance;
-               CurrentFile( const CurrentFile& ); // Disable copy constructor
-               void operator=( const CurrentFile& ); // Disable assignment operator
-       
-               CurrentFile() { 
-                       phylipfile = "";
-                       columnfile = "";
-                       listfile = "";
-                       rabundfile = "";
-                       sabundfile = "";
-                       namefile = "";
-                       groupfile = "";
-                       designfile = "";
-                       orderfile = "";
-                       treefile = "";
-                       sharedfile = "";
-                       ordergroupfile = "";
-                       relabundfile = "";
-                       fastafile = "";
-                       qualfile = "";
-                       sfffile = "";
-                       oligosfile = "";
-               }
-               ~CurrentFile() { instance = 0; }
-};
-/***********************************************/
-
-#endif
-
diff --git a/database.cpp b/database.cpp
deleted file mode 100644 (file)
index f587f42..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  database.cpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sequence.hpp"
-#include "database.hpp"
-
-/**************************************************************************************************/
-
-Database::Database(){          
-       longest = 0;
-       numSeqs = 0;
-       m = MothurOut::getInstance();
-}
-/**************************************************************************************************/
-
-Database::~Database(){}
-
-/**************************************************************************************************/
-
-float Database::getSearchScore()       {       return searchScore;             }       //      we're assuming that the search is already done
-
-
-/**************************************************************************************************/
-
-int Database::getLongestBase() {       return longest+1;               }       
-
-/**************************************************************************************************/
diff --git a/database.hpp b/database.hpp
deleted file mode 100644 (file)
index 49f3903..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef DATABASE_HPP
-#define DATABASE_HPP
-
-/*
- *  database.hpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-/* This class is a parent to blastdb, kmerdb, suffixdb.  */
-
-#include "mothur.h"
-#include "sequence.hpp"
-
-/**************************************************************************************************/
-struct seqMatch {  //used to select top n matches
-               int seq;
-               int match;
-               seqMatch() {}
-               seqMatch(int s, int m) : seq(s), match(m) {}
-};
-/**************************************************************************************************/
-inline bool compareSeqMatches (seqMatch member, seqMatch member2){ //sorts largest to smallest
-       if(member.match > member2.match){
-               return true;   }   
-       else{
-               return false; 
-       }
-}
-/**************************************************************************************************/
-inline bool compareSeqMatchesReverse (seqMatch member, seqMatch member2){ //sorts largest to smallest
-       if(member.match < member2.match){
-               return true;   }   
-       else{
-               return false; 
-       }
-}
-
-/**************************************************************************************************/
-class Database {
-
-public:
-       Database();
-       virtual ~Database();
-       virtual void generateDB() = 0; 
-       virtual void addSequence(Sequence) = 0;  //add sequence to search engine
-       virtual string getName(int) { return ""; }  
-       virtual vector<int> findClosestSequences(Sequence*, int) = 0;  // returns indexes of n closest sequences to query
-       virtual vector<int> findClosestMegaBlast(Sequence*, int, int){return results;}
-       virtual float getSearchScore();
-       virtual vector<float> getSearchScores() { return Scores; } //assumes you already called findClosestMegaBlast
-       virtual int getLongestBase(); 
-       virtual void readKmerDB(ifstream&){};
-       virtual void setNumSeqs(int i) {        numSeqs = i;    }
-       virtual vector<int> getSequencesWithKmer(int){ vector<int> filler; return filler; };  
-       virtual int getReversed(int) { return 0; } 
-       virtual int getMaxKmer(){       return 1;       }
-       
-protected:
-       MothurOut* m;
-       int numSeqs, longest;
-       float searchScore;
-       vector<int> results;
-       vector<float> Scores;
-};
-/**************************************************************************************************/
-#endif
diff --git a/datavector.hpp b/datavector.hpp
deleted file mode 100644 (file)
index e6c839d..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef datavector_h
-#define datavector_h
-
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/* This class is parent to listvector, ordervector, rabundvector, sabundvector, sharedordervector, sharedrabundvector, sharedsabundvector. 
-       The child classes all contain OTU information in different forms. */
-       
-
-class RAbundVector;
-class SAbundVector;
-class OrderVector;
-class SharedListVector;
-class SharedOrderVector;
-class SharedSAbundVector;
-class SharedRAbundVector;
-class SharedRAbundFloatVector;
-class GroupMap;
-
-class DataVector {
-       
-public:
-       DataVector(){ m = MothurOut::getInstance(); }// : maxRank(0), numBins(0), numSeqs(0){};
-       DataVector(string l) : label(l) {};
-       DataVector(const DataVector& dv) : label(dv.label){};//, maxRank(dv.maxRank), numBins(dv.numBins), numSeqs(dv.numSeqs) {};
-       DataVector(ifstream&);
-       DataVector(ifstream&, GroupMap*);
-       virtual ~DataVector(){};
-       
-//     virtual int getNumBins()        {       return numBins;         }
-//     virtual int getNumSeqs()        {       return numSeqs;         }
-//     virtual int getMaxRank()        {       return maxRank;         }
-       
-       virtual void resize(int) = 0;
-       virtual int size()      = 0;
-       virtual void print(ostream&) = 0;
-       virtual void printHeaders(ostream&) {};
-       virtual void clear() = 0;
-       
-       void setLabel(string l)         {       label = l;                      }
-       string getLabel()                       {       return label;           }
-
-       virtual RAbundVector getRAbundVector() = 0;
-       virtual SAbundVector getSAbundVector() = 0;
-       virtual OrderVector getOrderVector(map<string,int>* hold = NULL) = 0;
-       
-protected:
-       string label;
-       MothurOut* m;
-//     int maxRank;
-//     int numBins;
-//     int numSeqs;    
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/daxpy.f b/daxpy.f
deleted file mode 100644 (file)
index ddc7449..0000000
--- a/daxpy.f
+++ /dev/null
@@ -1,69 +0,0 @@
-      SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY)
-*     .. Scalar Arguments ..
-      DOUBLE PRECISION DA
-      INTEGER INCX,INCY,N
-*     ..
-*     .. Array Arguments ..
-      DOUBLE PRECISION DX(*),DY(*)
-*     ..
-*
-*  Purpose
-*  =======
-*
-*     DAXPY constant times a vector plus a vector.
-*     uses unrolled loops for increments equal to one.
-*
-*  Further Details
-*  ===============
-*
-*     jack dongarra, linpack, 3/11/78.
-*     modified 12/3/93, array(1) declarations changed to array(*)
-*
-*  =====================================================================
-*
-*     .. Local Scalars ..
-      INTEGER I,IX,IY,M,MP1
-*     ..
-*     .. Intrinsic Functions ..
-      INTRINSIC MOD
-*     ..
-      IF (N.LE.0) RETURN
-      IF (DA.EQ.0.0d0) RETURN
-      IF (INCX.EQ.1 .AND. INCY.EQ.1) THEN
-*
-*        code for both increments equal to 1
-*
-*
-*        clean-up loop
-*
-         M = MOD(N,4)
-         IF (M.NE.0) THEN
-            DO I = 1,M
-               DY(I) = DY(I) + DA*DX(I)
-            END DO
-         END IF
-         IF (N.LT.4) RETURN
-         MP1 = M + 1
-         DO I = MP1,N,4
-            DY(I) = DY(I) + DA*DX(I)
-            DY(I+1) = DY(I+1) + DA*DX(I+1)
-            DY(I+2) = DY(I+2) + DA*DX(I+2)
-            DY(I+3) = DY(I+3) + DA*DX(I+3)
-         END DO
-      ELSE
-*
-*        code for unequal increments or equal increments
-*          not equal to 1
-*
-         IX = 1
-         IY = 1
-         IF (INCX.LT.0) IX = (-N+1)*INCX + 1
-         IF (INCY.LT.0) IY = (-N+1)*INCY + 1
-         DO I = 1,N
-          DY(IY) = DY(IY) + DA*DX(IX)
-          IX = IX + INCX
-          IY = IY + INCY
-         END DO
-      END IF
-      RETURN
-      END
diff --git a/dayhoff.h b/dayhoff.h
deleted file mode 100644 (file)
index 44be916..0000000
--- a/dayhoff.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * dayhoff.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_NJ_DAYHOFF_H_
-#define _INC_NJ_DAYHOFF_H_ 1
-
-/*
- * As sequence divergence increases, we need to correct for multiple hits
- * when using Kimura distance correction method for amino acid sequences.
- *
- * This matrix of values represents the estimated "Accepted Point Mutations"
- * or PAMs for a range of amino acid sequence divergence, starting at 75% 
- * up through 93% (in 0.1% increments).
- *
- * This model is derived from Dayhoff (1978).
- *
- * This Dayhoff matrix and the shortcut methods for dealing with Kimura
- * correction at high sequence divergence (> 75%) are derived from similar 
- * work in Clustal W:
- *
- *     Thompson, J.D., Higgins, D.G., Gibson, T.J., "CLUSTAL W:
- *     improving the sensitivity of progressive multiple sequence
- *     alignment through sequence weighting, position-specific gap
- *     penalties and weight matrix choice.", 
- *     Nucleic Acids Research, 22:4673-4680, 1994
- *
- */
-
-
-int NJ_dayhoff[]={
-  195,    196,    197,    198,    199,    200,    200,    201,    202,  203,
-  204,    205,    206,    207,    208,    209,    209,    210,    211,  212,
-  213,    214,    215,    216,    217,    218,    219,    220,    221,  222,
-  223,    224,    226,    227,    228,    229,    230,    231,    232,  233,
-  234,    236,    237,    238,    239,    240,    241,    243,    244,  245,
-  246,    248,    249,    250,    252,    253,    254,    255,    257,  258,
-  260,    261,    262,    264,    265,    267,    268,    270,    271,  273,
-  274,    276,    277,    279,    281,    282,    284,    285,    287,  289,
-  291,    292,    294,    296,    298,    299,    301,    303,    305,  307,
-  309,    311,    313,    315,    317,    319,    321,    323,    325,  328,
-  330,    332,    335,    337,    339,    342,    344,    347,    349,  352,
-  354,    357,    360,    362,    365,    368,    371,    374,    377,  380,
-  383,    386,    389,    393,    396,    399,    403,    407,    410,  414,
-  418,    422,    426,    430,    434,    438,    442,    447,    451,  456,
-  461,    466,    471,    476,    482,    487,    493,    498,    504,  511,
-  517,    524,    531,    538,    545,    553,    560,    569,    577,  586,
-  595,    605,    615,    626,    637,    649,    661,    675,    688,  703,
-  719,    736,    754,    775,    796,    819,    845,    874,    907,  945,
-  988 
-};
-
-
-
-#endif /* _INC_NJ_DAYHOFF_H_ */
-
-
-
diff --git a/ddot.f b/ddot.f
deleted file mode 100644 (file)
index 373134f..0000000
--- a/ddot.f
+++ /dev/null
@@ -1,90 +0,0 @@
-*DECK DDOT
-      DOUBLE PRECISION FUNCTION DDOT (N, DX, INCX, DY, INCY)
-C***BEGIN PROLOGUE  DDOT
-C***PURPOSE  Compute the inner product of two vectors.
-C***LIBRARY   SLATEC (BLAS)
-C***CATEGORY  D1A4
-C***TYPE      DOUBLE PRECISION (SDOT-S, DDOT-D, CDOTU-C)
-C***KEYWORDS  BLAS, INNER PRODUCT, LINEAR ALGEBRA, VECTOR
-C***AUTHOR  Lawson, C. L., (JPL)
-C           Hanson, R. J., (SNLA)
-C           Kincaid, D. R., (U. of Texas)
-C           Krogh, F. T., (JPL)
-C***DESCRIPTION
-C
-C                B L A S  Subprogram
-C    Description of Parameters
-C
-C     --Input--
-C        N  number of elements in input vector(s)
-C       DX  double precision vector with N elements
-C     INCX  storage spacing between elements of DX
-C       DY  double precision vector with N elements
-C     INCY  storage spacing between elements of DY
-C
-C     --Output--
-C     DDOT  double precision dot product (zero if N .LE. 0)
-C
-C     Returns the dot product of double precision DX and DY.
-C     DDOT = sum for I = 0 to N-1 of  DX(LX+I*INCX) * DY(LY+I*INCY),
-C     where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is
-C     defined in a similar way using INCY.
-C
-C***REFERENCES  C. L. Lawson, R. J. Hanson, D. R. Kincaid and F. T.
-C                 Krogh, Basic linear algebra subprograms for Fortran
-C                 usage, Algorithm No. 539, Transactions on Mathematical
-C                 Software 5, 3 (September 1979), pp. 308-323.
-C***ROUTINES CALLED  (NONE)
-C***REVISION HISTORY  (YYMMDD)
-C   791001  DATE WRITTEN
-C   890831  Modified array declarations.  (WRB)
-C   890831  REVISION DATE from Version 3.2
-C   891214  Prologue converted to Version 4.0 format.  (BAB)
-C   920310  Corrected definition of LX in DESCRIPTION.  (WRB)
-C   920501  Reformatted the REFERENCES section.  (WRB)
-C***END PROLOGUE  DDOT
-      DOUBLE PRECISION DX(*), DY(*)
-C***FIRST EXECUTABLE STATEMENT  DDOT
-      DDOT = 0.0D0
-      DTEMP = 0.0D0
-      IF (N .LE. 0) RETURN
-      IF (INCX .EQ. INCY) IF (INCX-1) 5,20,60
-C
-C     Code for unequal or nonpositive increments.
-C
-    5 IX = 1
-      IY = 1
-      IF (INCX .LT. 0) IX = (-N+1)*INCX + 1
-      IF (INCY .LT. 0) IY = (-N+1)*INCY + 1
-      DO 10 I = 1,N
-        DDOT = DDOT + DX(IX)*DY(IY)
-        IX = IX + INCX
-        IY = IY + INCY
-   10 CONTINUE
-      RETURN
-C
-C     Code for both increments equal to 1.
-C
-C     Clean-up loop so remaining vector length is a multiple of 5.
-C
-   20 M = MOD(N,5)
-      IF (M .EQ. 0) GO TO 40
-      DO 30 I = 1,M
-         DDOT = DDOT + DX(I)*DY(I)
-   30 CONTINUE
-      IF (N .LT. 5) RETURN
-   40 MP1 = M + 1
-      DO  I = MP1,N,5
-      DDOT = DDOT + DX(I)*DY(I) + DX(I+1)*DY(I+1) + DX(I+2)*DY(I+2) +
-     1              DX(I+3)*DY(I+3) + DX(I+4)*DY(I+4)
-      END DO
-      RETURN
-C
-C     Code for equal, positive, non-unit increments.
-C
-   60 NS = N*INCX
-      DO 70 I = 1,NS,INCX
-        DDOT = DDOT + DX(I)*DY(I)
-   70 CONTINUE
-      RETURN
-      END
diff --git a/decalc.cpp b/decalc.cpp
deleted file mode 100644 (file)
index 98545f8..0000000
+++ /dev/null
@@ -1,1004 +0,0 @@
-/*
- *  decalc.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "decalc.h"
-#include "chimera.h"
-#include "dist.h"
-#include "eachgapdist.h"
-#include "ignoregaps.h"
-#include "eachgapdist.h"
-
-//***************************************************************************************************************
-void DeCalculator::setMask(string ms) { 
-       try {
-               seqMask = ms; 
-               int count = 0;
-               maskMap.clear();
-               
-               if (seqMask.length() != 0) {
-                       //whereever there is a base in the mask, save that value is query and subject
-                       for (int i = 0; i < seqMask.length(); i++) {
-                               if (isalpha(seqMask[i])) {
-                                       h.insert(i);
-                                       maskMap[count] = i;
-                                       count++;
-                                       
-                               }
-                       }
-               }else {
-                       for (int i = 0; i < alignLength; i++) {   
-                               h.insert(i); 
-                               maskMap[count] = i;
-                               count++;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "setMask");
-               exit(1);
-       } 
-}
-//***************************************************************************************************************
-void DeCalculator::runMask(Sequence* seq) {
-       try{
-               
-               string q = seq->getAligned();
-               string tempQuery = "";
-               
-               //whereever there is a base in the mask, save that value is query and subject
-               set<int>::iterator setit;
-               for ( setit=h.begin() ; setit != h.end(); setit++ )  {
-                       tempQuery += q[*setit];
-               }
-               
-               //save masked values
-               seq->setAligned(tempQuery);
-               seq->setUnaligned(tempQuery);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "runMask");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//num is query's spot in querySeqs
-void DeCalculator::trimSeqs(Sequence* query, Sequence* subject, map<int, int>& trim) {
-       try {
-               
-               string q = query->getAligned();
-               string s = subject->getAligned();
-               
-               int front = 0;
-               for (int i = 0; i < q.length(); i++) {
-//cout << "query = " << q[i] << " subject = " << s[i] << endl;
-                       if (isalpha(q[i]) && isalpha(s[i])) { front = i; break;  }
-               }
-//cout << endl << endl;                
-               int back = 0;           
-               for (int i = q.length(); i >= 0; i--) {
-//cout << "query = " << q[i] << " subject = " << s[i] << endl;
-                       if (isalpha(q[i]) && isalpha(s[i])) { back = i; break;  }
-               }
-               
-               trim[front] = back;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "trimSeqs");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<int>  DeCalculator::findWindows(Sequence* query, int front, int back, int& size, int increment) {
-       try {
-               
-               vector<int> win; 
-               
-               int cutoff = back - front;  //back - front 
-                       
-               //if window is set to default
-               if (size == 0) {  if (cutoff > 1200) {  size = 300; }
-                                                       else{  size = (cutoff / 4); }  } 
-               else if (size > (cutoff / 4)) { 
-                               m->mothurOut("You have selected too large a window size for sequence " + query->getName() + ".  I will choose an appropriate window size."); m->mothurOutEndLine();
-                               size = (cutoff / 4); 
-               }
-       
-       /*      string seq = query->getAligned().substr(front, cutoff);
-                       
-               //count bases
-               int numBases = 0;
-               for (int l = 0; l < seq.length(); l++) {  if (isalpha(seq[l])) { numBases++; }  }
-//cout << "num Bases = " << numBases << endl;                  
-               //save start of seq
-               win.push_back(front);
-//cout << front << '\t';               
-               //move ahead increment bases at a time until all bases are in a window
-               int countBases = 0;
-               int totalBases = 0;  //used to eliminate window of blanks at end of sequence
-                       
-               seq = query->getAligned();
-               for (int m = front; m < (back - size) ; m++) {
-                               
-                       //count number of bases you see
-                       if (isalpha(seq[m])) { countBases++;  }
-                               
-                       //if you have seen enough bases to make a new window
-                       if (countBases >= increment) {
-                               //total bases is the number of bases in a window already.
-                               totalBases += countBases;
-//cout << "total bases = " << totalBases << endl;
-                               win.push_back(m);  //save spot in alignment
-//cout << m << '\t';
-                               countBases = 0;                         //reset bases you've seen in this window
-                       }
-                               
-                       //no need to continue if all your bases are in a window
-                       if (totalBases == numBases) {   break;  }
-               }
-       
-
-               //get last window if needed
-               if (totalBases < numBases) {   win.push_back(back-size);  }
-//cout << endl << endl;
-*/     
-               
-               //this follows wigeon, but we may want to consider that it chops off the end values if the sequence cannot be evenly divided into steps
-               for (int i = front; i < (back - size) ; i+=increment) {  win.push_back(i);  }
-
-
-       
-               return win;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findWindows");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-vector<float> DeCalculator::calcObserved(Sequence* query, Sequence* subject, vector<int> window, int size) {
-       try {
-               
-               vector<float> temp;     
-               //int gaps = 0;         
-               for (int i = 0; i < window.size(); i++) {
-                                               
-                       string seqFrag = query->getAligned().substr(window[i], size);
-                       string seqFragsub = subject->getAligned().substr(window[i], size);
-                               
-                       int diff = 0;
-                       for (int b = 0; b < seqFrag.length(); b++) {
-                               //if at least one is a base and they are not equal
-                               if( (isalpha(seqFrag[b]) || isalpha(seqFragsub[b])) && (seqFrag[b] != seqFragsub[b]) ) { diff++; }
-                               
-                               //ignore gaps
-                               //if((!isalpha(seqFrag[b])) && (!isalpha(seqFragsub[b]))) { gaps++; }
-                       }
-               
-                       //percentage of mismatched bases
-                       float dist;
-                       
-                       //if the whole fragment is 0 distance = 0
-                       //if ((seqFrag.length()-gaps) == 0)  { dist =  0.0; }
-               
-                       //percentage of mismatched bases
-                       //else {  dist = diff / (float) (seqFrag.length()-gaps) * 100;   } 
-                       
-                       dist = diff / (float) (seqFrag.length()) * 100; 
-                       
-                       temp.push_back(dist);
-               }
-                       
-               return temp;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "calcObserved");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-float DeCalculator::calcDist(Sequence* query, Sequence* subject, int front, int back) {
-       try {
-               
-               //so you only look at the trimmed part of the sequence
-               int cutoff = back - front;  
-               int gaps = 0;
-                       
-               //from first startpoint with length back-front
-               string seqFrag = query->getAligned().substr(front, cutoff);
-               string seqFragsub = subject->getAligned().substr(front, cutoff);
-                                                                                                               
-               int diff = 0;
-               for (int b = 0; b < seqFrag.length(); b++) {
-                       //ignore gaps
-                       if((!isalpha(seqFrag[b])) && (!isalpha(seqFragsub[b]))) { gaps++; }
-                       if (seqFrag[b] != seqFragsub[b]) { diff++; }
-               }
-               
-               //if the whole fragment is 0 distance = 0
-               if ((seqFrag.length()-gaps) == 0)  { return 0.0; }
-               
-               //percentage of mismatched bases
-               float dist = diff / (float) (seqFrag.length()-gaps) * 100;       
-                               
-               return dist;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "calcDist");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-vector<float> DeCalculator::calcExpected(vector<float> qav, float coef) {
-       try {
-               
-               //for each window
-               vector<float> queryExpected;
-                       
-               for (int j = 0; j < qav.size(); j++) {          
-                               
-                       float expected = qav[j] * coef;
-                               
-                       queryExpected.push_back(expected);      
-               }
-                       
-               return queryExpected;
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "calcExpected");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-float DeCalculator::calcDE(vector<float> obs, vector<float> exp) {
-       try {
-               
-               //for each window
-               float sum = 0.0;  //sum = sum from 1 to i of (oi-ei)^2
-               int numZeros = 0;
-               for (int j = 0; j < obs.size(); j++) {          
-                       
-                       //if (obs[j] != 0.0) {
-                               sum += ((obs[j] - exp[j]) * (obs[j] - exp[j])); 
-                       //}else {  numZeros++;   }
-                       
-               }
-                       
-               float de = sqrt((sum / (obs.size() - 1 - numZeros)));
-                       
-               return de;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "calcDE");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-vector<float> DeCalculator::calcFreq(vector<Sequence*> seqs, string filename) {
-       try {
-
-               vector<float> prob;
-               string freqfile = m->getRootName(filename) + "freq";
-               ofstream outFreq;
-               
-               m->openOutputFile(freqfile, outFreq);
-               
-               outFreq << "#" << m->getVersion() << endl;
-               
-               string length = toString(seqs.size());  //if there are 5000 seqs in the template then set precision to 3
-               int precision = length.length() - 1;
-               
-               //format output
-               outFreq.setf(ios::fixed, ios::floatfield); outFreq.setf(ios::showpoint);
-               
-               //at each position in the sequence
-               for (int i = 0; i < seqs[0]->getAligned().length(); i++) {
-                       
-                       vector<int> freq;   freq.resize(4,0);
-                       int gaps = 0;
-                       
-                       //find the frequency of each nucleotide
-                       for (int j = 0; j < seqs.size(); j++) {
-                               
-                               char value = seqs[j]->getAligned()[i];
-                               
-                               if(toupper(value) == 'A')                                                                       {       freq[0]++;      }
-                               else if(toupper(value) == 'T' || toupper(value) == 'U')         {       freq[1]++;      }
-                               else if(toupper(value) == 'G')                                                          {       freq[2]++;      }
-                               else if(toupper(value) == 'C')                                                          {       freq[3]++;      }
-                               else { gaps++; }
-                       }
-                       
-                       //find base with highest frequency
-                       int highest = 0;
-                       for (int j = 0; j < freq.size(); j++) {   if (freq[j] > highest) {  highest = freq[j];  }               }
-                       
-                       float highFreq = highest / (float) (seqs.size());       
-                       
-                       float Pi;
-                       Pi =  (highFreq - 0.25) / 0.75; 
-                       
-                       //cannot have probability less than 0.
-                       if (Pi < 0) { Pi = 0.0; }
-                       
-                       //saves this for later
-                       outFreq << setprecision(precision) << i << '\t' << highFreq << endl;
-       
-                       if (h.count(i) > 0) {
-                               prob.push_back(Pi); 
-                       }
-               }
-               
-               outFreq.close();
-               
-               return prob;
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "calcFreq");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<float>  DeCalculator::findQav(vector<int> window, int size, vector<float> probabilityProfile) {
-       try {
-               vector<float>  averages; 
-                               
-               //for each window find average
-               for (int i = 0; i < window.size(); i++) {
-                               
-                       float average = 0.0;
-                               
-                       //while you are in the window for this sequence
-                       int count = 0;
-                       for (int j = window[i]; j < (window[i]+size); j++) {   
-                               average += probabilityProfile[j];
-                               count++;
-                       }
-                               
-                       average = average / count;
-       
-                       //save this windows average
-                       averages.push_back(average);
-               }
-                               
-               return averages;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findQav");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//seqs have already been masked
-vector< vector<float> > DeCalculator::getQuantiles(vector<Sequence*> seqs, vector<int> windowSizesTemplate, int window, vector<float> probProfile, int increment, int start, int end) {
-       try {
-               vector< vector<float> > quan; 
-               
-               //percentage of mismatched pairs 1 to 100
-               quan.resize(100);
-
-               //for each sequence
-               for(int i = start; i < end; i++){
-               
-                       m->mothurOut("Processing sequence " + toString(i)); m->mothurOutEndLine();
-                       Sequence* query = new Sequence(seqs[i]->getName(), seqs[i]->getAligned());
-                       
-                       //compare to every other sequence in template
-                       for(int j = 0; j < i; j++){
-                               
-                               Sequence* subject = new Sequence(seqs[j]->getName(), seqs[j]->getAligned());
-                               
-                               if (m->control_pressed) { delete query; delete subject; return quan; }
-                               
-                               map<int, int> trim;
-                               map<int, int>::iterator it;
-                               
-                               trimSeqs(query, subject, trim);
-                               
-                               it = trim.begin();
-                               int front = it->first; int back = it->second;
-                               
-                               //reset window for each new comparison
-                               windowSizesTemplate[i] = window;
-                               
-                               vector<int> win = findWindows(query, front, back, windowSizesTemplate[i], increment);
-                               
-                               vector<float> obsi = calcObserved(query, subject, win, windowSizesTemplate[i]);
-                               
-                               vector<float> q = findQav(win, windowSizesTemplate[i], probProfile);
-                                                                       
-                               float alpha = getCoef(obsi, q);
-                                               
-                               vector<float> exp = calcExpected(q, alpha);
-                               
-                               float de = calcDE(obsi, exp);
-                                                               
-                               float dist = calcDist(query, subject, front, back); 
-       //cout << i << '\t' <<  j << '\t' << dist << '\t' << de << endl;                        
-                               dist = ceil(dist);
-                               
-                               //quanMember newScore(de, i, j);
-                               
-                               quan[dist].push_back(de);
-
-                               delete subject;
-                       }
-                       
-                       delete query;
-               }
-       
-
-               return quan;
-                                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "getQuantiles");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareQuanMembers(quanMember left, quanMember right){
-       return (left.score < right.score);      
-} 
-//***************************************************************************************************************
-//this was going to be used by pintail to increase the sensitivity of the chimera detection, but it wasn't quite right.  may want to revisit in the future...
-void DeCalculator::removeObviousOutliers(vector< vector<float> >& quantiles, int num) {
-       try {
-                                               
-               for (int i = 0; i < quantiles.size(); i++) {
-                       
-                       //find mean of this quantile score
-                       sort(quantiles[i].begin(), quantiles[i].end());
-                       
-                       vector<float> temp;
-                       if (quantiles[i].size() != 0) {
-                               float high = quantiles[i][int(quantiles[i].size() * 0.99)];
-                               float low =  quantiles[i][int(quantiles[i].size() * 0.01)];
-                       
-                               //look at each value in quantiles to see if it is an outlier
-                               for (int j = 0; j < quantiles[i].size(); j++) {
-                                       //is this score between 1 and 99%
-                                       if ((quantiles[i][j] > low) && (quantiles[i][j] < high)) {
-                                               temp.push_back(quantiles[i][j]);
-                                       }
-                               }
-                       }
-                       quantiles[i] = temp;
-               }
-
-/*
-               //find contributer with most offending score related to it
-               int largestContrib = findLargestContrib(seen);
-       
-               //while you still have guys to eliminate
-               while (contributions.size() > 0) {
-               
-                       m->mothurOut("Removing scores contributed by sequence " + toString(largestContrib) + " in your template file."); m->mothurOutEndLine();
-                       
-                       //remove from quantiles all scores that were made using this largestContrib
-                       for (int i = 0; i < quantiles.size(); i++) {
-//cout << "before remove " << quantiles[i].size() << '\t';
-                               removeContrib(largestContrib, quantiles[i]);
-//cout << "after remove " << quantiles[i].size() << endl;
-                       }
-//cout << count << " largest contrib = " << largestContrib << endl;  count++;
-                       //remove from contributions all scores that were made using this largestContrib
-                       removeContrib(largestContrib, contributions);
-                       
-                       //"erase" largestContrib
-                       seen[largestContrib] = -1;
-                       
-                       //get next largestContrib
-                       largestContrib = findLargestContrib(seen);
-               }
-ABOVE IS ATTEMPT #1            
-**************************************************************************************************
-BELOW IS ATTEMPT #2            
-               vector<int> marked = returnObviousOutliers(quantiles, num);
-               vector<int> copyMarked = marked;
-               
-               //find the 99% of marked
-               sort(copyMarked.begin(), copyMarked.end());
-               int high = copyMarked[int(copyMarked.size() * 0.99)];
-cout << "high = " << high << endl;             
-               
-               for(int i = 0; i < marked.size(); i++) {
-                       if (marked[i] > high) { 
-                               m->mothurOut("Removing scores contributed by sequence " + toString(marked[i]) + " in your template file."); m->mothurOutEndLine();
-                               for (int i = 0; i < quantiles.size(); i++) {
-                                       removeContrib(marked[i], quantiles[i]);
-                               }
-                       }
-
-               }
-               
-               
-               //adjust quantiles
-               for (int i = 0; i < quantiles.size(); i++) {
-                       vector<float> temp;
-                       
-                       if (quantiles[i].size() == 0) {
-                               //in case this is not a distance found in your template files
-                               for (int g = 0; g < 6; g++) {
-                                       temp.push_back(0.0);
-                               }
-                       }else{
-                               
-                               sort(quantiles[i].begin(), quantiles[i].end(), compareQuanMembers);
-                               
-                               //save 10%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.10)].score);
-                               //save 25%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.25)].score);
-                               //save 50%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.5)].score);
-                               //save 75%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.75)].score);
-                               //save 95%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.95)].score);
-                               //save 99%
-                               temp.push_back(quantiles[i][int(quantiles[i].size() * 0.99)].score);
-                               
-                       }
-                       
-                       quan[i] = temp;
-                       
-               }
-*/
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "removeObviousOutliers");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//put quanMember in the vector based on how far they are from the 99% or 1%.  Biggest offenders in front.
-/*vector<quanMember> DeCalculator::sortContrib(map<quanMember*, float> quan) {
-       try{
-               
-               vector<quanMember> newQuan;
-               map<quanMember*, float>::iterator it;
-               
-               while (quan.size() > 0) {
-                       
-                        map<quanMember*, float>::iterator largest = quan.begin(); 
-                         
-                       //find biggest member
-                       for (it = quan.begin(); it != quan.end(); it++) {
-                               if (it->second > largest->second) {  largest = it;  }
-                       }
-cout << largest->second << '\t' << largest->first->score << '\t' << largest->first->member1 << '\t' << largest->first->member2 << endl;
-                       //save it 
-                       newQuan.push_back(*(largest->first));
-               
-                       //erase from quan
-                       quan.erase(largest);
-               }
-               
-               return newQuan;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "sortContrib");
-               exit(1);
-       }
-}
-
-***************************************************************************************************************
-//used by removeObviousOutliers which was attempt to increase sensitivity of chimera detection...not currently used...
-int DeCalculator::findLargestContrib(vector<int> seen) {
-       try{
-               
-               int largest = 0;
-               
-               int largestContribs;
-               
-               for (int i = 0; i < seen.size(); i++)  {  
-                       
-                       if (seen[i] > largest) {
-                               largestContribs = i;
-                               largest = seen[i];
-                       }
-               }
-               
-               return largestContribs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findLargestContribs");
-               exit(1);
-       }
-}
-***************************************************************************************************************
-void DeCalculator::removeContrib(int bad, vector<quanMember>& quan) {
-       try{
-       
-               vector<quanMember> newQuan;
-               for (int i = 0; i < quan.size(); i++)  {  
-                       if ((quan[i].member1 != bad) && (quan[i].member2 != bad) ) {  
-                               newQuan.push_back(quan[i]);  
-                       }
-               }
-               
-               quan = newQuan;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "removeContrib");
-               exit(1);
-       }
-}
-*/
-//***************************************************************************************************************
-float DeCalculator::findAverage(vector<float> myVector) {
-       try{
-               
-               float total = 0.0;
-               for (int i = 0; i < myVector.size(); i++)  {  total += myVector[i];  }
-               
-               float average = total / (float) myVector.size();
-               
-               return average;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findAverage");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-float DeCalculator::getCoef(vector<float> obs, vector<float> qav) {
-       try {
-       
-               //find average prob for this seqs windows
-               float probAverage = findAverage(qav);
-                               
-               //find observed average 
-               float obsAverage = findAverage(obs);
-                       
-               float coef = obsAverage / probAverage;
-                                               
-               return coef;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "getCoef");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-//gets closest matches to each end, since chimeras will most likely have different parents on each end
-vector<Sequence> DeCalculator::findClosest(Sequence querySeq, vector<Sequence*>& thisTemplate, vector<Sequence*>& thisFilteredTemplate, int numWanted, int minSim) {
-       try {
-               //indexes.clear();
-               
-               vector<Sequence> seqsMatches;  
-               
-               vector<SeqDist> distsLeft;
-               vector<SeqDist> distsRight;
-               
-               Dist* distcalculator = new eachGapDist();
-               
-               string queryUnAligned = querySeq.getUnaligned();
-               int numBases = int(queryUnAligned.length() * 0.33);
-               
-               string leftQuery = ""; //first 1/3 of the sequence
-               string rightQuery = ""; //last 1/3 of the sequence
-               string queryAligned = querySeq.getAligned();
-               
-               //left side
-               bool foundFirstBase = false;
-               int baseCount = 0;
-               int leftSpot = 0;
-               int firstBaseSpot = 0;
-               for (int i = 0; i < queryAligned.length(); i++) {
-                       //if you are a base
-                       if (isalpha(queryAligned[i])) {         
-                               baseCount++; 
-                               if (!foundFirstBase) {   foundFirstBase = true;  firstBaseSpot = i;  }
-                       }
-                       
-                       //eliminate opening .'s
-                       if (foundFirstBase) {   leftQuery += queryAligned[i];  }
-                       //if you have 1/3
-                       if (baseCount >= numBases) {  leftSpot = i; break; } //first 1/3
-               }
-               
-               //right side - count through another 1/3, so you are at last third
-               baseCount = 0;
-               int rightSpot = 0;
-               for (int i = leftSpot; i < queryAligned.length(); i++) {
-                       //if you are a base
-                       if (isalpha(queryAligned[i])) {         baseCount++;    }
-                       //if you have 1/3
-                       if (baseCount > numBases + 1) { rightSpot = i;  break; } //last 1/3
-               }
-               
-               //trim end
-               //find last position in query that is a non gap character
-               int lastBaseSpot = queryAligned.length()-1;
-               for (int j = queryAligned.length()-1; j >= 0; j--) {
-                       if (isalpha(queryAligned[j])) {
-                               lastBaseSpot = j;
-                               break;
-                       }
-               }
-               rightQuery = queryAligned.substr(rightSpot, (lastBaseSpot-rightSpot+1)); //sequence from pos spot to end
-               
-               Sequence queryLeft(querySeq.getName(), leftQuery);
-               Sequence queryRight(querySeq.getName(), rightQuery);
-               
-//cout << querySeq->getName() << '\t' << leftSpot << '\t' << rightSpot << '\t' << firstBaseSpot << '\t' << lastBaseSpot << endl;
-//cout << queryUnAligned.length() << '\t' << queryLeft.getUnaligned().length() << '\t' << queryRight.getUnaligned().length() << endl;
-               for(int j = 0; j < thisFilteredTemplate.size(); j++){
-                       
-                       string dbAligned = thisFilteredTemplate[j]->getAligned();
-                       string leftDB = dbAligned.substr(firstBaseSpot, (leftSpot-firstBaseSpot+1)); //first 1/3 of the sequence
-                       string rightDB = dbAligned.substr(rightSpot, (lastBaseSpot-rightSpot+1)); //last 1/3 of the sequence
-
-                       Sequence dbLeft(thisFilteredTemplate[j]->getName(), leftDB);
-                       Sequence dbRight(thisFilteredTemplate[j]->getName(), rightDB);
-
-                       distcalculator->calcDist(queryLeft, dbLeft);
-                       float distLeft = distcalculator->getDist();
-                       
-                       distcalculator->calcDist(queryRight, dbRight);
-                       float distRight = distcalculator->getDist();
-
-                       SeqDist subjectLeft;
-                       subjectLeft.seq = NULL;
-                       subjectLeft.dist = distLeft;
-                       subjectLeft.index = j;
-                       
-                       distsLeft.push_back(subjectLeft);
-                       
-                       SeqDist subjectRight;
-                       subjectRight.seq = NULL;
-                       subjectRight.dist = distRight;
-                       subjectRight.index = j;
-                       
-                       distsRight.push_back(subjectRight);
-
-               }
-               
-               delete distcalculator;
-               
-               //sort by smallest distance
-               sort(distsRight.begin(), distsRight.end(), compareSeqDist);
-               sort(distsLeft.begin(), distsLeft.end(), compareSeqDist);
-
-               
-               //merge results         
-               map<string, string> seen;
-               map<string, string>::iterator it;
-               
-               vector<SeqDist> dists;
-               float lastRight = distsRight[0].dist;
-               float lastLeft = distsLeft[0].dist;
-
-               float maxDist = 1.0 - (minSim / 100.0);
-
-               for (int i = 0; i < numWanted+1; i++) {
-                       if (m->control_pressed) { return seqsMatches; }
-                       
-                       //add left if you havent already
-                       it = seen.find(thisTemplate[distsLeft[i].index]->getName());
-                       if (it == seen.end() && distsLeft[i].dist <= maxDist) {  
-                               dists.push_back(distsLeft[i]);
-                               seen[thisTemplate[distsLeft[i].index]->getName()] = thisTemplate[distsLeft[i].index]->getName();
-                               lastLeft =  distsLeft[i].dist;
-//                             cout << "loop-left\t" << db[distsLeft[i].index]->getName() << '\t' << distsLeft[i].dist << endl;
-                       }
-
-                       //add right if you havent already
-                       it = seen.find(thisTemplate[distsRight[i].index]->getName());
-                       if (it == seen.end() && distsRight[i].dist <= maxDist) {  
-                               dists.push_back(distsRight[i]);
-                               seen[thisTemplate[distsRight[i].index]->getName()] = thisTemplate[distsRight[i].index]->getName();
-                               lastRight =  distsRight[i].dist;
-//                             cout << "loop-right\t" << db[distsRight[i].index]->getName() << '\t' << distsRight[i].dist << endl;
-                       }
-                       
-                       if (i == numWanted) { break; }
-                       
-               }
-               
-               //are we still above the minimum similarity cutoff
-               if ((lastLeft >= minSim) || (lastRight >= minSim)) {
-                       //add in ties from left
-                       int i = numWanted;
-                       while (i < distsLeft.size()) {  
-                               if (distsLeft[i].dist == lastLeft) {  dists.push_back(distsLeft[i]);  }
-                               else { break; }
-                               i++;
-                       }
-                       
-                       //add in ties from right
-                       i = numWanted;
-                       while (i < distsRight.size()) {  
-                               if (distsRight[i].dist == lastRight) {  dists.push_back(distsRight[i]);  }
-                               else { break; }
-                               i++;
-                       }
-               }
-               
-               //cout << numWanted << endl;
-               for (int i = 0; i < dists.size(); i++) {
-//                     cout << db[dists[i].index]->getName() << '\t' << dists[i].dist << endl;
-
-                       if ((thisTemplate[dists[i].index]->getName() != querySeq.getName()) && (((1.0-dists[i].dist)*100) >= minSim)) {
-                               Sequence temp(thisTemplate[dists[i].index]->getName(), thisTemplate[dists[i].index]->getAligned()); //have to make a copy so you can trim and filter without stepping on eachother.
-                               //cout << querySeq->getName() << '\t' << thisTemplate[dists[i].index]->getName()  << '\t' << dists[i].dist << endl;
-                               seqsMatches.push_back(temp);
-                       }
-
-               }
-               
-               return seqsMatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findClosest");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Sequence* DeCalculator::findClosest(Sequence* querySeq, vector<Sequence*> db) {
-       try {
-               
-               Sequence* seqsMatch;  
-               
-               Dist* distcalculator = new eachGapDist();
-               int index = 0;
-               int smallest = 1000000;
-               
-               for(int j = 0; j < db.size(); j++){
-                       
-                       distcalculator->calcDist(*querySeq, *db[j]);
-                       float dist = distcalculator->getDist();
-                       
-                       if (dist < smallest) { 
-                               smallest = dist;
-                               index = j;
-                       }
-               }
-               
-               delete distcalculator;
-               
-               seqsMatch = new Sequence(db[index]->getName(), db[index]->getAligned()); //have to make a copy so you can trim and filter without stepping on eachother.
-                       
-               return seqsMatch;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "findClosest");
-               exit(1);
-       }
-}
-/***************************************************************************************************************/
-map<int, int> DeCalculator::trimSeqs(Sequence& query, vector<Sequence>& topMatches) {
-       try {
-               
-               int frontPos = 0;  //should contain first position in all seqs that is not a gap character
-               int rearPos = query.getAligned().length();
-               
-               //********find first position in topMatches that is a non gap character***********//
-               //find first position all query seqs that is a non gap character
-               for (int i = 0; i < topMatches.size(); i++) {
-                       
-                       string aligned = topMatches[i].getAligned();
-                       int pos = 0;
-                       
-                       //find first spot in this seq
-                       for (int j = 0; j < aligned.length(); j++) {
-                               if (isalpha(aligned[j])) {
-                                       pos = j;
-                                       break;
-                               }
-                       }
-                       
-                       //save this spot if it is the farthest
-                       if (pos > frontPos) { frontPos = pos; }
-               }
-               
-               
-               string aligned = query.getAligned();
-               int pos = 0;
-                       
-               //find first position in query that is a non gap character
-               for (int j = 0; j < aligned.length(); j++) {
-                       if (isalpha(aligned[j])) {
-                               pos = j;
-                               break;
-                       }
-               }
-               
-               //save this spot if it is the farthest
-               if (pos > frontPos) { frontPos = pos; }
-               
-               
-               //********find last position in topMatches that is a non gap character***********//
-               for (int i = 0; i < topMatches.size(); i++) {
-                       
-                       string aligned = topMatches[i].getAligned();
-                       int pos = aligned.length();
-                       
-                       //find first spot in this seq
-                       for (int j = aligned.length()-1; j >= 0; j--) {
-                               if (isalpha(aligned[j])) {
-                                       pos = j;
-                                       break;
-                               }
-                       }
-                       
-                       //save this spot if it is the farthest
-                       if (pos < rearPos) { rearPos = pos; }
-               }
-               
-               
-               aligned = query.getAligned();
-               pos = aligned.length();
-               
-               //find last position in query that is a non gap character
-               for (int j = aligned.length()-1; j >= 0; j--) {
-                       if (isalpha(aligned[j])) {
-                               pos = j;
-                               break;
-                       }
-               }
-               
-               //save this spot if it is the farthest
-               if (pos < rearPos) { rearPos = pos; }
-               
-               map<int, int> trimmedPos;
-               //check to make sure that is not whole seq
-               if ((rearPos - frontPos - 1) <= 0) {  
-                       query.setAligned("");
-                       //trim topMatches
-                       for (int i = 0; i < topMatches.size(); i++) {
-                               topMatches[i].setAligned("");
-                       }
-                       
-               }else {
-
-                       //trim query
-                       string newAligned = query.getAligned();
-                       newAligned = newAligned.substr(frontPos, (rearPos-frontPos+1));
-                       query.setAligned(newAligned);
-                       
-                       //trim topMatches
-                       for (int i = 0; i < topMatches.size(); i++) {
-                               newAligned = topMatches[i].getAligned();
-                               newAligned = newAligned.substr(frontPos, (rearPos-frontPos+1));
-                               topMatches[i].setAligned(newAligned);
-                       }
-                       
-                       for (int i = 0; i < newAligned.length(); i++) {
-                               trimmedPos[i] = i+frontPos;
-                       }
-               }
-               return trimmedPos;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeCalculator", "trimSequences");
-               exit(1);
-       }
-
-}
-//***************************************************************************************************************
-
-
-
diff --git a/decalc.h b/decalc.h
deleted file mode 100644 (file)
index d6cca18..0000000
--- a/decalc.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef DECALC_H
-#define DECALC_H
-/*
- *  decalc.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sequence.hpp"
-
-/***********************************************************************/
-
-//This class was created using the algorythms described in the 
-// "At Least 1 in 20 16S rRNA Sequence Records Currently Held in the Public Repositories is Estimated To Contain Substantial Anomalies" paper 
-//by Kevin E. Ashelford 1, Nadia A. Chuzhanova 3, John C. Fry 1, Antonia J. Jones 2 and Andrew J. Weightman 1.
-
-/***********************************************************************/
-
-//this structure is necessary to determine the sequence that contributed to the outliers when we remove them
-//this way we can remove all scores that are contributed by outlier sequences.
-struct quanMember {
-       float score;
-       int member1;
-       int member2;
-       quanMember (float s, int m, int n) : score(s), member1(m),  member2(n) {}
-       quanMember() {}
-       
-};
-               
-//********************************************************************************************************************
-class DeCalculator {
-
-       public:
-               
-               DeCalculator() { m = MothurOut::getInstance(); }
-               ~DeCalculator() {};
-               
-               vector<Sequence> findClosest(Sequence, vector<Sequence*>&, vector<Sequence*>&, int, int);  //takes querySeq, a reference db, filteredRefDB, numWanted, minSim 
-               Sequence* findClosest(Sequence*, vector<Sequence*>);
-               set<int> getPos() {  return h;  }
-               void setMask(string); 
-               void setAlignmentLength(int l) {  alignLength = l;  }
-               void runMask(Sequence*);
-               void trimSeqs(Sequence*, Sequence*, map<int, int>&);
-               map<int, int> trimSeqs(Sequence&, vector<Sequence>&);
-               void removeObviousOutliers(vector< vector<float> >&, int);
-               vector<float> calcFreq(vector<Sequence*>, string);
-               vector<int> findWindows(Sequence*, int, int, int&, int);
-               vector<float> calcObserved(Sequence*, Sequence*, vector<int>, int);
-               vector<float>  calcExpected(vector<float>, float);
-               vector<float>  findQav(vector<int>, int, vector<float>);  
-               float calcDE(vector<float>, vector<float>);
-               float calcDist(Sequence*, Sequence*, int, int);
-               float getCoef(vector<float>, vector<float>);
-               vector< vector<float> > getQuantiles(vector<Sequence*>, vector<int>, int, vector<float>, int, int, int);
-               
-               vector<int> returnObviousOutliers(vector< vector<quanMember> >, int);
-               
-               map<int, int> getMaskMap() { return maskMap; }
-               
-       private:
-               //vector<quanMember> sortContrib(map<quanMember*, float>);  //used by mallard
-               float findAverage(vector<float>);
-               //int findLargestContrib(vector<int>);
-               //void removeContrib(int, vector<quanMember>&);
-               string seqMask;
-               set<int> h;
-               int alignLength;
-               map<int, int> maskMap;
-               MothurOut* m;
-
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp
deleted file mode 100644 (file)
index 3d0c0d5..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- *  deconvolute.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "deconvolutecommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> DeconvoluteCommand::setParameters(){    
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string DeconvoluteCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The unique.seqs command reads a fastafile and creates a namesfile.\n";
-               helpString += "It creates a file where the first column is the groupname and the second column is a list of sequence names who have the same sequence. \n";
-               helpString += "If the sequence is unique the second column will just contain its name. \n";
-               helpString += "The unique.seqs command parameters are fasta and name.  fasta is required, unless there is a valid current fasta file.\n";
-               helpString += "The unique.seqs command should be in the following format: \n";
-               helpString += "unique.seqs(fasta=yourFastaFile) \n";    
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DeconvoluteCommand::DeconvoluteCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-DeconvoluteCommand::DeconvoluteCommand(string option)  {       
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       inFastaName = validParameter.validFile(parameters, "fasta", true);
-                       if (inFastaName == "not open") { abort = true; }
-                       else if (inFastaName == "not found") {                          
-                               inFastaName = m->getFastaFile(); 
-                               if (inFastaName != "") { m->mothurOut("Using " + inFastaName + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(inFastaName); } 
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(inFastaName); //if user entered a file with a path then preserve it     
-                       }
-                       
-                       oldNameMapFName = validParameter.validFile(parameters, "name", true);
-                       if (oldNameMapFName == "not open") { oldNameMapFName = ""; abort = true; }
-                       else if (oldNameMapFName == "not found"){       oldNameMapFName = "";   }
-                       else { m->setNameFile(oldNameMapFName); }
-                       
-                       if (oldNameMapFName == "") {
-                               vector<string> files; files.push_back(inFastaName);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "DeconvoluteCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int DeconvoluteCommand::execute() {    
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               //prepare filenames and open files
-               string outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "names";
-               string outFastaFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique" + m->getExtension(inFastaName);
-               
-               map<string, string> nameMap;
-               map<string, string>::iterator itNames;
-               if (oldNameMapFName != "")  {  
-            m->readNames(oldNameMapFName, nameMap); 
-            if (oldNameMapFName == outNameFile){ outNameFile = outputDir + m->getRootName(m->getSimpleName(inFastaName)) + "unique.names";   }
-        }
-               
-               if (m->control_pressed) { return 0; }
-               
-               ifstream in; 
-               m->openInputFile(inFastaName, in);
-               
-               ofstream outFasta;
-               m->openOutputFile(outFastaFile, outFasta);
-               
-               map<string, string> sequenceStrings; //sequenceString -> list of names.  "atgc...." -> seq1,seq2,seq3.
-               map<string, string>::iterator itStrings;
-               set<string> nameInFastaFile; //for sanity checking
-               set<string>::iterator itname;
-               vector<string> nameFileOrder;
-               int count = 0;
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); outFasta.close(); m->mothurRemove(outFastaFile); return 0; }
-                       
-                       Sequence seq(in);
-                       
-                       if (seq.getName() != "") {
-                               
-                               //sanity checks
-                               itname = nameInFastaFile.find(seq.getName());
-                               if (itname == nameInFastaFile.end()) { nameInFastaFile.insert(seq.getName());  }
-                               else { m->mothurOut("[ERROR]: You already have a sequence named " + seq.getName() + " in your fasta file, sequence names must be unique, please correct."); m->mothurOutEndLine(); }
-
-                               itStrings = sequenceStrings.find(seq.getAligned());
-                               
-                               if (itStrings == sequenceStrings.end()) { //this is a new unique sequence
-                                       //output to unique fasta file
-                                       seq.printSequence(outFasta);
-                                       
-                                       if (oldNameMapFName != "") {
-                                               itNames = nameMap.find(seq.getName());
-                                               
-                                               if (itNames == nameMap.end()) { //namefile and fastafile do not match
-                                                       m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file, and not in your namefile, please correct."); m->mothurOutEndLine();
-                                               }else {
-                                                       sequenceStrings[seq.getAligned()] = itNames->second;
-                                                       nameFileOrder.push_back(seq.getAligned());
-                                               }
-                                       }else { sequenceStrings[seq.getAligned()] = seq.getName();      nameFileOrder.push_back(seq.getAligned()); }
-                               }else { //this is a dup
-                                       if (oldNameMapFName != "") {
-                                               itNames = nameMap.find(seq.getName());
-                                               
-                                               if (itNames == nameMap.end()) { //namefile and fastafile do not match
-                                                       m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file, and not in your namefile, please correct."); m->mothurOutEndLine();
-                                               }else {
-                                                       sequenceStrings[seq.getAligned()] += "," + itNames->second;
-                                               }
-                                       }else { sequenceStrings[seq.getAligned()] += "," + seq.getName();       }
-                               }
-                               
-                               count++;
-                       }
-                       
-                       m->gobble(in);
-                       
-                       if(count % 1000 == 0)   { m->mothurOut(toString(count) + "\t" + toString(sequenceStrings.size())); m->mothurOutEndLine();       }
-               }
-               
-               if(count % 1000 != 0)   { m->mothurOut(toString(count) + "\t" + toString(sequenceStrings.size())); m->mothurOutEndLine();       }
-               
-               in.close();
-               outFasta.close();
-               
-               if (m->control_pressed) { m->mothurRemove(outFastaFile); return 0; }
-               
-               //print new names file
-               ofstream outNames;
-               m->openOutputFile(outNameFile, outNames);
-               
-               for (int i = 0; i < nameFileOrder.size(); i++) {
-               //for (itStrings = sequenceStrings.begin(); itStrings != sequenceStrings.end(); itStrings++) {
-                       if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); outNames.close(); m->mothurRemove(outNameFile); return 0; }
-                       
-                       itStrings = sequenceStrings.find(nameFileOrder[i]);
-                       
-                       if (itStrings != sequenceStrings.end()) {
-                               //get rep name
-                               int pos = (itStrings->second).find_first_of(',');
-                       
-                               if (pos == string::npos) { // only reps itself
-                                       outNames << itStrings->second << '\t' << itStrings->second << endl;
-                               }else {
-                                       outNames << (itStrings->second).substr(0, pos) << '\t' << itStrings->second << endl;
-                               }
-                       }else{ m->mothurOut("[ERROR]: mismatch in namefile print."); m->mothurOutEndLine(); m->control_pressed = true; }
-               }
-               outNames.close();
-               
-               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); m->mothurRemove(outNameFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outFastaFile); m->mothurOutEndLine();      
-               m->mothurOut(outNameFile); m->mothurOutEndLine();
-               outputNames.push_back(outFastaFile);  outputNames.push_back(outNameFile); outputTypes["fasta"].push_back(outFastaFile);  outputTypes["name"].push_back(outNameFile); 
-               m->mothurOutEndLine();
-
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeconvoluteCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
diff --git a/deconvolutecommand.h b/deconvolutecommand.h
deleted file mode 100644 (file)
index 487c460..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef DECONVOLUTECOMMAND_H
-#define DECONVOLUTECOMMAND_H
-/*
- *  deconvolute.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "fastamap.h"
-
-/* The unique.seqs command reads a fasta file, finds the duplicate sequences and outputs a names file
-       containing 2 columns.  The first being the groupname and the second the list of identical sequence names. */ 
-
-
-class DeconvoluteCommand : public Command {
-
-public:
-       DeconvoluteCommand(string);
-       DeconvoluteCommand();
-       ~DeconvoluteCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "unique.seqs";         }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Unique.seqs"; }
-       string getDescription()         { return "creates a fasta containing the unique sequences as well as a namesfile with the names each sequence represents"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       string inFastaName, oldNameMapFName, outputDir;
-       vector<string> outputNames;
-
-       bool abort;
-};
-
-#endif
diff --git a/degapseqscommand.cpp b/degapseqscommand.cpp
deleted file mode 100644 (file)
index 1d83f3b..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- *  degapseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 6/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "degapseqscommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> DegapSeqsCommand::setParameters(){      
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string DegapSeqsCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The degap.seqs command reads a fastafile and removes all gap characters.\n";
-               helpString += "The degap.seqs command parameter is fasta.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your sequences, and is required unless you have a valid current fasta file. \n";
-               helpString += "You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The degap.seqs command should be in the following format: \n";
-               helpString += "degap.seqs(fasta=yourFastaFile) \n";     
-               helpString += "Example: degap.seqs(fasta=abrecovery.align) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DegapSeqsCommand::DegapSeqsCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "DegapSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-DegapSeqsCommand::DegapSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", false);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { fastaFileNames.push_back(fastafile); m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else { 
-                               m->splitAtDash(fastafile, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               ifstream in;
-                                               int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else { m->setFastaFile(fastaFileNames[i]); }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "DegapSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int DegapSeqsCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                               
-                       m->mothurOut("Degapping sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       ifstream inFASTA;
-                       m->openInputFile(fastaFileNames[s], inFASTA);
-                       
-                       ofstream outFASTA;
-                       string tempOutputDir = outputDir;
-                       if (outputDir == "") { tempOutputDir = m->hasPath(fastaFileNames[s]); }
-                       string degapFile = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "ng.fasta";
-                       m->openOutputFile(degapFile, outFASTA);
-                       
-                       while(!inFASTA.eof()){
-                               if (m->control_pressed) {   outputTypes.clear(); inFASTA.close();  outFASTA.close(); m->mothurRemove(degapFile); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]);        } return 0; }
-                                
-                               Sequence currSeq(inFASTA);  m->gobble(inFASTA);
-                               if (currSeq.getName() != "") {
-                                       outFASTA << ">" << currSeq.getName() << endl;
-                                       outFASTA << currSeq.getUnaligned() << endl;
-                               }
-                       }
-                       inFASTA.close();
-                       outFASTA.close();
-                       
-                       outputNames.push_back(degapFile); outputTypes["fasta"].push_back(degapFile);
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); m->mothurRemove(degapFile); for (int j = 0; j < outputNames.size(); j++) {      m->mothurRemove(outputNames[j]);        } return 0; }
-               }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DegapSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
diff --git a/degapseqscommand.h b/degapseqscommand.h
deleted file mode 100644 (file)
index 342cd36..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef DEGAPSEQSCOMMAND_H
-#define DEGAPSEQSCOMMAND_H
-
-/*
- *  degapseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 6/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-class DegapSeqsCommand : public Command {
-public:
-       DegapSeqsCommand(string);
-       DegapSeqsCommand();
-       ~DegapSeqsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "degap.seqs";          }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Degap.seqs"; }
-       string getDescription()         { return "removes gap characters from sequences"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-
-       bool abort;
-       string fastafile, outputDir;
-       vector<string> outputNames;
-       vector<string> fastaFileNames;
-       
-};
-
-#endif
-
diff --git a/deuniqueseqscommand.cpp b/deuniqueseqscommand.cpp
deleted file mode 100644 (file)
index 7481416..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- *  deuniqueseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "deuniqueseqscommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> DeUniqueSeqsCommand::setParameters(){   
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string DeUniqueSeqsCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The deunique.seqs command reads a fastafile and namefile, and creates a fastafile containing all the sequences.\n";
-               helpString += "The deunique.seqs command parameters are fasta and name, both are required, unless you have valid current name and fasta files.\n";
-               helpString += "The deunique.seqs command should be in the following format: \n";
-               helpString += "deunique.seqs(fasta=yourFastaFile, name=yourNameFile) \n";       
-               helpString += "Example deunique.seqs(fasta=abrecovery.unique.fasta, name=abrecovery.names).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DeUniqueSeqsCommand::DeUniqueSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "DeconvoluteCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-DeUniqueSeqsCommand::DeUniqueSeqsCommand(string option)  {     
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       fastaFile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastaFile == "not open") { abort = true; }
-                       else if (fastaFile == "not found") {                            
-                               fastaFile = m->getFastaFile(); 
-                               if (fastaFile != "") { m->mothurOut("Using " + fastaFile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastaFile); }   
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastaFile); //if user entered a file with a path then preserve it       
-                       }
-                       
-                       nameFile = validParameter.validFile(parameters, "name", true);
-                       if (nameFile == "not open") { abort = true; }
-                       else if (nameFile == "not found"){                                      
-                               nameFile = m->getNameFile(); 
-                               if (nameFile != "") { m->mothurOut("Using " + nameFile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current namefile and the name parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setNameFile(nameFile); }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "DeUniqueSeqsCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int DeUniqueSeqsCommand::execute() {   
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               //prepare filenames and open files
-               ofstream out;
-               string outFastaFile = m->getRootName(m->getSimpleName(fastaFile));
-               int pos = outFastaFile.find("unique");
-               if (pos != string::npos) {
-                       outFastaFile = outputDir + outFastaFile.substr(0, pos) + "redundant" + m->getExtension(fastaFile);
-               }else{
-                       outFastaFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "redundant" + m->getExtension(fastaFile);
-               }
-               m->openOutputFile(outFastaFile, out);
-               
-               readNamesFile();
-               if (m->control_pressed) {  out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; }
-               
-               ifstream in;
-               m->openInputFile(fastaFile, in);
-               
-               while (!in.eof()) {
-               
-                       if (m->control_pressed) { in.close(); out.close(); outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       
-                       if (seq.getName() != "") {
-                               
-                               //look for sequence name in nameMap
-                               map<string, string>::iterator it = nameMap.find(seq.getName());
-                               
-                               if (it == nameMap.end()) {      m->mothurOut("[ERROR]: Your namefile does not contain " + seq.getName() + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
-                               else {
-                                       vector<string> names;
-                                       m->splitAtComma(it->second, names);
-                                       
-                                       //output sequences
-                                       for (int i = 0; i < names.size(); i++) {
-                                               out << ">" << names[i] << endl;
-                                               out << seq.getAligned() << endl;
-                                       }
-                                       
-                                       //remove seq from name map so we can check for seqs in namefile not in fastafile later
-                                       nameMap.erase(it);
-                               }
-                       }
-               }
-               in.close();
-               out.close(); 
-               
-               if (nameMap.size() != 0) { //then there are names in the namefile not in the fastafile
-                       for (map<string, string>::iterator it = nameMap.begin(); it != nameMap.end(); it++) {  
-                               m->mothurOut(it->first + " is not in your fasta file, but is in your name file. Please correct."); m->mothurOutEndLine();
-                       }
-               }
-                               
-               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outFastaFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outFastaFile); m->mothurOutEndLine();      
-               outputNames.push_back(outFastaFile);  outputTypes["fasta"].push_back(outFastaFile);  
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int DeUniqueSeqsCommand::readNamesFile() {
-       try {
-               
-               ifstream inNames;
-               m->openInputFile(nameFile, inNames);
-               
-               string name, names;
-               map<string, string>::iterator it;
-       
-               while(inNames){
-                       
-                       if(m->control_pressed) { break; }
-                       
-                       inNames >> name;        m->gobble(inNames);             
-                       inNames >> names;               
-                       
-                       it = nameMap.find(name);
-                       
-                       if (it == nameMap.end()) {      nameMap[name] = names; }
-                       else { m->mothurOut("[ERROR]: Your namefile already contains " + name + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       
-                       m->gobble(inNames);
-               }
-               inNames.close();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeUniqueSeqsCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
-/**************************************************************************************/
diff --git a/deuniqueseqscommand.h b/deuniqueseqscommand.h
deleted file mode 100644 (file)
index 300a1ca..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef DEUNIQUESEQSCOMMAND_H
-#define DEUNIQUESEQSCOMMAND_H
-/*
- *  deuniqueseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 10/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-/* This command is the reverse of unique.seqs */ 
-
-class DeUniqueSeqsCommand : public Command {
-
-public:
-       DeUniqueSeqsCommand(string);
-       DeUniqueSeqsCommand();
-       ~DeUniqueSeqsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "deunique.seqs";               }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Deunique.seqs"; }
-       string getDescription()         { return "reverse of the unique.seqs command, and creates a fasta file from a fasta and name file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-
-       string fastaFile, nameFile, outputDir;
-       vector<string> outputNames;
-       bool abort;
-       
-       map<string, string> nameMap;
-       
-       int readNamesFile();
-       
-};
-
-#endif
-
diff --git a/deuniquetreecommand.cpp b/deuniquetreecommand.cpp
deleted file mode 100644 (file)
index c33c8e4..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- *  deuniquetreecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/27/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "deuniquetreecommand.h"
-#include "treereader.h"
-
-//**********************************************************************************************************************
-vector<string> DeuniqueTreeCommand::setParameters(){   
-       try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string DeuniqueTreeCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The deunique.tree command parameters are tree and name.  Both parameters are required unless you have valid current files.\n";
-               helpString += "The deunique.tree command should be in the following format: deunique.tree(tree=yourTreeFile, name=yourNameFile).\n";
-               helpString += "Example deunique.tree(tree=abrecovery.tree, name=abrecovery.names).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreeFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DeuniqueTreeCommand::DeuniqueTreeCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["tree"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "DeuniqueTreeCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-DeuniqueTreeCommand::DeuniqueTreeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["tree"] = tempOutNames;
-                                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-            //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { abort = true; }
-                       else if (treefile == "not found") {                             //if there is a current design file, use it
-                               treefile = m->getTreeFile(); 
-                               if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }else { m->setTreeFile(treefile); }     
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }
-                       else if (namefile == "not found") {                             //if there is a current design file, use it
-                               namefile = m->getNameFile(); 
-                               if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current name file and the name parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }else { m->setNameFile(namefile); }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(treefile);       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "DeuniqueTreeCommand");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-int DeuniqueTreeCommand::execute() {
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               m->setTreeFile(treefile);
-               
-               TreeReader* reader = new TreeReader(treefile, "", namefile);
-        vector<Tree*> T = reader->getTrees();
-        map<string, string> nameMap = reader->getNameMap();
-        delete reader;         
-               
-               //print new Tree
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + "deunique.tre";
-               outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
-               ofstream out;
-               m->openOutputFile(outputFile, out);
-               T[0]->print(out, nameMap);
-               out.close();
-               
-        delete (T[0]->getTreeMap());
-               for (int i = 0; i < T.size(); i++) { delete T[i]; }
-                               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("tree");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DeuniqueTreeCommand", "execute");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
-
diff --git a/deuniquetreecommand.h b/deuniquetreecommand.h
deleted file mode 100644 (file)
index 18a6e5e..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef DEUNIQUETREECOMMAND_H
-#define DEUNIQUETREECOMMAND_H
-
-/*
- *  deuniquetreecommand.h
- *  Mothur
- *
- *  Created by westcott on 5/27/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sharedutilities.h"
-#include "readtree.h"
-
-class DeuniqueTreeCommand : public Command {
-       
-public:
-       DeuniqueTreeCommand(string);    
-       DeuniqueTreeCommand();
-       ~DeuniqueTreeCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "deunique.tree";               }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Deunique.tree"; }
-       string getDescription()         { return "add the redundant sequence names back into a tree of unique sequences"; }
-       
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-       
-private:
-       int numUniquesInName;
-       
-       bool abort;
-       string outputDir, treefile, namefile;
-       vector<string> outputNames;
-       map<string, string> nameMap;
-       int readNamesFile();
-};
-
-#endif
diff --git a/display.h b/display.h
deleted file mode 100644 (file)
index 979caa5..0000000
--- a/display.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef DISPLAY_H
-#define DISPLAY_H
-
-#include "sabundvector.hpp"
-#include "sharedsabundvector.h"
-#include "calculator.h"
-#include "fileoutput.h"
-
-
-/***********************************************************************/
-
-class Display {
-       
-public:
-       virtual void update(SAbundVector* rank) = 0;
-       virtual void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb) = 0;
-       virtual void init(string) = 0;
-       virtual void reset() = 0;
-       virtual void close() = 0;
-       virtual void outputTempFiles(string) {}
-       virtual void inputTempFiles(string) {}
-       virtual bool isCalcMultiple() = 0;
-       virtual void setAll(bool){}
-       virtual bool hasLciHci(){ return false; }
-       virtual bool getAll()   {       bool a; return a;       }
-       virtual bool calcNeedsAll()    { bool a; return a;      }
-       virtual string getName() { return ""; };
-       virtual ~Display() {}
-       Display() {  m = MothurOut::getInstance();  }
-       
-protected:
-       MothurOut* m;
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/dist.h b/dist.h
deleted file mode 100644 (file)
index 1412424..0000000
--- a/dist.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef DIST_H
-#define DIST_H
-/*
- *  dist.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sequence.hpp"
-
-/**************************************************************************************************/
-
-class Dist {
-       
-public:
-       Dist(){ dist = 0; m = MothurOut::getInstance(); }
-       Dist(const Dist& d) : dist(d.dist) { m = MothurOut::getInstance(); }
-       virtual ~Dist() {}
-       virtual void calcDist(Sequence, Sequence) = 0;
-       double getDist()        {       return dist;    }
-
-protected:
-       double dist;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/distancecommand.cpp b/distancecommand.cpp
deleted file mode 100644 (file)
index 79b8fe7..0000000
+++ /dev/null
@@ -1,1287 +0,0 @@
-/*
- *  distancecommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "distancecommand.h"
-
-//**********************************************************************************************************************
-vector<string> DistanceCommand::setParameters(){       
-       try {
-               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "OldFastaColumn",false,false); parameters.push_back(pcolumn);
-               CommandParameter poldfasta("oldfasta", "InputTypes", "", "", "none", "none", "OldFastaColumn",false,false); parameters.push_back(poldfasta);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poutput("output", "Multiple", "column-lt-square", "column", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcountends);
-               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcompress);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string DistanceCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The dist.seqs command reads a file containing sequences and creates a distance file.\n";
-               helpString += "The dist.seqs command parameters are fasta, oldfasta, column, calc, countends, output, compress, cutoff and processors.  \n";
-               helpString += "The fasta parameter is required, unless you have a valid current fasta file.\n";
-               helpString += "The oldfasta and column parameters allow you to append the distances calculated to the column file.\n";
-               helpString += "The calc parameter allows you to specify the method of calculating the distances.  Your options are: nogaps, onegap or eachgap. The default is onegap.\n";
-               helpString += "The countends parameter allows you to specify whether to include terminal gaps in distance.  Your options are: T or F. The default is T.\n";
-               helpString += "The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0.\n";
-               helpString += "The output parameter allows you to specify format of your distance matrix. Options are column, lt, and square. The default is column.\n";
-               helpString += "The processors parameter allows you to specify number of processors to use.  The default is 1.\n";
-               helpString += "The compress parameter allows you to indicate that you want the resulting distance file compressed.  The default is false.\n";
-               helpString += "The dist.seqs command should be in the following format: \n";
-               helpString += "dist.seqs(fasta=yourFastaFile, calc=yourCalc, countends=yourEnds, cutoff= yourCutOff, processors=yourProcessors) \n";
-               helpString += "Example dist.seqs(fasta=amazon.fasta, calc=eachgap, countends=F, cutoff= 2.0, processors=3).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. calc), '=' and parameters (i.e.yourCalc).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DistanceCommand::DistanceCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["phylip"] = tempOutNames;
-               outputTypes["column"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "DistanceCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-DistanceCommand::DistanceCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               Estimators.clear();
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("dist.seqs");
-                       map<string, string>::iterator it2;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it2 = parameters.begin(); it2 != parameters.end(); it2++) { 
-                               if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["phylip"] = tempOutNames;
-                       outputTypes["column"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it2 = parameters.find("fasta");
-                               //user has given a template file
-                               if(it2 != parameters.end()){ 
-                                       path = m->hasPath(it2->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it2->second;           }
-                               }
-                               
-                               it2 = parameters.find("oldfasta");
-                               //user has given a template file
-                               if(it2 != parameters.end()){ 
-                                       path = m->hasPath(it2->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oldfasta"] = inputDir + it2->second;                }
-                               }
-                               
-                               it2 = parameters.find("column");
-                               //user has given a template file
-                               if(it2 != parameters.end()){ 
-                                       path = m->hasPath(it2->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it2->second;          }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); 
-                                       ifstream inFASTA;
-                                       m->openInputFile(fastafile, inFASTA);
-                                       alignDB = SequenceDB(inFASTA); 
-                                       inFASTA.close();
-                               }else {         m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else if (fastafile == "not open") { abort = true; }    
-                       else{
-                               ifstream inFASTA;
-                               m->openInputFile(fastafile, inFASTA);
-                               alignDB = SequenceDB(inFASTA); 
-                               inFASTA.close();
-                               m->setFastaFile(fastafile);
-                       }
-                       
-                       oldfastafile = validParameter.validFile(parameters, "oldfasta", true);
-                       if (oldfastafile == "not found") { oldfastafile = ""; }
-                       else if (oldfastafile == "not open") { abort = true; }  
-                       
-                       column = validParameter.validFile(parameters, "column", true);
-                       if (column == "not found") { column = ""; }
-                       else if (column == "not open") { abort = true; }        
-                       else { m->setColumnFile(column); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "onegap";  }
-                       else { 
-                                if (calc == "default")  {  calc = "onegap";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "countends", false);        if(temp == "not found"){        temp = "T";     }
-                       convert(temp, countends); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);           if(temp == "not found"){        temp = "1.0"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "compress", false);         if(temp == "not found"){  temp = "F"; }
-                       convert(temp, compress);
-
-                       output = validParameter.validFile(parameters, "output", false);         if(output == "not found"){      output = "column"; }
-                       
-                       if (((column != "") && (oldfastafile == "")) || ((column == "") && (oldfastafile != ""))) { m->mothurOut("If you provide column or oldfasta, you must provide both."); m->mothurOutEndLine(); abort=true; }
-                       
-                       if ((column != "") && (oldfastafile != "") && (output != "column")) { m->mothurOut("You have provided column and oldfasta, indicating you want to append distances to your column file. Your output must be in column format to do so."); m->mothurOutEndLine(); abort=true; }
-                       
-                       if ((output != "column") && (output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are column, lt and square. I will use column."); m->mothurOutEndLine(); output = "column"; }
-
-               }
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "DistanceCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int DistanceCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int startTime = time(NULL);
-               
-               //save number of new sequence
-               numNewFasta = alignDB.getNumSeqs();
-               
-               //sanity check the oldfasta and column file as well as add oldfasta sequences to alignDB
-               if ((oldfastafile != "") && (column != ""))  {  if (!(sanityCheck())) { return 0; }  }
-               
-               if (m->control_pressed) { return 0; }
-               
-               int numSeqs = alignDB.getNumSeqs();
-               cutoff += 0.005;
-               
-               if (!alignDB.sameLength()) {  m->mothurOut("[ERROR]: your sequences are not the same length, aborting."); m->mothurOutEndLine(); return 0; }
-               
-               string outputFile;
-                               
-               if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "phylip.dist";
-                       m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile);
-                       
-                       //output numSeqs to phylip formatted dist file
-               }else if (output == "column") { //user wants column format
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "dist";
-                       outputTypes["column"].push_back(outputFile);
-                       
-                       //so we don't accidentally overwrite
-                       if (outputFile == column) { 
-                               string tempcolumn = column + ".old"; 
-                               rename(column.c_str(), tempcolumn.c_str());
-                       }
-                       
-                       m->mothurRemove(outputFile);
-               }else { //assume square
-                       outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "square.dist";
-                       m->mothurRemove(outputFile);
-                       outputTypes["phylip"].push_back(outputFile);
-               }
-               
-
-#ifdef USE_MPI
-               
-               int pid, start, end; 
-               int tag = 2001;
-                               
-               MPI_Status status; 
-               MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               //each process gets where it should start and stop in the file
-               if (output != "square") {
-                       start = int (sqrt(float(pid)/float(processors)) * numSeqs);
-                       end = int (sqrt(float(pid+1)/float(processors)) * numSeqs);
-               }else{
-                       start = int ((float(pid)/float(processors)) * numSeqs);
-                       end = int ((float(pid+1)/float(processors)) * numSeqs);
-               }
-               
-               if (output == "column") {
-                       MPI_File outMPI;
-                       int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-                       //char* filename = new char[outputFile.length()];
-                       //memcpy(filename, outputFile.c_str(), outputFile.length());
-                       
-                       char filename[1024];
-                       strcpy(filename, outputFile.c_str());
-                       
-                       MPI_File_open(MPI_COMM_WORLD, filename, amode, MPI_INFO_NULL, &outMPI);
-                       //delete filename;
-
-                       if (pid == 0) { //you are the root process 
-                               
-                               //do your part
-                               string outputMyPart;
-                               
-                               driverMPI(start, end, outMPI, cutoff); 
-                               
-                               if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI);   return 0; }
-                       
-                               //wait on chidren
-                               for(int i = 1; i < processors; i++) { 
-                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);    return 0; }
-                                       
-                                       char buf[5];
-                                       MPI_Recv(buf, 5, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
-                               }
-                       }else { //you are a child process
-                               //do your part
-                               driverMPI(start, end, outMPI, cutoff); 
-                               
-                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);   return 0; }
-                       
-                               char buf[5];
-                               strcpy(buf, "done"); 
-                               //tell parent you are done.
-                               MPI_Send(buf, 5, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                       }
-                       
-                       MPI_File_close(&outMPI);
-                       
-               }else { //lower triangle format
-                       if (pid == 0) { //you are the root process 
-                       
-                               //do your part
-                               string outputMyPart;
-                               unsigned long long mySize;
-                               
-                               if (output != "square"){ driverMPI(start, end, outputFile, mySize); }
-                               else { driverMPI(start, end, outputFile, mySize, output); }
-       
-                               if (m->control_pressed) {  outputTypes.clear();   return 0; }
-                               
-                               int amode=MPI_MODE_APPEND|MPI_MODE_WRONLY|MPI_MODE_CREATE; //
-                               MPI_File outMPI;
-                               MPI_File inMPI;
-
-                               //char* filename = new char[outputFile.length()];
-                               //memcpy(filename, outputFile.c_str(), outputFile.length());
-                               
-                               char filename[1024];
-                               strcpy(filename, outputFile.c_str());
-
-                               MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-                               //delete filename;
-
-                               //wait on chidren
-                               for(int b = 1; b < processors; b++) { 
-                                       unsigned long long fileSize;
-                                       
-                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);   return 0; }
-                                       
-                                       MPI_Recv(&fileSize, 1, MPI_LONG, b, tag, MPI_COMM_WORLD, &status); 
-                                       
-                                       string outTemp = outputFile + toString(b) + ".temp";
-
-                                       char* buf = new char[outTemp.length()];
-                                       memcpy(buf, outTemp.c_str(), outTemp.length());
-                                       
-                                       MPI_File_open(MPI_COMM_SELF, buf, MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);
-                                       delete buf;
-
-                                       int count = 0;
-                                       while (count < fileSize) { 
-                                               char buf2[1];
-                                               MPI_File_read(inMPI, buf2, 1, MPI_CHAR, &status);
-                                               MPI_File_write(outMPI, buf2, 1, MPI_CHAR, &status);
-                                               count += 1;
-                                       }
-                                       
-                                       MPI_File_close(&inMPI); //deleted on close
-                               }
-                               
-                               MPI_File_close(&outMPI);
-                       }else { //you are a child process
-                               //do your part
-                               unsigned long long size;
-                               if (output != "square"){ driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size); }
-                               else { driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size, output); }
-                               
-                               if (m->control_pressed) {  return 0; }
-                       
-                               //tell parent you are done.
-                               MPI_Send(&size, 1, MPI_LONG, 0, tag, MPI_COMM_WORLD);
-                       }
-               }
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#else          
-                               
-       //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               //if you don't need to fork anything
-               if(processors == 1){
-                       if (output != "square") {  driver(0, numSeqs, outputFile, cutoff); }
-                       else { driver(0, numSeqs, outputFile, "square");  }
-               }else{ //you have multiple processors
-                       
-                       unsigned long long numDists = 0;
-                       
-                       if (output == "square") {
-                                numDists = numSeqs * numSeqs;
-                       }else {
-                               for(int i=0;i<numSeqs;i++){
-                                       for(int j=0;j<i;j++){
-                                               numDists++;
-                                               if (numDists > processors) { break; }
-                                       }
-                               }
-                       }
-                       
-                       if (numDists < processors) { processors = numDists; }
-                       
-                       for (int i = 0; i < processors; i++) {
-                               distlinePair tempLine;
-                               lines.push_back(tempLine);
-                               if (output != "square") {
-                                       lines[i].start = int (sqrt(float(i)/float(processors)) * numSeqs);
-                                       lines[i].end = int (sqrt(float(i+1)/float(processors)) * numSeqs);
-                               }else{
-                                       lines[i].start = int ((float(i)/float(processors)) * numSeqs);
-                                       lines[i].end = int ((float(i+1)/float(processors)) * numSeqs);
-                               }
-                               
-                       }
-                       
-                       createProcesses(outputFile); 
-               }
-       //#else
-               //ifstream inFASTA;
-               //if (output != "square") {  driver(0, numSeqs, outputFile, cutoff); }
-               //else { driver(0, numSeqs, outputFile, "square");  }
-       //#endif
-       
-#endif
-               if (m->control_pressed) { outputTypes.clear();  m->mothurRemove(outputFile); return 0; }
-               
-               #ifdef USE_MPI
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               //if (output == "square") {  convertMatrix(outputFile); }
-               
-               ifstream fileHandle;
-               fileHandle.open(outputFile.c_str());
-               if(fileHandle) {
-                       m->gobble(fileHandle);
-                       if (fileHandle.eof()) { m->mothurOut(outputFile + " is blank. This can result if there are no distances below your cutoff.");  m->mothurOutEndLine(); }
-               }
-               
-               //append the old column file to the new one
-               if ((oldfastafile != "") && (column != ""))  {
-                       //we had to rename the column file so we didnt overwrite above, but we want to keep old name
-                       if (outputFile == column) { 
-                               string tempcolumn = column + ".old";
-                               m->appendFiles(tempcolumn, outputFile);
-                               m->mothurRemove(tempcolumn);
-                       }else{
-                               m->appendFiles(outputFile, column);
-                               m->mothurRemove(outputFile);
-                               outputFile = column;
-                       }
-                       
-                       if (outputDir != "") { 
-                               string newOutputName = outputDir + m->getSimpleName(outputFile);
-                               rename(outputFile.c_str(), newOutputName.c_str());
-                               m->mothurRemove(outputFile);
-                               outputFile = newOutputName;
-                       }
-               }
-
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-               
-               if (m->control_pressed) { outputTypes.clear();  m->mothurRemove(outputFile); return 0; }
-               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("phylip");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
-               }
-               
-               //set column file as new current columnfile
-               itTypes = outputTypes.find("column");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFile); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("It took " + toString(time(NULL) - startTime) + " to calculate the distances for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
-
-
-               if (m->isTrue(compress)) {
-                       m->mothurOut("Compressing..."); m->mothurOutEndLine();
-                       m->mothurOut("(Replacing " + outputFile + " with " + outputFile + ".gz)"); m->mothurOutEndLine();
-                       system(("gzip -v " + outputFile).c_str());
-                       outputNames.push_back(outputFile + ".gz");
-               }else { outputNames.push_back(outputFile); }
-
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void DistanceCommand::createProcesses(string filename) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               processIDS.clear();
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               if (output != "square") {  driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", cutoff); }
-                               else { driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", "square"); }
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes. Error code: " + toString(pid)); m->mothurOutEndLine(); 
-                               perror(" : ");
-                               for (int i=0;i<processIDS.size();i++) {  int temp = processIDS[i]; kill (temp, SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent does its part
-               if (output != "square") {  driver(lines[0].start, lines[0].end, filename, cutoff); }
-               else { driver(lines[0].start, lines[0].end, filename, "square"); }
-               
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the distanceData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //that's why the distance calculator was moved inside of the driver to make separate copies.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<distanceData*> pDataArray; //[processors-1];
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor-1 worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       
-                       // Allocate memory for thread data.
-                       distanceData* tempDist = new distanceData(lines[i+1].start, lines[i+1].end, (filename + toString(i) + ".temp"), cutoff, alignDB, Estimators, m, output, numNewFasta, countends);
-                       pDataArray.push_back(tempDist);
-                       processIDS.push_back(i);
-                       
-                       //MyDistThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MyDistThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-               //do your part
-               if (output != "square") {  driver(lines[0].start, lines[0].end, filename, cutoff); }
-               else { driver(lines[0].start, lines[0].end, filename, "square"); }
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif
-               
-               //append and remove temp files
-               for (int i=0;i<processIDS.size();i++) { 
-                       m->appendFiles((filename + toString(processIDS[i]) + ".temp"), filename);
-                       m->mothurRemove((filename + toString(processIDS[i]) + ".temp"));
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int DistanceCommand::driver(int startLine, int endLine, string dFileName, float cutoff){
-       try {
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (m->isTrue(countends) == true) {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")                  {       distCalculator = new ignoreGaps();      }
-                                       else if (Estimators[i] == "eachgap")    {       distCalculator = new eachGapDist();     }
-                                       else if (Estimators[i] == "onegap")             {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")          {       distCalculator = new ignoreGaps();                                      }
-                                       else if (Estimators[i] == "eachgap"){   distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (Estimators[i] == "onegap")     {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               int startTime = time(NULL);
-               
-               //column file
-               ofstream outFile(dFileName.c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               if((output == "lt") && startLine == 0){ outFile << alignDB.getNumSeqs() << endl;        }
-               
-               for(int i=startLine;i<endLine;i++){
-                       if(output == "lt")      {       
-                               string name = alignDB.get(i).getName();
-                               if (name.length() < 10) { //pad with spaces to make compatible
-                                       while (name.length() < 10) {  name += " ";  }
-                               }
-                               outFile << name << '\t';        
-                       }
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { delete distCalculator; outFile.close(); return 0;  }
-                               
-                               //if there was a column file given and we are appending, we don't want to calculate the distances that are already in the column file
-                               //the alignDB contains the new sequences and then the old, so if i an oldsequence and j is an old sequence then break out of this loop
-                               if ((i >= numNewFasta) && (j >= numNewFasta)) { break; }
-                               
-                               distCalculator->calcDist(alignDB.get(i), alignDB.get(j));
-                               double dist = distCalculator->getDist();
-                               
-                               if(dist <= cutoff){
-                                       if (output == "column") { outFile << alignDB.get(i).getName() << ' ' << alignDB.get(j).getName() << ' ' << dist << endl; }
-                               }
-                               if (output == "lt") {  outFile << dist << '\t'; }
-                       }
-                       
-                       if (output == "lt") { outFile << endl; }
-                       
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                       }
-                       
-               }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               
-               outFile.close();
-               delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int DistanceCommand::driver(int startLine, int endLine, string dFileName, string square){
-       try {
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (m->isTrue(countends) == true) {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")                  {       distCalculator = new ignoreGaps();      }
-                                       else if (Estimators[i] == "eachgap")    {       distCalculator = new eachGapDist();     }
-                                       else if (Estimators[i] == "onegap")             {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")          {       distCalculator = new ignoreGaps();                                      }
-                                       else if (Estimators[i] == "eachgap"){   distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (Estimators[i] == "onegap")     {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               int startTime = time(NULL);
-               
-               //column file
-               ofstream outFile(dFileName.c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               if(startLine == 0){     outFile << alignDB.getNumSeqs() << endl;        }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       //pad with spaces to make compatible
-                       if (name.length() < 10) { while (name.length() < 10) {  name += " ";  } }
-                               
-                       outFile << name << '\t';        
-                       
-                       for(int j=0;j<alignDB.getNumSeqs();j++){
-                               
-                               if (m->control_pressed) { delete distCalculator; outFile.close(); return 0;  }
-                               
-                               distCalculator->calcDist(alignDB.get(i), alignDB.get(j));
-                               double dist = distCalculator->getDist();
-                               
-                               outFile << dist << '\t'; 
-                       }
-                       
-                       outFile << endl; 
-                       
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                       }
-                       
-               }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               
-               outFile.close();
-               delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "driver");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int DistanceCommand::driverMPI(int startLine, int endLine, MPI_File& outMPI, float cutoff){
-       try {
-               
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (m->isTrue(countends) == true) {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")                  {       distCalculator = new ignoreGaps();      }
-                                       else if (Estimators[i] == "eachgap")    {       distCalculator = new eachGapDist();     }
-                                       else if (Estimators[i] == "onegap")             {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")          {       distCalculator = new ignoreGaps();                                      }
-                                       else if (Estimators[i] == "eachgap"){   distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (Estimators[i] == "onegap")     {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               
-               MPI_Status status;
-               int startTime = time(NULL);
-               
-               string outputString = "";
-               
-               for(int i=startLine;i<endLine;i++){
-       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) {  delete distCalculator; return 0;  }
-                               
-                               //if there was a column file given and we are appending, we don't want to calculate the distances that are already in the column file
-                               //the alignDB contains the new sequences and then the old, so if i an oldsequence and j is an old sequence then break out of this loop
-                               if ((i >= numNewFasta) && (j >= numNewFasta)) { break; }
-                               
-                               distCalculator->calcDist(alignDB.get(i), alignDB.get(j));
-                               double dist = distCalculator->getDist();
-                               
-                               if(dist <= cutoff){
-                                        outputString += (alignDB.get(i).getName() + ' ' + alignDB.get(j).getName() + ' ' + toString(dist) + '\n'); 
-                               }
-                       }
-                       
-                       if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
-                       }
-                       
-                        
-                       //send results to parent
-                       int length = outputString.length();
-
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status);
-                       outputString = "";
-                       delete buf;
-                       
-               }
-               
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;        
-               delete distCalculator;
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "driverMPI");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned long long& size){
-       try {
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (m->isTrue(countends) == true) {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")                  {       distCalculator = new ignoreGaps();      }
-                                       else if (Estimators[i] == "eachgap")    {       distCalculator = new eachGapDist();     }
-                                       else if (Estimators[i] == "onegap")             {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")          {       distCalculator = new ignoreGaps();                                      }
-                                       else if (Estimators[i] == "eachgap"){   distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (Estimators[i] == "onegap")     {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               
-               MPI_Status status;
-               
-               MPI_File outMPI;
-               int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-               //char* filename = new char[file.length()];
-               //memcpy(filename, file.c_str(), file.length());
-               
-               char filename[1024];
-               strcpy(filename, file.c_str());
-
-               MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-               //delete filename;
-
-               int startTime = time(NULL);
-               
-               string outputString = "";
-               size = 0;
-               
-               if(startLine == 0){     outputString += toString(alignDB.getNumSeqs()) + "\n";  }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       if (name.length() < 10) { //pad with spaces to make compatible
-                               while (name.length() < 10) {  name += " ";  }
-                       }
-                       outputString += name + "\t";    
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { delete distCalculator; return 0;  }
-                               
-                               distCalculator->calcDist(alignDB.get(i), alignDB.get(j));
-                               double dist = distCalculator->getDist();
-                               
-                               outputString += toString(dist) + "\t"; 
-                       }
-                       
-                       outputString += "\n"; 
-
-               
-                       if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
-                       }
-                       
-                       
-                       //send results to parent
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write(outMPI, buf, length, MPI_CHAR, &status);
-                       size += outputString.length();
-                       outputString = "";
-                       delete buf;
-               }
-               
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;
-               MPI_File_close(&outMPI);
-               delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "driverMPI");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int DistanceCommand::driverMPI(int startLine, int endLine, string file, unsigned long long& size, string square){
-       try {
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (m->isTrue(countends) == true) {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")                  {       distCalculator = new ignoreGaps();      }
-                                       else if (Estimators[i] == "eachgap")    {       distCalculator = new eachGapDist();     }
-                                       else if (Estimators[i] == "onegap")             {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "nogaps")          {       distCalculator = new ignoreGaps();                                      }
-                                       else if (Estimators[i] == "eachgap"){   distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (Estimators[i] == "onegap")     {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               MPI_Status status;
-               
-               MPI_File outMPI;
-               int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-               //char* filename = new char[file.length()];
-               //memcpy(filename, file.c_str(), file.length());
-               
-               char filename[1024];
-               strcpy(filename, file.c_str());
-
-               MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-               //delete filename;
-
-               int startTime = time(NULL);
-               
-               string outputString = "";
-               size = 0;
-               
-               if(startLine == 0){     outputString += toString(alignDB.getNumSeqs()) + "\n";  }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       if (name.length() < 10) { //pad with spaces to make compatible
-                               while (name.length() < 10) {  name += " ";  }
-                       }
-                       outputString += name + "\t";    
-                       
-                       for(int j=0;j<alignDB.getNumSeqs();j++){
-                               
-                               if (m->control_pressed) { delete distCalculator; return 0;  }
-                               
-                               distCalculator->calcDist(alignDB.get(i), alignDB.get(j));
-                               double dist = distCalculator->getDist();
-                               
-                               outputString += toString(dist) + "\t"; 
-                       }
-                       
-                       outputString += "\n"; 
-
-               
-                       if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
-                       }
-                       
-                       
-                       //send results to parent
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write(outMPI, buf, length, MPI_CHAR, &status);
-                       size += outputString.length();
-                       outputString = "";
-                       delete buf;
-               }
-               
-               //m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               cout << (endLine-1) << '\t' << (time(NULL) - startTime) << endl;
-               MPI_File_close(&outMPI);
-               delete distCalculator;
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************
-int DistanceCommand::convertMatrix(string outputFile) {
-       try{
-
-               //sort file by first column so the distances for each row are together
-               string outfile = m->getRootName(outputFile) + "sorted.dist.temp";
-               
-               //use the unix sort 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       string command = "sort -n " + outputFile + " -o " + outfile;
-                       system(command.c_str());
-               #else //sort using windows sort
-                       string command = "sort " + outputFile + " /O " + outfile;
-                       system(command.c_str());
-               #endif
-               
-
-               //output to new file distance for each row and save positions in file where new row begins
-               ifstream in;
-               m->openInputFile(outfile, in);
-               
-               ofstream out;
-               m->openOutputFile(outputFile, out);
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-
-               out << alignDB.getNumSeqs() << endl;
-               
-               //get first currentRow
-               string first, currentRow, second;
-               float dist;
-               map<string, float> rowDists; //take advantage of the fact that maps are already sorted by key 
-               map<string, float>::iterator it;
-               
-               in >> first;
-               currentRow = first;
-               
-               rowDists[first] = 0.00; //distance to yourself is 0.0
-               
-               in.seekg(0);
-               //m->openInputFile(outfile, in);
-               
-               while(!in.eof()) {
-                       if (m->control_pressed) { in.close(); m->mothurRemove(outfile); out.close(); return 0; }
-                       
-                       in >> first >> second >> dist; m->gobble(in);
-                               
-                       if (first != currentRow) {
-                               //print out last row
-                               out << currentRow << '\t'; //print name
-
-                               //print dists
-                               for (it = rowDists.begin(); it != rowDists.end(); it++) {
-                                       out << it->second << '\t';
-                               }
-                               out << endl;
-                               
-                               //start new row
-                               currentRow = first;
-                               rowDists.clear();
-                               rowDists[first] = 0.00;
-                               rowDists[second] = dist;
-                       }else{
-                               rowDists[second] = dist;
-                       }
-               }
-               //print out last row
-               out << currentRow << '\t'; //print name
-                               
-               //print dists
-               for (it = rowDists.begin(); it != rowDists.end(); it++) {
-                       out << it->second << '\t';
-               }
-               out << endl;
-               
-               in.close();
-               out.close();
-               
-               m->mothurRemove(outfile);
-               
-               return 1;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "convertMatrix");
-               exit(1);
-       }
-}
-**************************************************************************************************
-int DistanceCommand::convertToLowerTriangle(string outputFile) {
-       try{
-
-               //sort file by first column so the distances for each row are together
-               string outfile = m->getRootName(outputFile) + "sorted.dist.temp";
-               
-               //use the unix sort 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       string command = "sort -n " + outputFile + " -o " + outfile;
-                       system(command.c_str());
-               #else //sort using windows sort
-                       string command = "sort " + outputFile + " /O " + outfile;
-                       system(command.c_str());
-               #endif
-               
-
-               //output to new file distance for each row and save positions in file where new row begins
-               ifstream in;
-               m->openInputFile(outfile, in);
-               
-               ofstream out;
-               m->openOutputFile(outputFile, out);
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-
-               out << alignDB.getNumSeqs() << endl;
-               
-               //get first currentRow
-               string first, currentRow, second;
-               float dist;
-               int i, j;
-               i = 0; j = 0;
-               map<string, float> rowDists; //take advantage of the fact that maps are already sorted by key 
-               map<string, float>::iterator it;
-               
-               in >> first;
-               currentRow = first;
-               
-               rowDists[first] = 0.00; //distance to yourself is 0.0
-               
-               in.seekg(0);
-               //m->openInputFile(outfile, in);
-               
-               while(!in.eof()) {
-                       if (m->control_pressed) { in.close(); m->mothurRemove(outfile); out.close(); return 0; }
-                       
-                       in >> first >> second >> dist; m->gobble(in);
-                               
-                       if (first != currentRow) {
-                               //print out last row
-                               out << currentRow << '\t'; //print name
-
-                               //print dists
-                               for (it = rowDists.begin(); it != rowDists.end(); it++) {
-                                       if (j >= i) { break; }
-                                       out << it->second << '\t';
-                                       j++;
-                               }
-                               out << endl;
-                               
-                               //start new row
-                               currentRow = first;
-                               rowDists.clear();
-                               rowDists[first] = 0.00;
-                               rowDists[second] = dist;
-                               j = 0;
-                               i++;
-                       }else{
-                               rowDists[second] = dist;
-                       }
-               }
-               //print out last row
-               out << currentRow << '\t'; //print name
-                               
-               //print dists
-               for (it = rowDists.begin(); it != rowDists.end(); it++) {
-                       out << it->second << '\t';
-               }
-               out << endl;
-               
-               in.close();
-               out.close();
-               
-               m->mothurRemove(outfile);
-               
-               return 1;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "convertToLowerTriangle");
-               exit(1);
-       }
-}
-**************************************************************************************************/
-//its okay if the column file does not contain all the names in the fasta file, since some distance may have been above a cutoff,
-//but no sequences can be in the column file that are not in oldfasta. also, if a distance is above the cutoff given then remove it.
-//also check to make sure the 2 files have the same alignment length.
-bool DistanceCommand::sanityCheck() {
-       try{
-               bool good = true;
-               
-               //make sure the 2 fasta files have the same alignment length
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               int fastaAlignLength = 0;
-               if (in) { 
-                       Sequence tempIn(in);
-                       fastaAlignLength = tempIn.getAligned().length();
-               }
-               in.close();
-               
-               ifstream in2;
-               m->openInputFile(oldfastafile, in2);
-               int oldfastaAlignLength = 0;
-               if (in2) { 
-                       Sequence tempIn2(in2);
-                       oldfastaAlignLength = tempIn2.getAligned().length();
-               }
-               in2.close();
-               
-               if (fastaAlignLength != oldfastaAlignLength) { m->mothurOut("fasta files do not have the same alignment length."); m->mothurOutEndLine(); return false;  }
-               
-               //read fasta file and save names as well as adding them to the alignDB
-               set<string> namesOldFasta;
-               
-               ifstream inFasta;
-               m->openInputFile(oldfastafile, inFasta);
-               
-               while (!inFasta.eof()) {
-                       if (m->control_pressed) {  inFasta.close(); return good;  }
-               
-                       Sequence temp(inFasta);
-                       
-                       if (temp.getName() != "") {
-                               namesOldFasta.insert(temp.getName());  //save name
-                               alignDB.push_back(temp);  //add to DB
-                       }
-                       
-                       m->gobble(inFasta);
-               }
-               
-               inFasta.close();
-               
-               //read through the column file checking names and removing distances above the cutoff
-               ifstream inDist;
-               m->openInputFile(column, inDist);
-               
-               ofstream outDist;
-               string outputFile = column + ".temp";
-               m->openOutputFile(outputFile, outDist);
-               
-               string name1, name2;
-               float dist;
-               while (!inDist.eof()) {
-                       if (m->control_pressed) {  inDist.close(); outDist.close(); m->mothurRemove(outputFile); return good;  }
-               
-                       inDist >> name1 >> name2 >> dist; m->gobble(inDist);
-                       
-                       //both names are in fasta file and distance is below cutoff
-                       if ((namesOldFasta.count(name1) == 0) || (namesOldFasta.count(name2) == 0)) {  good = false; break;  }
-                       else{
-                               if (dist <= cutoff) {
-                                       outDist << name1 << '\t' << name2 << '\t' << dist << endl;
-                               }
-                       }
-               }
-               
-               inDist.close();
-               outDist.close();
-               
-               if (good) {
-                       m->mothurRemove(column);
-                       rename(outputFile.c_str(), column.c_str());
-               }else{
-                       m->mothurRemove(outputFile); //temp file is bad because file mismatch above
-               }
-               
-               return good;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceCommand", "sanityCheck");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
-
-
diff --git a/distancecommand.h b/distancecommand.h
deleted file mode 100644 (file)
index 91f0ed5..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-#ifndef DISTANCECOMMAND_H
-#define DISTANCECOMMAND_H
-
-/*
- *  distancecommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "validcalculator.h"
-#include "dist.h"
-#include "sequencedb.h"
-#include "ignoregaps.h"
-#include "eachgapdist.h"
-#include "eachgapignore.h"
-#include "onegapdist.h"
-#include "onegapignore.h"
-
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct distanceData {
-       int startLine;
-       int endLine;
-       string dFileName;
-       float cutoff;
-       SequenceDB alignDB;
-       vector<string> Estimators;
-       MothurOut* m;
-       string output;
-       int numNewFasta;
-       string countends;
-       
-       distanceData(){}
-       distanceData(int s, int e, string dbname, float c, SequenceDB db, vector<string> Est, MothurOut* mout, string o, int num, string count) {
-               startLine = s;
-               endLine = e;
-               dFileName = dbname;
-               cutoff = c;
-               alignDB = db;
-               Estimators = Est;
-               m = mout;
-               output = o;
-               numNewFasta = num;
-               countends = count;
-               
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyDistThreadFunction(LPVOID lpParam){ 
-       distanceData* pDataArray;
-       pDataArray = (distanceData*)lpParam;
-       
-       try {
-               ValidCalculators validCalculator;
-               Dist* distCalculator;
-               if (pDataArray->m->isTrue(pDataArray->countends) == true) {
-                       for (int i=0; i<pDataArray->Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", pDataArray->Estimators[i]) == true) { 
-                                       if (pDataArray->Estimators[i] == "nogaps")                      {       distCalculator = new ignoreGaps();      }
-                                       else if (pDataArray->Estimators[i] == "eachgap")        {       distCalculator = new eachGapDist();     }
-                                       else if (pDataArray->Estimators[i] == "onegap")         {       distCalculator = new oneGapDist();      }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<pDataArray->Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("distance", pDataArray->Estimators[i]) == true) { 
-                                       if (pDataArray->Estimators[i] == "nogaps")              {       distCalculator = new ignoreGaps();                                      }
-                                       else if (pDataArray->Estimators[i] == "eachgap"){       distCalculator = new eachGapIgnoreTermGapDist();        }
-                                       else if (pDataArray->Estimators[i] == "onegap") {       distCalculator = new oneGapIgnoreTermGapDist();         }
-                               }
-                       }
-               }
-               
-               int startTime = time(NULL);
-               
-               //column file
-               ofstream outFile(pDataArray->dFileName.c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               
-               if (pDataArray->output != "square") { 
-                       if((pDataArray->output == "lt") && (pDataArray->startLine == 0)){       outFile << pDataArray->alignDB.getNumSeqs() << endl;    }
-                       
-                       for(int i=pDataArray->startLine;i<pDataArray->endLine;i++){
-                               if(pDataArray->output == "lt")  {       
-                                       string name = pDataArray->alignDB.get(i).getName();
-                                       if (name.length() < 10) { //pad with spaces to make compatible
-                                               while (name.length() < 10) {  name += " ";  }
-                                       }
-                                       outFile << name << '\t';        
-                               }
-                               for(int j=0;j<i;j++){
-                                       
-                                       if (pDataArray->m->control_pressed) { delete distCalculator; outFile.close(); return 0;  }
-                                       
-                                       //if there was a column file given and we are appending, we don't want to calculate the distances that are already in the column file
-                                       //the alignDB contains the new sequences and then the old, so if i an oldsequence and j is an old sequence then break out of this loop
-                                       if ((i >= pDataArray->numNewFasta) && (j >= pDataArray->numNewFasta)) { break; }
-                                       
-                                       distCalculator->calcDist(pDataArray->alignDB.get(i), pDataArray->alignDB.get(j));
-                                       double dist = distCalculator->getDist();
-                                       
-                                       if(dist <= pDataArray->cutoff){
-                                               if (pDataArray->output == "column") { outFile << pDataArray->alignDB.get(i).getName() << ' ' << pDataArray->alignDB.get(j).getName() << ' ' << dist << endl; }
-                                       }
-                                       if (pDataArray->output == "lt") {  outFile << dist << '\t'; }
-                               }
-                               
-                               if (pDataArray->output == "lt") { outFile << endl; }
-                               
-                               if(i % 100 == 0){
-                                       pDataArray->m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-                               }
-                               
-                       }
-                       pDataArray->m->mothurOut(toString(pDataArray->endLine-1) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-               }else{
-                       if(pDataArray->startLine == 0){ outFile << pDataArray->alignDB.getNumSeqs() << endl;    }
-                       
-                       for(int i=pDataArray->startLine;i<pDataArray->endLine;i++){
-                               
-                               string name = pDataArray->alignDB.get(i).getName();
-                               //pad with spaces to make compatible
-                               if (name.length() < 10) { while (name.length() < 10) {  name += " ";  } }
-                               
-                               outFile << name << '\t';        
-                               
-                               for(int j=0;j<pDataArray->alignDB.getNumSeqs();j++){
-                                       
-                                       if (pDataArray->m->control_pressed) { delete distCalculator; outFile.close(); return 0;  }
-                                       
-                                       distCalculator->calcDist(pDataArray->alignDB.get(i), pDataArray->alignDB.get(j));
-                                       double dist = distCalculator->getDist();
-                                       
-                                       outFile << dist << '\t'; 
-                               }
-                               
-                               outFile << endl; 
-                               
-                               if(i % 100 == 0){
-                                       pDataArray->m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-                               }
-                               
-                       }
-                       pDataArray->m->mothurOut(toString(pDataArray->endLine-1) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-               }
-               
-               outFile.close();
-               delete distCalculator;
-               
-               return 0; 
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "DistanceCommand", "MyDistThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-/**************************************************************************************************/
-class DistanceCommand : public Command {
-
-public:
-       DistanceCommand(string);
-       DistanceCommand();
-       ~DistanceCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "dist.seqs";                   }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD (2010). The effects of alignment quality, distance calculation method, sequence filtering, and region on the analysis of 16S rRNA gene-based studies. PLoS Comput Biol 6: e1000844. \nhttp://www.mothur.org/wiki/Dist.seqs"; }
-       string getDescription()         { return "calculate the pairwaise distances between aligned sequences"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       struct distlinePair {
-               int start;
-               int end;
-               
-       };
-       
-       //Dist* distCalculator;
-       SequenceDB alignDB;
-
-       string countends, output, fastafile, calc, outputDir, oldfastafile, column, compress;
-
-       int processors, numNewFasta;
-       float cutoff;
-       vector<int> processIDS;   //end line, processid
-       vector<distlinePair> lines;
-       
-       bool abort;
-       vector<string>  Estimators, outputNames; //holds estimators to be used
-       
-       //void m->appendFiles(string, string);
-       void createProcesses(string);
-       int driver(/*Dist*, SequenceDB, */int, int, string, float);
-       int driver(int, int, string, string);
-       
-       #ifdef USE_MPI 
-       int driverMPI(int, int, MPI_File&, float);
-       int driverMPI(int, int, string, unsigned long long&);
-       int driverMPI(int, int, string, unsigned long long&, string);
-       #endif
-       
-       //int convertMatrix(string);
-       bool sanityCheck();
-       //int convertToLowerTriangle(string);
-
-};
-
-#endif
-
-/**************************************************************************************************/
-
-
-
diff --git a/distancedb.cpp b/distancedb.cpp
deleted file mode 100644 (file)
index 27e2785..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- *  distancedb.cpp
- *  
- *
- *  Created by Pat Schloss on 12/29/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "database.hpp"
-#include "sequence.hpp"
-#include "distancedb.hpp"
-#include "onegapignore.h"
-
-
-/**************************************************************************************************/
-DistanceDB::DistanceDB() : Database() { 
-       try {
-               templateAligned = true;  
-               templateSeqsLength = 0; 
-               distCalculator = new oneGapIgnoreTermGapDist();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceDB", "DistanceDB");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-void DistanceDB::addSequence(Sequence seq) {
-       try {
-               //are the template sequences aligned
-               if (!isAligned(seq.getAligned())) {
-                       templateAligned = false;
-                       m->mothurOut(seq.getName() + " is not aligned. Sequences must be aligned to use the distance method.");
-                       m->mothurOutEndLine(); 
-               }
-               
-               if (templateSeqsLength == 0) { templateSeqsLength = seq.getAligned().length(); }
-                               
-               data.push_back(seq);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceDB", "addSequence");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-//returns indexes to top matches
-vector<int> DistanceDB::findClosestSequences(Sequence* query, int numWanted){
-       try {
-               vector<int> topMatches;
-               Scores.clear();
-               bool templateSameLength = true;
-               string sequence = query->getAligned();
-               vector<seqDist> dists; 
-               
-               searchScore = -1.0;
-       
-               if (numWanted > data.size()){
-                       m->mothurOut("numwanted is larger than the number of template sequences, using "+ toString(data.size()) + ".");
-                       m->mothurOutEndLine();
-                       numWanted = data.size();
-               }
-               
-               if (sequence.length() != templateSeqsLength) { templateSameLength = false; }
-               
-               if (templateSameLength && templateAligned) {
-                       if (numWanted != 1) {
-                               
-                               dists.resize(data.size());
-                               
-                               //calc distance from this sequence to every sequence in the template
-                               for (int i = 0; i < data.size(); i++) {
-                                       distCalculator->calcDist(*query, data[i]);
-                                       float dist = distCalculator->getDist();
-                                       
-                                       //save distance to each template sequence
-                                       dists[i].seq1 = -1;
-                                       dists[i].seq2 = i;
-                                       dists[i].dist = dist;
-                               }
-                               
-                               sort(dists.begin(), dists.end(), compareSequenceDistance);  //sorts by distance lowest to highest
-                               
-                               //save distance of best match
-                               searchScore = dists[0].dist;
-                               
-                               //fill topmatches with numwanted closest sequences indexes
-                               for (int i = 0; i < numWanted; i++) {
-                                       topMatches.push_back(dists[i].seq2);
-                                       Scores.push_back(dists[i].dist);
-                               }
-                       }else {
-                               int bestIndex = 0;
-                               float smallDist = 100000;
-                               for (int i = 0; i < data.size(); i++) {
-                                       distCalculator->calcDist(*query, data[i]);
-                                       float dist = distCalculator->getDist();
-                                       
-                                       //are you smaller?
-                                       if (dist < smallDist) {
-                                               bestIndex = i;
-                                               smallDist = dist;
-                                       }
-                               }
-                               searchScore = smallDist;
-                               topMatches.push_back(bestIndex);
-                               Scores.push_back(smallDist);
-                       }
-               
-               }else{
-                       m->mothurOut("cannot find closest matches using distance method for " + query->getName() + " without aligned template sequences of the same length.");
-                       m->mothurOutEndLine();
-                       exit(1);
-               }
-               
-               return topMatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceDB", "findClosestSequence");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-bool DistanceDB::isAligned(string seq){
-       try {
-               bool aligned;
-               
-               int pos = seq.find_first_of(".-");
-               
-               if (pos != seq.npos) {
-                       aligned = true;
-               }else { aligned = false; }
-               
-               
-               return aligned;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "DistanceDB", "isAligned");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
diff --git a/distancedb.hpp b/distancedb.hpp
deleted file mode 100644 (file)
index 2624d6d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef DISTANCEDB_HPP
-#define DISTANCEDB_HPP
-
-/*
- *  distancedb.hpp
- *  
- *
- *  Created by westcott on 1/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "dist.h"
-
-class DistanceDB : public Database {
-       
-public:
-       
-       DistanceDB();
-       ~DistanceDB() { delete distCalculator; }
-       
-       void generateDB() {} //doesn't generate a search db 
-       void addSequence(Sequence); 
-       string getName(int i) { return data[i].getName(); } 
-       vector<int> findClosestSequences(Sequence*, int);  // returns indexes of n closest sequences to query
-       
-       #ifdef USE_MPI  
-       int MPISend(int) {return 0;}
-       int MPIRecv(int) {return 0;}
-       #endif
-       
-private:
-       vector<Sequence> data;
-       Dist* distCalculator;
-       
-       int templateSeqsLength;
-       bool templateAligned;
-       
-       bool isAligned(string);
-       
-};
-
-#endif
diff --git a/distclearcut.cpp b/distclearcut.cpp
deleted file mode 100644 (file)
index cf69649..0000000
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * dist.c
- *
- * $Id$
- *
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Compute a distance matrix given a set of sequences
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "common.h"
-#include "dayhoff.h"
-#include "fasta.h"
-#include "distclearcut.h"
-
-
-
-
-/*
- * NJ_build_distance_matrix() - 
- *
- * Given a filename for an alignment, read the alignment
- * into memory and then compute the distance matrix
- * using the appropriate correction model
- */
-DMAT *
-NJ_build_distance_matrix(NJ_ARGS *nj_args) {
-  
-  DMAT *dmat;
-  NJ_alignment *alignment;
-
-  /* Read an alignment in FASTA format */
-  alignment = 
-    NJ_read_fasta(nj_args);
-  if(!alignment) {
-    return(NULL);
-  }
-
-  /* 
-   * Given a global multiple sequence alignment (MSA) and
-   * a specified distance correction model, compute a 
-   * corrected distance matrix
-   *
-   * From proteins, we may want to allow users to specify
-   * a substitution matrix (feature)
-   */
-
-  dmat = 
-    NJ_compute_dmat(nj_args,
-                   alignment);
-
-  // NJ_print_taxanames(dmat);
-
-  if(!dmat) {
-    fprintf(stderr, "Clearcut: Error computing distance matrix\n");
-  }
-  /* now free the memory associated with the alignment */
-  NJ_free_alignment(alignment);
-
-  return(dmat);
-}
-
-
-
-
-
-/* 
- * NJ_compute_dmat() - 
- *
- * Given an alignment and a correction model, compute the 
- * distance matrix and return it
- *
- */
-DMAT *
-NJ_compute_dmat(NJ_ARGS *nj_args,
-               NJ_alignment *alignment) {
-
-  DMAT *dmat;
-  long int i;
-  
-  
-  /* allocate distance matrix here */
-  dmat = (DMAT *)calloc(1, sizeof(DMAT));
-  if(!dmat) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_compute_dmat()\n");
-    return(NULL);
-  }
-  
-  dmat->ntaxa = alignment->nseq;
-  dmat->size  = alignment->nseq;
-
-  /* allocate memory to hold the taxa names */
-  dmat->taxaname = (char **)calloc(alignment->nseq, sizeof(char *));
-  if(!dmat->taxaname) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_compute_dmat()\n");
-    return(NULL);
-  }
-  
-  /* copy sequence titles */
-  for(i=0;i<alignment->nseq;i++) {
-    dmat->taxaname[i] = (char *)calloc(strlen(alignment->titles[i])+1, sizeof(char));
-    if(!dmat->taxaname[i]) {
-      fprintf(stderr, "Clearcut: Memory allocation error in NJ_compute_dmat()\n");
-      return(NULL);
-    }
-
-    strncpy(dmat->taxaname[i], alignment->titles[i], strlen(alignment->titles[i]));
-  }
-
-  /* allocate val matrix in dmat */
-  dmat->val = (float *)calloc(dmat->ntaxa*dmat->ntaxa, sizeof(float));
-
-  if(!dmat->val) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_compute_dmat()\n");
-    return(NULL);
-  }
-
-  /* now lets allocate space for the r and r2 columns */
-  dmat->r  = (float *)calloc(dmat->ntaxa, sizeof(float));
-  dmat->r2 = (float *)calloc(dmat->ntaxa, sizeof(float));
-
-  /* track some memory addresses */
-  dmat->rhandle   = dmat->r;
-  dmat->r2handle  = dmat->r2;
-  dmat->valhandle = dmat->val;
-  
-  /* apply model correction to matrix */
-  switch(nj_args->correction_model) {
-
-  case NJ_MODEL_JUKES:
-    
-    if(nj_args->dna_flag) {
-      NJ_DNA_jc_correction(dmat, alignment);
-    } else if(nj_args->protein_flag) {
-      NJ_PROTEIN_jc_correction(dmat, alignment);
-    } else {
-      fprintf(stderr, "Clearcut: Need to know sequence type for Jukes-Cantor model correction.\n");
-      return(NULL);
-    }
-
-    break;
-
-  case NJ_MODEL_KIMURA:
-
-    if(nj_args->dna_flag) {
-      NJ_DNA_k2p_correction(dmat, alignment);
-    } else if(nj_args->protein_flag) {
-      NJ_PROTEIN_kimura_correction(dmat, alignment);
-    } else {
-      fprintf(stderr, "Clearcut: Need to know sequence type for Kimura model correction.\n");
-      return(NULL);
-    }
-
-    break;
-
-  case NJ_MODEL_NONE:
-
-    NJ_no_correction(dmat, alignment);
-
-    break;
-
-  default:
-    fprintf(stderr, "Clearcut: Invalid distance correction model.\n");
-    return(NULL);
-  }
-  return(dmat);
-}
-
-
-
-
-
-/*
- * NJ_no_correction() - 
- *
- * Compute the distance matrix without correction 
- * (straight percent ID)
- *
- * Resolve ambiguities in sequence data by skipping
- * those nucleotides/residues
- * 
- */
-void
-NJ_no_correction(DMAT *dmat,
-                NJ_alignment *alignment) {
-
-  long int i, j;
-  float pdiff;
-
-  /* compute pairwise percent identity */
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-      pdiff = 1.0 - NJ_pw_percentid(alignment, i, j);      
-      dmat->val[NJ_MAP(i, j, dmat->size)] = pdiff;
-    }
-  }
-  
-  return;
-}
-
-
-
-
-/*
- * NJ_DNA_jc_correction() - 
- *
- * Compute the distance matrix with jukes-cantor correction
- * and assign high distance if sequence divergence exceeds
- * 0.75
- *
- *   Jukes, T.H. (1969), Evolution of protein molecules.  In H.N. Munro (Ed.),
- *   Mammalian Protein Metabolism, Volume III, Chapter 24, pp. 21-132. 
- *   New York: Academic Press
- *
- */
-void
-NJ_DNA_jc_correction(DMAT *dmat,
-                    NJ_alignment *alignment) {
-  
-  long int i, j;
-  long int k;
-  float d, cutoff, dist;
-  long int residues;
-
-  cutoff = 0.75;
-  
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-      
-      k = NJ_pw_differences(alignment, i, j, &residues);
-      d = 1.0 - NJ_pw_percentid(alignment, i, j);      
-      
-      if(d > cutoff) {
-       dist = NJ_BIGDIST;
-      } else {
-       dist = (-0.75) * log(1.0 - (4.0/3.0)*d);
-      }
-      
-      if(fabs(dist) < FLT_EPSILON) {
-       dmat->val[NJ_MAP(i, j, dmat->size)] = 0.0;
-      } else {
-       dmat->val[NJ_MAP(i, j, dmat->size)] = dist;
-      }
-    }
-  }
-
-
-  
-  return;
-}
-
-
-
-
-
-
-/*
- * NJ_PROTEIN_jc_correction() - 
- *
- * This function performs modified jukes/cantor correction on
- * a protein alignment 
- *
- *   Jukes, T.H. (1969), Evolution of protein molecules.  In H.N. Munro (Ed.),
- *   Mammalian Protein Metabolism, Volume III, Chapter 24, pp. 21-132. 
- *   New York: Academic Press
- *
- */
-void
-NJ_PROTEIN_jc_correction(DMAT *dmat,
-                        NJ_alignment *alignment) {
-  
-  long int i, j;
-  long int residues;
-  long int diff;
-  float dist, x;
-  
-
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-
-      diff = NJ_pw_differences(alignment, i, j, &residues);
-      
-      if(!diff || !residues) {
-       dist = 0.0;
-      } else {
-
-       dist = (float)diff/(float)residues;
-       x = ((20.0/19.0)*dist);
-
-       if(NJ_FLT_GT(x, 1.0)) {
-         dist = NJ_BIGDIST;
-       } else {
-         dist = -(19.0/20.0) * log(1.0 - x);
-       }
-      }
-      
-      dmat->val[NJ_MAP(i, j, dmat->size)] = dist;
-    }
-  }
-  
-  return;
-}
-
-
-
-
-
-
-/*
- * NJ_DNA_k2p_correction() -  
- *
- * Correct a distance matrix using k2p correction using
- * cutoffs to avoid problems with logarithms.
- *
- * dist = -0.5ln(1-2P-Q) - 0.25ln(1-2Q)
- *
- * But due to the logarithms, this is only valid when
- *
- * (2P+Q <= 1)  &&  
- * (2Q <= 1)
- *
- * So assign arbitary distances when these constraints are
- * not strictly followed.
- *
- *   Kimura, M. (1980), A simple method for estimating evolutionary
- *   rates of base substitutions through comparative studies of
- *   nucleotide sequences.  J. Mol. Evol., 16, 111-120
- *
- */
-void
-NJ_DNA_k2p_correction(DMAT *dmat,
-                     NJ_alignment *alignment) {
-
-  long int i, j;
-  float P;  /* proportion of transitions   */
-  float Q;  /* proportion of transversions */
-  long int nucleotides;
-  long int transitions, transversions;
-  float dist;
-  float log_x = 0.0;  /* the params for the first log  */
-  float log_y = 0.0;  /* the params for the second log */
-
-  int blowup;   /* a flag to specify if we have a log blowup */
-
-  
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-
-      blowup = 0;
-
-      /* count the number of transitions and transversions */
-      NJ_DNA_count_tt(alignment, i, j, &transitions, &transversions, &nucleotides);
-
-      if(!nucleotides) {   /* sequences have no non-ambiguous overlap in alignment */
-       P = 0.0;
-       Q = 0.0;
-      } else {
-       P = (float)transitions   / (float)nucleotides;
-       Q = (float)transversions / (float)nucleotides;
-      }
-
-      /* the first log blows up if 2*P+Q = 1.0 */
-      if(NJ_FLT_EQ((2.0 * P + Q), 1.0)) {
-       blowup = 1;
-      } else {
-       if( NJ_FLT_LT(1.0 - 2.0*P - Q, 0.0) ) {
-         blowup = 1;
-       } else {
-         log_x = log(1.0 - 2.0*P - Q);
-       }
-      }
-
-      /* the second log blows up if 2*Q >= 1.0 */
-      if( NJ_FLT_EQ((2.0 * Q), 1.0) ||
-         NJ_FLT_GT((2.0 * Q), 1.0) ) {
-       blowup = 1;
-      } else {
-       log_y = log(1.0 - 2.0*Q);
-      }
-      
-      /* if our logarithms blow up, we just set the distance to the max */
-      if(blowup) {
-       dist = NJ_BIGDIST;
-      } else {
-       dist = (-0.5)*log_x - 0.25*log_y;
-      }
-      
-      if(fabs(dist) < FLT_EPSILON) {
-       dmat->val[NJ_MAP(i, j, dmat->size)] = 0.0;
-      } else {
-       dmat->val[NJ_MAP(i, j, dmat->size)] = dist;
-      }
-    }
-  }
-  
-  return;
-}
-
-
-
-
-/*
- * NJ_PROTEIN_kimura_correction() - 
- *
- * Perform Kimura correction for distances derived from protein
- * alignments.
- *
- *   Kimura, M. (1983), The Neutral Theory of Molecular Evolution.
- *   p. 75., Cambridge University Press, Cambridge, England
- *
- */
-void
-NJ_PROTEIN_kimura_correction(DMAT *dmat,
-                            NJ_alignment *alignment) {
-
-  long int i, j;
-  long int residues;
-  long int diff;
-  float dist;
-  
-
-  printf("NJ_PROTEIN_kimura_correction()\n");
-
-  for(i=0;i<dmat->size;i++) {
-    for(j=i+1;j<dmat->size;j++) {
-      diff = NJ_pw_differences(alignment, i, j, &residues);
-      
-      if(!diff || !residues) {
-       dist = 0.0;
-      } else {
-       dist = (float)diff/(float)residues;
-      }
-      
-      if(NJ_FLT_LT(dist, 0.75)) {
-       if(NJ_FLT_GT(dist, 0.0) ) {
-         dist = -log(1.0 - dist - (dist * dist/5.0) );
-       }
-      } else {
-       if(NJ_FLT_GT(dist, 0.93) ) {
-         dist = 10.0; 
-       } else {
-         dist = (float)NJ_dayhoff[ (int)((dist*1000.0)-750.0) ] / 100.0 ;
-       }
-      }
-      
-      dmat->val[NJ_MAP(i, j, dmat->size)] = dist;
-    }
-  }
-  
-  return;
-}
-
-
-
-
-
-/*
- * NJ_DNA_count_tt() - 
- *
- * Count the number of transitions and transversions
- * between two aligned DNA sequences
- *
- * This routine automatically skips ambiguities when
- * counting transitions and transversions.
- *
- */
-void
-NJ_DNA_count_tt(NJ_alignment *alignment,
-               long int x,
-               long int y,
-               long int *transitions,
-               long int *transversions,
-               long int *residues) {
-
-  long int tmp_transitions   = 0;
-  long int tmp_transversions = 0;
-  long int tmp_residues      = 0;
-  char a, b;
-  long int i;
-
-  for(i=0;i<alignment->length;i++) {
-
-    a = toupper(alignment->data[x*alignment->length+i]);
-    b = toupper(alignment->data[y*alignment->length+i]);
-    
-    if( (a == 'A' && b == 'T') ||
-       (a == 'T' && b == 'A') ||
-       (a == 'A' && b == 'C') ||
-       (a == 'C' && b == 'A') ||
-       (a == 'T' && b == 'G') ||
-       (a == 'G' && b == 'T') ||
-       (a == 'C' && b == 'G') ||
-       (a == 'G' && b == 'C') ) {
-      tmp_transversions++;
-    }
-       
-    if( (a == 'C' && b == 'T') ||
-       (a == 'T' && b == 'C') ||
-       (a == 'G' && b == 'A') ||
-       (a == 'A' && b == 'G') ) {
-      tmp_transitions++;
-    }
-
-    /* count the number of residues */
-    if(a != NJ_AMBIGUITY_CHAR &&
-       b != NJ_AMBIGUITY_CHAR ) {
-      tmp_residues++;
-    }
-
-  }
-  
-  *transitions   = tmp_transitions;
-  *transversions = tmp_transversions;
-  
-  if(residues) {
-    *residues = tmp_residues;
-  }
-  
-  return;
-}
-
-
-
-
-
-/*
- * NJ_pw_percentid() - 
- *
- * Given an alignment and a specification
- * for two rows, compute the pairwise
- * percent identity between the two
- *
- */
-float
-NJ_pw_percentid(NJ_alignment *alignment,
-               long int x,
-               long int y) {
-  
-  float pid;
-  long int i;
-  long int residues;
-  long int same;
-  char c1, c2;
-
-  residues = 0;
-  same     = 0;
-  for(i=0;i<alignment->length;i++) {
-
-    c1 = alignment->data[x*alignment->length+i];
-    c2 = alignment->data[y*alignment->length+i];
-    
-    if( c1 != NJ_AMBIGUITY_CHAR ||
-        c2 != NJ_AMBIGUITY_CHAR ) {
-      
-      residues++;
-
-      if(c1 == c2) {
-       same++;
-      }
-    }
-
-  }
-
-  pid = (float)same/(float)residues;
-  
-  return(pid);
-}
-
-
-
-/*
- * NJ_pw_differences() - 
- *
- * Given an alignment and a specification
- * for two rows in the alignment, compute the
- * number of differences between the two sequences
- *
- * With respect to ambiguity codes, we will want to 
- * disregard those sites entirely in our count.
- *
- */
-long int
-NJ_pw_differences(NJ_alignment *alignment,
-                 long int x,
-                 long int y,
-                 long int *residues) {
-
-  long int i;
-  long int diff;
-  char c1, c2;
-  long int tmp_residues;
-  
-  diff         = 0;
-  tmp_residues = 0;
-  for(i=0;i<alignment->length;i++) {
-
-    c1 = alignment->data[x*alignment->length+i];
-    c2 = alignment->data[y*alignment->length+i];
-    
-    if( c1 != NJ_AMBIGUITY_CHAR ||
-        c2 != NJ_AMBIGUITY_CHAR ) {
-      
-      tmp_residues++;
-
-      if(c1 != c2) {
-       diff++;
-      }
-    }
-
-  }
-
-  *residues = tmp_residues;
-
-  return(diff);
-}
-
-
-
-
-
-
diff --git a/distclearcut.h b/distclearcut.h
deleted file mode 100644 (file)
index e4abef2..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * dist.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Compute a distance matrix given a set of sequences
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_DIST_H_
-#define _INC_DIST_H_ 1
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "fasta.h"
-#include "clearcut.h"
-
-
-
-/* 
- * An arbitrarily large distance to represent distances
- * which are too great to accurately correct.
- */
-#define NJ_BIGDIST 10.0  
-
-
-
-/* some function prototypes */
-DMAT *
-NJ_build_distance_matrix(NJ_ARGS *nj_args);
-
-DMAT *
-NJ_compute_dmat(NJ_ARGS *nj_args,
-               NJ_alignment *alignment);
-
-
-float
-NJ_pw_percentid(NJ_alignment *alignment,
-               long int x,
-               long int y);
-
-long int
-NJ_pw_differences(NJ_alignment *alignment,
-                 long int x,
-                 long int y,
-                 long int *residues);
-
-void
-NJ_no_correction(DMAT *dmat,
-                NJ_alignment *alignment);
-
-void
-NJ_DNA_jc_correction(DMAT *dmat,
-                    NJ_alignment *alignment);
-
-void
-NJ_PROTEIN_jc_correction(DMAT *dmat,
-                        NJ_alignment *alignment);
-
-void
-NJ_DNA_k2p_correction(DMAT *dmat,
-                     NJ_alignment *alignment);
-
-void
-NJ_PROTEIN_kimura_correction(DMAT *dmat,
-                            NJ_alignment *alignment);
-
-void
-NJ_DNA_count_tt(NJ_alignment *alignment,
-               long int x,
-               long int y,
-               long int *transitions,
-               long int *transversions,
-               long int *residues);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _INC_DIST_H_ */
-
-
-
-
-
-
-
-
-
diff --git a/dlibshuff.cpp b/dlibshuff.cpp
deleted file mode 100644 (file)
index 4947e05..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *  DLibshuff.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "dlibshuff.h"
-
-/***********************************************************************/
-
-DLibshuff::DLibshuff(FullMatrix* D, int it, float step, float co) : Libshuff(D, it, step, co){
-
-       numDXs = int(cutOff / stepSize);
-
-}
-
-/***********************************************************************/
-
-float DLibshuff::evaluatePair(int i, int j){
-       return dCalculate(i,j);
-}
-
-/***********************************************************************/
-
-vector<vector<double> > DLibshuff::evaluateAll(){
-       savedMins.resize(numGroups);
-       vector<vector<double> > dCXYValues(numGroups);
-       
-       for(int i=0;i<numGroups;i++){
-               savedMins[i].resize(numGroups);
-               dCXYValues[i].resize(numGroups);
-               for(int j=0;j<numGroups;j++){
-                       if(i!=j){       dCXYValues[i][j] = dCalculate(i,j);     }
-                       savedMins[i][i] = minX;
-                       savedMins[i][j] = minXY;
-               }
-       }
-       
-       return dCXYValues;
-}
-
-/***********************************************************************/
-
-double DLibshuff::dCalculate(int x, int y){
-       
-       double sum = 0;
-       
-       minX = getMinX(x);
-       
-       if (m->control_pressed) { return sum; }
-       
-       minXY = getMinXY(x, y);
-       
-       if (m->control_pressed) { return sum; }
-       
-       vector<int> nx = calcN(minX);
-       
-       if (m->control_pressed) { return sum; }
-       
-       vector<int> nxy = calcN(minXY);
-       
-       if (m->control_pressed) { return sum; }
-
-       for(int i=0;i<numDXs;i++){
-               float h = (nx[i] - nxy[i]) / (float) groupSizes[x];
-               sum += h * h * stepSize;
-       }
-
-       return sum;
-}
-
-/***********************************************************************/
-
-vector<int> DLibshuff::calcN(vector<double> minVector){
-
-       vector<int> counts(numDXs,0);
-       
-       int precision = int(1 / stepSize);
-       
-       for(int i=0;i<minVector.size();i++){
-               int bin = int (precision * minVector[i]);
-               if(bin < numDXs){       counts[bin]++;  }
-       }
-
-       for(int i=1;i<numDXs;i++){
-               counts[i] += counts[i-1];
-       }
-       
-       return counts;
-}
-
-/***********************************************************************/
diff --git a/dlibshuff.h b/dlibshuff.h
deleted file mode 100644 (file)
index 402f4f3..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef DLIBSHUFF
-#define DLIBSHUFF
-
-/*
- *  dlibshuff.h
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "fullmatrix.h"
-#include "libshuff.h"
-
-class DLibshuff : public Libshuff {
-
-public:
-       DLibshuff(FullMatrix*, int, float, float);
-       vector<vector<double> > evaluateAll();
-       float evaluatePair(int, int);
-
-private:
-       int numDXs;
-       double dCalculate(int, int);
-       vector<int> calcN(vector<double>);
-};
-
-#endif
diff --git a/dmat.cpp b/dmat.cpp
deleted file mode 100644 (file)
index 64fd67e..0000000
--- a/dmat.cpp
+++ /dev/null
@@ -1,869 +0,0 @@
-/*
- * dmat.c
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Distance matrix parser
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <float.h>
-#include <errno.h>
-#include <string.h>
-
-
-
-#include "common.h"
-#include "clearcut.h"
-
-#include "dmat.h"
-
-
-
-
-
-/*
- *
- * NJ_is_alpha() - determine if character is an alphabetic character
- *
- * INPUT:
- * ------
- *  c -- character to test
- *
- * RETURN:
- * -------
- *   int -- 1 if character is alphabetic (A-Z || a-z)
- *          0 if character is NOT alphabetic
- *
- */
-static inline
-int 
-NJ_is_alpha(char c) {
-
-  if( (c >= 'A' && c <= 'Z') ||
-      (c >= 'a' && c <= 'z') ) {
-    return(1);
-  } else {
-    return(0);
-  }
-}
-
-
-
-/*
- *
- * NJ_is_whitespace() - determine if character is a whitespace character
- *
- * INPUT:
- * ------
- *  c -- character to test
- *
- * RETURN:
- * -------
- *   int -- 1 if character is whitespace (space, tab, CR, LF)
- *          0 if character is NOT whitespace
- *
- */
-static inline
-int
-NJ_is_whitespace(char c) {
-
-  if( c == ' '  ||   /* space           */
-      c == '\n' ||   /* newline         */
-      c == '\r' ||   /* carriage-return */
-      c == '\v' ||   /* vertical tab    */
-      c == '\f' ||   /* form feed       */
-      c == '\t' ) {  /* horizontal tab  */
-    return(1);
-  } else {
-    return(0);
-  }
-
-}
-
-
-
-
-/*
- *
- * NJ_is_number() - determine if character is a number
- *
- * INPUT:
- * ------
- *  c -- character to test
- *
- * RETURN:
- * -------
- *   int -- 1 if character is a number (0-9)
- *          0 if character is NOT a number
- *
- */
-static inline
-int
-NJ_is_number(char c) {
-  if(c >= '0' && c <= '9') {
-    return(1);
-  } else {
-    return(0);
-  }
-}
-
-
-
-/*
- * NJ_is_distance() - check if string is a properly formatted distance value
- *
- */
-static inline
-int
-NJ_is_distance(char *token) {
-  
-  int i;
-  char c;
-  int exponent_state;
-  int expsign_state;
-  int dpoint_state;
-
-  /* if token is NULL return failure */
-  if(!token) {
-    return(0);
-  }
-  
-  exponent_state = 0;
-  expsign_state  = 0;
-  dpoint_state   = 0;
-  
-  /* The first character must be a number, a decimal point or a sign */
-  c = token[0];
-  if(!NJ_is_number(c) &&
-     c != '.'         &&
-     c != '-'         &&
-     c != '+' )  {
-    
-    goto BAD;
-  } 
-  
-  /* 
-   * if the first character is not a number, and string is only one 
-   * character long, then we return failure.
-   */
-  if(strlen(token) == 1) {
-    if(!NJ_is_number(c)) {
-      goto BAD;
-    }
-  }
-  
-  for(i=0;i<strlen(token);i++) {
-
-    c = token[i];
-    
-    /* make sure that all chars in dist string are in list of valid chars */
-    if(!NJ_is_number(c) &&
-       c != '.'         &&
-       c != '-'         &&
-       c != '+'         &&
-       c != 'e'         &&
-       c != 'E'         ) {
-
-      goto BAD;
-    }
-
-    /* not the first char and we are not in exponent state but read (+,-) */
-    if(i>0 && !exponent_state) {
-      if(c == '-' || 
-        c == '+') {
-       goto BAD;
-      }
-    }
-
-    /* if we are in the exponent state, and we've already seen a sign */
-    if(exponent_state && expsign_state) {
-      if(c == '-' ||
-        c == '+') {
-       goto BAD;
-      }
-    }
-    
-    /* if we are in the exponent state and we see a decimal point */
-    if(exponent_state) {
-      if(c == '.') {
-       goto BAD;
-      }
-    }
-    
-    /* if we are in the exponent state and see another e or E */
-    if(exponent_state) {
-      if(c == 'e' ||
-        c == 'E') {
-       goto BAD;
-      }
-    }
-    
-    /* if we are dpoint_state and see another decimal point */
-    if(dpoint_state) {
-      if(c == '.') {
-       goto BAD;
-      }
-    }
-    
-    
-    /* enter the exponent state if we need to */
-    if(!exponent_state) {
-      if(c == 'e' ||
-        c == 'E') {
-       exponent_state = 1;
-      }
-    }
-
-    /* enter the expsign_state if we need to */
-    if(exponent_state && !expsign_state) {
-      if(c == '-' ||
-        c == '+') {
-       expsign_state = 1;
-      }
-    }
-
-    /* if not in dpoint state and we see a dpoint */
-    if(!dpoint_state) {
-      if(c == '.') {
-       dpoint_state = 1;
-      }
-    }
-
-  }
-  
-  /* the token must end in a number char */
-  if(!NJ_is_number(token[strlen(token)-1])) {
-    goto BAD;
-  }
-  
-  /* token is a valid numerical distance */
-  return(1);
-  
- BAD:
-
-  /* token is invalid distance format */
-  return(0);
-}
-
-
-
-
-/*
- * NJ_is_label() - 
- *
- * Simply, if token is not a valid number, then it is a name
- *
- */
-static inline
-int
-NJ_is_label(char *token) {
-  if(NJ_is_distance(token)) {
-    return(0);
-  } else {
-    return(1);
-  }
-}
-
-
-
-/*
- * NJ_get_token() - get a token from an input stream 
- *
- */
-static inline
-int
-NJ_get_token(FILE *fp,
-            NJ_DIST_TOKEN *token) {
-
-  char c;
-  int index;
-
-  c = fgetc(fp);
-  if(feof(fp)) {
-    token->type = NJ_EOF_STATE;
-    return(token->type);
-  }
-
-  if(NJ_is_whitespace(c)) {
-    token->buf[0] = c;
-    token->buf[1] = '\0';
-    token->type   = NJ_WS_STATE;
-
-    return NJ_WS_STATE;
-  } 
-
-  index = 0;
-  while(!NJ_is_whitespace(c)) {
-
-    /* reallocate our buffer if necessary */
-    if(index >= token->bufsize) {
-      token->bufsize *= 2;
-      token->buf = (char *)realloc(token->buf, token->bufsize*sizeof(char));
-      if(!token->buf) {
-       fprintf(stderr, "Clearcut: Memory allocation error in NJ_get_token()\n");
-       exit(-1);
-      }
-    }
-
-    token->buf[index++] = c;
-    
-    c = fgetc(fp);
-    if(feof(fp)) {
-      token->type = NJ_EOF_STATE;
-      break;
-    }
-  }
-  
-  token->buf[index] = '\0';
-  
-  if(token->type != NJ_EOF_STATE) {
-
-    if(NJ_is_distance(token->buf)) {
-      token->type = NJ_FLOAT_STATE;
-    } else {
-      token->type = NJ_NAME_STATE;
-    }
-
-  }
-  
-  return(token->type);
-}
-
-
-
-
-
-/* 
- * NJ_parse_distance_matrix() -- Takes a filename and returns a distance matrix
- *
- *
- * INPUT:
- * ------
- *   nj_args -- a pointer to a structure containing the command-line arguments
- *
- * OUTPUT:
- * -------
- *   <DMAT *> -- NULL  (failure)
- *            -- A pointer to a populated distance matrix
- *
- * DESCRIPTION:
- * ------------
- *   This function implements a simple state machine to parse a distance matrix
- *   in approximate PHYLIP format.  This function auto-detects whether the 
- *   distance matrix is in upper, lower, or fully-symmetric format and handles
- *   it accordingly.  For full/symmetric matrices, values must be symmetric 
- *   around the diagonal, which is required to be zeroes.  Names and values must
- *   be separated by whitespace (space, tab, newlines, etc.).  Taxon labels can
- *   include numbers, but must start with non-numerical symbols.
- *
- *
- *   *** UPPER FORMAT EXAMPLE ***
- * 
- *   4
- *   seq1 0.2 0.3 0.1
- *   seq2     0.2 0.3
- *   seq3         0.1
- *   seq4
- * 
- *   *** LOWER FORMAT EXAMPLE ***
- *
- *   4
- *   seq1
- *   seq2 0.3
- *   seq3 0.2 0.4
- *   seq4 0.3 0.1 0.3
- *
- *   *** SYMMETRIC (FULL) EXAMPLE ***
- *  
- *   4
- *   seq1 0.0 0.3 0.5 0.3
- *   seq2 0.3 0.0 0.1 0.2
- *   seq3 0.5 0.1 0.0 0.9
- *   seq4 0.3 0.2 0.9 0.0
- *
- *  Values in the distance matrix can be positive or negative, integers or
- *  real values.  Values can also be parsed in exponential notation form.
- * 
- */
-DMAT *
-NJ_parse_distance_matrix(NJ_ARGS *nj_args) {
-  
-  DMAT *dmat           = NULL;
-  FILE *fp            = NULL;
-  NJ_DIST_TOKEN *token = NULL;
-
-  int state, dmat_type;
-  int row;
-  int fltcnt;
-  int x, y, i;
-  int numvalread;
-  int expectedvalues = -1;
-  float val;
-  int first_state = 0;
-
-
-  /* allocate our distance matrix and token structure */
-  dmat = (DMAT *)calloc(1, sizeof(DMAT));
-  token = (NJ_DIST_TOKEN *)calloc(1, sizeof(NJ_DIST_TOKEN));
-  if(token) {
-    token->bufsize = NJ_INITIAL_BUFSIZE;
-    token->buf     = (char *)calloc(token->bufsize, sizeof(char));
-  }
-  if(!dmat || !token || !token->buf) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_parse_distance_matrix()\n");
-    goto XIT_BAD;
-  }
-  
-  /* open distance matrix file here */
-  if(nj_args->stdin_flag) {
-    fp = stdin;
-  } else {
-    fp = fopen(nj_args->infilename, "r");
-    if(fp==NULL) {
-      fprintf(stderr, "Clearcut: Could not open distance matrix: %s\n", nj_args->infilename);
-      perror("Clearcut");
-      goto XIT_BAD;
-    }
-  }
-
-  /* get the number of taxa in this file */
-  fscanf(fp, "%ld\n", &dmat->ntaxa);
-  if(dmat->ntaxa < 2) {
-    fprintf(stderr, "Clearcut: Invalid number of taxa in distance matrix\n");
-
-    goto XIT_BAD;
-  }
-
-  /* set our initial working size according to the # of taxa */
-  dmat->size = dmat->ntaxa;
-
-  /* allocate space for the distance matrix values here */
-  dmat->val = 
-    (float *)calloc(NJ_NCELLS(dmat->ntaxa), sizeof(float));
-  if(!dmat->val) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_parse_distance_matrix()\n");
-    goto XIT_BAD;
-  }
-
-  /*  taxa names */
-  dmat->taxaname = (char **)calloc(dmat->ntaxa, sizeof(char *));
-  if(!dmat->taxaname) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_parse_distance_matrix()\n");
-    goto XIT_BAD;
-  }
-
-  /* set the initial state of our state machine */
-  dmat_type   = NJ_PARSE_UNKNOWN;
-  row         = -1;
-  fltcnt      = 0;
-  numvalread  = 0;
-
-
-  /* read the input one character at a time to drive simple state machine */
-  state = NJ_get_token(fp, token);
-  while(state != NJ_EOF_STATE) {
-    
-    switch(state) {
-
-    case NJ_NAME_STATE:
-      
-      if(first_state == 0) {
-       first_state = 1;
-      }
-
-      row++;
-
-      if(row > 0 && dmat_type == NJ_PARSE_UNKNOWN) {
-
-       if(fltcnt == dmat->ntaxa) {
-
-         dmat_type = NJ_PARSE_SYMMETRIC;
-         expectedvalues = dmat->ntaxa * dmat->ntaxa;
-
-       } else if (fltcnt == dmat->ntaxa-1) {
-
-         dmat_type = NJ_PARSE_UPPER;
-         expectedvalues = ((dmat->ntaxa) * (dmat->ntaxa-1)) / 2;
-
-         /* shift everything in first row by one char */
-         for(i=dmat->ntaxa-2;i>=0;i--) {
-           dmat->val[i+1] = dmat->val[i];
-         }
-
-       } else if (fltcnt == 0) {
-
-         dmat_type = NJ_PARSE_LOWER;
-         expectedvalues = ((dmat->ntaxa) * (dmat->ntaxa-1)) / 2;
-
-       } else {
-         goto XIT_BAD;
-       }
-      }
-      
-      if(row >= dmat->ntaxa) {
-       goto XIT_BAD;
-      }
-      
-      /* allocate space for this taxon label */
-      dmat->taxaname[row] = (char *)calloc(strlen(token->buf)+1, sizeof(char));
-      if(!dmat->taxaname[row]) {
-       fprintf(stderr, "Clearcut: Memory allocation error in NJ_parse_distance_matrix()\n");
-       goto XIT_BAD;
-      }
-      
-      strcpy(dmat->taxaname[row], token->buf); 
-      
-      fltcnt = 0;
-
-      break;
-
-
-    case NJ_FLOAT_STATE:
-
-      if(first_state == 0) {
-       goto XIT_BAD;
-      }
-
-      val = atof(token->buf);
-      if(errno) {
-       fprintf(stderr, "Clearcut: Distance value out-of-range.\n");
-       goto XIT_BAD;
-      }
-      
-      x = row;
-      y = fltcnt;
-
-      switch(dmat_type) {
-
-      case NJ_PARSE_UNKNOWN:
-
-       dmat->val[NJ_MAP(x, y, dmat->size)] = val;
-
-       break;
-
-      case NJ_PARSE_SYMMETRIC:
-       
-       if(fltcnt >= dmat->ntaxa) {
-         fprintf(stderr, "Clearcut: Incorrect number of distance values on row.\n");
-         goto XIT_BAD;
-       }
-
-       if(x < y) {
-         dmat->val[NJ_MAP(x, y, dmat->size)] = val;
-       } else if(x > y) {
-         if(!NJ_FLT_EQ(val, dmat->val[NJ_MAP(y, x, dmat->size)])) {
-           fprintf(stderr, "Clearcut: Full matrices must be symmetric.\n");
-           goto XIT_BAD;
-         }
-       } else {
-         if(!NJ_FLT_EQ(val, 0.0)) {
-           fprintf(stderr, "Clearcut: Values along the diagonal in a symmetric matrix must be zero.\n");
-           goto XIT_BAD;
-
-            }
-       }
-
-       break;
-       
-      case NJ_PARSE_UPPER:
-
-       if(fltcnt > dmat->ntaxa-row) {
-         fprintf(stderr, "Clearcut: Incorrect number of distance values on row.\n");
-         goto XIT_BAD;
-       }
-       
-       dmat->val[NJ_MAP(x, x+y+1, dmat->size)] = val;
-       
-       break;
-
-      case NJ_PARSE_LOWER:
-       
-       if(fltcnt > row-1) {
-         fprintf(stderr, "Clearcut: Incorrect number of distance values on row.\n");
-         goto XIT_BAD;
-       }
-
-       dmat->val[NJ_MAP(y, x, dmat->size)] = val;
-       
-       break;
-       
-      default:
-       
-       goto XIT_BAD;
-       
-       break;
-      }
-
-      fltcnt++;
-      numvalread++;
-      
-      break;
-
-    case NJ_WS_STATE:
-
-      break;
-
-    case NJ_EOF_STATE:
-
-      if(first_state == 0) {
-       goto XIT_BAD;
-      }
-
-      break;
-
-    default:
-
-      fprintf(stderr, "Clearcut: Unknown state in distance matrix parser.\n");
-      break;
-
-    }
-
-    /* get next token from stream */
-    state = NJ_get_token(fp, token);
-  }
-
-
-  /* 
-   * At the end, if we have not read the number of values that we predicted
-   * we would need, then there was a problem and we need to punt.
-   */
-  if(numvalread != expectedvalues) {
-    fprintf(stderr, "Clearcut: Incorrect number of values in the distance matrix.\n");
-    goto XIT_BAD;
-  }
-  
-  /* special check to make sure first value read is 0.0 */
-  if(dmat_type == NJ_PARSE_SYMMETRIC) {
-    if(!NJ_FLT_EQ(dmat->val[NJ_MAP(0, 0, dmat->size)], 0.0)) {
-      fprintf(stderr, "Clearcut: Values along the diagonal in a symmetric matrix must be zero.\n");
-      goto XIT_BAD;
-    }
-  }
-
-  
-  /* now lets allocate space for the r and r2 columns */
-  dmat->r  = (float *)calloc(dmat->ntaxa, sizeof(float));
-  dmat->r2 = (float *)calloc(dmat->ntaxa, sizeof(float));
-  if(!dmat->r || !dmat->r2) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_parse_distance_matrix()\n");
-    goto XIT_BAD;
-  }
-  
-  /* track some memory addresses */
-  dmat->rhandle   = dmat->r;
-  dmat->r2handle  = dmat->r2;
-  dmat->valhandle = dmat->val;
-
-  /* close matrix file here */
-  if(!nj_args->stdin_flag) {
-    fclose(fp);
-  }
-  
-  if(token) {
-    if(token->buf) {
-      free(token->buf);
-    }
-    free(token);
-  }
-
-  return(dmat);
-
-
-
-  /* clean up our partial progress */
- XIT_BAD:
-
-  if(fp) {
-    fprintf(stderr, "Clearcut: Syntax error in distance matrix at offset %ld.\n", ftell(fp));
-  }
-
-  /* close matrix file here */
-  if(!nj_args->stdin_flag) {
-    if(fp) {
-      fclose(fp);
-    }
-  }
-
-  /* if we have a valid dmat (partial or complete), we need to free it */
-  if(dmat) {
-    NJ_free_dmat(dmat);
-  }
-  
-  if(token) {
-    if(token->buf) {
-      free(token->buf);
-    }
-    free(token);
-  }
-  
-  return(NULL);
-}
-
-
-
-
-
-
-
-/*
- * NJ_output_matrix() - Output a distance matrix to the specified file 
- *
- *
- * INPUTS:
- * -------
- *  nj_args -- a pointer to a data structure holding the command-line args
- *     dmat -- a pointer to a distance matrix
- *
- *
- * RETURNS:
- * --------
- *   NOTHING
- *
- *
- * DESCRIPTION:
- * ------------
- *   If the appropriate flag was specified in the command-line, this function
- *   now outputs the parsed or computed distance matrix to a file.  This 
- *   can be useful if generating a distance matrix was the primary goal of 
- *   running the program, or if one wanted to debug and/or verify the
- *   correctness of the program.
- *
- *   Currently this function outputs full/symmetric matrices only.
- *
- */
-void
-NJ_output_matrix(NJ_ARGS *nj_args,
-                DMAT *dmat) {
-  
-  FILE *fp = NULL;
-  long int i, j;
-
-
-  
-  /* if we haven't specieid matrixout, return immediately */
-  if(!nj_args->matrixout) {
-    return;
-  }
-  
-  /* open the specified matrix file for writing */
-  fp = fopen(nj_args->matrixout, "w");
-  if(!fp) {
-    fprintf(stderr, "Clearcut: Could not open matrix file %s for output.\n", nj_args->matrixout);
-    return;
-  }
-
-  /* output the number of taxa in the matrix */
-  fprintf(fp, "   %ld\n", dmat->size);
-
-  fprintf(fp, "%s\n", dmat->taxaname[0]); // print the first taxon name outside of the main loop
-
-  for(i=1;i<dmat->size;i++) {
-    
-    /* output taxaname */
-    fprintf(fp, "%s\t", dmat->taxaname[i]);
-
-    for(j=0;j<i;j++) {
-      if(nj_args->expdist) {  /* exponential notation (or not) */
-       fprintf(fp, "%e ", dmat->val[NJ_MAP(j,i,dmat->size)]);  
-      } else {
-       fprintf(fp, "%f ", dmat->val[NJ_MAP(j,i,dmat->size)]);
-      }
-    }
-    
-    fprintf(fp, "\n");
-  }
-
-#ifdef FULL_SYMMETRIC_MATRIX 
-
-  /* output the number of taxa in the matrix */
-  fprintf(fp, "   %ld\n", dmat->size);
-  for(i=0;i<dmat->size;i++) {
-    
-    /* output taxaname */
-    fprintf(fp, "%s\t", dmat->taxaname[i]);
-
-    for(j=0;j<dmat->size;j++) {
-      if(i>j) {
-       if(nj_args->expdist) {  /* exponential notation (or not) */
-         fprintf(fp, "%e ", dmat->val[NJ_MAP(j,i,dmat->size)]);  
-       } else {
-         fprintf(fp, "%f ", dmat->val[NJ_MAP(j,i,dmat->size)]);
-       }
-      } else if(i<j) {
-       if(nj_args->expdist) {  /* exponential notation (or not) */
-         fprintf(fp, "%e ", dmat->val[NJ_MAP(i,j,dmat->size)]);
-       } else {
-         fprintf(fp, "%f ", dmat->val[NJ_MAP(i,j,dmat->size)]);
-       }
-      } else {
-       if(nj_args->expdist) {  /* exponential notation (or not) */
-         fprintf(fp, "%e ", 0.0);
-       } else {
-         fprintf(fp, "%f ", 0.0);
-       }
-      }
-    }
-    
-    fprintf(fp, "\n");
-  }
-
-#endif // FULL_SYMMETRIC_MATRIX
-  
-  /* close the file here */
-  if(fp) {
-    fclose(fp);
-  }
-  
-  return;
-}
-
-
-
-
-
diff --git a/dmat.h b/dmat.h
deleted file mode 100644 (file)
index 04305ab..0000000
--- a/dmat.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * dmat.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Distance matrix parser header file
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- */
-
-
-#ifndef _INC_DMAT_H_
-#define _INC_DMAT_H_ 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "clearcut.h"
-
-
-#define NJ_INITIAL_BUFSIZE 32
-
-#define NJ_NAME_STATE  100
-#define NJ_FLOAT_STATE 101
-#define NJ_WS_STATE    102
-#define NJ_EOF_STATE   103
-
-#define NJ_PARSE_SYMMETRIC 100
-#define NJ_PARSE_LOWER     101
-#define NJ_PARSE_UPPER     102
-#define NJ_PARSE_UNKNOWN   103
-
-
-/* some data structures */
-typedef struct _NJ_DIST_TOKEN_STRUCT {
-  
-  char *buf;
-  long int bufsize;
-  int type;
-
-} NJ_DIST_TOKEN;
-
-
-
-/* some function prototypes */
-
-DMAT *
-NJ_parse_distance_matrix(NJ_ARGS *nj_args);
-
-void
-NJ_output_matrix(NJ_ARGS *nj_args,
-                DMAT *dmat);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _INC_DMAT_H_ */
-
diff --git a/dpbfa.f b/dpbfa.f
deleted file mode 100644 (file)
index 95952c0..0000000
--- a/dpbfa.f
+++ /dev/null
@@ -1,109 +0,0 @@
-      subroutine dpbfa(abd,lda,n,m,info)
-
-      integer lda,n,m,info
-      double precision abd(lda,n)
-c
-c     dpbfa factors a double precision symmetric positive definite
-c     matrix stored in band form.
-c
-c     dpbfa is usually called by dpbco, but it can be called
-c     directly with a saving in time if  rcond  is not needed.
-c
-c     on entry
-c
-c        abd     double precision(lda, n)
-c                the matrix to be factored.  the columns of the upper
-c                triangle are stored in the columns of abd and the
-c                diagonals of the upper triangle are stored in the
-c                rows of abd .  see the comments below for details.
-c
-c        lda     integer
-c                the leading dimension of the array  abd .
-c                lda must be .ge. m + 1 .
-c
-c        n       integer
-c                the order of the matrix  a .
-c
-c        m       integer
-c                the number of diagonals above the main diagonal.
-c                0 .le. m .lt. n .
-c
-c     on return
-c
-c        abd     an upper triangular matrix  r , stored in band
-c                form, so that  a = trans(r)*r .
-c
-c        info    integer
-c                = 0  for normal return.
-c                = k  if the leading minor of order  k  is not
-c                     positive definite.
-c
-c     band storage
-c
-c           if  a  is a symmetric positive definite band matrix,
-c           the following program segment will set up the input.
-c
-c                   m = (band width above diagonal)
-c                   do 20 j = 1, n
-c                      i1 = max0(1, j-m)
-c                      do 10 i = i1, j
-c                         k = i-j+m+1
-c                         abd(k,j) = a(i,j)
-c                10    continue
-c                20 continue
-c
-c     linpack.  this version dated 08/14/78 .
-c     cleve moler, university of new mexico, argonne national lab.
-c
-c     subroutines and functions
-c
-c     blas ddot
-c     fortran max0,sqrt
-c
-c     internal variables
-c
-      double precision ddot,t, a(10), b(10), temp
-      double precision s
-      integer ik,j,jk,k,mu
-c     begin block with ...exits to 40
-c
-c
-          do i = 1, 10
-         a(i) = i
-         b(i) = 2*i
-c         PRINT *, 'a = ', a(i), 'i = ', i
-c         PRINT *, 'b = ', b(i)
-      end do
-         
-         temp = ddot(10,a,1,b,1)
-      
-         do 30 j = 1, n
-            info = j
-            s = 0.0d0
-            ik = m + 1
-            jk = max0(j-m,1)
-            mu = max0(m+2-j,1)
-            if (m .lt. mu) go to 20
-            do 10 k = mu, m
-
-               t = abd(k,j) - ddot(k-mu,abd(ik,jk),1,abd(mu,j),1)
-               t = t/abd(m+1,jk)
-               abd(k,j) = t
-               s = s + t*t
-               ik = ik - 1
-               jk = jk + 1
-   10       continue
-   20       continue
-
-            s = abd(m+1,j) - s
-c     ......exit
-            if (s .le. 0.0d0) go to 40
-
-            abd(m+1,j) = sqrt(s)
-
-   30    continue
-         info = 0
-   40 continue
-      return
-      end
-
diff --git a/dpbsl.f b/dpbsl.f
deleted file mode 100644 (file)
index d910dee..0000000
--- a/dpbsl.f
+++ /dev/null
@@ -1,83 +0,0 @@
-      subroutine dpbsl(abd,lda,n,m,b)
-
-      integer lda,n,m
-      double precision abd(lda,n),b(n)
-c
-c     dpbsl solves the double precision symmetric positive definite
-c     band system  a*x = b
-c     using the factors computed by dpbco or dpbfa.
-c
-c     on entry
-c
-c        abd     double precision(lda, n)
-c                the output from dpbco or dpbfa.
-c
-c        lda     integer
-c                the leading dimension of the array  abd .
-c
-c        n       integer
-c                the order of the matrix  a .
-c
-c        m       integer
-c                the number of diagonals above the main diagonal.
-c
-c        b       double precision(n)
-c                the right hand side vector.
-c
-c     on return
-c
-c        b       the solution vector  x .
-c
-c     error condition
-c
-c        a division by zero will occur if the input factor contains
-c        a zero on the diagonal.  technically this indicates
-c        singularity but it is usually caused by improper subroutine
-c        arguments.  it will not occur if the subroutines are called
-c        correctly and  info .eq. 0 .
-c
-c     to compute  inverse(a) * c  where  c  is a matrix
-c     with  p  columns
-c           call dpbco(abd,lda,n,rcond,z,info)
-c           if (rcond is too small .or. info .ne. 0) go to ...
-c           do 10 j = 1, p
-c              call dpbsl(abd,lda,n,c(1,j))
-c        10 continue
-c
-c     linpack.  this version dated 08/14/78 .
-c     cleve moler, university of new mexico, argonne national lab.
-c
-c     subroutines and functions
-c
-c     blas daxpy,ddot
-c     fortran min0
-c
-c     internal variables
-c
-      double precision ddot,t
-      integer k,kb,la,lb,lm
-c
-c     solve trans(r)*y = b
-c
-      do 10 k = 1, n
-         lm = min0(k-1,m)
-         la = m + 1 - lm
-         lb = k - lm
-         t = ddot(lm,abd(la,k),1,b(lb),1)
-         b(k) = (b(k) - t)/abd(m+1,k)
-   10 continue
-c
-c     solve r*x = y
-c
-      do 20 kb = 1, n
-         k = n + 1 - kb
-         lm = min0(k-1,m)
-         la = m + 1 - lm
-         lb = k - lm
-         b(k) = b(k)/abd(m+1,k)
-         t = -b(k)
-         call daxpy(lm,t,abd(la,k),1,b(lb),1)
-   20 continue
-      return
-      end
-
diff --git a/eachgapdist.h b/eachgapdist.h
deleted file mode 100644 (file)
index 1aca10c..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef EACHGAPDIST_H
-#define EACHGAPDIST_H
-/*
- *  eachgapdist.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "dist.h"
-
-/**************************************************************************************************/
-
-class eachGapDist : public Dist {
-       
-public:
-       
-       eachGapDist() {}
-       
-       void calcDist(Sequence A, Sequence B){          
-               int diff = 0;
-               int length = 0;
-               int start = 0;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-
-               int alignLength = seqA.length();
-               
-               for(int i=0; i<alignLength; i++){
-                       if(seqA[i] != '.' || seqB[i] != '.'){
-                               start = i;
-                               break;
-                       }
-               }
-
-               for(int i=start;i<alignLength;i++){
-                       if(seqA[i] == '.' && seqB[i] == '.'){
-                               break;  
-                       }
-                       else if((seqA[i] == '-' && seqB[i] == '-') || (seqA[i] == '-' && seqB[i] == '.') || (seqA[i] == '.' && seqB[i] == '-')){;}
-                       else{
-                               if(seqA[i] != seqB[i]){
-                                       diff++;
-                               }
-                               length++;
-                       }
-               }
-               
-               if(length == 0) {       dist = 1.0000;                                                          }
-               else                    {       dist = ((double)diff  / (double)length);        }
-       }
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/eachgapdistignorens.h b/eachgapdistignorens.h
deleted file mode 100644 (file)
index 9605a00..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef EACHGAPDISTIGNORENS_H
-#define EACHGAPDISTIGNORENS_H
-
-/*
- *  eachgapdistignorens.h
- *  Mothur
- *
- *  Created by Pat Schloss on 4/20/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "dist.h"
-
-/**************************************************************************************************/
-
-class eachGapDistIgnoreNs : public Dist {
-       
-public:
-       void calcDist(Sequence A, Sequence B){          
-               int diff = 0;
-               int length = 0;
-               int start = 0;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-               
-               int alignLength = seqA.length();
-               
-               for(int i=0; i<alignLength; i++){
-                       if(seqA[i] != '.' || seqB[i] != '.'){
-                               start = i;
-                               break;
-                       }
-               }
-               
-               for(int i=start;i<alignLength;i++){
-                       if(seqA[i] == '.' && seqB[i] == '.'){
-                               break;  
-                       }
-                       else if((seqA[i] == '-' && seqB[i] == '-') || (seqA[i] == '-' && seqB[i] == '.') || (seqA[i] == '.' && seqB[i] == '-') || seqA[i] == 'N' || seqB[i] == 'N'){;}
-                       else{
-                               if(seqA[i] != seqB[i]){
-                                       diff++;
-                               }
-                               length++;
-                       }
-               }
-               
-               if(length == 0) {       dist = 1.0000;                                                          }
-               else                    {       dist = ((double)diff  / (double)length);        }
-       }
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/eachgapignore.h b/eachgapignore.h
deleted file mode 100644 (file)
index 2e7fbd6..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef EACHGAPIGNORE_H
-#define EACHGAPIGNORE_H
-/*
- *  eachgapignore.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "dist.h"
-
-/**************************************************************************************************/
-
-class eachGapIgnoreTermGapDist : public Dist {
-       
-public:
-       eachGapIgnoreTermGapDist() {}
-       eachGapIgnoreTermGapDist(const eachGapIgnoreTermGapDist& ddb) {}
-       
-       void calcDist(Sequence A, Sequence B){          
-               int diff = 0;
-               int length = 0;
-               int start = 0;
-               int end = 0;
-               bool overlap = false;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-               int alignLength = seqA.length();
-               
-               for(int i=0;i<alignLength;i++){
-                       if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
-                               start = i;
-//                             cout << "start: " << start << endl;
-                               overlap = true;
-                               break;
-                       }
-               }
-               for(int i=alignLength-1;i>=0;i--){
-                       if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
-                               end = i;
-//                             cout << "end: " << end << endl;
-                               overlap = true;
-                               break;
-                       }
-               }
-               
-               for(int i=start;i<=end;i++){
-                       if(seqA[i] == '.' || seqB[i] == '.'){
-                               break;  
-                       }
-                       else if(seqA[i] != '-' || seqB[i] != '-'){
-                               if(seqA[i] != seqB[i]){
-                                       diff++;
-                               }
-                               length++;
-                       }
-               }
-               
-               //non-overlapping sequences
-               if (!overlap) { length = 0; }
-               
-               if(length == 0) {       dist = 1.0000;                                                          }
-               else                    {       dist = ((double)diff  / (double)length);        }
-               
-       }
-       
-};
-
-/**************************************************************************************************/
-
-#endif
-
-
diff --git a/efron.cpp b/efron.cpp
deleted file mode 100644 (file)
index 7e1cba8..0000000
--- a/efron.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *  efron.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "efron.h"
-
-/***********************************************************************/
-EstOutput Efron::getValues(SAbundVector* rank){
-
-       try {
-               data.resize(1,0);
-               
-               double n = (double)rank->getNumSeqs();
-               if(f > n || f == 0) {   f = n;  }
-               
-               double sum = 0;
-               for(int i = 1; i < rank->size(); i++){
-                       sum += pow(-1., i+1) * pow(((double)f / n), i) * (double)(rank->get(i));
-               }
-               data[0] = sum;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Efron", "getValues");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
diff --git a/efron.h b/efron.h
deleted file mode 100644 (file)
index e485c53..0000000
--- a/efron.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef EFRON_H
-#define EFRON_H
-
-/*
- *  efron.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the efron calculator on single group. 
- It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Efron : public Calculator  {
-       
-public: 
-       Efron(int size) : f(size), Calculator("efron", 1, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Efron"; }
-private:
-       int f;
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/endiannessmacros.h b/endiannessmacros.h
deleted file mode 100644 (file)
index 581fd6b..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-#ifndef EDIANNESSMACROS_H
-#define EDIANNESSMACROS_H
-
-/*
- *   endiannessmacros.h
- *  Mothur
- *
- *  Created by westcott on 7/9/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-/*********************************************************************/
-/*********************************************************************/
-// The following is copied from the staden io_lib-1.12.4 os.h - thanks!
-/*********************************************************************/
-/*********************************************************************/
-
-/*
- * Author: 
- *         MRC Laboratory of Molecular Biology
- *        Hills Road
- *        Cambridge CB2 2QH
- *        United Kingdom
- *
- * Description: operating system specific type definitions
- *
- */
-
-
-/* Mac FAT binaries or unknown. Auto detect based on CPU type */
-#if !defined(SP_BIG_ENDIAN) && !defined(SP_LITTLE_ENDIAN)
-       
-/*
- * x86 equivalents
- */
-#if  defined(__i386) || defined(__i386__) || defined(__ia64__) ||  defined(WIN32) || defined(__arm__) || (defined(__mips__) && defined(__MIPSEL__)) || defined(__SYMBIAN32__) || \
-     defined(__x86_64__) || defined(__x86_64) || defined(__i686__) || defined(__i686) || defined(__amd64__) || defined(__amd64) || defined(__LITTLE_ENDIAN__)
-#define SP_LITTLE_ENDIAN
-#else
-#define SP_BIG_ENDIAN
-#endif
-
-
-
-/*
- * SUN Sparc
- */
-#if defined(__sparc__) || defined(__sparc)
-#  if defined(SP_LITTLE_ENDIAN)
-#    undef SP_LITTLE_ENDIAN
-#  endif
-#  define SP_BIG_ENDIAN
-#endif
-
-/*
- * PowerPC
- */
-#if defined(__ppc__) || defined(__ppc)
-#  if defined(SP_LITTLE_ENDIAN)
-#    undef SP_LITTLE_ENDIAN
-#  endif
-#  define SP_BIG_ENDIAN
-#endif
-
-/* Some catch-alls */
-#if defined(__LITTLE_ENDIAN__) || defined(__LITTLEENDIAN__)
-#    define SP_LITTLE_ENDIAN
-#endif
-
-#if defined(__BIG_ENDIAN__) || defined(__BIGENDIAN__)
-#    define SP_BIG_ENDIAN
-#endif
-
-#if defined(SP_BIG_ENDIAN) && defined(SP_LITTLE_ENDIAN)
-#    error Both BIG and LITTLE endian defined. Fix os.h and/or Makefile
-#endif
-
-#if !defined(SP_BIG_ENDIAN) && !defined(SP_LITTLE_ENDIAN)
-#    error Neither BIG nor LITTLE endian defined. Fix os.h and/or Makefile
-#endif
-
-#endif
-
-/*-----------------------------------------------------------------------------
- * Byte swapping macros
- */
-
-/*
- * Our new swap runs at the same speed on Ultrix, but substantially faster
- * (300% for swap_int4, ~50% for swap_int2) on an Alpha (due to the lack of
- * decent 'char' support).
- *
- * They also have the ability to swap in situ (src == dst). Newer code now
- * relies on this so don't change back!
- */
-#define iswap_int8(x) \
-    (((x & 0x00000000000000ffLL) << 56) + \
-     ((x & 0x000000000000ff00LL) << 40) + \
-     ((x & 0x0000000000ff0000LL) << 24) + \
-     ((x & 0x00000000ff000000LL) <<  8) + \
-     ((x & 0x000000ff00000000LL) >>  8) + \
-     ((x & 0x0000ff0000000000LL) >> 24) + \
-     ((x & 0x00ff000000000000LL) >> 40) + \
-     ((x & 0xff00000000000000LL) >> 56))
-
-#define iswap_int4(x) \
-    (((x & 0x000000ff) << 24) + \
-     ((x & 0x0000ff00) <<  8) + \
-     ((x & 0x00ff0000) >>  8) + \
-     ((x & 0xff000000) >> 24))
-
-#define iswap_int2(x) \
-    (((x & 0x00ff) << 8) + \
-     ((x & 0xff00) >> 8))
-
-#define swap_int8(src, dst) ((dst) = iswap_int8(src))
-#define swap_int4(src, dst) ((dst) = iswap_int4(src))
-#define swap_int2(src, dst) ((dst) = iswap_int2(src))
-
-
-/*
- * Linux systems may use byteswap.h to get assembly versions of byte-swap
- * on intel systems. This can be as trivial as the bswap opcode, which works
- * out at over 2-times faster than iswap_int4 above.
- */
-#if 0
-#if defined(__linux__)
-#    include <byteswap.h>
-#    undef iswap_int8
-#    undef iswap_int4
-#    undef iswap_int2
-#    define iswap_int8 bswap_64
-#    define iswap_int4 bswap_32
-#    define iswap_int2 bswap_16
-#endif
-#endif
-
-
-/*
- * Macros to specify that data read in is of a particular endianness.
- * The macros here swap to the appropriate order for the particular machine
- * running the macro and return the new answer. These may also be used when
- * writing to a file to specify that we wish to write in (eg) big endian
- * format.
- *
- * This leads to efficient code as most of the time these macros are
- * trivial.
- */
-#ifdef SP_BIG_ENDIAN
-#define be_int8(x) (x)
-#define be_int4(x) (x)
-#define be_int2(x) (x)
-#define be_int1(x) (x)
-
-#define le_int8(x) iswap_int8((x))
-#define le_int4(x) iswap_int4((x))
-#define le_int2(x) iswap_int2((x))
-#define le_int1(x) (x)
-#endif
-
-#ifdef SP_LITTLE_ENDIAN
-#define be_int8(x) iswap_int8((x))
-#define be_int4(x) iswap_int4((x))
-#define be_int2(x) iswap_int2((x))
-#define be_int1(x) (x)
-
-#define le_int8(x) (x)
-#define le_int4(x) (x)
-#define le_int2(x) (x)
-#define le_int1(x) (x)
-#endif
-
-#endif
-
diff --git a/engine.cpp b/engine.cpp
deleted file mode 100644 (file)
index 24adcb5..0000000
+++ /dev/null
@@ -1,615 +0,0 @@
-/*
- *  engine.cpp
- *  
- *
- *  Created by Pat Schloss on 8/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *  There's a TON of duplicated code between InteractEngine and BatchEngine
- *  I couldn't figure out how to transition between ifstream (batch) and cin (interact)
- *  Fix later, don't have time now.
- *
- */
-
-
-#include "engine.hpp"
-
-/***********************************************************************/
-Engine::Engine(){
-       try {
-               cFactory = CommandFactory::getInstance();
-               mout = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "Engine", "Engine");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string Engine::findMothursPath(){
-       try { 
-               
-               string envPath = getenv("PATH");
-               string mothurPath = "";
-               
-               //delimiting path char
-               char delim;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       delim = ':';
-               #else
-                       delim = ';';
-               #endif
-               
-               //break apart path variable by ':'
-               vector<string> dirs;
-               mout->splitAtChar(envPath, dirs, delim);
-               
-               //get path related to mothur
-               for (int i = 0; i < dirs.size(); i++) {
-                       //to lower so we can find it
-                       string tempLower = "";
-                       for (int j = 0; j < dirs[i].length(); j++) {  tempLower += tolower(dirs[i][j]);  }
-                       
-                       //is this mothurs path?
-                       if (tempLower.find("mothur") != -1) {  mothurPath = dirs[i]; break;  }
-               }
-               
-               if (mothurPath != "") {
-                       //add mothur so it looks like what argv would look like
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               mothurPath += "/mothur";
-                       #else
-                               mothurPath += "\\mothur";
-                       #endif
-               }else {
-                       //okay mothur is not in the path, so the folder mothur is in must be in the path
-                       //lets find out which one
-                       
-                       //get path related to mothur
-                       for (int i = 0; i < dirs.size(); i++) {
-                                                               
-                               //is this mothurs path?
-                               ifstream in;
-                               string tempIn = dirs[i];
-                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                       tempIn += "/mothur";
-                               #else
-                                       tempIn += "\\mothur";
-                               #endif
-                               mout->openInputFile(tempIn, in, "");
-                               
-                               //if this file exists
-                               if (in) { in.close(); mothurPath = tempIn;  break;  }
-                       }
-               }
-               
-               return mothurPath;
-               
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "Engine", "findMothursPath");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-InteractEngine::InteractEngine(string path){
-
-       
-       string temppath = path.substr(0, (path.find_last_of("othur")-5));
-       
-       //this will happen if you set the path variable to contain mothur's exe location
-       if (temppath == "") { path = findMothursPath(); }
-       
-       mout->argv = path;
-}
-
-/***********************************************************************/
-
-InteractEngine::~InteractEngine(){}
-
-/***********************************************************************/
-//This function allows the user to input commands one line at a time until they quit.
-//If the command is garbage it does nothing.
-bool InteractEngine::getInput(){
-       try {
-               string input = "";
-               string commandName = "";
-               string options = "";
-               int quitCommandCalled = 0;
-               
-               while(quitCommandCalled != 1){
-
-                       #ifdef USE_MPI
-                               int pid, processors;
-                               MPI_Status status;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               
-                               if (pid == 0) {
-                               
-                       #endif
-                       
-                       mout->mothurOutEndLine();
-                       
-                       input = getCommand();   
-                       mout->mothurOutEndLine();       
-                       
-                       if (mout->control_pressed) { input = "quit()"; }
-                       
-                       //allow user to omit the () on the quit command
-                       if (input == "quit") { input = "quit()"; }
-
-                       
-                       #ifdef USE_MPI
-                               //send commandName
-                               for(int i = 1; i < processors; i++) { 
-                                               int length = input.length();
-                                               MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                               MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
-       
-                                       }
-                               }else {
-                                       int length;
-                                       MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                                       //recieve container
-                                       char* tempBuf = new char[length];
-                                       MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       input = tempBuf;
-                                       if (input.length() > length) { input = input.substr(0, length);  }
-                                       delete tempBuf; 
-                               }
-
-                       
-                       #endif
-               
-                       CommandOptionParser parser(input);
-                       commandName = parser.getCommandString();
-       
-                       options = parser.getOptionString();
-                       
-                       if (commandName != "") {
-                                       mout->executing = true;
-                                       #ifdef USE_MPI
-                                               int pid;
-                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                               
-                                               if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
-                                       //cout << pid << " is in execute " << commandName << endl;
-                                       #endif
-                                       //executes valid command
-                                       mout->runParse = true;
-                                       mout->clearGroups();
-                                       mout->clearAllGroups();
-                                       mout->Treenames.clear();
-                                       mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
-                                       mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
-                                                       
-                                       Command* command = cFactory->getCommand(commandName, options);
-                                       if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
-                                       else { quitCommandCalled = command->execute(); }
-                                                       
-                                       //if we aborted command
-                                       if (quitCommandCalled == 2) {  mout->mothurOut("[ERROR]: did not complete " + commandName + "."); mout->mothurOutEndLine(); }
-
-                                       mout->control_pressed = 0;
-                                       mout->executing = false;
-                                                                               
-                                       #ifdef USE_MPI
-                                               }
-                                       #endif
-                               }else {         
-                                       mout->mothurOut("Invalid."); 
-                                       mout->mothurOutEndLine();
-                               }
-               }       
-               return 1;
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "InteractEngine", "getInput");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string Engine::getCommand()  {
-       try {
-       
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       #ifdef USE_READLINE
-                               char* nextCommand = NULL;
-                               nextCommand = readline("mothur > ");
-                               
-                               if(nextCommand != NULL) {  add_history(nextCommand);  } 
-                               else{ //^D causes null string and we want it to quit mothur
-                                       nextCommand = strdup("quit");
-                                       mout->mothurOut(nextCommand);
-                               }       
-                               
-                               mout->mothurOutJustToLog("mothur > " + toString(nextCommand));
-                               return nextCommand;
-                       #else
-                               string nextCommand = "";
-                               mout->mothurOut("mothur > ");
-                               getline(cin, nextCommand);
-                               mout->mothurOutJustToLog("mothur > " + toString(nextCommand));
-                               
-                               return nextCommand;
-                       #endif
-               #else
-                               string nextCommand = "";
-                               
-                               mout->mothurOut("mothur > ");
-                               getline(cin, nextCommand);
-                               mout->mothurOutJustToLog(toString(nextCommand));
-                               
-                               return nextCommand;
-               #endif
-       
-                                               
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "Engine", "getCommand");
-               exit(1);
-       }
-}
-/***********************************************************************/
-//This function opens the batchfile to be used by BatchEngine::getInput.
-BatchEngine::BatchEngine(string path, string batchFileName){
-       try {
-       
-               openedBatch = mout->openInputFile(batchFileName, inputBatchFile);
-               
-               string temppath = path.substr(0, (path.find_last_of("othur")-5));
-       
-               //this will happen if you set the path variable to contain mothur's exe location
-               if (temppath == "") { path = findMothursPath(); }
-               
-               mout->argv = path;
-                               
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "BatchEngine", "BatchEngine");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-BatchEngine::~BatchEngine(){   }
-
-/***********************************************************************/
-//This Function allows the user to run a batchfile containing several commands on Dotur
-bool BatchEngine::getInput(){
-       try {
-               //check if this is a valid batchfile
-               if (openedBatch == 1) {  
-                       mout->mothurOut("unable to open batchfile");  
-                       mout->mothurOutEndLine();
-                       return 1; 
-               }
-       
-               string input = "";
-               string commandName = "";
-               string options = "";
-               
-               //CommandFactory cFactory;
-               int quitCommandCalled = 0;
-           int count = 0;
-               while(quitCommandCalled != 1){
-                       
-                       #ifdef USE_MPI
-                               int pid, processors;
-                               MPI_Status status;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               
-                               if (pid == 0) {
-                               
-                       #endif
-                       
-                       input = getNextCommand(inputBatchFile);
-                       count++;
-                       
-                       #ifdef USE_MPI
-                               //send commandName
-                               for(int i = 1; i < processors; i++) { 
-                                               int length = input.length();
-                                               MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                               MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
-       
-                                       }
-                               }else {
-                                       int length;
-                                       MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                                       //recieve container
-                                       char* tempBuf = new char[length];
-                                       MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       input = tempBuf;
-                                       if (input.length() > length) { input = input.substr(0, length);  }
-                                       delete tempBuf; 
-                               }
-
-                       
-                       #endif
-
-                       
-                       
-                       if (input[0] != '#') {
-                               
-                               mout->mothurOutEndLine();
-                               mout->mothurOut("mothur > " + input);
-                               mout->mothurOutEndLine();
-                                                       
-                               if (mout->control_pressed) { input = "quit()"; }
-                               
-                               //allow user to omit the () on the quit command
-                               if (input == "quit") { input = "quit()"; }
-
-                               CommandOptionParser parser(input);
-                               commandName = parser.getCommandString();
-                               options = parser.getOptionString();
-                                                                               
-                               if (commandName != "") {
-                                       mout->executing = true;
-                                       #ifdef USE_MPI
-                                               int pid;
-                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                               
-//cout << pid << " is here " << commandName << '\t' << count << endl;
-                                               if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
-                                       #endif
-                                       //executes valid command
-                                       mout->runParse = true;
-                                       mout->clearGroups();
-                                       mout->clearAllGroups();
-                                       mout->Treenames.clear();
-                                       mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
-                                       mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
-
-                                                       
-                                       Command* command = cFactory->getCommand(commandName, options);
-                                       if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
-                                       else { quitCommandCalled = command->execute(); }
-                                                       
-                                       //if we aborted command
-                                       if (quitCommandCalled == 2) {  mout->mothurOut("[ERROR]: did not complete " + commandName + "."); mout->mothurOutEndLine(); }
-
-                                       mout->control_pressed = 0;
-                                       mout->executing = false;
-                                                                               
-                                       #ifdef USE_MPI
-                                               }
-                                       #endif
-                               }else {         
-                                       mout->mothurOut("Invalid."); 
-                                       mout->mothurOutEndLine();
-                               }
-                               
-                       }
-                       mout->gobble(inputBatchFile);
-               }
-               
-               inputBatchFile.close();
-               return 1;
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "BatchEngine", "getInput");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string BatchEngine::getNextCommand(ifstream& inputBatchFile) {
-       try {
-                       
-               string nextcommand = "";
-               
-               if (inputBatchFile.eof()) { nextcommand = "quit()"; }
-               else { nextcommand = mout->getline(inputBatchFile); }
-               
-               return nextcommand;
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "BatchEngine", "getNextCommand");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-/***********************************************************************/
-//This function opens the batchfile to be used by BatchEngine::getInput.
-ScriptEngine::ScriptEngine(string path, string commandString){
-       try {
-               
-               //remove quotes
-               listOfCommands = commandString.substr(1, (commandString.length()-1));
-               
-               string temppath = path.substr(0, (path.find_last_of("othur")-5));
-
-               //this will happen if you set the path variable to contain mothur's exe location
-               if (temppath == "") { path = findMothursPath(); }
-               
-               mout->argv = path;
-                               
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "ScriptEngine", "ScriptEngine");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-ScriptEngine::~ScriptEngine(){         }
-
-/***********************************************************************/
-//This Function allows the user to run a batchfile containing several commands on mothur
-bool ScriptEngine::getInput(){
-       try {
-                       
-               string input = "";
-               string commandName = "";
-               string options = "";
-               
-               
-               //CommandFactory cFactory;
-               int quitCommandCalled = 0;
-       
-               while(quitCommandCalled != 1){
-                       
-                       #ifdef USE_MPI
-                               int pid, processors;
-                               MPI_Status status;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               
-                               if (pid == 0) {
-                               
-                       #endif
-                       
-                       input = getNextCommand(listOfCommands); 
-                       
-                       if (input == "") { input = "quit()"; }
-                       
-                       if (mout->gui) {
-                               if ((input.find("quit") != string::npos) || (input.find("set.logfile") != string::npos)) {}
-                               else if ((input.find("get.current") != string::npos) && (!mout->hasCurrentFiles())) {}
-                               else { mout->mothurOutEndLine(); mout->mothurOut("mothur > " + input); mout->mothurOutEndLine(); }
-                       }else{
-                               mout->mothurOutEndLine(); mout->mothurOut("mothur > " + input); mout->mothurOutEndLine();
-                       }
-                       
-                       #ifdef USE_MPI
-                               //send commandName
-                               for(int i = 1; i < processors; i++) { 
-                                               int length = input.length();
-                                               MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                               MPI_Send(&input[0], length, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
-       
-                                       }
-                               }else {
-                                       int length;
-                                       MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                                       //recieve container
-                                       char* tempBuf = new char[length];
-                                       MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       input = tempBuf;
-                                       if (input.length() > length) { input = input.substr(0, length);  }
-                                       delete tempBuf; 
-                               }
-
-                       
-                       #endif
-                       
-                       
-                       if (mout->control_pressed) { input = "quit()"; }
-                               
-                       //allow user to omit the () on the quit command
-                       if (input == "quit") { input = "quit()"; }
-
-                       CommandOptionParser parser(input);
-                       commandName = parser.getCommandString();
-                       options = parser.getOptionString();
-                                                                               
-                       if (commandName != "") {
-                                       mout->executing = true;
-                                       #ifdef USE_MPI
-                                               int pid, numProcesses;
-                                               
-                                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                               MPI_Comm_size(MPI_COMM_WORLD, &numProcesses); 
-                                       
-//cout << pid << " is here " << commandName  << endl;
-                                               if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
-                                                       //cout << pid << " is in execute" << endl;      
-                                       #endif
-                                       //executes valid command
-                                       mout->runParse = true;
-                                       mout->clearGroups();
-                                       mout->clearAllGroups();
-                                       mout->Treenames.clear();
-                                       mout->saveNextLabel = "";
-                                       mout->printedHeaders = false;
-                                       mout->commandInputsConvertError = false;
-                                       mout->currentBinLabels.clear();
-                                       mout->binLabelsInFile.clear();
-
-                                       Command* command = cFactory->getCommand(commandName, options);
-                                       if (mout->commandInputsConvertError) { quitCommandCalled = 2; }
-                                       else { quitCommandCalled = command->execute(); }
-                                       
-                                       //if we aborted command
-                                       if (quitCommandCalled == 2) {  mout->mothurOut("[ERROR]: did not complete " + commandName + "."); mout->mothurOutEndLine(); }
-                                                       
-                                       mout->control_pressed = 0;
-                                       mout->executing = false;
-                                                                       
-                                       #ifdef USE_MPI
-                                       //cout << pid << " is done in execute" << endl;
-                                               }
-                                       #endif
-                               }else {         
-                                       mout->mothurOut("Invalid."); 
-                                       mout->mothurOutEndLine();
-                               }
-
-                       
-               }
-               
-               return 1;
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "ScriptEngine", "getInput");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string ScriptEngine::getNextCommand(string& commandString) {
-       try {
-               
-               string nextcommand = "";
-               int count = 0;
-               bool ignoreSemiColons = false;
-               
-               //go through string until you reach ; or end
-               while (count < commandString.length()) { 
-                       
-                        //you want to ignore any ; until you reach the next '
-                       if ((commandString[count] == '\'') && (!ignoreSemiColons)) {  ignoreSemiColons = true;  } 
-                       else if ((commandString[count] == '\'') && (ignoreSemiColons)) {  ignoreSemiColons = false;  } 
-                               
-                       if ((commandString[count] == ';') && (!ignoreSemiColons)) {  break;   }
-                       else {          nextcommand += commandString[count];    }
-                       
-                       count++;
-               }
-               
-               //if you are not at the end
-               if (count != commandString.length())  {   commandString = commandString.substr(count+1, commandString.length());  }
-               else { commandString = ""; }
-                               
-               
-               //get rid of spaces in between commands if any
-               if (commandString.length() > 0) {
-                       while (commandString[0] == ' ') {  
-                               commandString = commandString.substr(1,commandString.length());
-                               if (commandString.length() == 0) {  break;  }
-                       }
-               }
-               
-               return nextcommand;
-       }
-       catch(exception& e) {
-               mout->errorOut(e, "ScriptEngine", "getNextCommand");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/engine.hpp b/engine.hpp
deleted file mode 100644 (file)
index 5311da9..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef ENGINE_HPP
-#define ENGINE_HPP
-
-/*
- *  engine.hpp
- *  
- *
- *  Created by Pat Schloss on 8/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "commandoptionparser.hpp"
-#include "command.hpp"
-#include "commandfactory.hpp"
-#include "mothurout.h"
-
-class Engine {
-public:
-       Engine(); 
-       virtual ~Engine(){}
-       virtual bool getInput() = 0;
-       virtual string getCommand();
-       virtual string getOutputDir()                   {       return cFactory->getOutputDir();        }
-       virtual string getLogFileName()                 {       return cFactory->getLogfileName();      }
-       virtual bool getAppend()                                {       return cFactory->getAppend();           }
-
-       vector<string> getOptions()             {       return options;         }
-protected:
-       vector<string> options;
-       CommandFactory* cFactory;
-       MothurOut* mout;
-       string findMothursPath();
-};
-
-
-
-class BatchEngine : public Engine {
-public:
-       BatchEngine(string, string);
-       ~BatchEngine();
-       virtual bool getInput();
-       int openedBatch;
-private:
-       ifstream inputBatchFile;
-       string getNextCommand(ifstream&);
-
-};
-
-
-
-class InteractEngine : public Engine {
-public:
-       InteractEngine(string);
-       ~InteractEngine();
-       virtual bool getInput();
-private:
-       
-};
-
-
-class ScriptEngine : public Engine {
-public:
-       ScriptEngine(string, string);
-       ~ScriptEngine();
-       virtual bool getInput();
-       int openedBatch;
-private:
-       string listOfCommands;
-       string getNextCommand(string&);
-
-};
-
-
-#endif
diff --git a/fasta.cpp b/fasta.cpp
deleted file mode 100644 (file)
index 1dc17fc..0000000
--- a/fasta.cpp
+++ /dev/null
@@ -1,755 +0,0 @@
-/*
- * fasta.c
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Functions for parsing FASTA formatted alignment files
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "clearcut.h"
-#include "common.h"
-#include "fasta.h"
-
-
-#define NJ_NUM_DNA_AMBIGUITY_SYMS 14
-static const char NJ_dna_ambiguity_syms[NJ_NUM_DNA_AMBIGUITY_SYMS] = 
-{
-  'M', 'R', 'W', 'S', 'Y', 'K',
-  'V', 'H', 'D', 'B', 'X', 'N',
-  '-', '.'
-};
-
-
-#define NJ_NUM_PROTEIN_AMBIGUITY_SYMS 6
-static const char NJ_protein_ambiguity_syms[NJ_NUM_PROTEIN_AMBIGUITY_SYMS] =
-{
-  'X', 'B', 'Z', '*', '-', '.'
-};
-
-#define NJ_NUM_DNA_SYMS 5
-static const char NJ_dna_syms[NJ_NUM_DNA_SYMS] = 
-{
-  'A', 'G', 'C', 'T', 'U'
-};
-
-
-#define NJ_NUM_PROTEIN_SYMS 20
-static const char NJ_protein_syms[NJ_NUM_PROTEIN_SYMS] = 
-{
-  'A', 'R', 'N', 'D', 'C', 'Q', 'E', 'G', 'H', 'I', 
-  'L', 'K', 'M', 'F', 'P', 'S', 'T', 'W', 'Y', 'V'
-};
-
-
-
-
-
-/*
- * NJ_is_whitespace() - Check to see if character is whitespace
- *
- * INPUTS:
- * -------
- *     c -- character to check
- *
- * RETURNS:
- * --------
- *    int -- 0 if not whitespace
- *           1 if whitespace
- */
-static inline
-int
-NJ_is_whitespace(char c) {
-  if( c == ' '  ||   /* space           */
-      c == '\n' ||   /* newline         */
-      c == '\r' ||   /* carriage-return */
-      c == '\v' ||   /* vertical tab    */
-      c == '\f' ||   /* form feed       */
-      c == '\t' ) {  /* horizontal tab  */
-    return(1);
-  } else {
-    return(0);
-  }
-}
-
-
-
-
-
-/*
- * NJ_is_dna() - 
- *
- * Determines if the given symbol is DNA
- *
- * RETURNS: 1 if DNA
- *          0 if not DNA
- *
- */
-static inline
-int
-NJ_is_dna(char c) {
-
-  int i;
-  char up_c;
-  
-  up_c = toupper(c);
-  
-  for(i=0;i<NJ_NUM_DNA_SYMS;i++) {
-    if(up_c == NJ_dna_syms[i]) {
-      return(1);
-    }
-  }
-
-  return(0);
-}
-
-
-
-
-
-/*
- * NJ_is_dna_ambiguity() - 
- *
- * Determines if the given symbol is a 
- * DNA ambiguity code
- *
- * RETURNS: 1 if DNA Ambiguity Code
- *          0 if not DNA Ambiguity Code
- *
- */
-static inline
-int
-NJ_is_dna_ambiguity(char c) {
-  
-  int i;
-  char up_c;
-  
-  up_c = toupper(c);
-  
-  for(i=0;i<NJ_NUM_DNA_AMBIGUITY_SYMS;i++) {
-    if(up_c == NJ_dna_ambiguity_syms[i]) {
-      return(1);
-    }
-  }
-  
-  return(0);
-}
-
-
-
-/*
- * NJ_is_protein() - 
- *
- * Determines if supplied symbol is amino acid symbol
- *
- * RETURNS: 1 if amino acid
- *          0 if not amino acid
- *
- */
-static inline
-int
-NJ_is_protein(char c) {
-
-  int i;
-  char up_c;
-  
-  up_c = toupper(c);
-  
-  for(i=0;i<NJ_NUM_PROTEIN_SYMS;i++) {
-    if(up_c == NJ_protein_syms[i]) {
-      return(1);
-    }
-  }
-  
-  return(0);
-}
-
-
-
-
-/*
- * NJ_is_protein_ambiguity() - 
- *
- * Determines if supplied symbol is amino acid ambiguity symbol
- *
- * RETURNS: 1 if amino acid ambiguity symbol
- *          0 if not amino acid ambiguity symbol
- *
- */
-static inline
-int 
-NJ_is_protein_ambiguity(char c) {
-
-  int i;
-  char up_c;
-  
-  up_c = toupper(c);
-
-  for(i=0;i<NJ_NUM_PROTEIN_AMBIGUITY_SYMS;i++) {
-    if(up_c == NJ_protein_ambiguity_syms[i]) {
-      return(1);
-    }
-  }
-  
-  return(0);
-}
-
-
-
-
-
-
-/*
- * NJ_read_fasta() - A function for inputing FASTA sequences into an alignment
- *                   data structure
- *
- *
- * INPUTS:
- * -------
- *   nj_args -- A pointer to a data structure containing command-line args
- *
- * RETURNS:
- * --------
- *   NJ_alignment * -- A pointer to a multiple sequence alignment
- *
- * DESCRIPTION:
- * ------------
- *
- * 
- * This function implements a state machine parser for parsing FASTA-formatted
- * multiple sequence alignment files.  
- * 
- * Example Input:
- *
- *   > sequence1
- *   ATAGATATAGATTAGAATAT----TATAGATAT----ATATAT-TTT-
- *   > sequence2 
- *   --ATAGATA---ATATATATATTTT--GTCTCATAGT---ATATGCTT
- *   > sequence3
- *   TTATAGATA---ATATATATATTTTAAGTCTCATAGT-A-ATATGC--
- * 
- * This function will parse alignments for DNA or protein, and will do
- * so mindful of ambiguity codes for these kinds of sequences.  All 
- * ambiguity codes are ignored by this program for the purposes of 
- * computing a distance matrix from a multiple alignment.  By design, 
- * this program does not auto-detect DNA vs. Protein, and requires that 
- * the user explictly specify that on the command-line.
- *
- * Gaps can be represented either with the '-' or '.' characters.
- * 
- * Newlines and other whitespace are allowed to be interspersed 
- * throughout the sequences.
- *
- * Taxon labels are required to be unique, and they must start with 
- * an alphabetic character (not a number, etc.).  The parser will read
- * the first token after the > character in the description line up until the
- * first whitespace and use that for the taxon label.
- *
- * For example, in the line "> taxon1 is homo sapien", the taxon label will be 
- * "taxon1"
- *
- */
-NJ_alignment *
-NJ_read_fasta(NJ_ARGS *nj_args) {
-
-  FILE *fp  = NULL;
-  char *buf = NULL;
-  char *ptr = NULL;
-  NJ_alignment *alignment = NULL;
-
-  char c;
-  int state;
-  long int index, x, seq;
-  long int i;
-  long int bufsize, nseqs = NJ_INITIAL_NSEQS;
-  int first_sequence_flag;
-
-
-  
-
-  /* 
-   * In this function, we implement a FASTA alignment parser which
-   * reads in an alignment character-by-character, maintaining state
-   * information which guides the parser.
-   *
-   * The program reads either DNA or Protein alignments.  All title lines
-   * and sequences can be arbitrarily long.  Gaps can be represented by 
-   * "-" or "." characters.  
-   *
-   * Ambiguity codes are also handled.
-   * 
-   */
-
-  /* 
-   * We can't handle reading fasta input unless the user explicity 
-   * specifies the input type...just to be sure.
-   */
-  if( (!nj_args->dna_flag && !nj_args->protein_flag) ||
-      (nj_args->dna_flag  &&  nj_args->protein_flag) ) {
-    fprintf(stderr, "Clearcut: Explicitly specify protein or DNA\n");
-    goto XIT_BAD;
-  }
-
-  /* open specified fasta file here */
-  if(nj_args->stdin_flag) {
-    fp = stdin;
-  } else {
-    fp = fopen(nj_args->infilename, "r");
-    if(!fp) {
-      fprintf(stderr, "Clearcut: Failed to open input FASTA file: %s\n", nj_args->infilename);
-      perror("Clearcut");
-      goto XIT_BAD;
-    }
-  }
-
-  /* allocate the initial buffer */
-  bufsize = NJ_INITIAL_BUFFER_SIZE;
-  buf = (char *)calloc(bufsize, sizeof(char));
-  
-  /* allocate the alignment container here */
-  alignment = (NJ_alignment *)calloc(1, sizeof(NJ_alignment));
-  
-  /* allocate initial title array */
-  //  printf("allocating initial title array\n");
-  alignment->titles = (char **)calloc(NJ_INITIAL_NSEQS, sizeof(char *));
-
-  /* make sure that we successfully allocated memory */
-  if(!buf || !alignment || !alignment->titles) {
-    fprintf(stderr, "Clearcut: Memory allocation error in NJ_read_fasta()\n");
-    goto XIT_BAD;
-  }
-
-  /* a flag */
-  first_sequence_flag = 1;  
-  
-  index  = 0;  /* tracks the position in buffer     */
-  x      = 0;  /* tracks the position on sequence   */
-  seq    = 0;  /* tracks the active sequence        */
-
-  /* intitial state of state machine */
-  state  = NJ_FASTA_MODE_UNKNOWN;
-
-  while(1) {
-    
-    /* get the next character */
-    c = fgetc(fp);
-    if(feof(fp)) {
-
-      if(state == NJ_FASTA_MODE_SEQUENCE) {
-       buf[index+1] = '\0';
-
-       /* copy buf to alignment */
-       for(i=1;i<=alignment->length;i++) {
-         alignment->data[seq*alignment->length+i-1] = buf[i];
-       }
-      }
-
-      break;
-    }
-
-    /* make sure our dynamic buffer is big enough */
-    if(index >= bufsize) {
-      bufsize *= 2;
-      buf = (char *)realloc(buf, bufsize);
-      if(!buf) {
-       fprintf(stderr, "Clearcut: Memory allocation error in NJ_read_fasta()\n");
-       goto XIT_BAD;
-      }
-    }
-
-    switch(state) {
-      
-    case NJ_FASTA_MODE_UNKNOWN:
-      
-      if(!NJ_is_whitespace(c)) {
-       if(c == '>') {
-         state = NJ_FASTA_MODE_TITLE;
-         buf[0] = '>';
-       } else {
-         goto XIT_BAD;
-       }
-      }
-
-      break;
-
-    case NJ_FASTA_MODE_TITLE:
-
-      if( c == '\n' ||
-         c == '\r' ) {
-
-       buf[index] = '\0';
-       state = NJ_FASTA_MODE_SEQUENCE;
-       index = 0;
-       x     = -1;
-
-       /* make sure we've allocated enough space for titles and sequences */
-       if(seq == nseqs) {
-
-         //      printf("realloc().  seq = %d, nseqs = %d\n", seq, nseqs);
-
-         nseqs *= 2;
-
-         alignment->titles = (char **)realloc(alignment->titles, nseqs*sizeof(char *));
-         if(!alignment->titles) {
-           fprintf(stderr, "Clearcut:  Memory allocation error in NJ_read_fasta()\n");
-           goto XIT_BAD;
-         }
-
-         alignment->data = (char *)realloc(alignment->data, alignment->length*nseqs*sizeof(char));
-         if(!alignment->data) {
-           fprintf(stderr, "Clearcut: Allocation error in NJ_read_fasta()\n");
-           goto XIT_BAD;
-         }
-       }
-
-       // printf("Allocating %d bytes for title %d: %s\n", (int)strlen(buf), (int)seq, buf);
-
-       alignment->titles[seq] = (char *)calloc(strlen(buf), sizeof(char));
-       if(!alignment->titles[seq]) {
-         fprintf(stderr, "Clearcut:  Memory allocation error in NJ_read_fasta()\n");
-         goto XIT_BAD;
-       }
-
-       /* lets forward to the first non-space (space/tab) character after the '>' */
-
-       if(first_sequence_flag) {
-         ptr = buf;
-       } else {
-         ptr = &buf[1];
-       }
-       while(*ptr == '\t' || *ptr == ' ') {
-         ptr++;
-       }
-       sscanf(ptr, "%s", alignment->titles[seq]);  /* get the first word and use as the title */
-
-       alignment->nseq++;
-      }
-       
-      buf[index++] = c;
-
-      break;
-
-
-    case NJ_FASTA_MODE_SEQUENCE:
-
-      if(c == '>') {
-
-       if(first_sequence_flag) {
-         first_sequence_flag = 0;
-
-         /* allocate our alignment data section here */
-         alignment->length = index-1;
-
-         nseqs = NJ_INITIAL_NSEQS;
-         alignment->data = (char *)calloc(alignment->length*nseqs, sizeof(char));
-         if(!alignment->data) {
-           fprintf(stderr, "Clearcut: Allocation error in NJ_read_fasta()\n");
-           goto XIT_BAD;
-         }
-       } 
-       
-       if(!first_sequence_flag) {
-         if(index-1 < alignment->length) {
-           fprintf(stderr, "Clearcut: Sequences must be of uniform length in alignment at sequence %ld\n", seq);
-           goto XIT_BAD;
-         }
-       }
-
-       /* re-allocate if necessary */
-       /*
-       if(seq >= nseqs) {
-         nseqs *= 2;
-         alignment->data = (char *)realloc(alignment->data, alignment->length*nseqs*sizeof(char));
-         if(!alignment->data) {
-           fprintf(stderr, "Clearcut: Allocation error in NJ_read_fasta()\n");
-           goto XIT_BAD;
-         }
-       }
-       */
-
-       /* copy buf to alignment */
-       for(i=1;i<=alignment->length;i++) {
-         alignment->data[seq*alignment->length+i-1] = buf[i];
-       }
-         
-       state = NJ_FASTA_MODE_TITLE;
-       index = 1;
-       x     = 1;
-         
-       buf[0] = c;
-       
-       seq++;
-
-      } else {
-         
-       if(NJ_is_whitespace(c)) {
-         break;
-       }
-               
-       if(!first_sequence_flag) {
-         if(index-1 >= alignment->length) {
-           fprintf(stderr, "Clearcut: Sequences must be of uniform length in alignment at sequence %ld\n", seq);
-           goto XIT_BAD;
-         }
-       }
-
-
-       /* 
-        * Here we check to make sure that the symbol read is appropriate
-        * for the type of data the user specified.  (dna or protein).
-        * We also handle ambiguity codes by converting them to a specific
-        * assigned ambiguity code character.  Ambiguity codes are ignored
-        * when computing distances
-        */
-
-       if(nj_args->dna_flag) {
-         if(NJ_is_dna(c)) {
-           buf[index++] = toupper(c);
-         } else {
-           if(NJ_is_dna_ambiguity(c)) {
-             buf[index++] = NJ_AMBIGUITY_CHAR;
-           } else {
-             fprintf(stderr, "Clearcut: Unknown symbol '%c' in nucleotide sequence %ld.\n", c, seq);
-             goto XIT_BAD;
-           }
-         }
-       } else if(nj_args->protein_flag) {
-         if(NJ_is_protein(c)) {
-           buf[index++] = toupper(c);
-         } else {
-           if(NJ_is_protein_ambiguity(c)) {
-             buf[index++] = NJ_AMBIGUITY_CHAR;
-           } else {
-             fprintf(stderr, "Clearcut: Unknown symbol '%c' in protein sequence %ld.\n", c, seq);
-             goto XIT_BAD;
-           }
-         }
-       }
-
-      }
-
-      break;
-       
-    default:
-      goto XIT_BAD;
-       
-      break;
-
-    }
-  }
-  
-  if(index-1 != alignment->length) {
-    fprintf(stderr, "Clearcut: Sequences must be of uniform length in alignment at sequence %ld\n", seq);
-    goto XIT_BAD;
-  }
-  
-  /* check for duplicate taxon labels */
-  if(!NJ_taxaname_unique(alignment)) {
-    goto XIT_BAD;
-  }
-  
-  return(alignment);
-
-  
- XIT_BAD:
-
-  if(fp) {
-    fprintf(stderr, "Clearcut: Fatal error parsing FASTA file at file offset %ld.\n", ftell(fp));
-  }
-  
-  if(buf) {
-    free(buf);
-  }
-  
-  NJ_free_alignment(alignment);
-
-  return(NULL);
-}
-
-
-
-
-/*
- * NJ_print_alignment() - Print multiple sequence alignment (for debugging)
- *
- * INPUTS:
- * -------
- *    alignment -- A pointer to the alignment
- *
- * RETURNS:
- * --------
- *    NONE
- *
- */
-void
-NJ_print_alignment(NJ_alignment *alignment) {
-  
-  long int i, j;
-  
-  printf("nseq = %ld, length = %ld\n", alignment->nseq, alignment->length);
-  
-  for(i=0;i<alignment->nseq;i++) {
-    
-    printf("> %s\n", alignment->titles[i]);
-
-    for(j=0;j<alignment->length;j++) {
-      printf("%c", alignment->data[i*alignment->length+j]);
-    }
-
-    printf("\n");
-  }
-
-  return;
-}
-
-
-
-
-
-
-
-/*
- *
- * NJ_free_alignment() - Free all of the memory allocated for the
- *                       multiple sequence alignment 
- *
- * INPUTS:
- * -------
- *   alignment -- A pointer to the multiple sequence alignment
- *
- * RETURNS:
- * --------
- *    NONE
- *
- */
-void
-NJ_free_alignment(NJ_alignment *alignment) {
-  
-  long int i;
-  
-  if(alignment) {
-
-    /* free the allocated titles */
-    if(alignment->titles) {
-      for(i=0;i<alignment->nseq;i++) {
-
-       if(alignment->titles[i]) {
-         free(alignment->titles[i]);
-       }
-      }
-      
-      free(alignment->titles);
-    }
-
-    /* free the alignment data */
-    if(alignment->data) {
-      free(alignment->data);
-    }
-
-    /* free the alignment itself */
-    free(alignment);
-  }
-
-  return;
-}
-
-
-
-
-/*
- * NJ_taxaname_unique() - Check to see if taxanames are unique in alignment
- *
- * INPUTS:
- * -------
- *  alignment -- a pointer to a multiple sequence alignment
- *
- * OUTPUTS:
- * --------
- *  int -- 0 if all taxanames in alignment are unique
- *         1 if all taxanames in alignment are NOT unique
- *
- *
- * DESCRIPTION:
- * ------------
- *
- * Check to see if the taxanames in the alignment are unique.  It
- * will be impossible to make sense of the final tree if the taxon
- * labels are not unqiue.
- *
- */
-int
-NJ_taxaname_unique(NJ_alignment *alignment) {
-  
-  long int i, j;
-  
-  for(i=0;i<alignment->nseq;i++) {
-    for(j=i+1;j<alignment->nseq;j++) {
-        if(!strcmp(alignment->titles[i], 
-                alignment->titles[j])) {
-       fprintf(stderr, "Clearcut: Taxa %ld and %ld (%s) do not have unique taxon labels.\n", 
-               i, j, alignment->titles[i]);
-       return(0);
-      }
-    }
-  }
-  
-  return(1);
-}
-
-
-void
-NJ_print_titles(NJ_alignment *alignment) {
-
-  int i;
-
-  for(i=0;i<alignment->nseq;i++) {
-    printf("%d: %s\n", i, alignment->titles[i]);
-  }
-
-  return;
-}
diff --git a/fasta.h b/fasta.h
deleted file mode 100644 (file)
index 8b9e3d6..0000000
--- a/fasta.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * fasta.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_NJ_FASTA_H_
-#define _INC_NJ_FASTA_H_ 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "clearcut.h"
-
-#define NJ_INITIAL_BUFFER_SIZE   512
-#define NJ_INITIAL_NSEQS         64
-
-#define NJ_FASTA_MODE_TITLE      100
-#define NJ_FASTA_MODE_SEQUENCE   101
-#define NJ_FASTA_MODE_NEWLINE    102
-#define NJ_FASTA_MODE_UNKNOWN    103
-
-
-typedef struct _STRUCT_NJ_ALIGNMENT {
-
-  long int nseq;
-  long int length;
-  
-  char **titles;
-  
-  char *data;
-
-} NJ_alignment;
-
-
-NJ_alignment *
-NJ_read_fasta(NJ_ARGS *nj_args);
-
-void
-NJ_print_alignment(NJ_alignment *alignment);
-
-void
-NJ_free_alignment(NJ_alignment *alignment);
-
-int
-NJ_taxaname_unique(NJ_alignment *alignment);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _INC_NJ_FASTA_H_ */
-
-
-
-
diff --git a/fastamap.cpp b/fastamap.cpp
deleted file mode 100644 (file)
index bf55493..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- *  fastamap.cpp
- *  mothur
- *
- *  Created by Sarah Westcott on 1/16/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-
-#include "fastamap.h"
-#include "sequence.hpp"
-
-/*******************************************************************************/
-
-void FastaMap::readFastaFile(string inFileName) {
-       try {
-               ifstream in;
-               m->openInputFile(inFileName, in);
-               string name, sequence, line;
-               sequence = "";
-               string temp;
-               map<string, string>::iterator itName;
-               
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               if(currSeq.getIsAligned())      {       sequence = currSeq.getAligned();        }
-                               else                                            {       sequence = currSeq.getUnaligned();      }
-                               
-                               itName = seqmap.find(name);
-                               if (itName == seqmap.end()) { seqmap[name] = sequence;  }
-                               else { m->mothurOut("You already have a sequence named " + name + ", sequence names must be unique, please correct."); m->mothurOutEndLine(); }
-                               
-                               map<string,group>::iterator it = data.find(sequence);
-                               if (it == data.end()) {         //it's unique.
-                                       data[sequence].groupname = name;  //group name will be the name of the first duplicate sequence found.
-                                       //                              data[sequence].groupnumber = 1;
-                                       data[sequence].names = name;
-                               }else { // its a duplicate.
-                                       data[sequence].names += "," + name;
-                                       //                              data[sequence].groupnumber++;
-                               }       
-                       }
-                       m->gobble(in);
-               }
-               in.close();             
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FastaMap", "readFastaFile");
-               exit(1);
-       }
-}
-
-/*******************************************************************************/
-
-void FastaMap::readFastaFile(string inFastaFile, string oldNameFileName){ //prints data
-       
-       ifstream oldNameFile;
-       m->openInputFile(oldNameFileName, oldNameFile);
-       
-       map<string,string> oldNameMap;
-       map<string, string>::iterator itName;
-       string name, list;
-       while(!oldNameFile.eof()){
-               if (m->control_pressed) { break; }
-               
-               oldNameFile >> name; m->gobble(oldNameFile);
-               oldNameFile >> list;
-               oldNameMap[name] = list;
-               m->gobble(oldNameFile);
-       }
-       oldNameFile.close();
-       
-       ifstream inFASTA;
-       m->openInputFile(inFastaFile, inFASTA);
-       string sequence;
-       while(!inFASTA.eof()){
-               if (m->control_pressed) { break; }
-               
-               Sequence currSeq(inFASTA);
-               name = currSeq.getName();
-               
-               if (name != "") {
-                       if(currSeq.getIsAligned())      {       sequence = currSeq.getAligned();        }
-                       else                                            {       sequence = currSeq.getUnaligned();      }
-                       
-                       itName = seqmap.find(name);
-                       if (itName == seqmap.end()) { seqmap[name] = sequence;  }
-                       else { m->mothurOut("You already have a sequence named " + name + ", sequence names must be unique, please correct."); m->mothurOutEndLine(); }
-                       
-                       seqmap[name] = sequence;  
-                       map<string,group>::iterator it = data.find(sequence);
-                       if (it == data.end()) {         //it's unique.
-                               data[sequence].groupname = name;  //group name will be the name of the first duplicate sequence found.
-                               //                      data[sequence].groupnumber = 1;
-                               data[sequence].names = oldNameMap[name];
-                       }else { // its a duplicate.
-                               data[sequence].names += "," + oldNameMap[name];
-                               //                      data[sequence].groupnumber++;
-                       }       
-               }
-               m->gobble(inFASTA);
-       }
-       
-       
-       inFASTA.close();
-}
-
-/*******************************************************************************/
-
-string FastaMap::getGroupName(string seq) {  //pass a sequence name get its group
-       return data[seq].groupname;
-}
-
-/*******************************************************************************/
-
-string FastaMap::getNames(string seq) {        //pass a sequence get the string of names in the group separated by ','s.
-       return data[seq].names;
-}
-
-/*******************************************************************************/
-
-string FastaMap::getSequence(string name) {
-       
-       map<string,string>::iterator it = seqmap.find(name);
-       if (it == seqmap.end()) {       return "not found";             }
-       else                                    {       return it->second;              }
-       
-}      
-
-/*******************************************************************************/
-
-void FastaMap::push_back(string name, string seq) {
-       
-       map<string,group>::iterator it = data.find(seq);
-       if (it == data.end()) {         //it's unique.
-               data[seq].groupname = name;  //group name will be the name of the first duplicate sequence found.
-               data[seq].names = name;
-       }else { // its a duplicate.
-               data[seq].names += "," + name;
-       }
-       seqmap[name] = seq;
-}
-
-/*******************************************************************************/
-
-int FastaMap::sizeUnique(){ //returns datas size which is the number of unique sequences
-       return data.size();
-}
-
-/*******************************************************************************/
-
-void FastaMap::printNamesFile(string outFileName){ //prints data
-       try {
-               ofstream outFile;
-               m->openOutputFile(outFileName, outFile);
-               
-               // two column file created with groupname and them list of identical sequence names
-               for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
-                       if (m->control_pressed) { break; }
-                       outFile << it->second.groupname << '\t' << it->second.names << endl;
-               }
-               outFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FastaMap", "printNamesFile");
-               exit(1);
-       }
-}
-
-/*******************************************************************************/
-
-void FastaMap::printCondensedFasta(string outFileName){ //prints data
-       try {
-               ofstream out;
-               m->openOutputFile(outFileName, out);
-               //creates a fasta file
-               for (map<string,group>::iterator it = data.begin(); it != data.end(); it++) {
-                       if (m->control_pressed) { break; }
-                       out << ">" << it->second.groupname << endl;
-                       out << it->first << endl;
-               }
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FastaMap", "printCondensedFasta");
-               exit(1);
-       }
-}
-
-/*******************************************************************************/
-
diff --git a/fastamap.h b/fastamap.h
deleted file mode 100644 (file)
index e1ff3df..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef FASTAMAP_H
-#define FASTAMAP_H
-
-/*
- *  fastamap.h
- *  mothur
- *
- *  Created by Sarah Westcott on 1/16/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-#include "mothur.h"
-#include "mothurout.h"
-
-
-/* This class represents the fasta file.  It reads a fasta file a populates the internal data structure "data".
-Data is a map where the key is the sequence and the value is a struct containing the sequences groupname, 
-a list of the sequences names who have the same sequence and a number of how many sequence names there are. */
-
-
-class FastaMap  {
-
-public:
-       FastaMap() { m = MothurOut::getInstance(); }
-       ~FastaMap() {};
-       
-       string getGroupName(string);  //pass a sequence name get its group
-       string getNames(string);        //pass a sequence get the string of names in the group separated by ','s.
-       void push_back(string, string); //sequencename, sequence
-       int sizeUnique();                                       //returns number of unique sequences
-       void printNamesFile(string);            //produces a 2 column file with the groupname in the first column and the names in the second column - a names file.
-       void printCondensedFasta(string);               //produces a fasta file.
-       void readFastaFile(string);
-       void readFastaFile(string, string);
-       string getSequence(string);             //pass it a name of a sequence, it returns the sequence.
-
-private:
-       struct group {
-               string groupname;                                       //the group name for identical sequences, will be set to the first sequence found.
-               string names;                                           //the names of the sequence separated by ','.
-       };
-
-       map<string, group>  data;  //sequence, groupinfo        - condensed representation of file
-       map<string, string>  seqmap;  //name, sequence  -  uncondensed representation of file
-       MothurOut* m;
-};
-
-#endif
diff --git a/fileoutput.cpp b/fileoutput.cpp
deleted file mode 100644 (file)
index a4a68a8..0000000
+++ /dev/null
@@ -1,474 +0,0 @@
-/*
- *  fileoutput.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "fileoutput.h"
-
-/***********************************************************************/
-
-ThreeColumnFile::~ThreeColumnFile(){
-       
-       inFile.close();
-       outFile.close();
-       m->mothurRemove(outName);
-}
-
-/***********************************************************************/
-
-void ThreeColumnFile::initFile(string label){
-       try {
-               if(counter != 0){
-                       m->openOutputFile(outName, outFile);
-                       m->openInputFile(inName, inFile);
-
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << '\t' << label << "\tlci\thci" << endl;
-               }
-               else{
-                       m->openOutputFile(outName, outFile);
-                       outFile << "numsampled\t" << label << "\tlci\thci" << endl;
-               }
-
-               outFile.setf(ios::fixed, ios::floatfield);
-               outFile.setf(ios::showpoint);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ThreeColumnFile", "initFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ThreeColumnFile::output(int nSeqs, vector<double> data){
-       try {
-               if(counter != 0){               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
-               }
-               else{
-                       outFile << nSeqs << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ThreeColumnFile", "output");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ThreeColumnFile::resetFile(){
-       try {
-               if(counter != 0){
-                       outFile.close();
-                       inFile.close();
-               }
-               else{
-                       outFile.close();
-               }
-               counter = 1;
-               
-               m->mothurRemove(inName);
-               renameOk = rename(outName.c_str(), inName.c_str());
-               
-               //renameFile(outName, inName);
-               
-               //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { 
-                       m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
-                       perror(" : ");
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ThreeColumnFile", "resetFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-/***********************************************************************/
-
-ColumnFile::~ColumnFile(){
-       
-       inFile.close();
-       outFile.close();
-       m->mothurRemove(outName);
-}
-
-/***********************************************************************/
-
-void ColumnFile::initFile(string label, vector<string> tags){
-       try {
-               if(counter != 0){
-                       m->openOutputFile(outName, outFile);
-                       m->openInputFile(inName, inFile);
-
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << '\t'; 
-                       for(int i = 0; i < tags.size(); i++) {
-                               outFile << label + tags[i] << '\t';
-                       }
-                       outFile << endl;
-               }
-               else{
-                       m->openOutputFile(outName, outFile);
-                       for(int i = 0; i < tags.size(); i++) {
-                               outFile << label + tags[i] << '\t';
-                       }
-                       outFile << endl;
-               }
-
-               outFile.setf(ios::fixed, ios::floatfield);
-               outFile.setf(ios::showpoint);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ColumnFile", "initFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ColumnFile::output(vector<double> data){
-       try {
-       
-               if(counter != 0){               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-
-                       outFile << inputBuffer << '\t' << setprecision(6) << data[0] << setprecision(iters.length());
-                       for (int i = 1; i< data.size(); i++) {
-                               outFile << '\t' << data[i]; 
-                       }
-                       outFile << endl;
-               }
-               else{
-                       outFile << setprecision(6) << data[0] << setprecision(iters.length());
-                       for (int i = 1; i< data.size(); i++) {
-                               outFile << '\t' << data[i]; 
-                       }
-                       outFile << endl;
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ColumnFile", "output");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ColumnFile::resetFile(){
-       try {
-               if(counter != 0){
-                       outFile.close();
-                       inFile.close();
-               }
-               else{
-                       outFile.close();
-               }
-               counter = 1;
-               
-               m->mothurRemove(inName);
-               renameOk = rename(outName.c_str(), inName.c_str());
-               
-               //renameFile(outName, inName);
-               
-               //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { 
-                       m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
-                       perror(" : ");
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ColumnFile", "resetFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-/***********************************************************************/
-
-SharedThreeColumnFile::~SharedThreeColumnFile(){
-       
-       inFile.close();
-       outFile.close();
-       m->mothurRemove(outName);
-}
-
-/***********************************************************************/
-
-void SharedThreeColumnFile::initFile(string label){
-       try {
-               if(counter != 0){
-                       m->openOutputFile(outName, outFile);
-                       m->openInputFile(inName, inFile);
-
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << '\t' << label << "\tlci\thci" << endl;
-               }
-               else{
-                       m->openOutputFile(outName, outFile);
-                       outFile << "numsampled\t" << groupLabel << '\t' << label << "\tlci\thci" << endl;
-               }
-
-               outFile.setf(ios::fixed, ios::floatfield);
-               outFile.setf(ios::showpoint);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedThreeColumnFile", "initFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedThreeColumnFile::output(int nSeqs, vector<double> data){
-       try {
-               if(counter != 0){               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
-               }
-               else{
-                       outFile << numGroup << setprecision(4) << '\t' << data[0] << '\t' << data[1] << '\t' << data[2] << endl;
-                       numGroup++;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedThreeColumnFile", "output");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedThreeColumnFile::resetFile(){
-       try {
-               if(counter != 0){
-                       outFile.close();
-                       inFile.close();
-               }
-               else{
-                       outFile.close();
-               }
-               counter = 1;
-               
-               m->mothurRemove(inName);
-               renameOk = rename(outName.c_str(), inName.c_str());
-               
-               //renameFile(outName, inName);
-               
-               //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { 
-                       m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
-                       perror(" : ");
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedThreeColumnFile", "resetFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-/***********************************************************************/
-
-OneColumnFile::~OneColumnFile(){
-       
-       inFile.close();
-       outFile.close();
-       m->mothurRemove(outName);       
-}
-
-/***********************************************************************/
-
-void OneColumnFile::initFile(string label){
-       try {
-               if(counter != 0){
-                       m->openOutputFile(outName, outFile);
-                       m->openInputFile(inName, inFile);
-               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << '\t' << label << endl;
-               }
-               else{
-                       m->openOutputFile(outName, outFile);
-                       outFile << "numsampled\t" << label << endl;
-               }
-       
-               outFile.setf(ios::fixed, ios::floatfield);
-               outFile.setf(ios::showpoint);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OneColumnFile", "initFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void OneColumnFile::output(int nSeqs, vector<double> data){
-       try {   
-               if(counter != 0){               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << setprecision(4) << '\t'  << data[0] << endl;
-               }
-               else{   
-                       outFile << nSeqs << setprecision(4) << '\t' << data[0] << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OneColumnFile", "output");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void OneColumnFile::resetFile(){
-       try {
-               if(counter != 0){
-                       outFile.close();
-                       inFile.close();
-               }else{
-                       outFile.close();
-               }       
-               counter = 1;
-               
-               m->mothurRemove(inName);
-               renameOk = rename(outName.c_str(), inName.c_str());
-               
-               //renameFile(outName, inName);
-               
-               //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { 
-                       m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
-                       perror(" : ");
-               }       
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OneColumnFile", "resetFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-/***********************************************************************/
-
-SharedOneColumnFile::~SharedOneColumnFile(){
-       
-       inFile.close();
-       outFile.close();
-       m->mothurRemove(outName);       
-}
-
-/***********************************************************************/
-
-void SharedOneColumnFile::initFile(string label){
-       try {
-               if(counter != 0){
-                       m->openOutputFile(outName, outFile);
-                       m->openInputFile(inName, inFile);
-               
-                       string inputBuffer;
-                       inputBuffer = m->getline(inFile);
-               
-                       outFile <<  inputBuffer << '\t' << label  << endl;
-
-               }
-               else{
-                       m->openOutputFile(outName, outFile);
-                       outFile << "sampled\t" << label << endl;
-               
-               }
-       
-               outFile.setf(ios::fixed, ios::floatfield);
-               outFile.setf(ios::showpoint);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOneColumnFile", "initFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedOneColumnFile::output(int nSeqs, vector<double> data){
-       try {   
-                       string dataOutput;
-                       float sam;
-                       sam = data[0];
-                       dataOutput = "";
-                       for (int i = 0; i < data.size(); i++) {
-                               dataOutput = dataOutput + "\t" + toString(data[i]);
-                       }
-                       if(counter != 0){               
-                               string inputBuffer;
-                               inputBuffer = m->getline(inFile);
-
-                               outFile <<  inputBuffer << setprecision(2) << '\t' << dataOutput << endl;
-                       }
-                       else{   
-                               outFile << nSeqs << setprecision(2) << '\t' << dataOutput << endl;
-                       }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOneColumnFile", "output");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedOneColumnFile::resetFile(){
-       try {
-               if(counter != 0){
-                       outFile.close();
-                       inFile.close();
-               }
-               else{
-                       outFile.close();
-               }       
-               counter = 1;
-
-               m->mothurRemove(inName);
-               renameOk = rename(outName.c_str(), inName.c_str());
-               
-               //renameFile(outName, inName);
-               
-               //checks to make sure user was able to rename and remove successfully
-               if ((renameOk != 0)) { 
-                       m->mothurOut("Unable to rename " + outName); m->mothurOutEndLine();
-                       perror(" : ");
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOneColumnFile", "resetFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/fileoutput.h b/fileoutput.h
deleted file mode 100644 (file)
index 170ee68..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-#ifndef FILEOUTPUT_H
-#define FILEOUTPUT_H
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/***********************************************************************/
-
-class FileOutput {
-       
-public:
-       FileOutput(){ m = MothurOut::getInstance(); }
-       virtual ~FileOutput(){};
-       
-       virtual void initFile(string) = 0;
-       virtual void initFile(string, vector<string>) = 0;
-       virtual void output(int, vector<double>) = 0;
-       virtual void output(vector<double>) = 0;
-       virtual void resetFile() = 0;
-       virtual string getFileName() = 0;
-
-protected:
-       int renameOk;
-       MothurOut* m;
-
-};     
-       
-/***********************************************************************/
-
-class ThreeColumnFile : public FileOutput {
-       
-public:
-       ThreeColumnFile(string n) : FileOutput(), inName(n), counter(0), outName(n + ".temp") { };
-       ~ThreeColumnFile();
-       void initFile(string);
-       void output(int, vector<double>);
-       void resetFile();
-       string getFileName()    { return inName;        };
-       
-       void initFile(string, vector<string>){};
-       void output(vector<double>) {};
-
-private:
-       string inName;
-       string outName;
-       ifstream inFile;
-       ofstream outFile;
-       int counter;
-};
-
-
-/***********************************************************************/
-class OneColumnFile : public FileOutput {
-       
-       
-public:
-       OneColumnFile(string n) : inName(n), counter(0), outName(n + ".temp") {};
-       ~OneColumnFile();
-       void output(int, vector<double>);
-       void initFile(string);
-       void resetFile();
-       string getFileName()    { return inName;        };
-       
-       void initFile(string, vector<string>) {};
-       void output(vector<double>) {};
-
-
-private:
-       string outName;
-       ifstream inFile;
-       string inName;
-       ofstream outFile;
-       int counter;
-};
-
-/***********************************************************************/
-class SharedOneColumnFile : public FileOutput {
-       
-       
-public:
-       SharedOneColumnFile(string n) : inName(n), counter(0), outName(n + ".temp") {};
-       ~SharedOneColumnFile();
-       void output(int, vector<double>);
-       void initFile(string);
-       void resetFile();
-       string getFileName()    { return inName;        };
-       
-       void initFile(string, vector<string>) {};
-       void output(vector<double>) {};
-
-
-private:
-       string outName;
-       ifstream inFile;
-       string inName;
-       ofstream outFile;
-       int counter;
-               
-};
-
-/***********************************************************************/
-
-class SharedThreeColumnFile : public FileOutput {
-       
-public:
-       SharedThreeColumnFile(string n, string groups) : FileOutput(), groupLabel(groups), inName(n), counter(0), numGroup(1), outName(n + ".temp") {   };
-       ~SharedThreeColumnFile();
-       void initFile(string);
-       void output(int, vector<double>);
-       void resetFile();
-       string getFileName()    { return inName;        };
-       
-       
-       void initFile(string, vector<string>) {};
-       void output(vector<double>) {};
-
-private:
-       string inName, groupLabel;
-       string outName;
-       ifstream inFile;
-       ofstream outFile;
-       int counter, numGroup;
-};
-
-/***********************************************************************/
-//used by parsimony, unifrac.weighted and unifrac.unweighted
-class ColumnFile : public FileOutput {
-       
-public:
-       ColumnFile(string n, string i) : FileOutput(), iters(i), inName(n), counter(0), outName(n + ".temp") {};
-       ~ColumnFile();
-       
-       //to make compatible with parent class
-       void output(int, vector<double>){};
-       void initFile(string){};
-       
-       void initFile(string, vector<string>);
-       void output(vector<double>);
-       void resetFile();
-       string getFileName()    { return inName;        };
-private:
-       string inName;
-       string outName;
-       ifstream inFile;
-       ofstream outFile;
-       int counter;
-       string iters;
-};
-
-
-
-#endif
diff --git a/filters.h b/filters.h
deleted file mode 100644 (file)
index 21bc8bb..0000000
--- a/filters.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef FILTERS_H
-#define FILTERS_H
-
-/*
- *  filters.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/29/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sequence.hpp"
-
-
-/***********************************************************************/
-
-class Filters {
-
-public:
-       Filters() { m = MothurOut::getInstance(); };
-       ~Filters(){};
-               
-       string getFilter()                      {       return filter;          }
-       void setFilter(string s)        {  filter = s;                  }
-       void setLength(int l)           { alignmentLength = l;  }
-       void setSoft(float s)           {               soft = s;               }
-       void setTrump(float t)          {               trump = t;              }
-       void setNumSeqs(int num)        {       numSeqs = num;          }
-       vector<int> a, t, g, c, gap;
-       
-       
-       void initialize() {
-               a.assign(alignmentLength, 0);
-               t.assign(alignmentLength, 0);
-               g.assign(alignmentLength, 0);
-               c.assign(alignmentLength, 0);
-               gap.assign(alignmentLength, 0);
-       }
-
-       void doSoft() { 
-               int threshold = int (soft * numSeqs);
-       
-               for(int i=0;i<alignmentLength;i++){
-                       if(a[i] < threshold && t[i] < threshold && g[i] < threshold && c[i] < threshold){       filter[i] = 0;  }
-               }
-       }
-
-       void mergeFilter(string newFilter){
-               for(int i=0;i<alignmentLength;i++){
-                       if(newFilter[i] == '0'){
-                               filter[i] = 0;
-                       }
-               }
-       }
-       
-       void doVertical() {
-
-               for(int i=0;i<alignmentLength;i++){
-                       if(gap[i] == numSeqs)   {       filter[i] = '0';        }
-               }
-       
-       }
-       
-       void doTrump(Sequence seq) {
-       
-               string curAligned = seq.getAligned();
-
-               for(int j = 0; j < alignmentLength; j++) {
-                       if(curAligned[j] == trump){
-                               filter[j] = '0';
-                       }
-               }
-
-       }
-
-       void doHard(string hard) {
-               ifstream fileHandle;
-               m->openInputFile(hard, fileHandle);
-       
-               fileHandle >> filter;
-       
-               fileHandle.close();
-       }
-
-       void getFreqs(Sequence seq) {
-       
-               string curAligned = seq.getAligned();
-       
-               for(int j=0;j<alignmentLength;j++){
-                       if(toupper(curAligned[j]) == 'A')                                                                               {       a[j]++;         }
-                       else if(toupper(curAligned[j]) == 'T' || toupper(curAligned[j]) == 'U') {       t[j]++;         }
-                       else if(toupper(curAligned[j]) == 'G')                                                                  {       g[j]++;         }
-                       else if(toupper(curAligned[j]) == 'C')                                                                  {       c[j]++;         }
-                       else if(curAligned[j] == '-' || curAligned[j] == '.')                                   {       gap[j]++;       }
-               }
-       }
-               
-protected:
-       string filter;
-       int alignmentLength, numSeqs;
-       float soft;
-       char trump;
-       MothurOut* m;
-
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp
deleted file mode 100644 (file)
index a7d42b3..0000000
+++ /dev/null
@@ -1,1181 +0,0 @@
-/*
- *  filterseqscommand.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/4/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "filterseqscommand.h"
-#include "sequence.hpp"
-
-
-//**********************************************************************************************************************
-vector<string> FilterSeqsCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter phard("hard", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(phard);
-               CommandParameter ptrump("trump", "String", "", "*", "", "", "",false,false); parameters.push_back(ptrump);
-               CommandParameter psoft("soft", "Number", "", "0", "", "", "",false,false); parameters.push_back(psoft);
-               CommandParameter pvertical("vertical", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pvertical);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string FilterSeqsCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The filter.seqs command reads a file containing sequences and creates a .filter and .filter.fasta file.\n";
-               helpString += "The filter.seqs command parameters are fasta, trump, soft, hard, processors and vertical. \n";
-               helpString += "The fasta parameter is required, unless you have a valid current fasta file. You may enter several fasta files to build the filter from and filter, by separating their names with -'s.\n";
-               helpString += "For example: fasta=abrecovery.fasta-amazon.fasta \n";
-               helpString += "The trump option will remove a column if the trump character is found at that position in any sequence of the alignment. Default=*, meaning no trump. \n";
-               helpString += "A soft mask removes any column where the dominant base (i.e. A, T, G, C, or U) does not occur in at least a designated percentage of sequences. Default=0.\n";
-               helpString += "The hard parameter allows you to enter a file containing the filter you want to use.\n";
-               helpString += "The vertical parameter removes columns where all sequences contain a gap character. The default is T.\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "The filter.seqs command should be in the following format: \n";
-               helpString += "filter.seqs(fasta=yourFastaFile, trump=yourTrump) \n";
-               helpString += "Example filter.seqs(fasta=abrecovery.fasta, trump=.).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-FilterSeqsCommand::FilterSeqsCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["filter"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-FilterSeqsCommand::FilterSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               filterFileName = "";
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("filter.seqs");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["filter"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("hard");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["hard"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       fasta = validParameter.validFile(parameters, "fasta", false);
-                       if (fasta == "not found") {                             
-                               fasta = m->getFastaFile(); 
-                               if (fasta != "") { 
-                    fastafileNames.push_back(fasta);  
-                    m->mothurOut("Using " + fasta + " as input file for the fasta parameter."); m->mothurOutEndLine();
-                    string simpleName = m->getSimpleName(fasta);
-                    filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
-                }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else { 
-                               m->splitAtDash(fasta, fastafileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastafileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastafileNames[i] == "current") { 
-                                               fastafileNames[i] = m->getFastaFile(); 
-                                               if (fastafileNames[i] != "") {  m->mothurOut("Using " + fastafileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastafileNames.erase(fastafileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastafileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastafileNames[i] = inputDir + fastafileNames[i];               }
-                                               }
-
-                                               ifstream in;
-                                               int ableToOpen = m->openInputFile(fastafileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastafileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastafileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastafileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastafileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastafileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastafileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
-                                                       //erase from file list
-                                                       fastafileNames.erase(fastafileNames.begin()+i);
-                                                       i--;
-                                               }else{  
-                                                       string simpleName = m->getSimpleName(fastafileNames[i]);
-                                                       filterFileName += simpleName.substr(0, simpleName.find_first_of('.'));
-                                                       m->setFastaFile(fastafileNames[i]);
-                                               }
-                                               in.close();
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastafileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (!abort) {
-                               //if the user changes the output directory command factory will send this info to us in the output parameter 
-                               outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                                       outputDir = ""; 
-                                       outputDir += m->hasPath(fastafileNames[0]); //if user entered a file with a path then preserve it       
-                               }
-                       }
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       
-                       string temp;
-                       hard = validParameter.validFile(parameters, "hard", true);                              if (hard == "not found") { hard = ""; }
-                       else if (hard == "not open") { hard = ""; abort = true; }       
-
-                       temp = validParameter.validFile(parameters, "trump", false);                    if (temp == "not found") { temp = "*"; }
-                       trump = temp[0];
-                       
-                       temp = validParameter.validFile(parameters, "soft", false);                             if (temp == "not found") { soft = 0; }
-                       else {  soft = (float)atoi(temp.c_str()) / 100.0;  }
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       vertical = validParameter.validFile(parameters, "vertical", false);             
-                       if (vertical == "not found") { 
-                               if ((hard == "") && (trump == '*') && (soft == 0)) { vertical = "T"; } //you have not given a hard file or set the trump char.
-                               else { vertical = "F";  }
-                       }
-                       
-                       numSeqs = 0;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "FilterSeqsCommand");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-
-int FilterSeqsCommand::execute() {     
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               ifstream inFASTA;
-               m->openInputFile(fastafileNames[0], inFASTA);
-               
-               Sequence testSeq(inFASTA);
-               alignmentLength = testSeq.getAlignLength();
-               inFASTA.close();
-               
-               ////////////create filter/////////////////
-               m->mothurOut("Creating Filter... "); m->mothurOutEndLine();
-               
-               filter = createFilter();
-               
-               m->mothurOutEndLine();  m->mothurOutEndLine();
-               
-               if (m->control_pressed) { outputTypes.clear(); return 0; }
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output the filter
-               #endif
-               
-               ofstream outFilter;
-               
-               //prevent giantic file name
-               string filterFile;
-               if (fastafileNames.size() > 3) { filterFile = outputDir + "merge.filter"; }
-               else {  filterFile = outputDir + filterFileName + ".filter";  }
-               
-               m->openOutputFile(filterFile, outFilter);
-               outFilter << filter << endl;
-               outFilter.close();
-               outputNames.push_back(filterFile); outputTypes["filter"].push_back(filterFile);
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-               
-               ////////////run filter/////////////////
-               
-               m->mothurOut("Running Filter... "); m->mothurOutEndLine();
-               
-               filterSequences();
-               
-               m->mothurOutEndLine();  m->mothurOutEndLine();
-                                       
-               int filteredLength = 0;
-               for(int i=0;i<alignmentLength;i++){
-                       if(filter[i] == '1'){   filteredLength++;       }
-               }
-               
-               if (m->control_pressed) {  outputTypes.clear(); for(int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }  return 0; }
-
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Length of filtered alignment: " + toString(filteredLength)); m->mothurOutEndLine();
-               m->mothurOut("Number of columns removed: " + toString((alignmentLength-filteredLength))); m->mothurOutEndLine();
-               m->mothurOut("Length of the original alignment: " + toString(alignmentLength)); m->mothurOutEndLine();
-               m->mothurOut("Number of sequences used to construct filter: " + toString(numSeqs)); m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for(int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();      }
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int FilterSeqsCommand::filterSequences() {     
-       try {
-               
-               numSeqs = 0;
-               
-               for (int s = 0; s < fastafileNames.size(); s++) {
-                       
-                               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                               
-                               string filteredFasta = outputDir + m->getRootName(m->getSimpleName(fastafileNames[s])) + "filter.fasta";
-#ifdef USE_MPI 
-                               int pid, numSeqsPerProcessor, num; 
-                               int tag = 2001;
-                               vector<unsigned long long>MPIPos;
-                                               
-                               MPI_Status status; 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               
-                               MPI_File outMPI;
-                               MPI_File inMPI;
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               int inMode=MPI_MODE_RDONLY; 
-                               
-                               char outFilename[1024];
-                               strcpy(outFilename, filteredFasta.c_str());
-                       
-                               char inFileName[1024];
-                               strcpy(inFileName, fastafileNames[s].c_str());
-                               
-                               MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
-
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  return 0;  }
-
-                               if (pid == 0) { //you are the root process 
-                                       
-                                       MPIPos = m->setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
-                                       numSeqs += num;
-                                       
-                                       //send file positions to all processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&MPIPos[0], (num+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       //figure out how many sequences you have to do
-                                       numSeqsPerProcessor = num / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = num - pid * numSeqsPerProcessor;  }
-                                       
-                               
-                                       //do your part
-                                       driverMPIRun(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  return 0;  }
-                                       
-                                       //wait on chidren
-                                       for(int i = 1; i < processors; i++) { 
-                                               char buf[5];
-                                               MPI_Recv(buf, 5, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
-                                       }
-                                       
-                               }else { //you are a child process
-                                       MPI_Recv(&num, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(num+1);
-                                       numSeqs += num;
-                                       MPI_Recv(&MPIPos[0], (num+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = num / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = num - pid * numSeqsPerProcessor;  }
-                                       
-                                       
-                                       //align your part
-                                       driverMPIRun(startIndex, numSeqsPerProcessor, inMPI, outMPI, MPIPos);           
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI);  return 0;  }
-                                       
-                                       char buf[5];
-                                       strcpy(buf, "done"); 
-                                       
-                                       //tell parent you are done.
-                                       MPI_Send(buf, 5, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                               }
-                               
-                               MPI_File_close(&outMPI);
-                               MPI_File_close(&inMPI);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               
-#else
-            
-            vector<unsigned long long> positions;
-            if (savedPositions.size() != 0) { positions = savedPositions[s]; }
-            else {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               positions = m->divideFile(fastafileNames[s], processors);
-#else
-                if(processors != 1){
-                    int numFastaSeqs = 0;
-                    positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); 
-                    if (positions.size() < processors) { processors = positions.size(); }
-                }
-#endif
-            }
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       //vector<unsigned long long> positions = m->divideFile(fastafileNames[s], processors);
-                       
-                       for (int i = 0; i < (positions.size()-1); i++) {
-                               lines.push_back(new linePair(positions[i], positions[(i+1)]));
-                       }       
-                       
-                               if(processors == 1){
-                                       int numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]);
-                                       numSeqs += numFastaSeqs;
-                               }else{
-                                       int numFastaSeqs = createProcessesRunFilter(filter, fastafileNames[s], filteredFasta); 
-                                       numSeqs += numFastaSeqs;
-                               }
-                               
-                               if (m->control_pressed) {  return 1; }
-               #else
-            if(processors == 1){
-                lines.push_back(new linePair(0, 1000));
-                               int numFastaSeqs = driverRunFilter(filter, filteredFasta, fastafileNames[s], lines[0]);
-                               numSeqs += numFastaSeqs;
-            }else {
-                int numFastaSeqs = positions.size()-1;
-                //positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); 
-                
-                //figure out how many sequences you have to process
-                int numSeqsPerProcessor = numFastaSeqs / processors;
-                for (int i = 0; i < processors; i++) {
-                    int startIndex =  i * numSeqsPerProcessor;
-                    if(i == (processors - 1)){ numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                    lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
-                }
-                
-                numFastaSeqs = createProcessesRunFilter(filter, fastafileNames[s], filteredFasta); 
-                numSeqs += numFastaSeqs;
-            }
-
-                               if (m->control_pressed) {  return 1; }
-               #endif
-#endif
-                       outputNames.push_back(filteredFasta); outputTypes["fasta"].push_back(filteredFasta);
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "filterSequences");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-/**************************************************************************************/
-int FilterSeqsCommand::driverMPIRun(int start, int num, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long long>& MPIPos) {       
-       try {
-               string outputString = "";
-               int count = 0;
-               MPI_Status status; 
-               
-               for(int i=0;i<num;i++){
-               
-                       if (m->control_pressed) { return 0; }
-               
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-       
-                       Sequence seq(iss);  m->gobble(iss);
-                       
-                       if (seq.getName() != "") {
-                               string align = seq.getAligned();
-                               string filterSeq = "";
-                                       
-                               for(int j=0;j<alignmentLength;j++){
-                                       if(filter[j] == '1'){
-                                               filterSeq += align[j];
-                                       }
-                               }
-                               
-                               count++;
-                               outputString += ">" + seq.getName() + "\n" + filterSeq + "\n";
-                               
-                               if(count % 10 == 0){ //output to file 
-                                       //send results to parent
-                                       int length = outputString.length();
-                                       char* buf = new char[length];
-                                       memcpy(buf, outputString.c_str(), length);
-                               
-                                       MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status);
-                                       outputString = "";
-                                       delete buf;
-                               }
-
-                       }
-                       
-                       if((i+1) % 100 == 0){   cout << (i+1) << endl;   m->mothurOutJustToLog(toString(i+1) + "\n");   }
-               }
-               
-               if(outputString != ""){ //output to file 
-                       //send results to parent
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status);
-                       outputString = "";
-                       delete buf;
-               }
-               
-               if((num) % 100 != 0){   cout << (num) << endl;   m->mothurOutJustToLog(toString(num) + "\n");   }
-                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "driverRunFilter");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************/
-int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string inputFilename, linePair* filePos) {     
-       try {
-               ofstream out;
-               m->openOutputFile(outputFilename, out);
-               
-               ifstream in;
-               m->openInputFile(inputFilename, in);
-                               
-               in.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-                               
-                               if (m->control_pressed) { in.close(); out.close(); return 0; }
-                               
-                               Sequence seq(in); m->gobble(in);
-                               if (seq.getName() != "") {
-                                       string align = seq.getAligned();
-                                       string filterSeq = "";
-                                       
-                                       for(int j=0;j<alignmentLength;j++){
-                                               if(filter[j] == '1'){
-                                                       filterSeq += align[j];
-                                               }
-                                       }
-                                       
-                                       out << '>' << seq.getName() << endl << filterSeq << endl;
-                               count++;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = in.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (in.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               
-               
-               out.close();
-               in.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "driverRunFilter");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int FilterSeqsCommand::createProcessesRunFilter(string F, string filename, string filteredFastaName) {
-       try {
-        
-        int process = 1;
-               int num = 0;
-               processIDS.clear();
-        
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               string filteredFasta = filename + toString(getpid()) + ".temp";
-                               num = driverRunFilter(F, filteredFasta, filename, lines[process]);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = filename +  toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-        num = driverRunFilter(F, filteredFastaName, filename, lines[0]);
-        
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }       
-                                       
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  filename + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-            
-            m->appendFiles((filename + toString(processIDS[i]) + ".temp"), filteredFastaName);
-            m->mothurRemove((filename + toString(processIDS[i]) + ".temp"));
-               }
-               
-#else
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the filterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to F.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<filterRunData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++){
-                       
-            string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; }
-            
-                       filterRunData* tempFilter = new filterRunData(filter, filename, (filteredFastaName + extension), m, lines[i]->start, lines[i]->end, alignmentLength, i);
-                       pDataArray.push_back(tempFilter);
-                       processIDS.push_back(i);
-            
-                       hThreadArray[i] = CreateThread(NULL, 0, MyRunFilterThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-        
-        num = driverRunFilter(F, (filteredFastaName + toString(processors-1) + ".temp"), filename, lines[processors-1]);
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-        
-        for (int i = 1; i < processors; i++) {
-            m->appendFiles((filteredFastaName + toString(i) + ".temp"), filteredFastaName);
-            m->mothurRemove((filteredFastaName + toString(i) + ".temp"));
-               }
-#endif 
-        
-        return num;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "createProcessesRunFilter");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-string FilterSeqsCommand::createFilter() {     
-       try {
-               string filterString = "";                       
-               Filters F;
-               
-               if (soft != 0)                  {  F.setSoft(soft);             }
-               if (trump != '*')               {  F.setTrump(trump);   }
-               
-               F.setLength(alignmentLength);
-               
-               if(trump != '*' || m->isTrue(vertical) || soft != 0){
-                       F.initialize();
-               }
-               
-               if(hard.compare("") != 0)       {       F.doHard(hard);         }
-               else                                            {       F.setFilter(string(alignmentLength, '1'));      }
-               
-               numSeqs = 0;
-               if(trump != '*' || m->isTrue(vertical) || soft != 0){
-                       for (int s = 0; s < fastafileNames.size(); s++) {
-                       
-                               for (int i = 0; i < lines.size(); i++) {  delete lines[i];  }  lines.clear();
-                       
-#ifdef USE_MPI 
-                               int pid, numSeqsPerProcessor, num; 
-                               int tag = 2001;
-                               vector<unsigned long long> MPIPos;
-                               
-                               MPI_Status status; 
-                               MPI_File inMPI; 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                                       
-                               //char* tempFileName = new char(fastafileNames[s].length());
-                               //tempFileName = &(fastafileNames[s][0]);
-                               
-                               char tempFileName[1024];
-                               strcpy(tempFileName, fastafileNames[s].c_str());
-               
-                               MPI_File_open(MPI_COMM_WORLD, tempFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  return 0;  }
-                               
-                               if (pid == 0) { //you are the root process
-                                               MPIPos = m->setFilePosFasta(fastafileNames[s], num); //fills MPIPos, returns numSeqs
-                                               numSeqs += num;
-                                               
-                                               //send file positions to all processes
-                                               for(int i = 1; i < processors; i++) { 
-                                                       MPI_Send(&num, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                                       MPI_Send(&MPIPos[0], (num+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                               }
-                                                               
-                                               //figure out how many sequences you have to do
-                                               numSeqsPerProcessor = num / processors;
-                                               int startIndex =  pid * numSeqsPerProcessor;
-                                               if(pid == (processors - 1)){    numSeqsPerProcessor = num - pid * numSeqsPerProcessor;  }
-                                               
-                               
-                                               //do your part
-                                               MPICreateFilter(startIndex, numSeqsPerProcessor, F, inMPI, MPIPos);
-                                               
-                                               if (m->control_pressed) {  MPI_File_close(&inMPI);  return 0;  }
-                                                                                               
-                               }else { //i am the child process
-                                       MPI_Recv(&num, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(num+1);
-                                       numSeqs += num;
-                                       MPI_Recv(&MPIPos[0], (num+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = num / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = num - pid * numSeqsPerProcessor;  }
-                                       
-                                       
-                                       //do your part
-                                       MPICreateFilter(startIndex, numSeqsPerProcessor, F, inMPI,  MPIPos);
-                                       
-                                       if (m->control_pressed) {  MPI_File_close(&inMPI);  return 0;  }
-                               }
-                               
-                               MPI_File_close(&inMPI);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               
-#else
-                               
-                vector<unsigned long long> positions;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               positions = m->divideFile(fastafileNames[s], processors);
-                               for (int i = 0; i < (positions.size()-1); i++) {
-                                       lines.push_back(new linePair(positions[i], positions[(i+1)]));
-                               }       
-                               
-                               if(processors == 1){
-                                       int numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]);
-                                       numSeqs += numFastaSeqs;
-                               }else{
-                                       int numFastaSeqs = createProcessesCreateFilter(F, fastafileNames[s]); 
-                                       numSeqs += numFastaSeqs;
-                               }
-               #else
-                if(processors == 1){
-                    lines.push_back(new linePair(0, 1000));
-                    int numFastaSeqs = driverCreateFilter(F, fastafileNames[s], lines[0]);
-                    numSeqs += numFastaSeqs;
-                               }else {
-                    int numFastaSeqs = 0;
-                    positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); 
-                    if (positions.size() < processors) { processors = positions.size(); }
-                    
-                    //figure out how many sequences you have to process
-                    int numSeqsPerProcessor = numFastaSeqs / processors;
-                    for (int i = 0; i < processors; i++) {
-                        int startIndex =  i * numSeqsPerProcessor;
-                        if(i == (processors - 1)){     numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                        lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
-                    }
-                    
-                    numFastaSeqs = createProcessesCreateFilter(F, fastafileNames[s]); 
-                                       numSeqs += numFastaSeqs;
-                }
-               #endif
-                //save the file positions so we can reuse them in the runFilter function
-                savedPositions[s] = positions;
-                
-                               if (m->control_pressed) {  return filterString; }
-#endif
-                       
-                       }
-               }
-
-
-#ifdef USE_MPI 
-               int pid;
-               int Atag = 1; int Ttag = 2; int Ctag = 3; int Gtag = 4; int Gaptag = 5;
-               MPI_Status status;
-               
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-               
-               if(trump != '*' || m->isTrue(vertical) || soft != 0){
-                       
-                       if (pid == 0) { //only one process should output the filter
-                       
-                               vector<int> temp; temp.resize(alignmentLength+1);
-                                                               
-                               //get the frequencies from the child processes
-                               for(int i = 1; i < processors; i++) { 
-                               
-                                       for (int j = 0; j < 5; j++) {
-                                       
-                                               MPI_Recv(&temp[0], (alignmentLength+1), MPI_INT, i, 2001, MPI_COMM_WORLD, &status); 
-                                               int receiveTag = temp[temp.size()-1];  //child process added a int to the end to indicate what letter count this is for
-                                               
-                                               if (receiveTag == Atag) { //you are recieveing the A frequencies
-                                                       for (int k = 0; k < alignmentLength; k++) {             F.a[k] += temp[k];      }
-                                               }else if (receiveTag == Ttag) { //you are recieveing the T frequencies
-                                                       for (int k = 0; k < alignmentLength; k++) {             F.t[k] += temp[k];      }
-                                               }else if (receiveTag == Ctag) { //you are recieveing the C frequencies
-                                                       for (int k = 0; k < alignmentLength; k++) {             F.c[k] += temp[k];      }
-                                               }else if (receiveTag == Gtag) { //you are recieveing the G frequencies
-                                                       for (int k = 0; k < alignmentLength; k++) {             F.g[k] += temp[k];      }
-                                               }else if (receiveTag == Gaptag) { //you are recieveing the gap frequencies
-                                                       for (int k = 0; k < alignmentLength; k++) {             F.gap[k] += temp[k];    }
-                                               }
-                                       }
-                               } 
-                       }else{
-                       
-                               //send my fequency counts
-                               F.a.push_back(Atag);
-                               int ierr = MPI_Send(&(F.a[0]), (alignmentLength+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               F.t.push_back(Ttag);
-                               ierr = MPI_Send (&(F.t[0]), (alignmentLength+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               F.c.push_back(Ctag);
-                               ierr = MPI_Send(&(F.c[0]), (alignmentLength+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               F.g.push_back(Gtag);
-                               ierr = MPI_Send(&(F.g[0]), (alignmentLength+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               F.gap.push_back(Gaptag);
-                               ierr = MPI_Send(&(F.gap[0]), (alignmentLength+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                       }
-                       
-               }
-               
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               
-               if (pid == 0) { //only one process should output the filter
-#endif
-
-               F.setNumSeqs(numSeqs);
-               if(m->isTrue(vertical) == 1)    {       F.doVertical(); }
-               if(soft != 0)                           {       F.doSoft();             }
-               filterString = F.getFilter();
-               
-#ifdef USE_MPI
-               //send filter string to kids
-               //for(int i = 1; i < processors; i++) { 
-               //      MPI_Send(&filterString[0], alignmentLength, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
-               //}
-               MPI_Bcast(&filterString[0], alignmentLength, MPI_CHAR, 0, MPI_COMM_WORLD);
-       }else{
-               //recieve filterString
-               char* tempBuf = new char[alignmentLength];
-               //MPI_Recv(&tempBuf[0], alignmentLength, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
-               MPI_Bcast(tempBuf, alignmentLength, MPI_CHAR, 0, MPI_COMM_WORLD);
-               
-               filterString = tempBuf;
-               if (filterString.length() > alignmentLength) { filterString = filterString.substr(0, alignmentLength);  }
-               delete tempBuf; 
-       }
-       
-       MPI_Barrier(MPI_COMM_WORLD);
-#endif
-            
-               return filterString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "createFilter");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair* filePos) {    
-       try {
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-                               
-               in.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-                               
-                       if (m->control_pressed) { in.close(); return 1; }
-                                       
-                       Sequence seq(in); m->gobble(in);
-                       if (seq.getName() != "") {
-                                       if (seq.getAligned().length() != alignmentLength) { m->mothurOut("Sequences are not all the same length, please correct."); m->mothurOutEndLine(); m->control_pressed = true;  }
-                                       
-                                       if(trump != '*')                        {       F.doTrump(seq);         }
-                                       if(m->isTrue(vertical) || soft != 0)    {       F.getFreqs(seq);        }
-                                       cout.flush();
-                                       count++;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = in.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (in.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               in.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "driverCreateFilter");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-/**************************************************************************************/
-int FilterSeqsCommand::MPICreateFilter(int start, int num, Filters& F, MPI_File& inMPI, vector<unsigned long long>& MPIPos) {  
-       try {
-               
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-               for(int i=0;i<num;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-       
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence seq(iss);  
-
-                       if (seq.getAligned().length() != alignmentLength) {  cout << "Alignment length is " << alignmentLength << " and sequence " << seq.getName() << " has length " << seq.getAligned().length() << ", please correct." << endl; exit(1);  }
-                       
-                       if(trump != '*'){       F.doTrump(seq); }
-                       if(m->isTrue(vertical) || soft != 0){   F.getFreqs(seq);        }
-                       cout.flush();
-                                               
-                       //report progress
-                       if((i+1) % 100 == 0){   cout << (i+1) << endl;   m->mothurOutJustToLog(toString(i+1) + "\n");   }
-               }
-               
-               //report progress
-               if((num) % 100 != 0){   cout << num << endl; m->mothurOutJustToLog(toString(num) + "\n");       }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "MPICreateFilter");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-
-int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) {
-       try {
-        int process = 1;
-               int num = 0;
-               processIDS.clear();
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               //reset child's filter counts to 0;
-                               F.a.clear(); F.a.resize(alignmentLength, 0);
-                               F.t.clear(); F.t.resize(alignmentLength, 0);
-                               F.g.clear(); F.g.resize(alignmentLength, 0);
-                               F.c.clear(); F.c.resize(alignmentLength, 0);
-                               F.gap.clear(); F.gap.resize(alignmentLength, 0);
-                               
-                               num = driverCreateFilter(F, filename, lines[process]);
-                               
-                               //write out filter counts to file
-                               filename += toString(getpid()) + "filterValues.temp";
-                               ofstream out;
-                               m->openOutputFile(filename, out);
-                               
-                               out << num << endl;
-                               out << F.getFilter() << endl;
-                               for (int k = 0; k < alignmentLength; k++) {             out << F.a[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < alignmentLength; k++) {             out << F.t[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < alignmentLength; k++) {             out << F.g[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < alignmentLength; k++) {             out << F.c[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < alignmentLength; k++) {             out << F.gap[k] << '\t'; }  out << endl;
-
-                               //cout << F.getFilter() << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent do your part
-               num = driverCreateFilter(F, filename, lines[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //parent reads in and combines Filter info
-               for (int i = 0; i < processIDS.size(); i++) {
-                       string tempFilename = filename + toString(processIDS[i]) + "filterValues.temp";
-                       ifstream in;
-                       m->openInputFile(tempFilename, in);
-                       
-                       int temp, tempNum;
-                       string tempFilterString;
-
-                       in >> tempNum; m->gobble(in); num += tempNum;
-
-                       in >> tempFilterString;
-                       F.mergeFilter(tempFilterString);
-
-                       for (int k = 0; k < alignmentLength; k++) {             in >> temp; F.a[k] += temp; }           m->gobble(in);
-                       for (int k = 0; k < alignmentLength; k++) {             in >> temp; F.t[k] += temp; }           m->gobble(in);
-                       for (int k = 0; k < alignmentLength; k++) {             in >> temp; F.g[k] += temp; }           m->gobble(in);
-                       for (int k = 0; k < alignmentLength; k++) {             in >> temp; F.c[k] += temp; }           m->gobble(in);
-                       for (int k = 0; k < alignmentLength; k++) {             in >> temp; F.gap[k] += temp; } m->gobble(in);
-                               
-                       in.close();
-                       m->mothurRemove(tempFilename);
-               }
-               
-               
-#else
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the filterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to F.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<filterData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors];
-               HANDLE  hThreadArray[processors]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors; i++ ){
-                       
-                       filterData* tempFilter = new filterData(filename, m, lines[i]->start, lines[i]->end, alignmentLength, trump, vertical, soft, hard, i);
-                       pDataArray.push_back(tempFilter);
-                       processIDS.push_back(i);
-            
-                       hThreadArray[i] = CreateThread(NULL, 0, MyCreateFilterThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            F.mergeFilter(pDataArray[i]->F.getFilter());
-            
-                       for (int k = 0; k < alignmentLength; k++) {      F.a[k] += pDataArray[i]->F.a[k];       }
-                       for (int k = 0; k < alignmentLength; k++) {      F.t[k] += pDataArray[i]->F.t[k];       }
-                       for (int k = 0; k < alignmentLength; k++) {      F.g[k] += pDataArray[i]->F.g[k];       }
-                       for (int k = 0; k < alignmentLength; k++) {      F.c[k] += pDataArray[i]->F.c[k];       }
-                       for (int k = 0; k < alignmentLength; k++) {      F.gap[k] += pDataArray[i]->F.gap[k];   }
-
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-#endif 
-        return num;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FilterSeqsCommand", "createProcessesCreateFilter");
-               exit(1);
-       }
-}
-/**************************************************************************************/
diff --git a/filterseqscommand.h b/filterseqscommand.h
deleted file mode 100644 (file)
index 4405c33..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-#ifndef FILTERSEQSCOMMAND_H\r
-#define FILTERSEQSCOMMAND_H\r
-\r
-/*\r
- *  filterseqscommand.h\r
- *  Mothur\r
- *\r
- *  Created by Thomas Ryabin on 5/4/09.\r
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.\r
- *\r
- */\r
-\r
-#include "command.hpp"\r
-#include "filters.h"\r
-\r
-class Sequence;\r
-class FilterSeqsCommand : public Command {\r
-\r
-public:\r
-       FilterSeqsCommand(string);\r
-       FilterSeqsCommand();\r
-       ~FilterSeqsCommand() {};\r
-       \r
-       vector<string> setParameters();\r
-       string getCommandName()                 { return "filter.seqs";                 }\r
-       string getCommandCategory()             { return "Sequence Processing"; }\r
-       string getHelpString(); \r
-       string getCitation() { return "http://www.mothur.org/wiki/Filter.seqs"; }\r
-       string getDescription()         { return "removes columns from alignments based on a criteria defined by the user"; }\r
-       \r
-       int execute(); \r
-       void help() { m->mothurOut(getHelpString()); }  \r
-       \r
-private:\r
-       struct linePair {\r
-               unsigned long long start;\r
-               unsigned long long end;\r
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}\r
-       };\r
-\r
-       vector<linePair*> lines;\r
-       vector<int> processIDS;\r
-    map<int, vector<unsigned long long> > savedPositions;\r
-\r
-       string vertical, filter, fasta, hard, outputDir, filterFileName;\r
-       vector<string> fastafileNames;  \r
-       int alignmentLength, processors;\r
-       vector<int> bufferSizes;\r
-       vector<string> outputNames;\r
-\r
-       char trump;\r
-       bool abort;\r
-       float soft;\r
-       int numSeqs;\r
-       \r
-       string createFilter();\r
-       int filterSequences();\r
-       int createProcessesCreateFilter(Filters&, string);\r
-       int createProcessesRunFilter(string, string, string);\r
-       int driverRunFilter(string, string, string, linePair*);\r
-       int driverCreateFilter(Filters& F, string filename, linePair* line);\r
-       #ifdef USE_MPI\r
-       int driverMPIRun(int, int, MPI_File&, MPI_File&, vector<unsigned long long>&);\r
-       int MPICreateFilter(int, int, Filters&, MPI_File&, vector<unsigned long long>&);        \r
-       #endif\r
-       \r
-};\r
-\r
-\r
-/**************************************************************************************************/\r
-//custom data structure for threads to use.\r
-// This is passed by void pointer so it can be any data type\r
-// that can be passed using a single void pointer (LPVOID).\r
-struct filterData {\r
-       Filters F;\r
-    int count, tid, alignmentLength;\r
-    unsigned long long start, end;\r
-    MothurOut* m;\r
-    string filename, vertical, hard;\r
-    char trump;\r
-    float soft;\r
-       \r
-       filterData(){}\r
-       filterData(string fn, MothurOut* mout, unsigned long long st, unsigned long long en, int aLength, char tr, string vert, float so, string ha, int t) {\r
-        filename = fn;\r
-               m = mout;\r
-               start = st;\r
-               end = en;\r
-        tid = t;\r
-        trump = tr;\r
-        alignmentLength = aLength;\r
-        vertical = vert;\r
-        soft = so;\r
-        hard = ha;\r
-               count = 0;\r
-       }\r
-};\r
-/**************************************************************************************************/\r
-//custom data structure for threads to use.\r
-// This is passed by void pointer so it can be any data type\r
-// that can be passed using a single void pointer (LPVOID).\r
-struct filterRunData {\r
-    int count, tid, alignmentLength;\r
-    unsigned long long start, end;\r
-    MothurOut* m;\r
-    string filename;\r
-    string filter, outputFilename;\r
-       \r
-       filterRunData(){}\r
-       filterRunData(string f, string fn, string ofn, MothurOut* mout, unsigned long long st, unsigned long long en, int aLength, int t) {\r
-        filter = f;\r
-        outputFilename = ofn;\r
-        filename = fn;\r
-               m = mout;\r
-               start = st;\r
-               end = en;\r
-        tid = t;\r
-        alignmentLength = aLength;\r
-               count = 0;\r
-       }\r
-};\r
-\r
-/**************************************************************************************************/\r
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)\r
-#else\r
-static DWORD WINAPI MyCreateFilterThreadFunction(LPVOID lpParam){ \r
-       filterData* pDataArray;\r
-       pDataArray = (filterData*)lpParam;\r
-       \r
-       try {\r
-\r
-               if (pDataArray->soft != 0)                      {  pDataArray->F.setSoft(pDataArray->soft);             }\r
-               if (pDataArray->trump != '*')           {  pDataArray->F.setTrump(pDataArray->trump);   }\r
-               \r
-               pDataArray->F.setLength(pDataArray->alignmentLength);\r
-               \r
-               if(pDataArray->trump != '*' || pDataArray->m->isTrue(pDataArray->vertical) || pDataArray->soft != 0){\r
-                       pDataArray->F.initialize();\r
-               }\r
-               \r
-               if(pDataArray->hard.compare("") != 0)   {       pDataArray->F.doHard(pDataArray->hard);         }\r
-               else                                            {       pDataArray->F.setFilter(string(pDataArray->alignmentLength, '1'));      }\r
-        \r
-               ifstream in;\r
-               pDataArray->m->openInputFile(pDataArray->filename, in);\r
-        \r
-               //print header if you are process 0\r
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {\r
-                       in.seekg(0);\r
-               }else { //this accounts for the difference in line endings. \r
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); \r
-               }\r
-               \r
-               pDataArray->count = pDataArray->end;\r
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process\r
-                       \r
-                       if (pDataArray->m->control_pressed) { in.close(); pDataArray->count = 1; return 1; }\r
-                       \r
-                       Sequence current(in); pDataArray->m->gobble(in); \r
-                       \r
-                       if (current.getName() != "") {\r
-                               if (current.getAligned().length() != pDataArray->alignmentLength) { pDataArray->m->mothurOut("Sequences are not all the same length, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true;  }\r
-                \r
-                if(pDataArray->trump != '*')                   {       pDataArray->F.doTrump(current);         }\r
-                if(pDataArray->m->isTrue(pDataArray->vertical) || pDataArray->soft != 0)       {       pDataArray->F.getFreqs(current);        }\r
-                       }\r
-            \r
-            //report progress\r
-                       if((i) % 100 == 0){     pDataArray->m->mothurOut(toString(i)); pDataArray->m->mothurOutEndLine();               }\r
-               }\r
-               \r
-        if((pDataArray->count) % 100 != 0){    pDataArray->m->mothurOut(toString(pDataArray->count)); pDataArray->m->mothurOutEndLine();               }\r
-        \r
-               in.close();\r
-               \r
-               return 0;\r
-               \r
-       }\r
-       catch(exception& e) {\r
-               pDataArray->m->errorOut(e, "FilterSeqsCommand", "MyCreateFilterThreadFunction");\r
-               exit(1);\r
-       }\r
-} \r
-/**************************************************************************************************/\r
-static DWORD WINAPI MyRunFilterThreadFunction(LPVOID lpParam){ \r
-       filterRunData* pDataArray;\r
-       pDataArray = (filterRunData*)lpParam;\r
-       \r
-       try {\r
-        \r
-        ofstream out;\r
-               pDataArray->m->openOutputFile(pDataArray->outputFilename, out);\r
-\r
-               ifstream in;\r
-               pDataArray->m->openInputFile(pDataArray->filename, in);\r
-        \r
-               //print header if you are process 0\r
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {\r
-                       in.seekg(0);\r
-               }else { //this accounts for the difference in line endings. \r
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); \r
-               }\r
-               \r
-               pDataArray->count = pDataArray->end;\r
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process\r
-                       \r
-                       if (pDataArray->m->control_pressed) { in.close(); out.close(); pDataArray->count = 1; return 1; }\r
-                       \r
-                       Sequence seq(in); pDataArray->m->gobble(in);\r
-            if (seq.getName() != "") {\r
-                string align = seq.getAligned();\r
-                string filterSeq = "";\r
-                \r
-                for(int j=0;j<pDataArray->alignmentLength;j++){\r
-                    if(pDataArray->filter[j] == '1'){\r
-                        filterSeq += align[j];\r
-                    }\r
-                }\r
-                \r
-                out << '>' << seq.getName() << endl << filterSeq << endl;\r
-            }\r
-            \r
-            //report progress\r
-                       if((i) % 100 == 0){     pDataArray->m->mothurOut(toString(i)); pDataArray->m->mothurOutEndLine();               }\r
-               }\r
-               \r
-        if((pDataArray->count) % 100 != 0){    pDataArray->m->mothurOut(toString(pDataArray->count)); pDataArray->m->mothurOutEndLine();               }\r
-        \r
-               in.close();\r
-        out.close();\r
-               \r
-               return 0;\r
-               \r
-       }\r
-       catch(exception& e) {\r
-               pDataArray->m->errorOut(e, "FilterSeqsCommand", "MyRunFilterThreadFunction");\r
-               exit(1);\r
-       }\r
-} \r
-/**************************************************************************************************/\r
-#endif\r
-\r
-\r
-#endif\r
diff --git a/flowdata.cpp b/flowdata.cpp
deleted file mode 100644 (file)
index 1420f84..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- *  flowdata.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "flowdata.h"
-
-//**********************************************************************************************************************
-
-FlowData::FlowData(){}
-
-//**********************************************************************************************************************
-
-FlowData::~FlowData(){ /*      do nothing      */      }
-
-//**********************************************************************************************************************
-
-FlowData::FlowData(int numFlows, float signal, float noise, int maxHomoP, string baseFlow) : 
-                       numFlows(numFlows), signalIntensity(signal), noiseIntensity(noise), maxHomoP(maxHomoP), baseFlow(baseFlow){
-
-       try {
-               m = MothurOut::getInstance();
-
-               flowData.assign(numFlows, 0);
-//             baseFlow = "TACG";
-               seqName = "";
-               locationString = "";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "FlowData");
-               exit(1);
-       }
-       
-}
-
-//**********************************************************************************************************************
-
-bool FlowData::getNext(ifstream& flowFile){
-       
-       try {
-               flowFile >> seqName >> endFlow; 
-               //cout << "in Flowdata " + seqName << endl;
-               for(int i=0;i<numFlows;i++)     {       flowFile >> flowData[i];        }
-               //cout << "in Flowdata read " << seqName + " done" << endl;
-               updateEndFlow(); 
-               translateFlow();
-               
-               m->gobble(flowFile);
-               if(flowFile){   return 1;       }
-               else            {       return 0;       }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "getNext");
-               exit(1);
-       }
-       
-}
-
-//**********************************************************************************************************************
-
-void FlowData::updateEndFlow(){
-       try{
-               
-               //int currLength = 0;
-               float maxIntensity = (float) maxHomoP + 0.49;
-               
-               int deadSpot = 0;
-                               
-               while(deadSpot < endFlow){
-                       int signal = 0;
-                       int noise = 0;
-                       
-                       for(int i=0;i<4;i++){
-                               float intensity = flowData[i + deadSpot];
-                               if(intensity > signalIntensity){
-                                       signal++;
-
-                                       if(intensity  < noiseIntensity || intensity > maxIntensity){
-                                               noise++;
-                                       }
-                               }
-                       }
-
-                       if(noise > 0 || signal == 0){
-                               break;
-                       }
-               
-                       deadSpot += 4;
-               }
-               endFlow = deadSpot;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "findDeadSpot");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void FlowData::translateFlow(){
-       
-       try{
-               sequence = "";
-               for(int i=0;i<endFlow;i++){
-                       int intensity = (int)(flowData[i] + 0.5);
-                       char base = baseFlow[i % 4];
-                       
-                       for(int j=0;j<intensity;j++){
-                               sequence += base;
-                       }
-               }
-
-               if(sequence.size() > 4){
-                       sequence = sequence.substr(4);
-               }
-               else{
-                       sequence = "NNNN";
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "translateFlow");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void FlowData::capFlows(int mF){
-       
-       try{
-               
-               maxFlows = mF;
-               if(endFlow > maxFlows){ endFlow = maxFlows;     }       
-        translateFlow();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "capFlows");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-bool FlowData::hasMinFlows(int minFlows){
-       
-       try{
-               bool pastMin = 0;
-               if(endFlow >= minFlows){        pastMin = 1;    }
-
-               return pastMin;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "hasMinFlows");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-Sequence FlowData::getSequence(){
-       
-       try{
-               return Sequence(seqName, sequence);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "getSequence");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void FlowData::printFlows(ofstream& outFlowFile){
-       try{
-//     outFlowFile << '>' << seqName << locationString << " length=" << seqLength << " numflows=" << maxFlows << endl;
-               outFlowFile << seqName << ' ' << endFlow << ' ' << setprecision(2);
-
-               for(int i=0;i<maxFlows;i++){
-                       outFlowFile << flowData[i] << ' ';
-               }
-               outFlowFile << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "printFlows");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void FlowData::printFlows(ofstream& outFlowFile, string scrapCode){
-       try{
-               outFlowFile << seqName << '|' << scrapCode << ' ' << endFlow << ' ' << setprecision(2);
-               
-               for(int i=0;i<numFlows;i++){
-                       outFlowFile << flowData[i] << ' ';
-               }
-               outFlowFile << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "printFlows");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-string FlowData::getName(){
-       
-       try{
-               return seqName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FlowData", "getName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/flowdata.h b/flowdata.h
deleted file mode 100644 (file)
index 1007653..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef FLOWDATA_H
-#define FLOWDATA_H
-
-/*
- *  flowdata.h
- *  Mothur
- *
- *  Created by Pat Schloss on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "sequence.hpp"
-
-class FlowData {
-
-public:
-       FlowData();
-       FlowData(int, float, float, int, string);
-       ~FlowData();
-       bool getNext(ifstream&);
-       string getName();
-       void capFlows(int);
-       bool hasMinFlows(int);
-       Sequence getSequence();
-
-       void printFlows(ofstream&);
-       void printFlows(ofstream&, string);
-private:
-       MothurOut* m;
-       
-       void updateEndFlow();
-       void translateFlow();
-       float signalIntensity, noiseIntensity;
-       int maxHomoP;
-       string seqName, locationString, sequence, baseFlow;
-       int numFlows, maxFlows, endFlow;
-       vector<float> flowData;
-};
-
-#endif
diff --git a/formatcolumn.cpp b/formatcolumn.cpp
deleted file mode 100644 (file)
index 6b29f90..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- *  formatcolumn.cpp
- *  Mothur
- *
- *  Created by westcott on 1/13/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "formatcolumn.h"
-#include "progress.hpp"
-
-/***********************************************************************/
-FormatColumnMatrix::FormatColumnMatrix(string df) : filename(df){
-       m->openInputFile(filename, fileHandle);
-}
-/***********************************************************************/
-
-int FormatColumnMatrix::read(NameAssignment* nameMap){
-       try {           
-
-               string firstName, secondName;
-               float distance;
-               int nseqs = nameMap->size();
-
-               list = new ListVector(nameMap->getListVector());
-       
-               Progress* reading = new Progress("Formatting matrix:     ", nseqs * nseqs);
-
-               int lt = 1;
-               int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose
-               int refCol = 0; //shows up later - Cell(refCol,refRow).  If it does, then its a square matrix
-
-               //need to see if this is a square or a triangular matrix...
-               
-               ofstream out;
-               string tempOutFile = filename + ".temp";
-               m->openOutputFile(tempOutFile, out);
-       
-               while(fileHandle && lt == 1){  //let's assume it's a triangular matrix...
-               
-                       if (m->control_pressed) { out.close();  m->mothurRemove(tempOutFile); fileHandle.close();  delete reading; return 0; }
-               
-                       fileHandle >> firstName >> secondName >> distance;      // get the row and column names and distance
-       
-                       map<string,int>::iterator itA = nameMap->find(firstName);
-                       map<string,int>::iterator itB = nameMap->find(secondName);
-                       if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                       if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-
-                       if (distance == -1) { distance = 1000000; }
-               
-                       if((distance < cutoff) && (itA != itB)){
-                               if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
-                                       refRow = itA->second;
-                                       refCol = itB->second;
-                                       
-                                       //making it square
-                                       out << itA->second << '\t' << itB->second << '\t' << distance << endl;
-                                       out << itB->second << '\t' << itA->second << '\t' << distance << endl;
-                               }
-                               else if(refRow == itA->second && refCol == itB->second){        lt = 0;         } //you are square
-                               else if(refRow == itB->second && refCol == itA->second){        lt = 0;         }  //you are square
-                               else{   //making it square
-                                       out << itA->second << '\t' << itB->second << '\t' << distance << endl;
-                                       out << itB->second << '\t' << itA->second << '\t' << distance << endl;
-                               }
-                               
-                               reading->update(itA->second * nseqs / 2);
-                       }
-                       m->gobble(fileHandle);
-               }
-               out.close();
-               fileHandle.close();
-       
-               string squareFile;
-               if(lt == 0){  // oops, it was square
-                       squareFile = filename;
-               }else{ squareFile = tempOutFile; }
-               
-               //sort file by first column so the distances for each row are together
-               string outfile = m->getRootName(squareFile) + "sorted.dist.temp";
-               
-               //use the unix sort 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       string command = "sort -n " + squareFile + " -o " + outfile;
-                       system(command.c_str());
-               #else //sort using windows sort
-                       string command = "sort " + squareFile + " /O " + outfile;
-                       system(command.c_str());
-               #endif
-               
-               if (m->control_pressed) { m->mothurRemove(tempOutFile); m->mothurRemove(outfile); delete reading; return 0; }
-
-               //output to new file distance for each row and save positions in file where new row begins
-               ifstream in;
-               m->openInputFile(outfile, in);
-               
-               distFile = outfile + ".rowFormatted";
-               m->openOutputFile(distFile, out);
-               
-               rowPos.resize(nseqs, -1);
-               int currentRow;
-               int first, second;
-               float dist;
-               map<int, float> rowMap;
-               map<int, float>::iterator itRow;
-               
-               //get first currentRow
-               in >> first;
-               currentRow = first;
-               
-               string firstString = toString(first);
-               for(int k = 0; k < firstString.length(); k++)  {   in.putback(firstString[k]);  }
-               
-               while(!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(distFile); m->mothurRemove(tempOutFile); m->mothurRemove(outfile); delete reading; return 0; }
-                       
-                       in >> first >> second >> dist; m->gobble(in);
-                       
-                       if (first != currentRow) {
-                               //save position in file of each new row
-                               rowPos[currentRow] = out.tellp();
-                               
-                               out << currentRow << '\t' << rowMap.size() << '\t';
-                               
-                               for (itRow = rowMap.begin(); itRow != rowMap.end(); itRow++) {
-                                       out << itRow->first << '\t' << itRow->second << '\t';
-                               }
-                               out << endl;
-                               
-                               currentRow = first;
-                               rowMap.clear();
-                               
-                               //save row you just read
-                               if (dist < cutoff) {
-                                       rowMap[second] = dist;
-                               }
-                       }else{
-                               if (dist < cutoff) {
-                                       rowMap[second] = dist;
-                               }
-                       }
-               }
-               
-               //print last Row
-               //save position in file of each new row
-               rowPos[currentRow] = out.tellp();
-               
-               out << currentRow << '\t' << rowMap.size() << '\t';
-               
-               for (itRow = rowMap.begin(); itRow != rowMap.end(); itRow++) {
-                       out << itRow->first << '\t' << itRow->second << '\t';
-               }
-               out << endl;
-               
-               
-               in.close();
-               out.close();
-               
-               if (m->control_pressed) {  m->mothurRemove(distFile); m->mothurRemove(tempOutFile); m->mothurRemove(outfile);  delete reading; return 0; }
-               
-               m->mothurRemove(tempOutFile);
-               m->mothurRemove(outfile);
-               
-               reading->finish();
-               
-               delete reading;
-               list->setLabel("0");
-               
-               if (m->control_pressed) {  m->mothurRemove(distFile);  return 0; }
-
-               return 1;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FormatColumnMatrix", "read");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-FormatColumnMatrix::~FormatColumnMatrix(){}
-/***********************************************************************/
-
-
-
diff --git a/formatcolumn.h b/formatcolumn.h
deleted file mode 100644 (file)
index 0fe96ed..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef FORMATCOLUMN_H
-#define FORMATCOLUMN_H
-/*
- *  formatcolumn.h
- *  Mothur
- *
- *  Created by westcott on 1/13/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "formatmatrix.h"
-
-/******************************************************/
-
-class FormatColumnMatrix : public FormatMatrix {
-       
-public:
-       FormatColumnMatrix(string);
-       ~FormatColumnMatrix();
-       int read(NameAssignment*);
-       
-private:
-       ifstream fileHandle;
-       string filename;
-       
-};
-
-/******************************************************/
-
-#endif
-
diff --git a/formatmatrix.h b/formatmatrix.h
deleted file mode 100644 (file)
index 7e7a99c..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef FORMATMATRIX_H
-#define FORMATMATRIX_H
-
-/*
- *  formatmatrix.h
- *  Mothur
- *
- *  Created by westcott on 1/13/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "listvector.hpp"
-#include "nameassignment.hpp"
-
-
-//**********************************************************************************************************************
-//  This class takes a distance matrix file and converts it to a file where each row contains all distances below the cutoff
-//  for a given sequence.
-
-//  Example:
-       /*      5
-               A  
-               B  0.01 
-               C  0.015 0.03 
-               D  0.03 0.02 0.02  
-               E  0.04 0.05 0.03 0.02   
-               
-               becomes 
-               
-               0       4       1       0.01    2       0.015   3       0.03    4       0.04    
-               1       4       0       0.01    2       0.03    3       0.02    4       0.05    
-               2       4       0       0.015   1       0.03    3       0.02    4       0.03    
-               3       4       0       0.03    1       0.02    2       0.02    4       0.02    
-               4       4       0       0.04    1       0.05    2       0.03    3       0.02
-               
-               column 1 - sequence name converted to row number
-               column 2 - numDists under cutoff
-               rest of line - sequence row -> distance, sequence row -> distance
-               
-               if you had a cutoff of 0.03 then the file would look like,
-               
-               0       3       1       0.01    2       0.015   3       0.03    
-               1       3       0       0.01    2       0.03    3       0.02    
-               2       4       0       0.015   1       0.03    3       0.02    4       0.03    
-               3       4       0       0.03    1       0.02    2       0.02    4       0.02    
-               4       2       2       0.03    3       0.02    
-               
-               This class also creates a vector of ints, rowPos.
-               
-               rowPos[0] = position in the file of distances related to sequence 0.
-               If a sequence is excluded by the cutoff, it's rowPos = -1.
-*/
-//**********************************************************************************************************************
-
-class FormatMatrix {
-
-public:
-       FormatMatrix(){ m = MothurOut::getInstance(); }
-       virtual ~FormatMatrix() {}
-       
-       virtual int read(NameAssignment*){ return 1; }
-       
-       void setCutoff(float c)                 {       cutoff = c;                     }
-       ListVector* getListVector()             {       return list;            }
-       string getFormattedFileName()   {       return distFile;        }
-       vector<int> getRowPositions()   {       return rowPos;          }
-       
-protected:
-       ListVector* list;
-       float cutoff;
-       string distFile;
-       vector<int> rowPos;
-       MothurOut* m;
-};
-
-//**********************************************************************************************************************
-
-#endif
-
diff --git a/formatphylip.cpp b/formatphylip.cpp
deleted file mode 100644 (file)
index 6059117..0000000
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- *  formatphylip.cpp
- *  Mothur
- *
- *  Created by westcott on 1/13/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "formatphylip.h"
-#include "progress.hpp"
-
-/***********************************************************************/
-FormatPhylipMatrix::FormatPhylipMatrix(string df) : filename(df) {
-        m->openInputFile(filename, fileHandle);
-}
-/***********************************************************************/
-//not using nameMap
-int FormatPhylipMatrix::read(NameAssignment* nameMap){
-       try {
-        
-                       float distance;
-                       int square, nseqs;
-                       string name;
-                       ofstream out;
-                       
-                       string numTest;
-                       fileHandle >> numTest >> name;
-                       
-                       if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ", quitting."); m->mothurOutEndLine(); exit(1); }
-                       else { convert(numTest, nseqs); }
-               
-                                               
-                       list = new ListVector(nseqs);
-                       list->set(0, name);
-                       
-                       char d;
-                       while((d=fileHandle.get()) != EOF){
-                
-                               if(isalnum(d)){  //you are square
-                                       square = 1;
-                                       fileHandle.close();  //reset file
-                                       
-                                       //open and get through numSeqs, code below formats rest of file
-                                       m->openInputFile(filename, fileHandle);
-                                       fileHandle >> nseqs; m->gobble(fileHandle);
-                                       
-                                       distFile = filename + ".rowFormatted";
-                                       m->openOutputFile(distFile, out);
-                                       break;
-                               }
-                               if(d == '\n'){
-                                       square = 0;
-                                       break;
-                               }
-                       }
-                       
-                       Progress* reading;
-                       reading = new Progress("Formatting matrix:     ", nseqs * nseqs);
-                       
-                       //lower triangle, so must go to column then formatted row file
-                       if(square == 0){
-                               int  index = 0;
-                               
-                               ofstream outTemp;
-                               string tempFile = filename + ".temp";
-                               m->openOutputFile(tempFile, outTemp);
-                
-                               //convert to square column matrix
-                               for(int i=1;i<nseqs;i++){
-                               
-                                       fileHandle >> name;
-                                       
-                                       list->set(i, name);
-                                       
-                                       for(int j=0;j<i;j++){
-                                       
-                                               if (m->control_pressed) { outTemp.close(); m->mothurRemove(tempFile); fileHandle.close();  delete reading; return 0; }
-                                                                                       
-                                               fileHandle >> distance;
-                                               
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if(distance < cutoff){
-                                                       outTemp << i << '\t' << j << '\t' << distance << endl;
-                                                       outTemp << j << '\t' << i << '\t' << distance << endl;
-                                               }
-                                               index++;
-                                               reading->update(index);
-                                       }
-                               }
-                               outTemp.close();
-                               
-                               //format from square column to rowFormatted
-                               //sort file by first column so the distances for each row are together
-                               string outfile = m->getRootName(tempFile) + "sorted.dist.temp";
-                               
-                               //use the unix sort 
-                               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                       string command = "sort -n " + tempFile + " -o " + outfile;
-                                       system(command.c_str());
-                               #else //sort using windows sort
-                                       string command = "sort " + tempFile + " /O " + outfile;
-                                       system(command.c_str());
-                               #endif
-                               
-                               if (m->control_pressed) { m->mothurRemove(tempFile); m->mothurRemove(outfile);  delete reading; return 0; }
-
-                               //output to new file distance for each row and save positions in file where new row begins
-                               ifstream in;
-                               m->openInputFile(outfile, in);
-                               
-                               distFile = outfile + ".rowFormatted";
-                               m->openOutputFile(distFile, out);
-                               
-                               rowPos.resize(nseqs, -1);
-                               int currentRow;
-                               int first, second;
-                               float dist;
-                               map<int, float> rowMap;
-                               map<int, float>::iterator itRow;
-                               
-                               //get first currentRow
-                               in >> first;
-                               currentRow = first;
-                               
-                               string firstString = toString(first);
-                               for(int k = 0; k < firstString.length(); k++)  {   in.putback(firstString[k]);  }
-                               
-                               while(!in.eof()) {
-                                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); m->mothurRemove(distFile); m->mothurRemove(outfile);  delete reading; return 0; }
-
-                                       in >> first >> second >> dist; m->gobble(in);
-                                       
-                                       if (first != currentRow) {
-                                               //save position in file of each new row
-                                               rowPos[currentRow] = out.tellp();
-                                               
-                                               out << currentRow << '\t' << rowMap.size() << '\t';
-                                               
-                                               for (itRow = rowMap.begin(); itRow != rowMap.end(); itRow++) {
-                                                       out << itRow->first << '\t' << itRow->second << '\t';
-                                               }
-                                               out << endl;
-                                               
-                                               currentRow = first;
-                                               rowMap.clear();
-                                               
-                                               //save row you just read
-                                               rowMap[second] = dist;
-                                               
-                                               index++;
-                                               reading->update(index);
-                                       }else{
-                                               rowMap[second] = dist;
-                                       }
-                               }
-                               
-                               //print last Row
-                               //save position in file of each new row
-                               rowPos[currentRow] = out.tellp();
-                               
-                               out << currentRow << '\t' << rowMap.size() << '\t';
-                               
-                               for (itRow = rowMap.begin(); itRow != rowMap.end(); itRow++) {
-                                       out << itRow->first << '\t' << itRow->second << '\t';
-                               }
-                               out << endl;
-                               
-                               in.close();
-                               out.close();
-                               
-                               m->mothurRemove(tempFile);
-                               m->mothurRemove(outfile);
-                               
-                               if (m->control_pressed) {  m->mothurRemove(distFile);   delete reading; return 0; }
-
-                       }
-                       else{ //square matrix convert directly to formatted row file
-                               int index = nseqs;
-                               map<int, float> rowMap;
-                               map<int, float>::iterator itRow;
-                               rowPos.resize(nseqs, -1);
-                
-                               for(int i=0;i<nseqs;i++){
-                                       fileHandle >> name;                
-                                                                       
-                                       list->set(i, name);
-                                       
-                                       for(int j=0;j<nseqs;j++){
-                                               if (m->control_pressed) {  fileHandle.close(); out.close(); m->mothurRemove(distFile);   delete reading; return 0; }
-                                               
-                                               fileHandle >> distance;
-                                       
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if((distance < cutoff) && (j != i)){
-                                                       rowMap[j] = distance;
-                                               }
-                                               index++;
-                                               reading->update(index);
-                                       }
-                                       
-                                       m->gobble(fileHandle);
-                       
-                                       //save position in file of each new row
-                                       rowPos[i] = out.tellp();
-
-                                       //output row to file
-                                       out << i << '\t' << rowMap.size() << '\t';
-                                       for (itRow = rowMap.begin(); itRow != rowMap.end(); itRow++) {
-                                               out << itRow->first << '\t' << itRow->second << '\t';
-                                       }
-                                       out << endl;
-                                       
-                                       //clear map for new row's info
-                                       rowMap.clear();
-                               }
-                       }
-                       reading->finish();
-                       delete reading;
-                       fileHandle.close();
-                       out.close();
-                       
-                       if (m->control_pressed) { m->mothurRemove(distFile);  return 0; }
-                       
-                       list->setLabel("0");
-                       
-                       return 1;
-                       
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FormatPhylipMatrix", "read");
-                exit(1);
-       }
-}
-/***********************************************************************/
-FormatPhylipMatrix::~FormatPhylipMatrix(){}
-/***********************************************************************/
-
-
diff --git a/formatphylip.h b/formatphylip.h
deleted file mode 100644 (file)
index b920d08..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef FORMATPHYLIP_H
-#define FORMATPHYLIP_H
-
-/*
- *  formatphylip.h
- *  Mothur
- *
- *  Created by westcott on 1/13/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "formatmatrix.h"
-
-/******************************************************/
-
-class FormatPhylipMatrix : public FormatMatrix {
-       
-public:
-       FormatPhylipMatrix(string);
-       ~FormatPhylipMatrix();
-       int read(NameAssignment*);
-private:
-       ifstream fileHandle;
-       string filename;
-};
-
-/******************************************************/
-
-#endif
-
diff --git a/fullmatrix.cpp b/fullmatrix.cpp
deleted file mode 100644 (file)
index 4451d66..0000000
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- *  fullmatrix.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "fullmatrix.h"
-
-/**************************************************************************/
-//This constructor reads a distance matrix file and stores the data in the matrix.
-FullMatrix::FullMatrix(ifstream& filehandle, GroupMap* g, bool s) : groupmap(g), sim(s) {
-       try{
-               m = MothurOut::getInstance();
-               
-               string name, group;
-               
-               filehandle >> numSeqs >> name;
-       
-               //make the matrix filled with zeros
-               matrix.resize(numSeqs); 
-               for(int i = 0; i < numSeqs; i++) {
-                       matrix[i].resize(numSeqs, 0.0);
-               }
-               group = groupmap->getGroup(name);
-               if(group == "not found") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
-               index.resize(numSeqs);
-               index[0].seqName = name;
-               index[0].groupName = group;
-               
-               //determine if matrix is square or lower triangle
-               //if it is square read the distances for the first sequence
-               char d;
-               bool square;
-               while((d=filehandle.get()) != EOF){
-                       
-                       //is d a number meaning its square
-                       if(isalnum(d)){ 
-                               square = true;
-                               filehandle.putback(d);
-                               
-                               for(int i=0;i<numSeqs;i++){
-                                       filehandle >> matrix[0][i];
-                                       if (sim) {  matrix[0][i] = 1.0 - matrix[0][i];  }
-                               }
-                               break;
-                       }
-                       
-                       //is d a line return meaning its lower triangle
-                       if(d == '\n'){
-                               square = false;
-                               break;
-                       }
-               }
-       
-               //read rest of matrix
-               if (square == true) {  readSquareMatrix(filehandle); }
-               else {  readLTMatrix(filehandle); }
-               
-               filehandle.close();
-               
-               if (!m->control_pressed) { sortGroups(0, numSeqs-1); }  
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "FullMatrix");
-               exit(1);
-       }
-}
-/**************************************************************************/
-int FullMatrix::readSquareMatrix(ifstream& filehandle) {
-       try {
-       
-               Progress* reading;
-               reading = new Progress("Reading matrix:     ", numSeqs * numSeqs);
-               
-               int count = 0;
-               
-               string group, name;
-       
-               for(int i=1;i<numSeqs;i++){
-                       filehandle >> name;             
-                       
-                       group = groupmap->getGroup(name);
-                       index[i].seqName = name;
-                       index[i].groupName = group;
-                       
-                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine(); exit(1); }
-                               
-                       for(int j=0;j<numSeqs;j++){
-                               if (m->control_pressed) { delete reading;  return 0; }
-                               
-                               filehandle >> matrix[i][j];
-                               if (sim) {  matrix[i][j] = 1.0 - matrix[i][j];  }
-                               
-                               count++;
-                               reading->update(count);
-                       }
-               }
-               
-               if (m->control_pressed) { delete reading;  return 0; }
-               
-               reading->finish();
-               delete reading;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "readSquareMatrix");
-               exit(1);
-       }
-} 
-/**************************************************************************/
-int FullMatrix::readLTMatrix(ifstream& filehandle) {
-       try {
-               
-               Progress* reading;
-               reading = new Progress("Reading matrix:     ", numSeqs * (numSeqs - 1) / 2);
-               
-               int count = 0;
-               float distance;
-
-               string group, name;
-       
-               for(int i=1;i<numSeqs;i++){
-                       filehandle >> name;             
-                                       
-                       group = groupmap->getGroup(name);
-                       index[i].seqName = name;
-                       index[i].groupName = group;
-       
-                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                               
-                       for(int j=0;j<i;j++){
-                               if (m->control_pressed) { delete reading;  return 0; }
-                               
-                               filehandle >> distance;
-                               if (sim) {  distance = 1.0 - distance;  }
-                               
-                               matrix[i][j] = distance;  matrix[j][i] = distance;
-                               
-                               count++;
-                               reading->update(count);
-                       }
-               }
-               
-               if (m->control_pressed) { delete reading;  return 0; }
-               
-               reading->finish();
-               delete reading;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "readLTMatrix");
-               exit(1);
-       }
-}
-
-/**************************************************************************/
-
-void FullMatrix::sortGroups(int low, int high){
-       try{
-               
-               if (low < high) {
-                       int i = low+1;
-                       int j = high;
-                       int pivot = (low+high) / 2;
-                       
-                       swapRows(low, pivot);  //puts pivot in final spot
-                       
-                       /* compare value */
-                       //what group does this row belong to
-                       string key = index[low].groupName;
-                       
-                       /* partition */
-                       while(i <= j) {
-                               /* find member above ... */
-                               while((i <= high) && (index[i].groupName <= key))       {  i++;  }  
-                               
-                               /* find element below ... */
-                               while((j >= low) && (index[j].groupName > key))         {  j--;  } 
-                                                               
-                               if(i < j) {
-                                       swapRows(i, j);
-                               }
-                       } 
-                       
-                       swapRows(low, j);
-                       
-                       /* recurse */
-                       sortGroups(low, j-1);
-                       sortGroups(j+1, high); 
-               }
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "sortGroups");
-               exit(1);
-       }
-}
-
-/**************************************************************************/   
-void FullMatrix::swapRows(int i, int j) {
-       try {
-       
-               float y;
-               string z, name;
-               
-               /* swap rows*/
-               for (int h = 0; h < numSeqs; h++) {
-                       y = matrix[i][h];
-                       matrix[i][h] = matrix[j][h]; 
-                       matrix[j][h] = y;
-               }
-               
-               /* swap columns*/
-               for (int b = 0; b < numSeqs; b++) {
-                       y = matrix[b][i];
-                       matrix[b][i] = matrix[b][j]; 
-                       matrix[b][j] = y;
-               }
-               
-               //swap map elements
-               z = index[i].groupName;
-               index[i].groupName = index[j].groupName;
-               index[j].groupName = z;
-               
-               name = index[i].seqName;
-               index[i].seqName = index[j].seqName;
-               index[j].seqName = name;
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "swapRows");
-               exit(1);
-       }
-}
-/**************************************************************************/   
-
-float FullMatrix::get(int i, int j){   return matrix[i][j];            }
-
-/**************************************************************************/   
-
-vector<string> FullMatrix::getGroups(){        return groups;          }
-
-/**************************************************************************/   
-
-vector<int> FullMatrix::getSizes(){    return sizes;           }
-
-/**************************************************************************/   
-
-int FullMatrix::getNumGroups(){        return groups.size();           }
-
-/**************************************************************************/   
-
-int FullMatrix::getNumSeqs(){  return numSeqs;         }
-
-/**************************************************************************/
-
-void FullMatrix::printMatrix(ostream& out) {
-       try{
-               for (int i = 0; i < numSeqs; i++) {
-                       out << "row " << i << " group = " << index[i].groupName << " name = " << index[i].seqName << endl;
-                       for (int j = 0; j < numSeqs; j++) {
-                               out << i << '\t' << j << '\t' << matrix[i][j] << endl;
-                       }
-                       out << endl;
-               }
-               
-               for (int i = 0; i < numSeqs; i++) {  out << i << '\t' <<  index[i].seqName << endl;  }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "FullMatrix", "printMatrix");
-               exit(1);
-       }
-}
-
-/**************************************************************************/
-
diff --git a/fullmatrix.h b/fullmatrix.h
deleted file mode 100644 (file)
index 9de7ead..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef FULLMATRIX_H
-#define FULLMATRIX_H
-/*
- *  fullmatrix.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "groupmap.h"
-#include "progress.hpp"
-
-
-struct Names {
-       string          seqName;
-       string          groupName;
-};
-
-class FullMatrix {
-       
-public:
-       //FullMatrix(){ m = MothurOut::getInstance(); }
-       FullMatrix(ifstream&, GroupMap*, bool);
-       ~FullMatrix(){};
-       
-       int getNumSeqs();
-       vector<int> getSizes();
-       vector<string> getGroups();
-       void setGroups(vector<string> names) { groups = names;  }
-       void setSizes(vector<int> s)             { sizes = s;           }
-       int getNumGroups();
-       void printMatrix(ostream&);
-       float get(int, int);
-       Names getRowInfo(int row)  {  return index[row];  }
-       
-private:
-       vector< vector<float> > matrix;  //a 2D distance matrix of all the sequences and their distances to eachother.
-       int readSquareMatrix(ifstream&);  
-       int readLTMatrix(ifstream&);
-       vector<Names> index; // row in vector, sequence group.  need to know this so when we sort it can be updated.
-       vector<int> sizes;
-       vector<string> groups;
-       
-       void sortGroups(int, int);  //this function sorts the sequences within the matrix.
-       void swapRows(int, int);
-       
-       GroupMap* groupmap;  //maps sequences to groups they belong to.
-       int numSeqs;
-       int numGroups;
-       int numUserGroups;
-       bool sim;
-       MothurOut* m;
-};
-
-#endif
diff --git a/geom.cpp b/geom.cpp
deleted file mode 100644 (file)
index 5bd150e..0000000
--- a/geom.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- *  geom.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "geom.h"
-
-/***********************************************************************/
-
-double Geom::kEq(double k, double spec){
-       return k/(1-k)*pow(1-k, spec)/(1-pow(1-k, spec));
-}
-
-RAbundVector Geom::getRAbundVector(SAbundVector* rank){
-               vector <int> rData;
-               int mr = 1;
-               int nb = 0;
-               int ns = 0;
-               
-               for(int i = rank->size()-1; i > 0; i--) {
-                       int cur = rank->get(i);
-                       if(mr == 1 && cur > 0)
-                               mr = i;
-                       nb += cur;
-                       ns += i*cur;
-                       for(int j = 0; j < cur; j++)
-                               rData.push_back(i);
-               }
-               
-               RAbundVector rav = RAbundVector(rData, mr, nb, ns);
-               rav.setLabel(rank->getLabel());
-               return rav;
-}
-
-/***********************************************************************************/
-
-/***********************************************************************************/
-EstOutput Geom::getValues(SAbundVector* rank){
-       try {
-               data.resize(3,0);
-               
-               rdata = getRAbundVector(rank);
-               double numInd = rdata.getNumSeqs();
-               double numSpec = rdata.getNumBins();
-               double min = rdata.get(rdata.size()-1);
-               double k = .5;
-               double step = .49999;
-               
-               while(fabs(min - numInd*kEq(k, (double)numSpec)) > .0001) { //This uses a binary search to find the value of k.
-                       if(numInd*kEq(k, numSpec) > min)
-                               k += step;
-                       else
-                               k -= step;
-                       step /= 2;
-               }
-               
-               double cK = 1/(1-pow(1-k, numSpec));
-               double sumExp = 0;
-               double sumObs = 0;
-               double maxDiff = 0;
-               
-               for(int i = 0; i < numSpec; i++)
-               {
-                       sumObs += rdata.get(i);
-                       sumExp += numInd*cK*k*pow(1-k, i);
-                       
-                       double diff = fabs(sumObs-sumExp);
-                       if(diff > maxDiff)      {       maxDiff = diff;         }
-                       
-               }
-
-
-               data[0] = maxDiff/numInd;
-               data[1] = 0.886/sqrt(numSpec);
-               data[2] = 1.031/sqrt(numSpec);
-
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Geom", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-
-
-
-
-
diff --git a/geom.h b/geom.h
deleted file mode 100644 (file)
index a07676b..0000000
--- a/geom.h
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef GEOM_H
-#define GEOM_H
-
-/*
- *  geom.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/* This class implements the geometric estimator on single group. 
-It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Geom : public Calculator  {
-       
-public:
-
-       Geom() : Calculator("geometric", 3, false) {};
-
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Geometric"; }
-private:
-       double kEq(double, double);
-       RAbundVector getRAbundVector(SAbundVector*);
-       RAbundVector rdata;
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
-
-
diff --git a/getcommandinfocommand.cpp b/getcommandinfocommand.cpp
deleted file mode 100644 (file)
index 03c6b17..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- *  getcommandinfo.cpp
- *  Mothur
- *
- *  Created by westcott on 4/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getcommandinfocommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetCommandInfoCommand::setParameters(){ 
-       try {
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCommandInfoCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetCommandInfoCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "This command is used by the gui to get the information about current commands available in mothur.\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCommandInfoCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-GetCommandInfoCommand::GetCommandInfoCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       output = validParameter.validFile(parameters, "output", false);                 
-                       if (output == "not found") {  output = ""; m->mothurOut("You must provide an output filename."); m->mothurOutEndLine(); abort=true; } 
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCommandInfoCommand", "GetCommandInfoCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetCommandInfoCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               commandFactory = CommandFactory::getInstance();
-               
-               ofstream out;
-               m->openOutputFile(output+".temp", out);
-               
-               int numNonHidden = 0;
-               
-               out << "mothurLocation=" << m->getFullPathName(m->argv) << endl;
-               out << "mothurVersion=" << m->getVersion() << endl;
-               
-               map<string, string> commands = commandFactory->getListCommands();
-               map<string, string>::iterator it;
-               
-               //loop through each command outputting info
-               for (it = commands.begin(); it != commands.end(); it++) {
-                       
-                       if (m->control_pressed) { m->mothurOut("[ERROR]: did not complete making the file."); m->mothurOutEndLine(); out.close(); m->mothurRemove((output+".temp")); }
-                       
-                       Command* thisCommand = commandFactory->getCommand(it->first);
-                       
-                       //don't add hidden commands
-                       if (thisCommand->getCommandCategory() != "Hidden") {
-                               numNonHidden++;
-                               
-                               //general info
-                               out << "commandName=" << thisCommand->getCommandName() << endl;
-                               //cout << thisCommand->getCommandName() << " current citation = " << thisCommand->getCitation() << endl;
-                               out << "commandCategory=" << thisCommand->getCommandCategory() << endl;
-                               
-                               //remove /n from help string since gui reads line by line
-                               string myhelpString = thisCommand->getHelpString();
-                               string newHelpString = "";
-                               for (int i = 0; i < myhelpString.length(); i++) { 
-                                       if (myhelpString[i] != '\n') { newHelpString += myhelpString[i]; }
-                               }
-                               out << "help=" << newHelpString << endl;
-                               
-                               //remove /n from citation string since gui reads line by line
-                               string mycitationString = thisCommand->getCitation();
-                               string newCitationString = "";
-                               for (int i = 0; i < mycitationString.length(); i++) { 
-                                       if (mycitationString[i] != '\n') { newCitationString += mycitationString[i]; }
-                               }
-                               out << "citation=" << newCitationString << endl;
-                               
-                               out << "description=" << thisCommand->getDescription() << endl;
-                               
-                               //outputTypes - makes something like outputTypes=fasta-name-qfile
-                               map<string, vector<string> > thisOutputTypes = thisCommand->getOutputFiles();
-                               map<string, vector<string> >::iterator itTypes;
-                               
-                               if (thisOutputTypes.size() == 0) { out << "outputTypes=none" << endl; }
-                               else {
-                                       string types = "";
-                                       for (itTypes = thisOutputTypes.begin(); itTypes != thisOutputTypes.end(); itTypes++) {  types += itTypes->first + "-";  }
-                                       //rip off last -
-                                       types = types.substr(0, types.length()-1);
-                                       out << "outputTypes=" << types << endl;
-                               }
-                               
-                               vector<string> booleans; vector<string> numbers; vector<string> multiples; vector<string> Strings;
-                               vector<string> inputGroupNames; map<string, string> inputTypes;
-                               
-                               getInfo(thisCommand->getParameters(), booleans, numbers, multiples, Strings, inputGroupNames, inputTypes);
-                               
-                               //output booleans
-                               out << "Boolean=" << booleans.size() << endl;
-                               for (int i = 0; i < booleans.size(); i++) { out << booleans[i] << endl; }
-                               
-                               //output mulitples
-                               out << "Multiple=" << multiples.size() << endl;
-                               for (int i = 0; i < multiples.size(); i++) { out << multiples[i] << endl; }
-                               
-                               //output numbers
-                               out << "Numbers=" << numbers.size() << endl;
-                               for (int i = 0; i < numbers.size(); i++) { out << numbers[i] << endl; }
-                               
-                               //output strings
-                               out << "String=" << Strings.size() << endl;
-                               for (int i = 0; i < Strings.size(); i++) { out << Strings[i] << endl; }
-                               
-                               //output groups
-                               out << "inputGroupNames=" << inputGroupNames.size() << endl;
-                               for (int i = 0; i < inputGroupNames.size(); i++) { out << inputGroupNames[i] << endl; }
-                               
-                               //output input types
-                               if (inputTypes.size() == 0) { out << "inputTypes=" << endl; }
-                               else {
-                                       string types = "";
-                                       for (map<string, string>::iterator it2 = inputTypes.begin(); it2 != inputTypes.end(); it2++) {  types += it2->first + "-";      }
-                                       //rip off last -
-                                       types = types.substr(0, types.length()-1);
-                                       out << "inputTypes=" << types << endl;
-                                       
-                                       for (map<string, string>::iterator it2 = inputTypes.begin(); it2 != inputTypes.end(); it2++) {  
-                                               out << it2->first << "=" << it2->second << endl;
-                                       }
-                               }
-                               
-                       }
-               }
-               
-               out.close();
-               
-               ofstream out2;
-               m->openOutputFile(output, out2);
-               out2 << numNonHidden << endl; 
-               out2.close();
-               
-               m->appendFiles(output+".temp", output);
-               m->mothurRemove((output+".temp"));
-       
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(output); m->mothurOutEndLine();    
-               m->mothurOutEndLine();
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCommandInfoCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetCommandInfoCommand::getInfo(vector<CommandParameter> para, vector<string>& booleans, vector<string>& numbers, vector<string>& multiples, vector<string>& strings, vector<string>& inputGroupNames, map<string, string>& inputTypes){
-       try {
-               
-               map<string, set<string> > groups;
-               map<string,  set<string> >::iterator itGroups;
-               
-               for (int i = 0; i < para.size(); i++) {
-                       if ((para[i].name == "inputdir") || (para[i].name == "outputdir")) {} //ignore
-                       else {
-                               if (para[i].type == "Boolean") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
-                                       booleans.push_back(temp);
-                               }else if (para[i].type == "Multiple") {
-                                       string multAllowed = "F";
-                                       if (para[i].multipleSelectionAllowed) { multAllowed = "T"; }
-                                       string temp = para[i].name + "=" + para[i].options + "|" + para[i].optionsDefault + "|" + multAllowed;
-                                       multiples.push_back(temp);
-                               }else if (para[i].type == "Number") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
-                                       numbers.push_back(temp);
-                               }else if (para[i].type == "String") {
-                                       string temp = para[i].name + "=" + para[i].optionsDefault;
-                                       strings.push_back(temp);
-                               }else if (para[i].type == "InputTypes") {
-                                       string required = "F";
-                                       if (para[i].required) { required = "T"; }
-                                       string temp = required + "|" + para[i].chooseOnlyOneGroup + "|" + para[i].chooseAtLeastOneGroup + "|" + para[i].linkedGroup;
-                                       inputTypes[para[i].name] = temp;
-                                       
-                                       //add choose only one groups
-                                       groups[para[i].chooseOnlyOneGroup].insert(para[i].name);
-                                       
-                                       //add at least one group names
-                                       groups[para[i].chooseAtLeastOneGroup].insert(para[i].name);
-                                       
-                                       //add at linked group names
-                                       groups[para[i].linkedGroup].insert(para[i].name);
-                                                 
-                               }else { m->mothurOut("[ERROR]: " + para[i].type + " is an unknown parameter type, please correct."); m->mothurOutEndLine(); }
-                       }
-               }
-               
-               for (itGroups = groups.begin(); itGroups != groups.end(); itGroups++) {
-                       if (itGroups->first != "none") {
-                               set<string> tempNames = itGroups->second;
-                               string temp = itGroups->first + "=";
-                               for (set<string>::iterator itNames = tempNames.begin(); itNames != tempNames.end(); itNames++) {
-                                       temp += *itNames + "-";
-                               }
-                               //rip off last -
-                               temp = temp.substr(0, temp.length()-1);
-                               inputGroupNames.push_back(temp);
-                       }
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCommandInfoCommand", "getInfo");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************/
diff --git a/getcommandinfocommand.h b/getcommandinfocommand.h
deleted file mode 100644 (file)
index 463c94c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef GETCOMMANDINFOCOMMAND_H
-#define GETCOMMANDINFOCOMMAND_H
-
-/*
- *  getcommandinfo.h
- *  Mothur
- *
- *  Created by westcott on 4/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-/**********************************************************/
-
-class GetCommandInfoCommand : public Command {
-       
-public:
-       GetCommandInfoCommand(string);
-       GetCommandInfoCommand() { abort = true; calledHelp = true; setParameters(); }
-       ~GetCommandInfoCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.commandinfo";             }
-       string getCommandCategory()             { return "Hidden";                              }
-       string getHelpString(); 
-       string getCitation() { return "no citation"; }
-       string getDescription()         { return "get.commandinfo"; }
-       
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       CommandFactory* commandFactory;
-       string output;
-       bool abort;
-       vector<string> outputNames;
-       
-       int getInfo(vector<CommandParameter>, vector<string>&, vector<string>&, vector<string>&, vector<string>&, vector<string>&, map<string, string>&);
-
-       
-       
-};
-
-/**********************************************************/
-
-#endif
-
diff --git a/getcurrentcommand.cpp b/getcurrentcommand.cpp
deleted file mode 100644 (file)
index ca83231..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- *  getcurrentcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 3/16/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getcurrentcommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetCurrentCommand::setParameters(){     
-       try {
-               CommandParameter pclear("clear", "String", "", "", "", "", "",false,false); parameters.push_back(pclear);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCurrentCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetCurrentCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The get.current command outputs the current files saved by mothur.\n";
-               helpString += "The get.current command has one parameter: clear.\n";
-               helpString += "The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n";
-               helpString += "The get.current command should be in the following format: \n";
-               helpString += "get.current() or get.current(clear=fasta-name-accnos)\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCurrentCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetCurrentCommand::GetCurrentCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetCurrentCommand::GetCurrentCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       clearTypes = validParameter.validFile(parameters, "clear", false);                      
-                       if (clearTypes == "not found") { clearTypes = ""; }
-                       else { m->splitAtDash(clearTypes, types);       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetCurrentCommand", "GetCurrentCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetCurrentCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //user wants to clear a type
-               if (types.size() != 0) {
-                       for (int i = 0; i < types.size(); i++) {
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               //look for file types
-                               if (types[i] == "fasta") {
-                                       m->setFastaFile("");
-                               }else if (types[i] == "qfile") {
-                                       m->setQualFile("");
-                               }else if (types[i] == "phylip") {
-                                       m->setPhylipFile("");
-                               }else if (types[i] == "column") {
-                                       m->setColumnFile("");
-                               }else if (types[i] == "list") {
-                                       m->setListFile("");
-                               }else if (types[i] == "rabund") {
-                                       m->setRabundFile("");
-                               }else if (types[i] == "sabund") {
-                                       m->setSabundFile("");
-                               }else if (types[i] == "name") {
-                                       m->setNameFile("");
-                               }else if (types[i] == "group") {
-                                       m->setGroupFile("");
-                               }else if (types[i] == "order") {
-                                       m->setOrderFile("");
-                               }else if (types[i] == "ordergroup") {
-                                       m->setOrderGroupFile("");
-                               }else if (types[i] == "tree") {
-                                       m->setTreeFile("");
-                               }else if (types[i] == "shared") {
-                                       m->setSharedFile("");
-                               }else if (types[i] == "relabund") {
-                                       m->setRelAbundFile("");
-                               }else if (types[i] == "design") {
-                                       m->setDesignFile("");
-                               }else if (types[i] == "sff") {
-                                       m->setSFFFile("");
-                               }else if (types[i] == "oligos") {
-                                       m->setOligosFile("");
-                               }else if (types[i] == "accnos") {
-                                       m->setAccnosFile("");
-                               }else if (types[i] == "taxonomy") {
-                                       m->setTaxonomyFile("");
-                               }else if (types[i] == "flow") {
-                                       m->setFlowFile("");
-                }else if (types[i] == "biom") {
-                                       m->setBiomFile("");
-                               }else if (types[i] == "processors") {
-                                       m->setProcessors("1");
-                               }else if (types[i] == "all") {
-                                       m->clearCurrentFiles();
-                               }else {
-                                       m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
-                               }
-                       }
-               }
-               
-               if (m->hasCurrentFiles()) {
-                       m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
-                       m->printCurrentFiles();
-               }
-               
-               return 0;       
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "GetCurrentCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
diff --git a/getcurrentcommand.h b/getcurrentcommand.h
deleted file mode 100644 (file)
index dfff0fa..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef GETCURRENTCOMMAND_H
-#define GETCURRENTCOMMAND_H
-
-/*
- *  getcurrentcommand.h
- *  Mothur
- *
- *  Created by westcott on 3/16/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class GetCurrentCommand : public Command {
-
-       public:
-               GetCurrentCommand(string);
-               GetCurrentCommand();
-               ~GetCurrentCommand() {}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "get.current"; }
-               string getCommandCategory()             { return "General";             }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Get.current"; }
-               string getDescription()         { return "get current files saved by mothur"; }
-
-       
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       private:
-               
-               vector<string> outputNames;
-               bool abort;
-       
-               string clearTypes;
-               vector<string> types;
-               
-};
-
-#endif
-
diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp
deleted file mode 100644 (file)
index 8dae3f3..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- *  getgroupcommand.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "getgroupcommand.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> GetgroupCommand::setParameters(){       
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "current", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetgroupCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetgroupCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The get.group command parameter is shared and it's required if you have no valid current file.\n";
-               //m->mothurOut("The get.group command outputs a .bootGroups file to you can use in addition to the tree file generated by the bootstrap.shared command to run the consensus command.\n");
-               helpString += "You may not use any parameters with the get.group command.\n";
-               helpString += "The get.group command should be in the following format: \n";
-               helpString += "get.group()\n";
-               helpString += "Example get.group().\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetgroupCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetgroupCommand::GetgroupCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["bootgroup"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetgroupCommand::GetgroupCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["bootgroup"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetgroupCommand", "GetgroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetgroupCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-                       
-               //open output file
-               outputFile = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "bootGroups";
-               m->openOutputFile(outputFile, out);
-               
-               InputData input(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
-               
-               for (int i = 0; i < lookup.size(); i++) {
-                       out << lookup[i]->getGroup() << '\t' << lookup[i]->getGroup() << endl;
-                       m->mothurOut(lookup[i]->getGroup()); m->mothurOutEndLine();
-                       delete lookup[i];
-               }
-               
-               out.close();
-               
-               if (m->control_pressed) {  m->mothurRemove(outputFile);   return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFile); m->mothurOutEndLine();        outputNames.push_back(outputFile); outputTypes["bootgroup"].push_back(outputFile);
-               m->mothurOutEndLine();
-               
-               return 0;       
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetgroupCommand", "execute");
-               exit(1);
-       }
-}
-
-
diff --git a/getgroupcommand.h b/getgroupcommand.h
deleted file mode 100644 (file)
index a3e47e0..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef GETGROUPCOMMAND_H
-#define GETGROUPCOMMAND_H
-
-/*
- *  getgroupcommand.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class GetgroupCommand : public Command {
-public:
-       GetgroupCommand(string);
-       GetgroupCommand();
-       ~GetgroupCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.group";                           }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.group"; }
-       string getDescription()         { return "outputs group names"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       
-       string outputFile, sharedfile, outputDir;
-       vector<string> outputNames;
-       ofstream out;
-       ifstream in;
-       bool abort;
-
-};
-
-#endif
diff --git a/getgroupscommand.cpp b/getgroupscommand.cpp
deleted file mode 100644 (file)
index 5ed31dd..0000000
+++ /dev/null
@@ -1,868 +0,0 @@
-/*
- *  getgroupscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getgroupscommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-#include "sharedutilities.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> GetGroupsCommand::setParameters(){      
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(pfasta);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pgroup);
-        CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pdesign);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetGroupsCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The get.groups command selects sequences from a specfic group or set of groups from the following file types: fasta, name, group, list, taxonomy, design or shared file.\n";
-               helpString += "It outputs a file containing the sequences in the those specified groups, or a sharedfile containing only those groups.\n";
-               helpString += "The get.groups command parameters are accnos, fasta, name, group, list, taxonomy, shared, design and groups. The group parameter is required, unless you have a current group file, or are using a shared file.\n";
-               helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like.  You can separate group names with dashes.\n";
-               helpString += "The get.groups command should be in the following format: get.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n";
-               helpString += "Example get.groups(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n";
-               helpString += "or get.groups(groups=pasture, fasta=amazon.fasta, group=amazon.groups).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetGroupsCommand::GetGroupsCommand(){  
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-        outputTypes["design"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "GetGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetGroupsCommand::GetGroupsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-            outputTypes["design"] = tempOutNames;
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                
-                it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = ""; }
-                       else { m->setAccnosFile(accnosfile); }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";                   }
-                       else { m->setGroupFile(groupfile); }    
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { taxfile = ""; abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else {
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }
-                       else if (sharedfile == "not found") {  sharedfile = "";  }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") {    groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-            
-            designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { designfile = ""; abort = true; }
-                       else if (designfile == "not found") {   designfile = "";        }
-                       else { m->setDesignFile(designfile); }
-                       
-                       if ((sharedfile == "") && (groupfile == "") && (designfile == "")) { 
-                               //is there are current file available for any of these?
-                               if ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != "")) {
-                                       //give priority to group, then shared
-                                       groupfile = m->getGroupFile(); 
-                                       if (groupfile != "") {  m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               sharedfile = m->getSharedFile(); 
-                                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
-                                               }
-                                       }
-                               }else {
-                                       //give priority to shared, then group
-                                       sharedfile = m->getSharedFile(); 
-                                       if (sharedfile != "") {  m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               groupfile = m->getGroupFile(); 
-                                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       designfile = m->getDesignFile(); 
-                            if (designfile != "") { m->mothurOut("Using " + designfile + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                            else { 
-                                m->mothurOut("You have no current groupfile or sharedfile or designfile and one is required."); m->mothurOutEndLine(); abort = true;
-                            }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "")  && (designfile == "") && (sharedfile == "") && (listfile == "") && (taxfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, taxonomy, group, shared, design or list."); m->mothurOutEndLine(); abort = true; }
-                       if ((groupfile == "") && ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != "")))  { m->mothurOut("If using a fasta, name, taxonomy, group or list, then you must provide a group file."); m->mothurOutEndLine(); abort = true; }
-
-                       if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
-                               vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "GetGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetGroupsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
-               
-               if (groupfile != "") {
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-                       
-                       //make sure groups are valid
-                       //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
-                       vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, gNamesOfGroups);
-                       groupMap->setNamesOfGroups(gNamesOfGroups);
-                       delete util;
-                       
-                       //fill names with names of sequences that are from the groups we want to remove 
-                       fillNames();
-                       
-                       delete groupMap;
-               }
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (namefile != "")                     {               readName();             }
-               if (fastafile != "")            {               readFasta();    }
-               if (groupfile != "")            {               readGroup();    }
-               if (listfile != "")                     {               readList();             }
-               if (taxfile != "")                      {               readTax();              }
-               if (sharedfile != "")           {               readShared();   }
-        if (designfile != "")          {               readDesign();   }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-               
-               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("shared");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-                       }
-            
-            itTypes = outputTypes.find("design");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setDesignFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetGroupsCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) != 0) {
-                                       wroteSomething = true;
-                                       
-                                       currSeq.printSequence(out);
-                                       selectedCount++;
-                               }else{
-                                       //if you are not in the accnos file check if you are a name that needs to be changed
-                                       map<string, string>::iterator it = uniqueToRedundant.find(name);
-                                       if (it != uniqueToRedundant.end()) {
-                                               wroteSomething = true;
-                                               currSeq.setName(it->second);
-                                               currSeq.printSequence(out);
-                                               selectedCount++;
-                                       }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your fasta file."); m->mothurOutEndLine();
-
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetGroupsCommand::readShared(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               
-               InputData input(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
-               
-               bool wroteSomething = false;
-               
-               while(lookup[0] != NULL) {
-                       
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
-                       ofstream out;
-                       m->openOutputFile(outputFileName, out);
-                       outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-                       
-                       if (m->control_pressed) { out.close();  m->mothurRemove(outputFileName);  for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
-                       
-                       lookup[0]->printHeaders(out); 
-                       
-                       for (int i = 0; i < lookup.size(); i++) {
-                               out << lookup[i]->getLabel() << '\t' << lookup[i]->getGroup() << '\t';
-                               lookup[i]->print(out);
-                               wroteSomething = true;
-                               
-                       }                       
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input.getSharedRAbundVectors();
-                       
-                       out.close();
-               }
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine();  }
-               
-               string groupsString = "";
-               for (int i = 0; i < Groups.size()-1; i++) {     groupsString += Groups[i] + ", "; }
-               groupsString += Groups[Groups.size()-1];
-               
-               m->mothurOut("Selected groups: " + groupsString + " from your shared file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetGroupsCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       
-                       selectedCount = 0;
-                       
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                               if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                               
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) != 0) {  newNames += name + ",";  selectedCount++;  }
-                                       else{
-                                               //if you are not in the accnos file check if you are a name that needs to be changed
-                                               map<string, string>::iterator it = uniqueToRedundant.find(name);
-                                               if (it != uniqueToRedundant.end()) {
-                                                       newNames += it->second + ",";
-                                                       selectedCount++;
-                                               }
-                                       }
-                               }
-                               
-                               //get last name
-                               if (names.count(binnames) != 0) {  newNames += binnames + ",";  selectedCount++;  }
-                               else{
-                                       //if you are not in the accnos file check if you are a name that needs to be changed
-                                       map<string, string>::iterator it = uniqueToRedundant.find(binnames);
-                                       if (it != uniqueToRedundant.end()) {
-                                               newNames += it->second + ",";
-                                               selectedCount++;
-                                       }
-                               }
-                               
-                               //if there are names in this bin add to new list
-                               if (newNames != "") {  
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                       
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetGroupsCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> firstCol;         m->gobble(in);          
-                       in >> secondCol;                        
-                       
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;  validSecond.clear();
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) != 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-                       
-                       selectedCount += validSecond.size();
-                       
-                       //if the name in the first column is in the set then print it and any other names in second column also in set
-                       if (names.count(firstCol) != 0) {
-                               
-                               wroteSomething = true;
-                               
-                               out << firstCol << '\t';
-                               
-                               //you know you have at least one valid second since first column is valid
-                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                               out << validSecond[validSecond.size()-1] << endl;
-                               
-                               //make first name in set you come to first column and then add the remaining names to second column
-                       }else {
-                               
-                               //you want part of this row
-                               if (validSecond.size() != 0) {
-                                       
-                                       wroteSomething = true;
-                                       
-                                       out << validSecond[0] << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       uniqueToRedundant[firstCol] = validSecond[0];
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your name file."); m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetGroupsCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                               selectedCount++;
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your group file."); m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetGroupsCommand::readDesign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + "pick" + m->getExtension(designfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(designfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (m->inUsersGroups(name, Groups)) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                selectedCount++;
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain groups from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["design"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " groups from your design file."); m->mothurOutEndLine();
-        
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readDesign");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-int GetGroupsCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << tax << endl;
-                       }else{
-                               //if you are not in the accnos file check if you are a name that needs to be changed
-                               map<string, string>::iterator it = uniqueToRedundant.find(name);
-                               if (it != uniqueToRedundant.end()) {
-                                       wroteSomething = true;
-                                       out << it->second << '\t' << tax << endl;
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file does NOT contain sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void GetGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetGroupsCommand::fillNames(){
-       try {
-               vector<string> seqs = groupMap->getNamesSeqs();
-               
-               for (int i = 0; i < seqs.size(); i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       string group = groupMap->getGroup(seqs[i]);
-                       
-                       if (m->inUsersGroups(group, Groups)) {
-                               names.insert(seqs[i]);
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetGroupsCommand", "fillNames");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/getgroupscommand.h b/getgroupscommand.h
deleted file mode 100644 (file)
index 224f4f0..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef GETGROUPSCOMMAND_H
-#define GETGROUPSCOMMAND_H
-
-/*
- *  getgroupscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "groupmap.h"
-
-class GetGroupsCommand : public Command {
-       
-public:
-       
-       GetGroupsCommand(string);       
-       GetGroupsCommand();
-       ~GetGroupsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.groups";                          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.groups"; }
-       string getDescription()         { return "gets sequences from a list, fasta, name, group, shared, design or taxonomy file from a given group or set of groups"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       set<string> names;
-       map<string, string> uniqueToRedundant; //if a namefile is given and the first column name is not selected
-                                                                                  //then the other files need to change the unique name in their file to match.
-                                                                                  //only add the names that need to be changed to keep the map search quick
-       string accnosfile, fastafile, namefile, groupfile, listfile, designfile, taxfile, outputDir, groups, sharedfile;
-       bool abort;
-       vector<string> outputNames, Groups;
-       GroupMap* groupMap;
-       
-       int readFasta();
-       int readName();
-       int readGroup();
-       void readAccnos();
-       int readList();
-       int readTax();
-       int fillNames();
-       int readShared();
-    int readDesign();
-       
-};
-
-#endif
-
-
-
diff --git a/getlabelcommand.cpp b/getlabelcommand.cpp
deleted file mode 100644 (file)
index 8535db3..0000000
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- *  GetlabelCommand.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 1/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "getlabelcommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> GetlabelCommand::setParameters(){       
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetlabelCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetlabelCommand::GetlabelCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetlabelCommand", "CollectCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetlabelCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The get.label command parameters are list, sabund and rabund file. \n";
-               helpString += "The get.label command should be in the following format: \n";
-               helpString += "get.label()\n";
-               helpString += "Example get.label().\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetlabelCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-GetlabelCommand::GetlabelCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-                       if ((listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       rabundfile = m->getRabundFile(); 
-                                       if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               sabundfile = m->getSabundFile(); 
-                                               if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("No valid current files. You must provide a list, sabund or rabund file."); m->mothurOutEndLine(); 
-                                                       abort = true;
-                                               }
-                                       }
-                               }
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetlabelCommand", "GetlabelCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetlabelCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               InputData* input = new InputData(inputfile, format);
-               OrderVector* order = input->getOrderVector();
-               string label = order->getLabel();
-               
-               while (order != NULL) {
-                       
-                       if (m->control_pressed) { delete input;  delete order; return 0; }
-                       
-                       label = order->getLabel();      
-                       
-                       m->mothurOut(label); m->mothurOutEndLine();
-                       
-                       delete order;           
-                       order = input->getOrderVector();
-               }
-               
-               delete input; 
-               
-               return 0;       
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetlabelCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/getlabelcommand.h b/getlabelcommand.h
deleted file mode 100644 (file)
index c5dc1a1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef GETLABELCOMMAND_H
-#define GETLABELCOMMAND_H
-
-/*
- *  getlabelcommand.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 1/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "ordervector.hpp"
-#include "inputdata.h"
-
-
-class GetlabelCommand : public Command {
-public:
-       GetlabelCommand(string);
-       GetlabelCommand();
-       ~GetlabelCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.label";                           }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.label"; }
-       string getDescription()         { return "outputs labels"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       string inputfile, listfile, rabundfile, sabundfile, format;
-       bool abort;
-       vector<string> outputNames;
-};
-
-#endif
diff --git a/getlineagecommand.cpp b/getlineagecommand.cpp
deleted file mode 100644 (file)
index c2be580..0000000
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- *  getlineagecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getlineagecommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-
-//**********************************************************************************************************************
-vector<string> GetLineageCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptaxon("taxon", "String", "", "", "", "", "",false,true); parameters.push_back(ptaxon);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetLineageCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The get.lineage command reads a taxonomy file and any of the following file types: fasta, name, group, list or alignreport file.\n";
-               helpString += "It outputs a file containing only the sequences from the taxonomy file that are from the taxon requested.\n";
-               helpString += "The get.lineage command parameters are taxon, fasta, name, group, list, taxonomy, alignreport and dups.  You must provide taxonomy unless you have a valid current taxonomy file.\n";
-               helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=false. \n";
-               helpString += "The taxon parameter allows you to select the taxons you would like to get and is required.\n";
-               helpString += "You may enter your taxons with confidence scores, doing so will get only those sequences that belong to the taxonomy and whose cofidence scores is above the scores you give.\n";
-               helpString += "If they belong to the taxonomy and have confidences below those you provide the sequence will not be selected.\n";
-               helpString += "The get.lineage command should be in the following format: get.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n";
-               helpString += "Example get.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n";
-               helpString += "Note: If you are running mothur in script mode you must wrap the taxon in ' characters so mothur will ignore the ; in the taxon.\n";
-               helpString += "Example get.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-GetLineageCommand::GetLineageCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "GetLineageCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetLineageCommand::GetLineageCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       
-                       //check for required parameters                 
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       alignfile = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignfile == "not open") { abort = true; }
-                       else if (alignfile == "not found") {  alignfile = "";  }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { taxfile = ""; abort = true; }
-                       else if (taxfile == "not found") {                              
-                               taxfile = m->getTaxonomyFile(); 
-                               if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setTaxonomyFile(taxfile); }
-                       
-                       string usedDups = "true";
-                       string temp = validParameter.validFile(parameters, "dups", false);      
-                       if (temp == "not found") { 
-                               if (namefile != "") {  temp = "true";                                   }
-                               else                            {  temp = "false"; usedDups = "";       }
-                       }
-                       dups = m->isTrue(temp);
-                       
-                       taxons = validParameter.validFile(parameters, "taxon", false);  
-                       if (taxons == "not found") { taxons = "";  m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine();  abort = true;  }
-                       else { 
-                               //rip off quotes
-                               if (taxons[0] == '\'') {  taxons = taxons.substr(1); }
-                               if (taxons[(taxons.length()-1)] == '\'') {  taxons = taxons.substr(0, (taxons.length()-1)); }
-                       }
-                       m->splitAtChar(taxons, listOfTaxons, '-');
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == ""))  { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy or listfile."); m->mothurOutEndLine(); abort = true; }
-               
-                       if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
-                               vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "GetLineageCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetLineageCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (taxfile != "")                      {               readTax();              }  //fills the set of names to get
-               if (namefile != "")                     {               readName();             }
-               if (fastafile != "")            {               readFasta();    }
-               if (groupfile != "")            {               readGroup();    }
-               if (alignfile != "")            {               readAlign();    }
-               if (listfile != "")                     {               readList();             }
-               
-               
-               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }                       
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetLineageCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" +  m->getExtension(fastafile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) != 0) {
-                                       wroteSomething = true;
-                                       
-                                       currSeq.printSequence(out);
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName);
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetLineageCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                       
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) != 0) {  newNames += name + ",";  }
-                               }
-                       
-                               //get last name
-                               if (names.count(binnames) != 0) {  newNames += binnames + ",";  }
-
-                               //if there are names in this bin add to new list
-                               if (newNames != "") { 
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                               
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetLineageCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" +  m->getExtension(namefile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> firstCol;                         
-                       in >> secondCol;
-                       
-                       string hold = "";
-                       if (dups) { hold = secondCol; }
-                       
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) != 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-
-                       if ((dups) && (validSecond.size() != 0)) { //dups = true and we want to add someone, then add everyone
-                               for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
-                               out << firstCol << '\t' << hold << endl;
-                               wroteSomething = true;
-                       }else {
-                               //if the name in the first column is in the set then print it and any other names in second column also in set
-                               if (names.count(firstCol) != 0) {
-                               
-                                       wroteSomething = true;
-                                       
-                                       out << firstCol << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       
-                               
-                               //make first name in set you come to first column and then add the remaining names to second column
-                               }else {
-                                       //you want part of this row
-                                       if (validSecond.size() != 0) {
-                                       
-                                               wroteSomething = true;
-                                               
-                                               out << validSecond[0] << '\t';
-                                       
-                                               //you know you have at least one valid second since first column is valid
-                                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                               out << validSecond[validSecond.size()-1] << endl;
-                                       }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["name"].push_back(outputFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetLineageCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t' << group << endl;
-                       }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["group"].push_back(outputFileName);
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetLineageCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               //bool wroteSomething = false;
-               vector<bool> taxonsHasConfidence; taxonsHasConfidence.resize(listOfTaxons.size(), false);
-               vector< vector< map<string, float> > > searchTaxons; searchTaxons.resize(listOfTaxons.size());
-               vector<string> noConfidenceTaxons; noConfidenceTaxons.resize(listOfTaxons.size(), "");
-               
-               for (int i = 0; i < listOfTaxons.size(); i++) {
-                       noConfidenceTaxons[i] = listOfTaxons[i];
-                       int hasConPos = listOfTaxons[i].find_first_of('(');
-                       if (hasConPos != string::npos) {  
-                               taxonsHasConfidence[i] = true; 
-                               searchTaxons[i] = getTaxons(listOfTaxons[i]); 
-                               noConfidenceTaxons[i] = listOfTaxons[i];
-                               m->removeConfidences(noConfidenceTaxons[i]);
-                       }
-               }
-               
-               
-               while(!in.eof()){
-
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       for (int j = 0; j < listOfTaxons.size(); j++) {
-                                                       
-                               string newtax = tax;
-                       
-                               //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
-                               if (!taxonsHasConfidence[j]) {
-                                       int hasConfidences = tax.find_first_of('(');
-                                       if (hasConfidences != string::npos) { 
-                                               newtax = tax;
-                                               m->removeConfidences(newtax);
-                                       }
-                               
-                                       int pos = newtax.find(noConfidenceTaxons[j]);
-                               
-                                       if (pos != string::npos) { //this sequence contains the taxon the user wants
-                                               names.insert(name); 
-                                               out << name << '\t' << tax << endl;
-                                               //since you belong to at least one of the taxons we want you are included so no need to search for other
-                                               break;
-                                       }
-                               }else{//if listOfTaxons[i] has them and you don't them remove taxons
-                                       int hasConfidences = tax.find_first_of('(');
-                                       if (hasConfidences == string::npos) { 
-                                       
-                                               int pos = newtax.find(noConfidenceTaxons[j]);
-                                       
-                                               if (pos != string::npos) { //this sequence contains the taxon the user wants
-                                                       names.insert(name);
-                                                       out << name << '\t' << tax << endl;
-                                                       //since you belong to at least one of the taxons we want you are included so no need to search for other
-                                                       break;
-                                               }
-                                       }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
-                                               //first remove confidences from both and see if the taxonomy exists
-                                       
-                                               string noNewTax = tax;
-                                               int hasConfidences = tax.find_first_of('(');
-                                               if (hasConfidences != string::npos) { 
-                                                       noNewTax = tax;
-                                                       m->removeConfidences(noNewTax);
-                                               }
-                                       
-                                               int pos = noNewTax.find(noConfidenceTaxons[j]);
-                                       
-                                               if (pos != string::npos) { //if yes, then are the confidences okay
-                                               
-                                                       bool good = true;
-                                                       vector< map<string, float> > usersTaxon = getTaxons(newtax);
-                                               
-                                                       //the usersTaxon is most likely longer than the searchTaxons, and searchTaxon[0] may relate to userTaxon[4]
-                                                       //we want to "line them up", so we will find the the index where the searchstring starts
-                                                       int index = 0;
-                                                       for (int i = 0; i < usersTaxon.size(); i++) {
-                                                       
-                                                               if (usersTaxon[i].begin()->first == searchTaxons[j][0].begin()->first) { 
-                                                                       index = i;  
-                                                                       int spot = 0;
-                                                                       bool goodspot = true;
-                                                                       //is this really the start, or are we dealing with a taxon of the same name?
-                                                                       while ((spot < searchTaxons[j].size()) && ((i+spot) < usersTaxon.size())) {
-                                                                               if (usersTaxon[i+spot].begin()->first != searchTaxons[j][spot].begin()->first) { goodspot = false; break; }
-                                                                               else { spot++; }
-                                                                       }
-                                                               
-                                                                       if (goodspot) { break; }
-                                                               }
-                                                       }
-                                               
-                                                       for (int i = 0; i < searchTaxons[j].size(); i++) {
-                                                       
-                                                               if ((i+index) < usersTaxon.size()) { //just in case, should never be false
-                                                                       if (usersTaxon[i+index].begin()->second < searchTaxons[j][i].begin()->second) { //is the users cutoff less than the search taxons
-                                                                               good = false;
-                                                                               break;
-                                                                       }
-                                                               }else {
-                                                                       good = false;
-                                                                       break;
-                                                               }
-                                                       }
-                                               
-                                                       //passed the test so add you
-                                                       if (good) {
-                                                               names.insert(name);
-                                                               out << name << '\t' << tax << endl;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-                               }
-                       
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (names.size() == 0) { m->mothurOut("Your taxonomy file does not contain any sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
-                       
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readTax");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector< map<string, float> > GetLineageCommand::getTaxons(string tax) {
-       try {
-               
-               vector< map<string, float> > t;
-               string taxon = "";
-               int taxLength = tax.length();
-               for(int i=0;i<taxLength;i++){
-                       if(tax[i] == ';'){
-               
-                               int openParen = taxon.find_first_of('(');
-                               int closeParen = taxon.find_last_of(')');
-                               
-                               string newtaxon, confidence;
-                               if ((openParen != string::npos) && (closeParen != string::npos)) {
-                                       newtaxon = taxon.substr(0, openParen); //rip off confidence
-                                       confidence = taxon.substr((openParen+1), (closeParen-openParen-1));  
-                               }else{
-                                       newtaxon = taxon;
-                                       confidence = "0";
-                               } 
-                               float con = 0;
-                               convert(confidence, con);
-                               
-                               map<string, float> temp;
-                               temp[newtaxon] = con;
-                               t.push_back(temp);
-                               
-                               taxon = "";
-                       }
-                       else{
-                               taxon += tax[i];
-                       }
-               }
-               
-               return t;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "getTaxons");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//alignreport file has a column header line then all other lines contain 16 columns.  we just want the first column since that contains the name
-int GetLineageCommand::readAlign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(alignfile, in);
-               string name, junk;
-               
-               bool wroteSomething = false;
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                       else                    {       break;                  }
-               }
-               out << endl;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-
-                       in >> name;                             //read from first column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t';
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                                       else                    {       break;                  }
-                               }
-                               out << endl;
-                               
-                       }else {//still read just don't do anything with it
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;             }
-                                       else                    {       break;                  }
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetLineageCommand", "readAlign");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
diff --git a/getlineagecommand.h b/getlineagecommand.h
deleted file mode 100644 (file)
index a677061..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef GETLINEAGECOMMAND_H
-#define GETLINEAGECOMMAND_H
-
-/*
- *  getlineagecommand.h
- *  Mothur
- *
- *  Created by westcott on 9/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-
-class GetLineageCommand : public Command {
-       
-       public:
-       
-               GetLineageCommand(string);
-               GetLineageCommand();
-               ~GetLineageCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "get.lineage";                         }
-               string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Get.lineage"; }
-               string getDescription()         { return "gets sequences from a list, fasta, name, group, alignreport or taxonomy file from a given taxonomy or set of taxonomies"; }
-
-       
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       private:
-               set<string> names;
-               vector<string> outputNames, listOfTaxons;
-               string fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir, taxons;
-               bool abort, dups;
-               
-               int readFasta();
-               int readName();
-               int readGroup();
-               int readAlign();
-               int readList();
-               int readTax();  
-               vector< map<string, float> > getTaxons(string);
-};
-
-#endif
-
diff --git a/getlistcountcommand.cpp b/getlistcountcommand.cpp
deleted file mode 100644 (file)
index 980c886..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *  getlistcountcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/12/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getlistcountcommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetListCountCommand::setParameters(){   
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter parasort("sort", "Multiple", "name-otu", "otu", "", "", "",false,false); parameters.push_back(parasort);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetListCountCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The get.otulist command parameters are list, sort and label.  list is required, unless you have a valid current list file.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like a output files created for, and are separated by dashes.\n";
-               helpString += "The sort parameter allows you to select how you want the output displayed. Options are otu and name.\n";
-               helpString += "If otu is selected the output will be otu number followed by the list of names in that otu.\n";
-               helpString += "If name is selected the output will be a sequence name followed by its otu number.\n";
-               helpString += "The get.otulist command should be in the following format: get.otulist(list=yourlistFile, label=yourLabels).\n";
-               helpString += "Example get.otulist(list=amazon.fn.list, label=0.10).\n";
-               helpString += "The default value for label is all lines in your inputfile.\n";
-               helpString += "The get.otulist command outputs a .otu file for each distance you specify listing the bin number and the names of the sequences in that bin.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetListCountCommand::GetListCountCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["otu"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetListCountCommand::GetListCountCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["otu"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found")  {                                 
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listfile == "not open") { abort = true; }      
-                       else { m->setListFile(listfile); }
-                       
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       sort = validParameter.validFile(parameters, "sort", false);       if (sort == "not found") { sort = "otu"; }
-                       if ((sort != "otu") && (sort != "name")) { m->mothurOut( sort + " is not a valid sort option. Options are otu and name. I will use otu."); m->mothurOutEndLine(); sort = "otu"; }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "GetListCountCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetListCountCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               input = new InputData(listfile, "list");
-               list = input->getListVector();
-               string lastLabel = list->getLabel();
-
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);        } return 0;  }
-               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){
-                       
-                               process(list);
-                               
-                               if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);        } return 0;  }
-                                                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list;
-                               list = input->getListVector(lastLabel);
-                               
-                               process(list);
-                               
-                               if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);        } return 0;  }
-
-                                                                                                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();                   
-                       
-                       delete list;
-                       list = input->getListVector();
-               }
-               
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {             delete list;    }
-                       list = input->getListVector(lastLabel);
-                               
-                       process(list);  
-                       
-                       if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);        } return 0;  }
-                       
-                       delete list;  
-               }
-               
-               delete input;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-//return 1 if error, 0 otherwise
-void GetListCountCommand::process(ListVector* list) {
-       try {
-               string binnames;
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + list->getLabel() + ".otu";
-               m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName); outputTypes["otu"].push_back(outputFileName);
-               
-               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-               
-               //for each bin in the list vector
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       if (m->control_pressed) { break; }
-                       
-                       binnames = list->get(i);
-                       
-                       if (sort == "otu") {
-                               out << i+1 << '\t' << binnames << endl;
-                       }else{ //sort = name
-                               vector<string> names;
-                               m->splitAtComma(binnames, names);
-                               
-                               for (int j = 0; j < names.size(); j++) {
-                                       out << names[j] << '\t' << i+1 << endl;
-                               }
-                       }
-               }
-               
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetListCountCommand", "process");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/getlistcountcommand.h b/getlistcountcommand.h
deleted file mode 100644 (file)
index 7a0c109..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef GETLISTCOUNTCOMMAND_H
-#define GETLISTCOUNTCOMMAND_H
-/*
- *  getlistcountcommand.h
- *  Mothur
- *
- *  Created by westcott on 10/12/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "listvector.hpp"
-
-/**********************************************************/
-
-class GetListCountCommand : public Command {
-       
-public:
-       GetListCountCommand(string);
-       GetListCountCommand();  
-       ~GetListCountCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.otulist";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getCitation() { return "http://www.mothur.org/wiki/Get.otulist"; }
-       string getDescription()         { return "lists each OTU number and the sequence contained in that OTU"; }
-
-       string getHelpString(); 
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       ListVector* list;
-       InputData* input;
-       
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string label, listfile, outputDir, sort;
-       ofstream out;
-       vector<string> outputNames;
-               
-       void process(ListVector*);
-};
-/**********************************************************/
-
-#endif
diff --git a/getopt_long.cpp b/getopt_long.cpp
deleted file mode 100644 (file)
index 3baa3ce..0000000
+++ /dev/null
@@ -1,2099 +0,0 @@
-/*
-  This getopt_long() is compatible with GNU's, however, added original
-  extention (short 1 byte option).
-
-
-  Copyright (c) 2004 Koji Arai
-
-  Permission is hereby granted, free of charge, to any person
-  obtaining a copy of this software and associated documentation files
-  (the "Software"), to deal in the Software without restriction,
-  including without limitation the rights to use, copy, modify, merge,
-  publish, distribute, sublicense, and/or sell copies of the Software,
-  and to permit persons to whom the Software is furnished to do so,
-  subject to the following conditions:
-
-  The above copyright notice and this permission notice shall be
-  included in all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-  SOFTWARE.
-
-
-  Compilation for Test:
-
-      GNU:
-      cc -DUSE_GNU -DDEBUG getopt_long.c -o test_getopt_long_gnu
-
-      not GNU:
-      cc -I. -DDEBUG getopt_long.c -o test_getopt_long
-
-      ./test_getopt_long
-      ./test_getopt_long_gnu
-
-  BUGS:
-    * not implemented any features for getopt() and getopt_long().
-*/
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-
-#if DEBUG
-static int
-puts_argv(char **argv)
-{
-    int i;
-
-    for (i = 0; argv[i]; i++) {
-        if (i) printf(" ");
-
-        printf("%s", argv[i]);
-    }
-    printf("\n");
-
-    return 0;
-}
-#endif
-
-#ifndef USE_GNU
-#include <stdio.h>
-#include "getopt_long.h"
-
-char *optarg;
-int optind;
-
-int opterr;
-int optopt;
-
-/*
-  return value 0: no option (include '-')
-               1: short option like '-x'
-               2: long option like '--xxx' and just '--'
-*/
-static int
-is_option(char *arg)
-{
-    if (arg[0] == '-') {
-        switch (arg[1]) {
-        case 0:                 /* just "-" */
-            return 0;
-        case '-':               /* long option (include just "--")*/
-            return 2;
-        default:                /* short option */
-            return 1;
-        }
-    }
-    return 0;
-}
-
-static int
-insert_argv(char **argv, int src, int dest)
-{
-    int i;
-    char *tmp = argv[src];
-
-    if (src > dest) {
-        for (i = src; i > dest; i--)
-            argv[i] = argv[i-1];  //printf("%s\n", argv[i]);
-    }
-    if (src < dest) {
-        for (i = src; i < dest; i++)
-            argv[i] = argv[i+1]; //printf("%s\n", argv[i]);
-    }
-
-    argv[dest] = tmp;
-       //printf("%s\n", argv[dest]);
-
-    return 0;
-}
-
-static int
-search_longopt(char *arg, struct option *longopts)
-{
-    int i, found = -1;
-    int len;
-    for (len = 0; arg[len] && arg[len] != '='; len++)
-        ;
-
-    for (i = 0; longopts[i].name; i++) {
-       //printf("%d\t%s\t", i, longopts[i].name); 
-       //printf("%s\n", arg);
-        if (strncmp(arg, longopts[i].name, len) == 0) {
-            if (found != -1)
-                return -1;      /* found some candidate */
-            found = i;
-       //printf("found = %d\n", found);
-        }
-    }
-    return found;
-}
-
-/*
- * implemented my extention feature.
- * optional 1 byte argument with [...]
- *   e.g.) shortopts = "a[0123]b"
- *          accepts "-a0 -a1b" (same as "-a0 -a1 -b")
- */
-static int
-has_argument_short(char *arg, const char *shortopts)
-{
-    int i;
-    int open_bracket = 0;
-    for (i = 0; shortopts[i]; i++) {
-        switch (shortopts[i]) {
-        case '[':
-            open_bracket++;
-            continue;
-        case ']':
-            if (open_bracket <= 0) {
-                fprintf(stderr, "getopt_long() -- unbalanced bracket in short options");
-                return -1;
-            }
-            open_bracket--;
-            continue;
-        }
-        if (open_bracket) continue;
-        if (*arg != shortopts[i]) continue;
-
-        switch (shortopts[i+1]) {
-        case ':':
-            if (shortopts[i+2] != ':') {
-                if (arg[1])
-                    return 1; /* following string is argument */
-                else
-                    return 2; /* next argv is argument */
-            }
-            else {
-                /* '::' means optional argument (GNU extention) */
-                if (arg[1])
-                    return 1;
-                else
-                    return 0; /* no argument */
-            }
-        case '[':
-            if (arg[1] == '\0')
-                return 0;   /* no argument */
-            /* my extention */
-            for (i++; shortopts[i] && shortopts[i] != ']'; i++) {
-                if (arg[1] == shortopts[i])
-                    return 3; /* has 1 byte argument */
-            }
-            if (!shortopts[i]) {
-                fprintf(stderr, "getopt_long() -- unbalanced bracket in short options");
-                return -1;
-            }
-            break;
-        default:
-            return 0;   /* no argument */
-        }
-    }
-    /* Invalid option */
-    return -1;
-}
-
-static int
-has_argument_long(char *arg, struct option *longopts)
-{
-    int i;
-
-    i = search_longopt(arg, longopts);
-    if (i == -1) {
-        /* Invalid option */
-        return -1;
-    }
-    else {
-        int len = strlen(arg);
-        char *p = strchr(arg, '=');
-        if (p) {
-            len = p - arg;
-        }
-
-        switch (longopts[i].has_arg) {
-        case no_argument:
-            return 0;
-        case required_argument:
-            if (arg[len] == '=')
-                return 1;
-            else
-                return 2;
-        case optional_argument:
-            if (arg[len] == '=')
-                return 1;
-            else
-                return 0;
-        default:
-            assert(0);
-        }
-    }
-}
-
-/*
-  -1: no option
-   0: no argument
-   1: has argument in this argv
-   2: has argument in next argv
-   3: has 1 byte argument in this argv
-*/
-static int
-has_argument(char *arg,
-             const char *shortopts,
-             struct option *longopts)
-{
-    int i, n;
-
-    switch (is_option(arg)) {
-    case 0:                     /* no option */
-        return -1;
-    case 1:
-        /* short option */
-        n = -1;
-        for (i = 1; arg[i]; i++) {
-            n = has_argument_short(arg+i, shortopts);
-            if (n == 0 && arg[i+1]) continue;
-            if (n == 3 && arg[i+2]) { i++; continue; }
-            break;
-        }
-        return n;
-    case 2:
-        /* long option */
-        return has_argument_long(arg+2, longopts);
-        break;
-    default:
-        assert(0);
-    }
-}
-
-int
-getopt_long(int argc, char **argv,
-            const char *shortopts,
-            struct option *longopts,
-            int *indexptr)
-{
-    char *opt;
-    int i;
-    static int shortoptind;
-    static int no_optind = 0;
-    
-    if (optind == 0) {            /* skip first argument (command name) */
-        optind++;
-        no_optind = 0;
-        shortoptind = 0;
-    }
-
-    optarg = 0;
-
-    if (no_optind && !shortoptind) {
-        while (!is_option(argv[no_optind]))
-            insert_argv(argv, no_optind, optind-1);
-
-        if (has_argument(argv[no_optind], shortopts, longopts) == 2)
-            no_optind += 2;
-        else
-            no_optind++;
-
-        if (argv[optind] && strcmp(argv[optind], "--") == 0) {
-            while (!is_option(argv[no_optind]))
-                insert_argv(argv, no_optind, optind);
-            optind = no_optind;
-            no_optind = 0;
-        }
-    }
-
-    if (optind >= argc)
-        goto end_of_option;
-
- retry:
-    /*
-    puts_argv(&argv[optind]);
-    */
-    opt = argv[optind];
-    if (shortoptind == 0 && is_option(opt) == 1) {
-        shortoptind++;
-    }
-
-    if (shortoptind) {
-        /* short option */
-        char *p = &opt[shortoptind];
-
-        if (*p == '\0')
-            assert(0);
-
-        switch (has_argument_short(p, shortopts)) {
-        case 0:
-            /* no argument */
-            optarg = 0;
-
-            shortoptind++;
-            if (opt[shortoptind] == '\0')
-                optind++, shortoptind = 0;
-            return *p;
-        case 1:
-            /* following character is argument */
-            optind++, shortoptind = 0;
-            optarg = &p[1];
-            return *p;
-        case 2:
-            /* next argv is argument */
-            optind++, shortoptind = 0;
-            optarg = argv[optind++];
-            return *p;
-        case 3:
-            /* has 1 byte argument */
-            optarg = &p[1];
-            if (p[2] == 0)
-                optind++, shortoptind = 0;
-            else
-                shortoptind += 2;
-            return *p;
-        default:
-            /* Invalid option */
-            if (opterr)
-                fprintf(stderr,
-                        "%s: invalid option -- %c\n",
-                        argv[0],
-                        *p);
-
-            optind++, shortoptind = 0;
-            optopt = *p;
-            return '?';
-        }
-    }
-    else if (opt[0] == '-' && opt[1] == '-') {
-        /* long option */
-
-        if (opt[2] == '\0') {
-            /* end of command line switch */
-            optind++;
-            return -1;
-        }
-
-        opt += 2;
-
-        i = search_longopt(opt, longopts);
-        if (i == -1) {
-            optind++;
-            optopt = 0;
-            return '?';
-        }
-        else {
-            int len = strlen(opt);
-            char *p = strchr(opt, '=');
-            if (p) {
-                len = p - opt;
-            }
-
-            switch (longopts[i].has_arg) {
-            case no_argument:
-                break;
-            case required_argument:
-                if (opt[len] == '=')
-                    optarg = opt + len + 1;
-                else {
-                    optind++;
-                    optarg = argv[optind];
-                    if (optarg == 0) {
-                        if (opterr)
-                            fprintf(stderr,
-                                    "%s: option `--%s' requires an argument\n",
-                                    argv[0],
-                                    opt);
-
-                        optopt = 0;
-                        return '?'; /* no argument */
-                    }
-                }
-                break;
-            case optional_argument:
-                if (opt[len] == '=')
-                    optarg = opt + len + 1;
-                else {
-                    optarg = 0;
-                }
-                break;
-            default:
-                break;
-            }
-
-            *indexptr = i;
-            optind++;
-            if (longopts[i].flag) {
-                *longopts[i].flag = longopts[i].val;
-                return 0;
-            }
-            else {
-                return longopts[i].val;
-            }
-        }
-
-        optind++;
-        optopt = 0;
-        return '?';
-    }
-
-    /* not option */
-    if (no_optind == 0)
-        no_optind = optind;
-
-    for (i = optind; argv[i]; i++) {
-        if (is_option(argv[i])) {
-            optind = i;
-            goto retry;
-        }
-    }
-
- end_of_option:
-    if (no_optind) {
-        optind = no_optind;
-        no_optind = 0;
-    }
-
-    return -1;
-}
-#endif /* USE_GNU */
-
-#if DEBUG
-
-#include <stdio.h>
-#include <assert.h>
-#include <stdlib.h>
-
-#if USE_GNU
-#include <getopt.h>  /* use GNU getopt_long() */
-#endif
-
-static int verbose_flag;
-static int option_index;
-int argc;
-char *argv[50];
-char **p;
-int c;
-static struct option long_options[] = {
-    {"verbose", no_argument, &verbose_flag, 1},
-    {"brief", no_argument, &verbose_flag, 0},
-    {"add", required_argument, 0, 'a'},
-    {"append", no_argument, 0, 0},
-    {"delete", required_argument, 0, 0},
-    {"create", optional_argument, 0, 0},
-    {"change", optional_argument, 0, 0},
-    {0, 0, 0, 0}
-};
-
-int
-call_getopt_long(int argc, char **argv,
-                 const char *shortopts,
-                 struct option *longopts,
-                 int *indexptr)
-{
-    int c;
-    c = getopt_long(argc, argv, shortopts, longopts, indexptr);
-    puts_argv(argv);
-    printf("ret=%d(%c) option_index=%d ", c, c, option_index);
-    printf("optind=%d optarg=[%s] opterr=%d optopt=%d(%c)\n",
-           optind, optarg, opterr, optopt, optopt);
-    if (c == 0) {
-        struct option *opt;
-        opt = &longopts[*indexptr];
-        printf("long option: --%s has_arg=%d\n", opt->name, opt->has_arg);
-        if (opt->flag)
-            printf("           flag=[%8p] val=%d\n", opt->flag, *opt->flag);
-    }
-
-    return c;
-}
-
-void
-test1()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-bcd";
-    argc++; *p++ = "-d";
-    argc++; *p++ = "-e";
-    argc++; *p++ = "-f";
-    argc++; *p++ = "-g";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'a');
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'b');
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'c');
-    assert(option_index == 0);
-    assert(optind == 3);
-    assert(optarg == &argv[2][3]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'd');
-    assert(option_index == 0);
-    assert(optind == 5);
-    assert(optarg == argv[4]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == '?');
-    assert(option_index == 0);
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 'f');
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == '?');
-    assert(option_index == 0);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 'g');
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == -1);
-    assert(option_index == 0);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-}
-
-void
-test2()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--verbose";
-    argc++; *p++ = "--brief";
-    argc++; *p++ = "--add";
-    argc++; *p++ = "add_argument";
-    argc++; *p++ = "--add=add_argument";
-    argc++; *p++ = "--append";
-    argc++; *p++ = "--delete=del_argument";
-    argc++; *p++ = "--create=cre_argument";
-    argc++; *p++ = "--create";
-    argc++; *p++ = "files...";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "verbose") == 0);
-    assert(*long_options[option_index].flag == 1);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 1);
-    assert(optind == 3);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "brief") == 0);
-    assert(*long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'a');
-    assert(option_index == 2);
-    assert(optind == 5);
-    assert(optarg == argv[4]);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "add") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 'a');
-    assert(option_index == 2);
-    assert(optind == 6);
-    assert(optarg == argv[5]+6);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "add") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 3);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "append") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 4);
-    assert(optind == 8);
-    assert(optarg == argv[7]+9);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "delete") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 9);
-    assert(optarg == argv[8]+9);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "create") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 10);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(long_options[option_index].name, "create") == 0);
-    assert(long_options[option_index].flag == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 10);
-    assert(optarg == 0);
-    assert(optopt == 'g');      /* no changed */
-    assert(strcmp(argv[optind], "files...") == 0);
-
-}
-
-void
-test3()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--delete";  /* required argument has no argument */
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == '?');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);        /* changed */
-    assert(optarg == 0);
-    assert(optopt == 0);       /* changed */
-    assert(argv[optind] == 0);
-
-    /* */
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--file";  /* not option */
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    assert(c == '?');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-    assert(argv[optind] == 0);
-}
-
-void
-test4()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "a1";
-    argc++; *p++ = "a2";
-    argc++; *p++ = "-b";
-    argc++; *p++ = "b";
-    argc++; *p++ = "-efg";      /* some options in a argument */
-    argc++; *p++ = "g";
-    argc++; *p++ = "-c";
-    argc++; *p++ = "c";
-    argc++; *p++ = "d";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'b');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 5);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'e');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'f');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'g');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 8);
-    assert(optarg == argv[7]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 10);
-    assert(optarg == argv[9]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:efg:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "-efg") == 0);
-    assert(strcmp(*p++, "g") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "a1") == 0);
-    assert(strcmp(*p++, "a2") == 0);
-    assert(strcmp(*p++, "b") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-}
-
-void
-test5()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-b";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(*p == 0);
-
-    assert(c == 'b');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 4);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 3);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test6()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-b";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(*p == 0);
-
-    assert(c == 'b');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 5);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-b") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 3);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test7()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-c";
-    argc++; *p++ = "c";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == argv[5]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 4);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test8()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-c";
-    argc++; *p++ = "c";
-    argc++; *p++ = "--";
-    argc++; *p++ = "-d";
-    argc++; *p++ = "d";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 4);
-    assert(optarg == argv[3]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 5);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 7);
-    assert(optarg == argv[6]);
-    assert(optopt == 0);
-}
-
-void
-test9()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-";
-    argc++; *p++ = "-c";
-    argc++; *p++ = "c";
-    argc++; *p++ = "--";
-    argc++; *p++ = "-d";
-    argc++; *p++ = "d";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == argv[5]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 5);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc:d:", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "c") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 9);
-    assert(optarg == argv[8]);
-    assert(optopt == 0);
-}
-
-void
-test10()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-cc";
-    argc++; *p++ = "-d";
-    argc++; *p++ = "d";
-    argc++; *p++ = "-c";        /* no argument */
-    argc++; *p++ = "-d";        /* at last */
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 3);
-    assert(optarg == argv[2]+2);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 4);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-cc") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "-c") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 5);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test11()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--verbose";
-    argc++; *p++ = "--create=c";
-    argc++; *p++ = "--change";
-    argc++; *p++ = "d";
-    argc++; *p++ = "--create";  /* no argument */
-    argc++; *p++ = "--change";  /* at last */
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 3);
-    assert(optarg == argv[2]+9);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 6);
-    assert(optind == 4);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 6);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 6);
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test12()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--verbose";
-    argc++; *p++ = "--create=c";
-    argc++; *p++ = "files...";
-    argc++; *p++ = "--delete";  /* required argument */
-    argc++; *p++ = "d";
-    argc++; *p++ = "--create";  /* no argument */
-    argc++; *p++ = "--change";  /* at last */
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 3);
-    assert(optarg == argv[2]+9);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 4);
-    assert(optind == 6);
-    assert(optarg == argv[5]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 6);
-    assert(optind == 8);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--create") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 6);
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-}
-
-void
-test13()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "--verbose";
-    argc++; *p++ = "--create=c";
-    argc++; *p++ = "files...";
-    argc++; *p++ = "--delete";
-    argc++; *p++ = "d";
-    argc++; *p++ = "--";        /* option terminator */
-    argc++; *p++ = "--change";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 0);
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 5);
-    assert(optind == 3);
-    assert(optarg == argv[2]+9);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == 0);
-    assert(option_index == 4);
-    assert(optind == 6);
-    assert(optarg == argv[5]);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc::d::", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "--verbose") == 0);
-    assert(strcmp(*p++, "--create=c") == 0);
-    assert(strcmp(*p++, "--delete") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "--") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(strcmp(*p++, "--change") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 4);
-    assert(optind == 6);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-}
-
-void
-test14()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-o5";
-    argc++; *p++ = "files...";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "o[567]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-o5") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(*p == 0);
-
-    assert(c == 'o');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == argv[1]+2);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-o5") == 0);
-    assert(strcmp(*p++, "files...") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-}
-
-void
-test15()
-{
-    optind = 0;
-    argc = 0;
-    p = argv;
-
-    argc++; *p++ = "command_name";
-    argc++; *p++ = "-a";
-    argc++; *p++ = "-ccd";
-    argc++; *p++ = "-ce";
-    argc++; *p++ = "-d";
-    argc++; *p++ = "d";
-    argc++; *p++ = "-cdd";
-    argc++; *p++ = "-d";
-    *p = 0;
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'a');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 2);
-    assert(optarg == argv[2]+2);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 3);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 4);
-    assert(optarg == argv[3]+2);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 5);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'c');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 6);
-    assert(optarg == argv[6]+2);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(*p == 0);
-
-    assert(c == 'd');
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 8);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-
-    /*************************/
-    c = call_getopt_long(argc, argv, "abc[cde]d[fgh]", long_options, &option_index);
-
-    p = argv;
-    assert(strcmp(*p++, "command_name") == 0);
-    assert(strcmp(*p++, "-a") == 0);
-    assert(strcmp(*p++, "-ccd") == 0);
-    assert(strcmp(*p++, "-ce") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "-cdd") == 0);
-    assert(strcmp(*p++, "-d") == 0);
-    assert(strcmp(*p++, "d") == 0);
-    assert(*p == 0);
-
-    assert(c == -1);
-    assert(option_index == 4);  /* no changed */
-    assert(optind == 7);
-    assert(optarg == 0);
-    assert(optopt == 0);
-
-
-}
-
-int
-main()
-{
-    opterr = 0;
-    optopt = 0;
-
-    test1();
-    test2();
-    test3();
-    test4();
-    test5();
-    test6();
-    test7();
-    test8();
-    test9();
-    test10();
-    test11();
-    test12();
-    test13();
-#ifndef USE_GNU
-    test14();
-    test15();
-#endif
-
-    return 0;
-}
-#endif
diff --git a/getopt_long.h b/getopt_long.h
deleted file mode 100644 (file)
index dbf7992..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-  This getopt_long() is compatible with GNU's, however, added original
-  extention (short 1 byte option).
-
-
-  Copyright (c) 2004 Koji Arai
-
-  Permission is hereby granted, free of charge, to any person
-  obtaining a copy of this software and associated documentation files
-  (the "Software"), to deal in the Software without restriction,
-  including without limitation the rights to use, copy, modify, merge,
-  publish, distribute, sublicense, and/or sell copies of the Software,
-  and to permit persons to whom the Software is furnished to do so,
-  subject to the following conditions:
-
-  The above copyright notice and this permission notice shall be
-  included in all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
-  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-  SOFTWARE.
-*/
-
-#ifndef _GETOPT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct option {
-    const char *name;
-    int has_arg;
-
-    /* values of has_arg */
-#define no_argument             0
-#define required_argument       1
-#define optional_argument       2
-
-    int *flag;
-    int val;
-};
-
-extern char *optarg;
-extern int optind;
-
-int getopt_long(int argc, char **argv,
-                const char *shortopts,
-                struct option *longopts,
-                int *indexptr);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
diff --git a/getoturepcommand.cpp b/getoturepcommand.cpp
deleted file mode 100644 (file)
index 35437e7..0000000
+++ /dev/null
@@ -1,1039 +0,0 @@
-/*
- *  getoturepcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "getoturepcommand.h"
-#include "readphylip.h"
-#include "readcolumn.h"
-#include "formatphylip.h"
-#include "formatcolumn.h"
-#include "sharedutilities.h"
-
-
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareName(repStruct left, repStruct right){
-       return (left.name < right.name);        
-}
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareBin(repStruct left, repStruct right){
-       return (left.bin < right.bin);  
-}
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSize(repStruct left, repStruct right){
-       return (left.size < right.size);        
-}
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareGroup(repStruct left, repStruct right){
-       return (left.group < right.group);      
-}
-
-//**********************************************************************************************************************
-vector<string> GetOTURepCommand::setParameters(){      
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pweighted("weighted", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pweighted);
-               CommandParameter psorted("sorted", "Multiple", "none-name-bin-size-group", "none", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetOTURepCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The get.oturep command parameters are phylip, column, list, fasta, name, group, large, weighted, cutoff, precision, groups, sorted and label.  The list parameter is required, as well as phylip or column and name, unless you have valid current files.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like a output files created for, and is separated by dashes.\n";
-               helpString += "The phylip or column parameter is required, but only one may be used.  If you use a column file the name filename is required. \n";
-               helpString += "If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n";
-               helpString += "The get.oturep command should be in the following format: get.oturep(phylip=yourDistanceMatrix, fasta=yourFastaFile, list=yourListFile, name=yourNamesFile, group=yourGroupFile, label=yourLabels).\n";
-               helpString += "Example get.oturep(phylip=amazon.dist, fasta=amazon.fasta, list=amazon.fn.list, group=amazon.groups).\n";
-               helpString += "The default value for label is all labels in your inputfile.\n";
-               helpString += "The sorted parameter allows you to indicate you want the output sorted. You can sort by sequence name, bin number, bin size or group. The default is no sorting, but your options are name, number, size, or group.\n";
-               helpString += "The large parameter allows you to indicate that your distance matrix is too large to fit in RAM.  The default value is false.\n";
-               helpString += "The weighted parameter allows you to indicate that want to find the weighted representative. You must provide a namesfile to set weighted to true.  The default value is false.\n";
-               helpString += "The representative is found by selecting the sequence that has the smallest total distance to all other sequences in the OTU. If a tie occurs the smallest average distance is used.\n";
-               helpString += "For weighted = false, mothur assumes the distance file contains only unique sequences, the list file may contain all sequences, but only the uniques are considered to become the representative. If your distance file contains all the sequences it would become weighted=true.\n";
-               helpString += "For weighted = true, mothur assumes the distance file contains only unique sequences, the list file must contain all sequences, all sequences are considered to become the representative, but unique name will be used in the output for consistency.\n";
-               helpString += "If your distance file contains all the sequence and you do not provide a name file, the weighted representative will be given, unless your listfile is unique. If you provide a namefile, then you can select weighted or unweighted.\n";
-               helpString += "The group parameter allows you provide a group file.\n";
-               helpString += "The groups parameter allows you to indicate that you want representative sequences for each group specified for each OTU, group name should be separated by dashes. ex. groups=A-B-C.\n";
-               helpString += "The get.oturep command outputs a .fastarep and .rep.names file for each distance you specify, selecting one OTU representative for each bin.\n";
-               helpString += "If you provide a groupfile, then it also appends the names of the groups present in that bin.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetOTURepCommand::GetOTURepCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetOTURepCommand::GetOTURepCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if (option == "help") { 
-                       help(); abort = true; calledHelp = true;
-               }else if(option == "citation") { citation(); abort = true; calledHelp = true;
-               } else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") { fastafile = ""; }
-                       else if (fastafile == "not open") { abort = true; }     
-                       else { m->setFastaFile(fastafile); }
-               
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not found") {                  
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listfile == "not open") { abort = true; }      
-                       else { m->setListFile(listfile); }
-                       
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not found") { phylipfile = "";  }
-                       else if (phylipfile == "not open") { abort = true; }    
-                       else { distFile = phylipfile; format = "phylip"; m->setPhylipFile(phylipfile);   }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not found") { columnfile = ""; }
-                       else if (columnfile == "not open") { abort = true; }    
-                       else { distFile = columnfile; format = "column";  m->setColumnFile(columnfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { //is there are current file available for either of these?
-                               //give priority to column, then phylip
-                               columnfile = m->getColumnFile(); 
-                               if (columnfile != "") {  distFile = columnfile; format = "column"; m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       phylipfile = m->getPhylipFile(); 
-                                       if (phylipfile != "") {  distFile = phylipfile; format = "phylip"; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a phylip or column file before you can use the get.oturep command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a get.oturep command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-               
-                       if (columnfile != "") {  
-                               if (namefile == "") {  
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               } 
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; allLines = 1;  }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       sorted = validParameter.validFile(parameters, "sorted", false);         if (sorted == "not found"){     sorted = "";    }
-                       if (sorted == "none") { sorted=""; }
-                       if ((sorted != "") && (sorted != "name") && (sorted != "bin") && (sorted != "size") && (sorted != "group")) {
-                               m->mothurOut(sorted + " is not a valid option for the sorted parameter. The only options are: name, bin, size and group. I will not sort."); m->mothurOutEndLine();
-                               sorted = "";
-                       }
-                       
-                       if ((sorted == "group") && (groupfile == "")) {
-                               m->mothurOut("You must provide a groupfile to sort by group. I will not sort."); m->mothurOutEndLine();
-                               sorted = "";
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               if (groupfile == "") {
-                                       m->mothurOut("You must provide a groupfile to use groups."); m->mothurOutEndLine();
-                                       abort = true;
-                               }else { 
-                                       m->splitAtDash(groups, Groups);
-                               }
-                       }
-                       m->setGroups(Groups);
-                       
-                       string temp = validParameter.validFile(parameters, "large", false);             if (temp == "not found") {      temp = "F";     }
-                       large = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "weighted", false);         if (temp == "not found") {       temp = "f";    }
-                       weighted = m->isTrue(temp);
-                       
-                       if ((weighted) && (namefile == "")) { m->mothurOut("You cannot set weighted to true unless you provide a namesfile."); m->mothurOutEndLine(); abort = true; }
-                       
-                       temp = validParameter.validFile(parameters, "precision", false);                        if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "10.0"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "GetOTURepCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int GetOTURepCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               int error;
-               list = NULL;
-               
-               if (!large) {
-                       //read distance files
-                       if (format == "column") { readMatrix = new ReadColumnMatrix(distFile); }        
-                       else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(distFile); }
-                       else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0;  }
-                       
-                       readMatrix->setCutoff(cutoff);
-       
-                       if(namefile != ""){     
-                               nameMap = new NameAssignment(namefile);
-                               nameMap->readMap();
-                       }else{  nameMap = NULL;         }
-                       
-                       readMatrix->read(nameMap);
-                       
-                       if (m->control_pressed) { delete readMatrix; return 0; }
-
-                       list = readMatrix->getListVector();
-
-                       SparseMatrix* matrix = readMatrix->getMatrix();
-                       
-                       // Create a data structure to quickly access the distance information.
-                       // It consists of a vector of distance maps, where each map contains
-                       // all distances of a certain sequence. Vector and maps are accessed
-                       // via the index of a sequence in the distance matrix
-                       seqVec = vector<SeqMap>(list->size()); 
-                       for (MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++) {
-                               if (m->control_pressed) { delete readMatrix; return 0; }
-                               seqVec[currentCell->row][currentCell->column] = currentCell->dist;
-                       }
-                       //add dummy map for unweighted calc
-                       SeqMap dummy;
-                       seqVec.push_back(dummy);
-                       
-                       delete matrix;
-                       delete readMatrix;
-                       delete nameMap;
-                       
-                       if (m->control_pressed) { return 0; }
-               }else {
-                       //process file and set up indexes
-                       if (format == "column") { formatMatrix = new FormatColumnMatrix(distFile); }    
-                       else if (format == "phylip") { formatMatrix = new FormatPhylipMatrix(distFile); }
-                       else { m->mothurOut("File format error."); m->mothurOutEndLine(); return 0;  }
-                       
-                       formatMatrix->setCutoff(cutoff);
-       
-                       if(namefile != ""){     
-                               nameMap = new NameAssignment(namefile);
-                               nameMap->readMap();
-                       }else{  nameMap = NULL;         }
-                       
-                       formatMatrix->read(nameMap);
-                       
-                       if (m->control_pressed) { delete formatMatrix;  return 0; }
-
-                       list = formatMatrix->getListVector();
-                       
-                       distFile = formatMatrix->getFormattedFileName();
-                       
-                       //positions in file where the distances for each sequence begin
-                       //rowPositions[1] = position in file where distance related to sequence 1 start.
-                       rowPositions = formatMatrix->getRowPositions();
-                       rowPositions.push_back(-1); //dummy row for unweighted calc
-                       
-                       delete formatMatrix;
-                       delete nameMap;
-                       
-                       //openfile for getMap to use
-                       m->openInputFile(distFile, inRow);
-                       
-                       if (m->control_pressed) { inRow.close(); m->mothurRemove(distFile); return 0; }
-               }
-               
-               
-               //list bin 0 = first name read in distance matrix, list bin 1 = second name read in distance matrix
-               if (list != NULL) {
-                       vector<string> names;
-                       string binnames;
-                       //map names to rows in sparsematrix
-                       for (int i = 0; i < list->size(); i++) {
-                               names.clear();
-                               binnames = list->get(i);
-                               
-                               m->splitAtComma(binnames, names);
-                               
-                               for (int j = 0; j < names.size(); j++) {
-                                       nameToIndex[names[j]] = i;
-                               }
-                       }
-               } else { m->mothurOut("error, no listvector."); m->mothurOutEndLine(); }
-               
-                               
-               if (m->control_pressed) { 
-                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
-                       return 0; 
-               }
-               
-               if (groupfile != "") {
-                       //read in group map info.
-                       groupMap = new GroupMap(groupfile);
-                       int error = groupMap->readMap();
-                       if (error == 1) { delete groupMap; m->mothurOut("Error reading your groupfile. Proceeding without groupfile."); m->mothurOutEndLine(); groupfile = "";  }
-                       
-                       if (Groups.size() != 0) {
-                               SharedUtil* util = new SharedUtil();
-                               vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
-                               util->setGroups(Groups, gNamesOfGroups, "getoturep");
-                               groupMap->setNamesOfGroups(gNamesOfGroups);
-                               delete util;
-                       }
-               }
-               
-               //done with listvector from matrix
-               if (list != NULL) { delete list; }
-               
-               input = new InputData(listfile, "list");
-               list = input->getListVector();
-               string lastLabel = list->getLabel();
-
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) { 
-                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
-                       delete input; delete list; return 0; 
-               }
-               
-               if ((!weighted) && (namefile != "")) { readNamesFile(weighted); }
-               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (allLines == 1 || labels.count(list->getLabel()) == 1){
-                                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                                       error = process(list);
-                                       if (error == 1) { return 0; } //there is an error in hte input files, abort command
-                                       
-                                       if (m->control_pressed) { 
-                                               if (large) {  inRow.close(); m->mothurRemove(distFile);  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                                               delete input; delete list; return 0; 
-                                       }
-                                       
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = list->getLabel();
-                                       
-                                       delete list;
-                                       list = input->getListVector(lastLabel);
-                                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                                       error = process(list);
-                                       if (error == 1) { return 0; } //there is an error in hte input files, abort command
-                                       
-                                       if (m->control_pressed) { 
-                                               if (large) {  inRow.close(); m->mothurRemove(distFile);  }
-                                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                                               delete input; delete list; return 0; 
-                                       }
-                                       
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();
-       
-                       delete list;
-                       list = input->getListVector();
-               }
-               
-               //output error messages about any remaining user labels
-               bool needToRun = false;
-               for (set<string>::iterator it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + (*it)); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       list = input->getListVector(lastLabel);
-                       m->mothurOut(list->getLabel() + "\t" + toString(list->size())); m->mothurOutEndLine();
-                       error = process(list);
-                       delete list;
-                       if (error == 1) { return 0; } //there is an error in hte input files, abort command
-                       
-                       if (m->control_pressed) { 
-                                       if (large) {  inRow.close(); m->mothurRemove(distFile);  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                                       delete input; delete list; return 0; 
-                       }
-               }
-               
-               //close and remove formatted matrix file
-               if (large) {
-                       inRow.close();
-                       m->mothurRemove(distFile);
-               }
-               
-               delete input;  
-               
-               if (!weighted) { nameFileMap.clear(); }
-               
-                               
-               if (fastafile != "") {
-                       //read fastafile
-                       fasta = new FastaMap();
-                       fasta->readFastaFile(fastafile);
-                       
-                       //if user gave a namesfile then use it
-                       if (namefile != "") {   readNamesFile();        }
-                       
-                       //output create and output the .rep.fasta files
-                       map<string, string>::iterator itNameFile;
-                       for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
-                               processFastaNames(itNameFile->first, itNameFile->second);
-                       }
-               }else {
-                       //output create and output the .rep.fasta files
-                       map<string, string>::iterator itNameFile;
-                       for (itNameFile = outputNameFiles.begin(); itNameFile != outputNameFiles.end(); itNameFile++) {
-                               processNames(itNameFile->first, itNameFile->second);
-                       }
-               }
-               
-                               
-               if (groupfile != "") { delete groupMap; }
-               
-               if (m->control_pressed) {  return 0; }
-               
-               //set fasta file as new current fastafile - use first one??
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-void GetOTURepCommand::readNamesFile() {
-       try {
-               ifstream in;
-               vector<string> dupNames;
-               m->openInputFile(namefile, in);
-               
-               string name, names, sequence;
-       
-               while(!in.eof()){
-                       in >> name;                     //read from first column  A
-                       in >> names;            //read from second column  A,B,C,D
-                       
-                       dupNames.clear();
-                       
-                       //parse names into vector
-                       m->splitAtComma(names, dupNames);
-                       
-                       //store names in fasta map
-                       sequence = fasta->getSequence(name);
-                       for (int i = 0; i < dupNames.size(); i++) {
-                               fasta->push_back(dupNames[i], sequence);
-                       }
-               
-                       m->gobble(in);
-               }
-               in.close();
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "readNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//read names file to find the weighted rep for each bin
-void GetOTURepCommand::readNamesFile(bool w) {
-       try {
-               ifstream in;
-               vector<string> dupNames;
-               m->openInputFile(namefile, in);
-               
-               string name, names, sequence;
-               
-               while(!in.eof()){
-                       in >> name;     m->gobble(in);          //read from first column  A
-                       in >> names;                                                    //read from second column  A,B,C,D
-                       
-                       dupNames.clear();
-                       
-                       //parse names into vector
-                       m->splitAtComma(names, dupNames);
-                       
-                       for (int i = 0; i < dupNames.size(); i++) {
-                               nameFileMap[dupNames[i]] = name;
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "readNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetOTURepCommand::findRep(vector<string> names) {
-       try{
-               // if only 1 sequence in bin or processing the "unique" label, then 
-               // the first sequence of the OTU is the representative one
-               if ((names.size() == 1)) {
-                       return names[0];
-               }else{
-                       vector<int> seqIndex(names.size());
-                       vector<float> max_dist(names.size());
-                       vector<float> total_dist(names.size());
-                       map<string, string>::iterator itNameFile;
-                       map<string, int>::iterator itNameIndex;
-
-                       //fill seqIndex and initialize sums
-                       for (size_t i = 0; i < names.size(); i++) {
-                               if (weighted) {
-                                       seqIndex[i] = nameToIndex[names[i]];
-                               }else { 
-                                       if (namefile == "") {
-                                               itNameIndex = nameToIndex.find(names[i]);
-                                               
-                                               if (itNameIndex == nameToIndex.end()) { // you are not in the distance file and no namesfile, then assume you are not unique
-                                                       if (large) {  seqIndex[i] = (rowPositions.size()-1); }
-                                                       else {  seqIndex[i] = (seqVec.size()-1); }
-                                               }else {
-                                                       seqIndex[i] = itNameIndex->second;
-                                               }
-                                               
-                                       }else {
-                                               itNameFile = nameFileMap.find(names[i]);
-                                               
-                                               if (itNameFile == nameFileMap.end()) {
-                                                       m->mothurOut("[ERROR]: " + names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; 
-                                               }else{
-                                                       string name1 = itNameFile->first;
-                                                       string name2 = itNameFile->second;
-                                                       
-                                                       if (name1 == name2) { //then you are unique so add your real dists
-                                                               seqIndex[i] = nameToIndex[names[i]];
-                                                       }else { //add dummy
-                                                               if (large) {  seqIndex[i] = (rowPositions.size()-1); }
-                                                               else {  seqIndex[i] = (seqVec.size()-1); }
-                                                       }
-                                               }
-                                       }
-                               }
-                               max_dist[i] = 0.0;
-                               total_dist[i] = 0.0;
-                       }
-                       
-                       // loop through all entries in seqIndex
-                       SeqMap::iterator it;
-                       SeqMap currMap;
-                       for (size_t i=0; i < seqIndex.size(); i++) {
-                               if (m->control_pressed) {  return  "control"; }
-                       
-                               if (!large) {   currMap = seqVec[seqIndex[i]];  }
-                               else            {       currMap = getMap(seqIndex[i]);  }
-                               
-                               for (size_t j=0; j < seqIndex.size(); j++) {
-                                       it = currMap.find(seqIndex[j]);         
-                                       if (it != currMap.end()) {
-                                               max_dist[i] = max(max_dist[i], it->second);
-                                               max_dist[j] = max(max_dist[j], it->second);
-                                               total_dist[i] += it->second;
-                                               total_dist[j] += it->second;
-                                       }else{ //if you can't find the distance make it the cutoff
-                                               max_dist[i] = max(max_dist[i], cutoff);
-                                               max_dist[j] = max(max_dist[j], cutoff);
-                                               total_dist[i] += cutoff;
-                                               total_dist[j] += cutoff;
-                                       }
-                               }
-                       }
-                       
-                       // sequence with the smallest maximum distance is the representative
-                       //if tie occurs pick sequence with smallest average distance
-                       float min = 10000;
-                       int minIndex;
-                       for (size_t i=0; i < max_dist.size(); i++) {
-                               if (m->control_pressed) {  return  "control"; }
-                               if (max_dist[i] < min) {
-                                       min = max_dist[i];
-                                       minIndex = i;
-                               }else if (max_dist[i] == min) {
-                                       float currentAverage = total_dist[minIndex] / (float) total_dist.size();
-                                       float newAverage = total_dist[i] / (float) total_dist.size();
-                                       
-                                       if (newAverage < currentAverage) {
-                                               min = max_dist[i];
-                                               minIndex = i;
-                                       }
-                               }
-                       }
-                       
-                       return(names[minIndex]);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "FindRep");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetOTURepCommand::process(ListVector* processList) {
-       try{
-               string name, sequence;
-               string nameRep;
-
-               //create output file
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-                               
-               ofstream newNamesOutput;
-               string outputNamesFile;
-               map<string, ofstream*> filehandles;
-               
-               if (Groups.size() == 0) { //you don't want to use groups
-                       outputNamesFile  = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + ".rep.names";
-                       m->openOutputFile(outputNamesFile, newNamesOutput);
-                       outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile); 
-                       outputNameFiles[outputNamesFile] = processList->getLabel();
-               }else{ //you want to use groups
-                       ofstream* temp;
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]] = temp;
-                               outputNamesFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + processList->getLabel() + "." + Groups[i] + ".rep.names";
-                               
-                               m->openOutputFile(outputNamesFile, *(temp));
-                               outputNames.push_back(outputNamesFile); outputTypes["name"].push_back(outputNamesFile);
-                               outputNameFiles[outputNamesFile] = processList->getLabel() + "." + Groups[i];
-                       }
-               }
-               
-               //for each bin in the list vector
-               for (int i = 0; i < processList->size(); i++) {
-                       if (m->control_pressed) { 
-                               out.close();  
-                               if (Groups.size() == 0) { //you don't want to use groups
-                                       newNamesOutput.close();
-                               }else{
-                                       for (int j=0; j<Groups.size(); j++) {
-                                               (*(filehandles[Groups[j]])).close();
-                                               delete filehandles[Groups[j]];
-                                       }
-                               }
-                               return 0; 
-                       }
-                       
-                       string temp = processList->get(i);
-                       vector<string> namesInBin;
-                       m->splitAtComma(temp, namesInBin);
-                       
-                       if (Groups.size() == 0) {
-                               nameRep = findRep(namesInBin);
-                               newNamesOutput << i << '\t' << nameRep << '\t' << processList->get(i) << endl;
-                       }else{
-                               map<string, vector<string> > NamesInGroup;
-                               for (int j=0; j<Groups.size(); j++) { //initialize groups
-                                       NamesInGroup[Groups[j]].resize(0);
-                               }
-                               
-                               for (int j=0; j<namesInBin.size(); j++) {
-                                       string thisgroup = groupMap->getGroup(namesInBin[j]);
-                                       
-                                       if (thisgroup == "not found") { m->mothurOut(namesInBin[j] + " is not in your groupfile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       
-                                       if (m->inUsersGroups(thisgroup, Groups)) { //add this name to correct group
-                                               NamesInGroup[thisgroup].push_back(namesInBin[j]);
-                                       }
-                               }
-                               
-                               //get rep for each group in otu
-                               for (int j=0; j<Groups.size(); j++) {
-                                       if (NamesInGroup[Groups[j]].size() != 0) { //are there members from this group in this otu?
-                                               //get rep for each group
-                                               nameRep = findRep(NamesInGroup[Groups[j]]);
-                                               
-                                               //output group rep and other members of this group
-                                               (*(filehandles[Groups[j]])) << i << '\t' << nameRep << '\t';
-                                               
-                                               for (int k=0; k<NamesInGroup[Groups[j]].size()-1; k++) {//output list of names in this otu from this group
-                                                       (*(filehandles[Groups[j]])) << NamesInGroup[Groups[j]][k] << ",";
-                                               }
-                                               //output last name
-                                               (*(filehandles[Groups[j]])) << NamesInGroup[Groups[j]][NamesInGroup[Groups[j]].size()-1] << endl;
-                                       }
-                               }
-                       }
-               }
-               
-               if (Groups.size() == 0) { //you don't want to use groups
-                       newNamesOutput.close();
-               }else{
-                       for (int i=0; i<Groups.size(); i++) {
-                               (*(filehandles[Groups[i]])).close();
-                               delete filehandles[Groups[i]];
-                       }
-               }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "process");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetOTURepCommand::processFastaNames(string filename, string label) {
-       try{
-
-               //create output file
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listfile)) + label + ".rep.fasta";
-               m->openOutputFile(outputFileName, out);
-               vector<repStruct> reps;
-               outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
-               
-               ofstream out2;
-               string tempNameFile = filename + ".temp";
-               m->openOutputFile(tempNameFile, out2);
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               int i = 0;
-               while (!in.eof()) {
-                       string rep, binnames;
-                       in >> i >> rep >> binnames; m->gobble(in);
-                       out2 << rep << '\t' << binnames << endl;
-                       
-                       vector<string> names;
-                       m->splitAtComma(binnames, names);
-                       int binsize = names.size();
-                       
-                       //if you have a groupfile
-                       string group = "";
-                       if (groupfile != "") {
-                               map<string, string> groups;
-                               map<string, string>::iterator groupIt;
-                               
-                               //find the groups that are in this bin
-                               for (size_t i = 0; i < names.size(); i++) {
-                                       string groupName = groupMap->getGroup(names[i]);
-                                       if (groupName == "not found") {  
-                                               m->mothurOut(names[i] + " is missing from your group file. Please correct. "); m->mothurOutEndLine();
-                                               groupError = true;
-                                       } else {
-                                               groups[groupName] = groupName;
-                                       }
-                               }
-                               
-                               //turn the groups into a string
-                               for (groupIt = groups.begin(); groupIt != groups.end(); groupIt++) {
-                                       group += groupIt->first + "-";
-                               }
-                               //rip off last dash
-                               group = group.substr(0, group.length()-1);
-                       }else{ group = ""; }
-
-                       
-                       //print out name and sequence for that bin
-                       string sequence = fasta->getSequence(rep);
-
-                       if (sequence != "not found") {
-                               if (sorted == "") { //print them out
-                                       rep = rep + "\t" + toString(i+1);
-                                       rep = rep + "|" + toString(binsize);
-                                       if (groupfile != "") {
-                                               rep = rep + "|" + group;
-                                       }
-                                       out << ">" << rep << endl;
-                                       out << sequence << endl;
-                               }else { //save them
-                                       repStruct newRep(rep, i+1, binsize, group);
-                                       reps.push_back(newRep);
-                               }
-                       }else { 
-                               m->mothurOut(rep + " is missing from your fasta or name file, ignoring. Please correct."); m->mothurOutEndLine(); 
-                       }
-               }
-               
-                       
-               if (sorted != "") { //then sort them and print them
-                       if (sorted == "name")           {  sort(reps.begin(), reps.end(), compareName);         }
-                       else if (sorted == "bin")       {  sort(reps.begin(), reps.end(), compareBin);          }
-                       else if (sorted == "size")      {  sort(reps.begin(), reps.end(), compareSize);         }
-                       else if (sorted == "group")     {  sort(reps.begin(), reps.end(), compareGroup);        }
-                       
-                       //print them
-                       for (int i = 0; i < reps.size(); i++) {
-                               string sequence = fasta->getSequence(reps[i].name);
-                               string outputName = reps[i].name + "\t" + toString(reps[i].bin);
-                               outputName = outputName + "|" + toString(reps[i].size);
-                               if (groupfile != "") {
-                                       outputName = outputName + "|" + reps[i].group;
-                               }
-                               out << ">" << outputName << endl;
-                               out << sequence << endl;
-                       }
-               }
-               
-               in.close();
-               out.close();
-               out2.close();
-               
-               m->mothurRemove(filename);
-               rename(tempNameFile.c_str(), filename.c_str());
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "processFastaNames");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetOTURepCommand::processNames(string filename, string label) {
-       try{
-               
-               //create output file
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               
-               ofstream out2;
-               string tempNameFile = filename + ".temp";
-               m->openOutputFile(tempNameFile, out2);
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               int i = 0;
-               string rep, binnames;
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       in >> i >> rep >> binnames; m->gobble(in);
-                       out2 << rep << '\t' << binnames << endl;
-               }
-               in.close();
-               out2.close();
-               
-               m->mothurRemove(filename);
-               rename(tempNameFile.c_str(), filename.c_str());
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "processNames");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SeqMap GetOTURepCommand::getMap(int row) {
-       try {
-               SeqMap rowMap;
-               
-               //make sure this row exists in the file, it may not if the seq did not have any distances below the cutoff
-               if (rowPositions[row] != -1){
-                       //go to row in file
-                       inRow.seekg(rowPositions[row]);
-                       
-                       int rowNum, numDists, colNum;
-                       float dist;
-                       
-                       inRow >> rowNum >> numDists;
-                       
-                       for(int i = 0; i < numDists; i++) {
-                               inRow >> colNum >> dist;
-                               rowMap[colNum] = dist;
-                               
-                       }
-               }
-               
-               return rowMap;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOTURepCommand", "getMap");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/getoturepcommand.h b/getoturepcommand.h
deleted file mode 100644 (file)
index 4168000..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-#ifndef GETOTUREPCOMMAND_H
-#define GETOTUREPCOMMAND_H
-/*
- *  getoturepcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
- /* The get.oturep command outputs a .fastarep file for each distance you specify, selecting one OTU representative for each bin. */
-
-#include "command.hpp"
-#include "listvector.hpp"
-#include "inputdata.h"
-#include "fastamap.h"
-#include "groupmap.h"
-#include "readmatrix.hpp"
-#include "formatmatrix.h"
-
-typedef list<PCell>::iterator MatData;
-typedef map<int, float> SeqMap;
-
-struct repStruct {
-               string name;
-               int     bin;
-               int size;
-               string group;
-               
-               repStruct(){}
-               repStruct(string n, int b, int s, string g) : name(n), bin(b), size(s), group(g) {}
-               ~repStruct() {}
-};
-
-class GetOTURepCommand : public Command {
-
-public:
-       GetOTURepCommand(string);
-       GetOTURepCommand();
-       ~GetOTURepCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.oturep";                          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.oturep"; }
-       string getDescription()         { return "gets a representative sequence for each OTU"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       ListVector* list;
-       InputData* input;
-       FastaMap* fasta;
-       GroupMap* groupMap;
-       ReadMatrix* readMatrix;
-       FormatMatrix* formatMatrix;
-       NameAssignment* nameMap;
-       string filename, fastafile, listfile, namefile, groupfile, label, sorted, phylipfile, columnfile, distFile, format, outputDir, groups;
-       ofstream out;
-       ifstream in, inNames, inRow;
-       bool abort, allLines, groupError, large, weighted;
-       set<string> labels; //holds labels to be used
-       map<string, int> nameToIndex;  //maps sequence name to index in sparsematrix
-       map<string, string> nameFileMap;
-       vector<string> outputNames, Groups;
-       map<string, string> outputNameFiles;
-       float cutoff;
-       int precision;
-       vector<SeqMap> seqVec;                  // contains maps with sequence index and distance
-                                                                       // for all distances related to a certain sequence
-       vector<int> rowPositions;
-
-       void readNamesFile();
-       void readNamesFile(bool);
-       int process(ListVector*);
-       SeqMap getMap(int);
-       string findRep(vector<string>);         // returns the name of the "representative" sequence of given bin or subset of a bin, for groups
-       int processNames(string, string);
-       int processFastaNames(string, string);
-};
-
-#endif
-
diff --git a/getotuscommand.cpp b/getotuscommand.cpp
deleted file mode 100644 (file)
index 4e8d319..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- *  getotuscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getotuscommand.h"
-#include "inputdata.h"
-#include "sharedutilities.h"
-
-
-//**********************************************************************************************************************
-vector<string> GetOtusCommand::setParameters(){        
-       try {
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetOtusCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The get.otus command selects otus containing sequences from a specfic group or set of groups.\n";
-               helpString += "It outputs a new list file containing the otus containing sequences from in the those specified groups.\n";
-               helpString += "The get.otus command parameters are accnos, group, list, label and groups. The group and list parameters are required, unless you have valid current files.\n";
-               helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like.  You can separate group names with dashes.\n";
-               helpString += "The label parameter allows you to specify which distance you want to process.\n";
-               helpString += "The get.otus command should be in the following format: get.otus(accnos=yourAccnos, list=yourListFile, group=yourGroupFile, label=yourLabel).\n";
-               helpString += "Example get.otus(accnos=amazon.accnos, list=amazon.fn.list, group=amazon.groups, label=0.03).\n";
-               helpString += "or get.otus(groups=pasture, list=amazon.fn.list, amazon.groups, label=0.03).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-GetOtusCommand::GetOtusCommand(){      
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "GetOtusCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetOtusCommand::GetOtusCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = ""; }
-                       else { m->setAccnosFile(accnosfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {                            
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current group file and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setGroupFile(groupfile); }   
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {                             
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setListFile(listfile); }     
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                       }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }  
-                       
-                       if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "GetOtusCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetOtusCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               groupMap = new GroupMap(groupfile);
-               groupMap->readMap();
-               
-               //get groups you want to get
-               if (accnosfile != "") { readAccnos(); }
-               
-               //make sure groups are valid
-               //takes care of user setting groupNames that are invalid or setting groups=all
-               SharedUtil* util = new SharedUtil();
-               vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
-               util->setGroups(Groups, gNamesOfGroups);
-               groupMap->setNamesOfGroups(gNamesOfGroups);
-               delete util;
-               
-               if (m->control_pressed) { delete groupMap; return 0; }
-               
-               //read through the list file keeping any otus that contain any sequence from the groups selected
-               readListGroup();
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-                               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set list file as new current listfile
-                       string current = "";
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetOtusCommand::readListGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick." + label +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               string GroupOutputDir = outputDir;
-               if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick." + label  + m->getExtension(groupfile);
-               
-               ofstream outGroup;
-               m->openOutputFile(outputGroupFileName, outGroup);
-                       
-               InputData* input = new InputData(listfile, "list");
-               ListVector* list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               //using first label seen if none is provided
-               if (label == "") { label = lastLabel; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               bool wroteSomething = false;
-
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((list != NULL) && (userLabels.size() != 0)) {
-                       
-                       if (m->control_pressed) {  delete list; delete input; out.close();  outGroup.close(); m->mothurRemove(outputFileName);  m->mothurRemove(outputGroupFileName);return 0;  }
-                       
-                       if(labels.count(list->getLabel()) == 1){
-                               processList(list, groupMap, out, outGroup, wroteSomething);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list; 
-                               
-                               list = input->getListVector(lastLabel);
-                               
-                               processList(list, groupMap, out, outGroup, wroteSomething);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();
-                       
-                       delete list; list = NULL;
-                       
-                       //get next line to process
-                       list = input->getListVector();                          
-               }
-               
-               
-               if (m->control_pressed) {  if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName);  m->mothurRemove(outputGroupFileName); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) { delete list; }
-                       
-                       list = input->getListVector(lastLabel);
-                       
-                       processList(list, groupMap, out, outGroup, wroteSomething);
-                       
-                       delete list; list = NULL;
-               }
-                                       
-               out.close();
-               outGroup.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("At distance " + label + " your file does NOT contain any otus containing sequences from the groups you wish to get."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               outputTypes["group"].push_back(outputGroupFileName); outputNames.push_back(outputGroupFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream& out, ofstream& outGroup, bool& wroteSomething){
-       try {
-               
-               //make a new list vector
-               ListVector newList;
-               newList.setLabel(list->getLabel());
-               
-               int numOtus = 0;
-               //for each bin
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       //parse out names that are in accnos file
-                       string binnames = list->get(i);
-                       
-                       bool keepBin = false;
-                       string groupFileOutput = "";
-                       
-                       //parse names
-                       string individual = "";
-                       int length = binnames.length();
-                       for(int j=0;j<length;j++){
-                               if(binnames[j] == ','){
-                                       string group = groupMap->getGroup(individual);
-                                       if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                                       
-                                       if (m->inUsersGroups(group, Groups)) {  keepBin = true; }
-                                       groupFileOutput += individual + "\t" + group + "\n";
-                                       individual = "";        
-                                       
-                               }
-                               else{  individual += binnames[j];  }
-                       }
-                       
-                       string group = groupMap->getGroup(individual);
-                       if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                       
-                       if (m->inUsersGroups(group, Groups)) {  keepBin = true; }
-                       groupFileOutput += individual + "\t" + group + "\n";
-                       
-                       //if there are sequences from the groups we want in this bin add to new list, output to groupfile
-                       if (keepBin) {  
-                               newList.push_back(binnames);    
-                               outGroup << groupFileOutput;
-                               numOtus++;
-                       }
-               }
-               
-               //print new listvector
-               if (newList.getNumBins() != 0) {
-                       wroteSomething = true;
-                       newList.print(out);
-               }
-               
-               m->mothurOut(newList.getLabel() + " - selected " + toString(numOtus) + " of the " + toString(list->getNumBins()) + " OTUs."); m->mothurOutEndLine();
-       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "processList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void GetOtusCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetOtusCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/getotuscommand.h b/getotuscommand.h
deleted file mode 100644 (file)
index 1a78493..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef GETOTUSCOMMAND_H
-#define GETOTUSCOMMAND_H
-
-/*
- *  getotuscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "command.hpp"
-#include "groupmap.h"
-#include "listvector.hpp"
-
-class GetOtusCommand : public Command {
-       
-public:
-       
-       GetOtusCommand(string); 
-       GetOtusCommand();
-       ~GetOtusCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.otus";                            }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.otus"; }
-       string getDescription()         { return "outputs a new list file containing the otus containing sequences from the groups specified"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       string accnosfile, groupfile, listfile, outputDir, groups, label;
-       bool abort;
-       vector<string> outputNames, Groups;
-       GroupMap* groupMap;
-       
-       void readAccnos();
-       int readListGroup();
-       int processList(ListVector*&, GroupMap*&, ofstream&, ofstream&, bool&);
-       
-};
-
-#endif
-
-
-
diff --git a/getrabundcommand.cpp b/getrabundcommand.cpp
deleted file mode 100644 (file)
index 5a33253..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- *  getrabundcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/2/09.
- *  Copyright 2009 Schloss Lab Umass Amherst. All rights reserved.
- *
- */
-
-#include "getrabundcommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetRAbundCommand::setParameters(){      
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);            
-               CommandParameter psorted("sorted", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetRAbundCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The get.rabund command parameters are list, sabund, label and sorted.  list or sabund parameters are required, unless you have valid current files.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like included in your .rabund file, and are separated by dashes.\n";
-               helpString += "The sorted parameters allows you to print the rabund results sorted by abundance or not.  The default is sorted.\n";
-               helpString += "The get.rabund command should be in the following format: get.rabund(label=yourLabels, sorted=yourSorted).\n";
-               helpString += "Example get.rabund(sorted=F).\n";
-               helpString += "The default value for label is all labels in your inputfile.\n";
-               helpString += "The get.rabund command outputs a .rabund file containing the lines you selected.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-GetRAbundCommand::GetRAbundCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetRAbundCommand::GetRAbundCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "sorted", false);                   if (temp == "not found") { temp = "T"; }
-                       sorted = m->isTrue(temp);
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       if ((listfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       sabundfile = m->getSabundFile(); 
-                                       if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a list or sabund file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);      }                       
-                       
-               }
-                       
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "GetRAbundCommand");
-               exit(1);
-       }                       
-}
-//**********************************************************************************************************************
-
-int GetRAbundCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "rabund";
-               m->openOutputFile(filename, out);
-               
-               input = new InputData(inputfile, format);
-               rabund = input->getRAbundVector();
-               string lastLabel = rabund->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) {  outputTypes.clear();  out.close(); m->mothurRemove(filename); delete rabund; delete input; return 0; }
-               
-               while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if(allLines == 1 || labels.count(rabund->getLabel()) == 1){
-                                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       
-                                       if (m->control_pressed) {   outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete input; delete rabund;  return 0;  }
-                                       
-                                       if(sorted)      {   rabund->print(out);                         }
-                                       else            {       rabund->nonSortedPrint(out);    }
-                                                                                                                       
-                                       processedLabels.insert(rabund->getLabel());
-                                       userLabels.erase(rabund->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = rabund->getLabel();
-                                       
-                                       delete rabund;
-                                       rabund = input->getRAbundVector(lastLabel);
-                                       
-                                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       
-                                       if (m->control_pressed) {   outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete input; delete rabund;  return 0;  }
-                                       
-                                       if(sorted)      {   rabund->print(out);                         }
-                                       else            {       rabund->nonSortedPrint(out);    }
-
-                                       processedLabels.insert(rabund->getLabel());
-                                       userLabels.erase(rabund->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       rabund->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = rabund->getLabel();         
-                       
-                       delete rabund;
-                       rabund = input->getRAbundVector();
-               }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (rabund != NULL) {   delete rabund;  }
-                       rabund = input->getRAbundVector(lastLabel);
-                       
-                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       
-                       if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete input; delete rabund;  return 0; }
-                       
-                       if(sorted)      {   rabund->print(out);                         }
-                       else            {       rabund->nonSortedPrint(out);    }
-
-                       delete rabund;
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(filename); m->mothurOutEndLine();  outputNames.push_back(filename); outputTypes["rabund"].push_back(filename);
-               m->mothurOutEndLine();
-               
-               out.close(); 
-                               
-               //set rabund file as new current rabundfile
-               string current = "";
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetRAbundCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/getrabundcommand.h b/getrabundcommand.h
deleted file mode 100644 (file)
index cb9e270..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef GETRABUNDCOMMAND_H
-#define GETRABUNDCOMMAND_H
-
-/*
- *  getrabundcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "listvector.hpp"
-
-
-class GetRAbundCommand : public Command {
-public:
-       GetRAbundCommand(string);
-       GetRAbundCommand();
-       ~GetRAbundCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.rabund";                          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.rabund"; }
-       string getDescription()         { return "creates a rabund file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       
-       string filename, listfile, sabundfile, inputfile, format, outputDir;
-       ofstream out;
-       InputData* input;
-       RAbundVector* rabund;
-       vector<string> outputNames;
-
-       bool abort, allLines, sorted;
-       set<string> labels; //holds labels to be used
-       string label;
-
-       
-};
-
-#endif
-
diff --git a/getrelabundcommand.cpp b/getrelabundcommand.cpp
deleted file mode 100644 (file)
index 8c8d8e1..0000000
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- *  getrelabundcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 6/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getrelabundcommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetRelAbundCommand::setParameters(){    
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pscale("scale", "Multiple", "totalgroup-totalotu-averagegroup-averageotu", "totalgroup", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetRelAbundCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The get.relabund command parameters are shared, groups, scale and label.  shared is required, unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The scale parameter allows you to select what scale you would like to use. Choices are totalgroup, totalotu, averagegroup, averageotu, default is totalgroup.\n";
-               helpString += "The get.relabund command should be in the following format: get.relabund(groups=yourGroups, label=yourLabels).\n";
-               helpString += "Example get.relabund(groups=A-B-C, scale=averagegroup).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "The get.relabund command outputs a .relabund file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetRelAbundCommand::GetRelAbundCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["relabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "GetRelAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetRelAbundCommand::GetRelAbundCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["relabund"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-               
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; pickedGroups = false; }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       scale = validParameter.validFile(parameters, "scale", false);                           if (scale == "not found") { scale = "totalgroup"; }
-                       
-                       if ((scale != "totalgroup") && (scale != "totalotu") && (scale != "averagegroup") && (scale != "averageotu")) {
-                               m->mothurOut(scale + " is not a valid scaling option for the get.relabund command. Choices are totalgroup, totalotu, averagegroup, averageotu."); m->mothurOutEndLine(); abort = true; 
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "GetRelAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetRelAbundCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "relabund";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  outputTypes.clear();  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups(); delete input;  out.close(); m->mothurRemove(outputFileName); return 0; }
-       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               getRelAbundance(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                       
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               getRelAbundance(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       
-                       if (m->control_pressed) {  outputTypes.clear();  m->clearGroups(); delete input;  out.close(); m->mothurRemove(outputFileName); return 0; }
-
-                       //get next line to process
-                       lookup = input->getSharedRAbundVectors();                               
-               }
-               
-               if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input;  out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-       
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                       getRelAbundance(lookup, out);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-       
-               //reset groups parameter
-               m->clearGroups();  
-               delete input; 
-               out.close();
-               
-               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0;}
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["relabund"].push_back(outputFileName);
-               m->mothurOutEndLine();
-               
-               //set relabund file as new current relabundfile
-               string current = "";
-               itTypes = outputTypes.find("relabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRelAbundFile(current); }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetRelAbundCommand::getRelAbundance(vector<SharedRAbundVector*>& thisLookUp, ofstream& out){
-       try {
-               
-                for (int i = 0; i < thisLookUp.size(); i++) {
-                       out << thisLookUp[i]->getLabel() << '\t' << thisLookUp[i]->getGroup() << '\t' << thisLookUp[i]->getNumBins() << '\t';
-                       
-                       for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) {
-                       
-                               if (m->control_pressed) { return 0; }
-                       
-                               int abund = thisLookUp[i]->getAbundance(j);
-                               
-                               float relabund = 0.0;
-                               
-                               if (scale == "totalgroup") { 
-                                       relabund = abund / (float) thisLookUp[i]->getNumSeqs();
-                               }else if (scale == "totalotu") {
-                                       //calc the total in this otu
-                                       int totalOtu = 0;
-                                       for (int l = 0; l < thisLookUp.size(); l++) {  totalOtu += thisLookUp[l]->getAbundance(j); }
-                                       relabund = abund / (float) totalOtu;
-                               }else if (scale == "averagegroup") {
-                                       relabund = abund / (float) (thisLookUp[i]->getNumSeqs() / (float) thisLookUp[i]->getNumBins());
-                               }else if (scale == "averageotu") {
-                                       //calc the total in this otu
-                                       int totalOtu = 0;
-                                       for (int l = 0; l < thisLookUp.size(); l++) {  totalOtu += thisLookUp[l]->getAbundance(j); }
-                                       float averageOtu = totalOtu / (float) thisLookUp.size();
-                                       
-                                       relabund = abund / (float) averageOtu;
-                               }else{ m->mothurOut(scale + " is not a valid scaling option."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-                               
-                               out << relabund << '\t';
-                       }
-                       out << endl;
-                }
-       
-                return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetRelAbundCommand", "getRelAbundance");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/getrelabundcommand.h b/getrelabundcommand.h
deleted file mode 100644 (file)
index 1d5163d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef GETRELABUNDCOMMAND_H
-#define GETRELABUNDCOMMAND_H
-
-/*
- *  getrelabundcommand.h
- *  Mothur
- *
- *  Created by westcott on 6/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedrabundvector.h"
-
-
-class GetRelAbundCommand : public Command {
-
-public:
-       GetRelAbundCommand(string);
-       GetRelAbundCommand();
-       ~GetRelAbundCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.relabund";                        }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.relabund"; }
-       string getDescription()         { return "calculates the relative abundance of each OTU in a sample"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       InputData* input;
-       vector<SharedRAbundVector*> lookup;
-       
-       bool abort, allLines, pickedGroups;
-       set<string> labels; //holds labels to be used
-       string groups, label, outputDir, scale, sharedfile;
-       vector<string> Groups, outputNames;
-       
-       int getRelAbundance(vector<SharedRAbundVector*>&, ofstream&);
-
-};
-
-#endif
-
diff --git a/getsabundcommand.cpp b/getsabundcommand.cpp
deleted file mode 100644 (file)
index 4ae2eaa..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- *  getsabundcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "getsabundcommand.h"
-
-//**********************************************************************************************************************
-vector<string> GetSAbundCommand::setParameters(){      
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);            
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetSAbundCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The get.sabund command parameters is list, rabund and label.  list or rabund is required unless a valid current file exists.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like included in your .sabund file, and are separated by dashes.\n";
-               helpString += "The get.sabund command should be in the following format: get.sabund(label=yourLabels).\n";
-               helpString += "Example get.sabund().\n";
-               helpString += "The default value for label is all labels in your inputfile.\n";
-               helpString += "The get.sabund command outputs a .sabund file containing the labels you selected.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-GetSAbundCommand::GetSAbundCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetSAbundCommand::GetSAbundCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-               
-                                               //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       if ((listfile == "") && (rabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       rabundfile = m->getRabundFile(); 
-                                       if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a list or rabund file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);      }                       
-                       
-                       
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "GetSAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetSAbundCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               filename = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "sabund";
-               m->openOutputFile(filename, out);
-               
-               input = new InputData(inputfile, format);
-               sabund = input->getSAbundVector();
-               string lastLabel = sabund->getLabel();
-               
-                                               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete sabund; delete input; return 0; }
-
-               
-               while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if(allLines == 1 || labels.count(sabund->getLabel()) == 1){
-                                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                                       
-                                       sabund->print(out);
-                                       
-                               if (m->control_pressed) { outputTypes.clear();  out.close(); m->mothurRemove(filename);  delete sabund; delete input;  return 0; }
-
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = sabund->getLabel();
-                                       
-                                       delete sabund;          
-                                       sabund = (input->getSAbundVector(lastLabel));
-                                       
-                                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                                       sabund->print(out);
-                                       
-                                       if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete sabund; delete input;  return 0; }
-
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       sabund->setLabel(saveLabel);
-                       }
-                       
-                       
-                       lastLabel = sabund->getLabel(); 
-                       
-                       delete sabund;          
-                       sabund = (input->getSAbundVector());
-               }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + ".");  m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + ".");  m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (sabund != NULL) {   delete sabund;  }
-                       sabund = (input->getSAbundVector(lastLabel));
-                       
-                       m->mothurOut(sabund->getLabel());  m->mothurOutEndLine();
-                       sabund->print(out);
-                       delete sabund;
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); out.close(); m->mothurRemove(filename);  delete input; return 0; }
-                       
-               }
-               
-               out.close();
-               delete input;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(filename); m->mothurOutEndLine();  outputNames.push_back(filename); outputTypes["sabund"].push_back(filename);
-               m->mothurOutEndLine();
-               
-               //set sabund file as new current sabundfile
-               string current = "";
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetSAbundCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/getsabundcommand.h b/getsabundcommand.h
deleted file mode 100644 (file)
index 5be00df..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef GETSABUNDCOMMAND_H
-#define GETSABUNDCOMMAND_H
-
-/*
- *  getsabundcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "sabundvector.hpp"
-
-class GetSAbundCommand : public Command {
-public:
-       GetSAbundCommand(string);
-       GetSAbundCommand();
-       ~GetSAbundCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "get.sabund";                          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Get.sabund"; }
-       string getDescription()         { return "creates a sabund file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string filename, format, inputfile, listfile, rabundfile, outputDir;
-       ofstream out;
-       InputData* input;
-       SAbundVector* sabund;
-       vector<string> outputNames;
-
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string label;
-
-};
-
-#endif
diff --git a/getseqscommand.cpp b/getseqscommand.cpp
deleted file mode 100644 (file)
index 9bf188d..0000000
+++ /dev/null
@@ -1,935 +0,0 @@
-/*
- *  getseqscommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "getseqscommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-
-//**********************************************************************************************************************
-vector<string> GetSeqsCommand::setParameters(){        
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter paccnos2("accnos2", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos2);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetSeqsCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The get.seqs command reads an .accnos file and any of the following file types: fasta, name, group, list, taxonomy, quality or alignreport file.\n";
-               helpString += "It outputs a file containing only the sequences in the .accnos file.\n";
-               helpString += "The get.seqs command parameters are accnos, fasta, name, group, list, taxonomy, qfile, alignreport and dups.  You must provide accnos unless you have a valid current accnos file, and at least one of the other parameters.\n";
-               helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=false. \n";
-               helpString += "The get.seqs command should be in the following format: get.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
-               helpString += "Example get.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-GetSeqsCommand::GetSeqsCommand(){      
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-               outputTypes["accnosreport"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "GetSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetSeqsCommand::GetSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       outputTypes["accnosreport"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("accnos2");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos2"] = inputDir + it->second;          }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  
-                               accnosfile = m->getAccnosFile(); 
-                               if (accnosfile != "") {  m->mothurOut("Using " + accnosfile + " as input file for the accnos parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("You have no valid accnos file and accnos is required."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               } 
-                       }else { m->setAccnosFile(accnosfile); } 
-                       
-                       if (accnosfile2 == "not found") { accnosfile2 = ""; }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       alignfile = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignfile == "not open") { abort = true; }
-                       else if (alignfile == "not found") {  alignfile = "";  }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { taxfile = ""; abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { abort = true; }
-                       else if (qualfile == "not found") {  qualfile = "";  }
-                       else { m->setQualFile(qualfile); }
-                       
-                       accnosfile2 = validParameter.validFile(parameters, "accnos2", true);
-                       if (accnosfile2 == "not open") { abort = true; }
-                       else if (accnosfile2 == "not found") {  accnosfile2 = "";  }
-                       
-                       
-                       string usedDups = "true";
-                       string temp = validParameter.validFile(parameters, "dups", false);      if (temp == "not found") { temp = "true"; usedDups = ""; }
-                       dups = m->isTrue(temp);
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == "") && (accnosfile2 == ""))  { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy, quality or listfile."); m->mothurOutEndLine(); abort = true; }
-               
-                       if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
-                               vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "GetSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get names you want to keep
-               readAccnos();
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (namefile != "")                     {               readName();                     }
-               if (fastafile != "")            {               readFasta();            }
-               if (groupfile != "")            {               readGroup();            }
-               if (alignfile != "")            {               readAlign();            }
-               if (listfile != "")                     {               readList();                     }
-               if (taxfile != "")                      {               readTax();                      }
-               if (qualfile != "")                     {               readQual();                     }
-               if (accnosfile2 != "")          {               compareAccnos();        }
-               
-               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("qfile");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-                       }
-                       
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetSeqsCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" +  m->getExtension(fastafile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) != 0) {
-                                       wroteSomething = true;
-                                       
-                                       currSeq.printSequence(out);
-                                       selectedCount++;
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["fasta"].push_back(outputFileName); 
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your fasta file."); m->mothurOutEndLine();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetSeqsCommand::readQual(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "pick" +  m->getExtension(qualfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               
-               ifstream in;
-               m->openInputFile(qualfile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               
-               while(!in.eof()){       
-                       string saveName = "";
-                       string name = "";
-                       string scores = "";
-                       
-                       in >> name; 
-                               
-                       if (name.length() != 0) { 
-                               saveName = name.substr(1);
-                               while (!in.eof())       {       
-                                       char c = in.get(); 
-                                       if (c == 10 || c == 13){        break;  }
-                                       else { name += c; }     
-                               } 
-                               m->gobble(in);
-                       }
-                       
-                       while(in){
-                               char letter= in.get();
-                               if(letter == '>'){      in.putback(letter);     break;  }
-                               else{ scores += letter; }
-                       }
-                       
-                       m->gobble(in);
-                       
-                       if (names.count(saveName) != 0) {
-                               wroteSomething = true;
-                                               
-                               out << name << endl << scores;
-                               selectedCount++;
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["qfile"].push_back(outputFileName); 
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your quality file."); m->mothurOutEndLine();
-
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readQual");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetSeqsCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-                       
-                       selectedCount = 0;
-                       
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                       
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) != 0) {  newNames += name + ",";  selectedCount++; }
-                               }
-                       
-                               //get last name
-                               if (names.count(binnames) != 0) {  newNames += binnames + ",";  selectedCount++; }
-
-                               //if there are names in this bin add to new list
-                               if (newNames != "") { 
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                               
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your list file."); m->mothurOutEndLine();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetSeqsCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" +  m->getExtension(namefile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> firstCol;                         
-                       in >> secondCol;
-                       
-                       string hold = "";
-                       if (dups) { hold = secondCol; }
-                       
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) != 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-
-                       if ((dups) && (validSecond.size() != 0)) { //dups = true and we want to add someone, then add everyone
-                               for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
-                               out << firstCol << '\t' << hold << endl;
-                               wroteSomething = true;
-                               selectedCount += parsedNames.size();
-                       }else {
-                               selectedCount += validSecond.size();
-                               
-                               //if the name in the first column is in the set then print it and any other names in second column also in set
-                               if (names.count(firstCol) != 0) {
-                               
-                                       wroteSomething = true;
-                                       
-                                       out << firstCol << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       
-                               
-                               //make first name in set you come to first column and then add the remaining names to second column
-                               }else {
-                                       //you want part of this row
-                                       if (validSecond.size() != 0) {
-                                       
-                                               wroteSomething = true;
-                                               
-                                               out << validSecond[0] << '\t';
-                                       
-                                               //you know you have at least one valid second since first column is valid
-                                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                               out << validSecond[validSecond.size()-1] << endl;
-                                       }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your name file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int GetSeqsCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t' << group << endl;
-                               selectedCount++;
-                       }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["group"].push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your group file."); m->mothurOutEndLine();
-
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int GetSeqsCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               while(!in.eof()){
-
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t' << tax << endl;
-                               selectedCount++;
-                       }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["taxonomy"].push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine();
-                       
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//alignreport file has a column header line then all other lines contain 16 columns.  we just want the first column since that contains the name
-int GetSeqsCommand::readAlign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-
-               ifstream in;
-               m->openInputFile(alignfile, in);
-               string name, junk;
-               
-               bool wroteSomething = false;
-               int selectedCount = 0;
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                       else                    {       break;                  }
-               }
-               out << endl;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-
-                       in >> name;                             //read from first column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) != 0) {
-                               wroteSomething = true;
-                               selectedCount++;
-                               
-                               out << name << '\t';
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                                       else                    {       break;                  }
-                               }
-                               out << endl;
-                               
-                       }else {//still read just don't do anything with it
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;             }
-                                       else                    {       break;                  }
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) { m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["alignreport"].push_back(outputFileName);
-               
-               m->mothurOut("Selected " + toString(selectedCount) + " sequences from your alignreport file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readAlign");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                                               
-                       names.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetSeqsCommand::compareAccnos(){
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(accnosfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(accnosfile)) + "accnos.report";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(accnosfile2, in);
-               string name;
-               
-               set<string> namesAccnos2;
-               set<string> namesDups;
-               set<string> namesAccnos = names;
-               
-               map<string, int> nameCount;
-               
-               if (namefile != "") {
-                       ifstream inName;
-                       m->openInputFile(namefile, inName);
-                       
-                       
-                       while(!inName.eof()){
-                               
-                               if (m->control_pressed) { inName.close(); return 0; }
-                               
-                               string thisname, repnames;
-                               
-                               inName >> thisname;             m->gobble(inName);              //read from first column
-                               inName >> repnames;                     //read from second column
-                               
-                               int num = m->getNumNames(repnames);
-                               nameCount[thisname] = num;
-                               
-                               m->gobble(inName);
-                       }
-                       inName.close(); 
-               }
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       if (namesAccnos.count(name) == 0){ //name unique to accnos2
-                               int pos = name.find_last_of('_');
-                               string tempName = name;
-                               if (pos != string::npos) {  tempName = tempName.substr(pos+1); cout << tempName << endl; }
-                               if (namesAccnos.count(tempName) == 0){
-                                       namesAccnos2.insert(name);
-                               }else { //you are in both so erase
-                                       namesAccnos.erase(name);
-                                       namesDups.insert(name);
-                               }
-                       }else { //you are in both so erase
-                               namesAccnos.erase(name);
-                               namesDups.insert(name);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               out << "Names in both files : " + toString(namesDups.size()) << endl;
-               m->mothurOut("Names in both files : " + toString(namesDups.size())); m->mothurOutEndLine();
-               
-               for (set<string>::iterator it = namesDups.begin(); it != namesDups.end(); it++) {
-                       out << (*it);
-                       if (namefile != "") { out << '\t' << nameCount[(*it)]; }
-                       out << endl;
-               }
-               
-               out << "Names unique to " + accnosfile + " : " + toString(namesAccnos.size()) << endl;
-               m->mothurOut("Names unique to " + accnosfile + " : " + toString(namesAccnos.size())); m->mothurOutEndLine();
-               
-               for (set<string>::iterator it = namesAccnos.begin(); it != namesAccnos.end(); it++) {
-                       out << (*it);
-                       if (namefile != "") { out << '\t' << nameCount[(*it)]; }
-                       out << endl;
-               }
-               
-               out << "Names unique to " + accnosfile2 + " : " + toString(namesAccnos2.size()) << endl;
-               m->mothurOut("Names unique to " + accnosfile2 + " : " + toString(namesAccnos2.size())); m->mothurOutEndLine();
-               
-               for (set<string>::iterator it = namesAccnos2.begin(); it != namesAccnos2.end(); it++) {
-                       out << (*it);
-                       if (namefile != "") { out << '\t' << nameCount[(*it)]; }
-                       out << endl;
-               }
-
-               out.close(); 
-               
-               outputNames.push_back(outputFileName);  outputTypes["accnosreport"].push_back(outputFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-
diff --git a/getseqscommand.h b/getseqscommand.h
deleted file mode 100644 (file)
index 4561d28..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef GETSEQSCOMMAND_H
-#define GETSEQSCOMMAND_H
-
-/*
- *  getseqscommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "command.hpp"
-
-class GetSeqsCommand : public Command {
-       
-       public:
-       
-               GetSeqsCommand(string);
-               GetSeqsCommand();
-               ~GetSeqsCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "get.seqs";                            }
-               string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Get.seqs"; }
-               string getDescription()         { return "gets sequences from a list, fasta, name, group, alignreport, quality or taxonomy file"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       private:
-               set<string> names;
-               vector<string> outputNames;
-               string accnosfile, accnosfile2, fastafile, namefile, groupfile, alignfile, listfile, taxfile, qualfile, outputDir;
-               bool abort, dups;
-               
-               int readFasta();
-               int readName();
-               int readGroup();
-               int readAlign();
-               int readAccnos();
-               int readList();
-               int readTax();
-               int readQual();
-               int compareAccnos();
-               
-};
-
-#endif
-
diff --git a/getsharedotucommand.cpp b/getsharedotucommand.cpp
deleted file mode 100644 (file)
index 02d8413..0000000
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
- *  getsharedotucommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/22/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "getsharedotucommand.h"
-#include "sharedutilities.h"
-
-//**********************************************************************************************************************
-vector<string> GetSharedOTUCommand::setParameters(){   
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(plist);
-               CommandParameter poutput("output", "Multiple", "accnos-default", "default", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter punique("unique", "String", "", "", "", "", "",false,false); parameters.push_back(punique);
-               CommandParameter pshared("shared", "String", "", "", "", "", "",false,false); parameters.push_back(pshared);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string GetSharedOTUCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The get.sharedseqs command parameters are list, group, label, unique, shared, output and fasta.  The list and group parameters are required, unless you have valid current files.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like output files for, and are separated by dashes.\n";
-               helpString += "The unique and shared parameters allow you to select groups you would like to know the shared info for, and are separated by dashes.\n";
-               helpString += "If you enter your groups under the unique parameter mothur will return the otus that contain ONLY sequences from those groups.\n";
-               helpString += "If you enter your groups under the shared parameter mothur will return the otus that contain sequences from those groups and may also contain sequences from other groups.\n";
-               helpString += "If you do not enter any groups then the get.sharedseqs command will return sequences that are unique to all groups in your group file.\n";
-               helpString += "The fasta parameter allows you to input a fasta file and outputs a fasta file for each distance level containing only the sequences that are in OTUs shared by the groups specified.\n";
-               helpString += "The output parameter allows you to output the list of names without the group and bin number added. \n";
-               helpString += "With this option you can use the names file as an input in get.seqs and remove.seqs commands. To do this enter output=accnos. \n";
-               helpString += "The get.sharedseqs command outputs a .names file for each distance level containing a list of sequences in the OTUs shared by the groups specified.\n";
-               helpString += "The get.sharedseqs command should be in the following format: get.sharedseqs(list=yourListFile, group=yourGroupFile, label=yourLabels, unique=yourGroups, fasta=yourFastafile, output=yourOutput).\n";
-               helpString += "Example get.sharedseqs(list=amazon.fn.list, label=unique-0.01, group= amazon.groups, unique=forest-pasture, fasta=amazon.fasta, output=accnos).\n";
-               helpString += "The output to the screen is the distance and the number of otus at that distance for the groups you specified.\n";
-               helpString += "The default value for label is all labels in your inputfile. The default for groups is all groups in your file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetSharedOTUCommand::GetSharedOTUCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["sharedseqs"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-GetSharedOTUCommand::GetSharedOTUCommand(string option)  {
-       try {
-       
-               abort = false; calledHelp = false;   
-               unique = true;
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       outputTypes["sharedseqs"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { 
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current list file. You must provide a list file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               }
-                       }else {  format = "list";       m->setListFile(listfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { 
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current group file. You must provide a group file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               }
-                       }else { m->setGroupFile(groupfile); }
-                                               
-                       if ((listfile == "") || (groupfile == "")) { m->mothurOut("The list and group parameters are required."); m->mothurOutEndLine(); abort = true; }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       output = validParameter.validFile(parameters, "output", false);                 
-                       if (output == "not found") { output = ""; }
-                       else if (output == "default") { output = ""; }
-                       
-                       groups = validParameter.validFile(parameters, "unique", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               userGroups = "unique." + groups;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                               
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "shared", false);                 
-                       if (groups == "not found") { groups = "";  }
-                       else { 
-                               userGroups = groups;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                               unique = false;
-                       }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }        
-                       else { m->setFastaFile(fastafile); }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "GetSharedOTUCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int GetSharedOTUCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               groupMap = new GroupMap(groupfile);
-               int error = groupMap->readMap();
-               if (error == 1) { delete groupMap; return 0; }
-               
-               if (m->control_pressed) { delete groupMap; return 0; }
-               
-               if (Groups.size() == 0) {
-                       Groups = groupMap->getNamesOfGroups();
-                       
-                       //make string for outputfile name
-                       userGroups = "unique.";
-                       for(int i = 0; i < Groups.size(); i++) {  userGroups += Groups[i] + "-";  }
-                       userGroups = userGroups.substr(0, userGroups.length()-1);
-               }else{
-                       //sanity check for group names
-                       SharedUtil util;
-                       vector<string> namesOfGroups = groupMap->getNamesOfGroups(); 
-                       util.setGroups(Groups, namesOfGroups);
-                       groupMap->setNamesOfGroups(namesOfGroups);
-               }
-       
-               //put groups in map to find easier
-               for(int i = 0; i < Groups.size(); i++) {
-                       groupFinder[Groups[i]] = Groups[i];
-               }
-               
-               if (fastafile != "") {
-                       ifstream inFasta;
-                       m->openInputFile(fastafile, inFasta);
-                       
-                       while(!inFasta.eof()) {
-                               if (m->control_pressed) { outputTypes.clear(); inFasta.close(); delete groupMap; return 0; }
-                               
-                               Sequence seq(inFasta); m->gobble(inFasta);
-                               if (seq.getName() != "") {  seqs.push_back(seq);   }
-                       }
-                       inFasta.close();
-               }
-               
-               ListVector* lastlist = NULL;
-               string lastLabel = "";
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((!in.eof()) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { 
-                               if (lastlist != NULL) {         delete lastlist;        }
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); }  outputTypes.clear();
-                               delete groupMap; return 0;
-                       }
-                       
-                       list = new ListVector(in);
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
-                               m->mothurOut(list->getLabel()); 
-                               process(list);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = list->getLabel();
-                                       
-                                       m->mothurOut(lastlist->getLabel()); 
-                                       process(lastlist);
-                                       
-                                       processedLabels.insert(lastlist->getLabel());
-                                       userLabels.erase(lastlist->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       list->setLabel(saveLabel);
-                       }
-
-                       lastLabel = list->getLabel();
-                       
-                       if (lastlist != NULL) {         delete lastlist;        }
-                       lastlist = list;                        
-               }
-               
-               in.close();
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                               m->mothurOut(lastlist->getLabel()); 
-                               process(lastlist);
-                                       
-                               processedLabels.insert(lastlist->getLabel());
-                               userLabels.erase(lastlist->getLabel());
-               }
-               
-
-               //reset groups parameter
-               m->clearGroups();  
-               
-               if (lastlist != NULL) {         delete lastlist;        }
-               
-               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]); }  delete groupMap; return 0; } 
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               if (output == "accnos") {
-                       itTypes = outputTypes.find("accnos");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-                       }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-
-               return 0;
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "execute");
-               exit(1);
-       }
-}
-/***********************************************************/
-int GetSharedOTUCommand::process(ListVector* shared) {
-       try {
-               
-               map<string, string> fastaMap;
-               
-               ofstream outNames;
-               string outputFileNames;
-               
-               if (outputDir == "") { outputDir += m->hasPath(listfile); }
-               if (output != "accnos") {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".shared.seqs";
-               }else {
-                       outputFileNames = outputDir + m->getRootName(m->getSimpleName(listfile)) + shared->getLabel() + userGroups + ".accnos";
-               }
-               m->openOutputFile(outputFileNames, outNames);
-               
-               bool wroteSomething = false;
-               int num = 0;
-                               
-               //go through each bin, find out if shared
-               for (int i = 0; i < shared->getNumBins(); i++) {
-                       if (m->control_pressed) { outNames.close(); m->mothurRemove(outputFileNames); return 0; }
-                       
-                       bool uniqueOTU = true;
-                       
-                       map<string, int> atLeastOne;
-                       for (int f = 0; f < Groups.size(); f++) {
-                               atLeastOne[Groups[f]] = 0;
-                       }
-                       
-                       vector<string> namesOfSeqsInThisBin;
-                       
-                       string names = shared->get(i);  
-                       while ((names.find_first_of(',') != -1)) { 
-                               string name = names.substr(0,names.find_first_of(','));
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                               
-                               //find group
-                               string seqGroup = groupMap->getGroup(name);
-                               if (output != "accnos") {
-                                       namesOfSeqsInThisBin.push_back((name + "|" + seqGroup + "|" + toString(i+1)));
-                               }else {  namesOfSeqsInThisBin.push_back(name);  }
-                               
-                               if (seqGroup == "not found") { m->mothurOut(name + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1);  }
-                               
-                               //is this seq in one of hte groups we care about
-                               it = groupFinder.find(seqGroup);
-                               if (it == groupFinder.end()) {  uniqueOTU = false;  } //you have a sequence from a group you don't want
-                               else {  atLeastOne[seqGroup]++;  }
-                       }
-                       
-                       //get last name
-                       string seqGroup = groupMap->getGroup(names);
-                       if (output != "accnos") {
-                               namesOfSeqsInThisBin.push_back((names + "|" + seqGroup + "|" + toString(i+1)));
-                       }else {  namesOfSeqsInThisBin.push_back(names); }
-                       
-                       if (seqGroup == "not found") { m->mothurOut(names + " is not in your groupfile. Please correct."); m->mothurOutEndLine(); exit(1);  }
-                       
-                       //is this seq in one of hte groups we care about
-                       it = groupFinder.find(seqGroup);
-                       if (it == groupFinder.end()) {  uniqueOTU = false;  } //you have a sequence from a group you don't want
-                       else {  atLeastOne[seqGroup]++;  }
-                       
-                       
-                       //make sure you have at least one seq from each group you want
-                       bool sharedByAll = true;
-                       map<string, int>::iterator it2;
-                       for (it2 = atLeastOne.begin(); it2 != atLeastOne.end(); it2++) {
-                               if (it2->second == 0) {  sharedByAll = false;   }
-                       }
-                       
-                       //if the user wants unique bins and this is unique then print
-                       //or this the user wants shared bins and this bin is shared then print
-                       if ((unique && uniqueOTU && sharedByAll) || (!unique && sharedByAll)) {
-                               
-                               wroteSomething = true;
-                               num++;
-                               
-                               //output list of names 
-                               for (int j = 0; j < namesOfSeqsInThisBin.size(); j++) {
-                                       outNames << namesOfSeqsInThisBin[j] << endl;
-                                       
-                                       if (fastafile != "") { 
-                                               if (output != "accnos") {
-                                                       string seqName = namesOfSeqsInThisBin[j].substr(0,namesOfSeqsInThisBin[j].find_last_of('|'));
-                                                       seqName = seqName.substr(0,seqName.find_last_of('|'));
-                                                       fastaMap[seqName] = namesOfSeqsInThisBin[j];  //fastaMap needs to contain just the seq name for output later
-                                               }else {
-                                                       fastaMap[namesOfSeqsInThisBin[j]] = namesOfSeqsInThisBin[j];
-                                               }
-                                       }
-                               }
-                       }
-               }
-               
-               outNames.close();
-               
-               if (!wroteSomething) {
-                       m->mothurRemove(outputFileNames);
-                       string outputString = "\t" + toString(num) + " - No otus shared by groups";
-                       
-                       string groupString = "";
-                       for (int h = 0; h < Groups.size(); h++) {
-                               groupString += "  " + Groups[h];
-                       }
-                       
-                       outputString += groupString + ".";
-                       m->mothurOut(outputString); m->mothurOutEndLine();
-               }else { 
-                       m->mothurOut("\t" + toString(num)); m->mothurOutEndLine(); 
-                       outputNames.push_back(outputFileNames);
-                       if (output != "accnos") { outputTypes["sharedseqs"].push_back(outputFileNames); }
-                       else { outputTypes["accnos"].push_back(outputFileNames); }
-               }
-               
-               //if fasta file provided output new fasta file
-               if ((fastafile != "") && wroteSomething) {
-                       if (outputDir == "") { outputDir += m->hasPath(fastafile); }
-                       string outputFileFasta = outputDir + m->getRootName(m->getSimpleName(fastafile)) + shared->getLabel() + userGroups + ".shared.fasta";
-                       ofstream outFasta;
-                       m->openOutputFile(outputFileFasta, outFasta);
-                       outputNames.push_back(outputFileFasta); outputTypes["fasta"].push_back(outputFileFasta);
-                       
-                       for (int k = 0; k < seqs.size(); k++) {
-                               if (m->control_pressed) { outFasta.close(); return 0; }
-                       
-                               //if this is a sequence we want, output it
-                               it = fastaMap.find(seqs[k].getName());
-                               if (it != fastaMap.end()) {
-                               
-                                       if (output != "accnos") {
-                                               outFasta << ">" << it->second << endl;
-                                       }else {
-                                               outFasta << ">" << it->first << endl;
-                                       }
-                                       
-                                       outFasta << seqs[k].getAligned() << endl;
-                               }
-                       }
-                       
-                       outFasta.close();
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GetSharedOTUCommand", "process");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/getsharedotucommand.h b/getsharedotucommand.h
deleted file mode 100644 (file)
index ea6ed94..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef GETSHAREDOTUCOMMAND_H
-#define GETSHAREDOTUCOMMAND_H
-
-/*
- *  getsharedotucommand.h
- *  Mothur
- *
- *  Created by westcott on 9/22/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "listvector.hpp"
-#include "sequence.hpp"
-#include "groupmap.h"
-
-//**********************************************************************************************************************
-class GetSharedOTUCommand : public Command {
-       
-       public:
-       
-               GetSharedOTUCommand(string);    
-               GetSharedOTUCommand();  
-               ~GetSharedOTUCommand() {}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "get.sharedseqs";                      }
-               string getCommandCategory()             { return "OTU-Based Approaches";        }
-               string getRequiredCommand()             { return "none";                                        }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Get.sharedseqs"; }
-               string getDescription()         { return "identifies sequences that are either unique or shared by specific groups"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-               
-       private:
-               ListVector* list;
-               GroupMap* groupMap;
-               
-               set<string> labels;
-               string fastafile, label, groups, listfile, groupfile, output, userGroups, outputDir, format;
-               bool abort, allLines, unique;
-               vector<string> Groups;
-               map<string, string> groupFinder;
-               map<string, string>::iterator it;
-               vector<Sequence> seqs;
-               vector<string> outputNames;
-               
-               int process(ListVector*);
-               
-};
-//**********************************************************************************************************************
-
-#endif
-
diff --git a/goodscoverage.cpp b/goodscoverage.cpp
deleted file mode 100644 (file)
index 75baa7b..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  goodscoverage.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "goodscoverage.h"
-#include "calculator.h"
-
-/**********************************************************/
-
-EstOutput GoodsCoverage::getValues(SAbundVector* rank){
-       try {
-               data.resize(1,0);
-               
-               double numSingletons = rank->get(1);
-               double totalIndividuals = rank->getNumSeqs();
-               
-               data[0] = 1 - numSingletons/totalIndividuals;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GoodsCoverage", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/goodscoverage.h b/goodscoverage.h
deleted file mode 100644 (file)
index 0ec7730..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef GOODSCOVERAGE_H
-#define GOODSCOVERAGE_H
-
-/*
- *  goodscoverage.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/* This class implements the LogSD estimator on single group. 
-It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class GoodsCoverage : public Calculator  {
-       
-public:
-       GoodsCoverage() : Calculator("goodscoverage", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/GoodsCoverage"; }
-
-private:
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/gotohoverlap.cpp b/gotohoverlap.cpp
deleted file mode 100644 (file)
index ea27df0..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- *  gotohoverlap.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is an Alignment child class that implements the Gotoh pairwise alignment algorithm as described in:
- *             
- *             Gotoh O. 1982.  An improved algorithm for matching biological sequences.  J. Mol. Biol.  162:705-8.
- *             Myers, EW & Miller, W.  1988.  Optimal alignments in linear space.  Comput Appl Biosci. 4:11-7.
- *
- *     This method is nice because it allows for an affine gap penalty to be assessed, which is analogous to what is used
- *     in blast and is an alternative to Needleman-Wunsch, which only charges the same penalty for each gap position.
- *     Because this method typically has problems at the ends when two sequences do not full overlap, we employ a separate
- *     method to fix the ends (see Overlap class documentation)
- *
- */
-
-
-#include "alignmentcell.hpp"
-#include "overlap.hpp"
-#include "alignment.hpp"
-#include "gotohoverlap.hpp"
-
-/**************************************************************************************************/
-
-GotohOverlap::GotohOverlap(float gO, float gE, float f, float mm, int r) :
-       gapOpen(gO), gapExtend(gE), match(f), mismatch(mm), Alignment(r) {
-       
-       try {
-               for(int i=1;i<nCols;i++){                               //      we initialize the dynamic programming matrix by setting the pointers in
-                       alignment[0][i].prevCell = 'l';         //      the first row to the left
-                       alignment[0][i].cValue = 0;
-                       alignment[0][i].dValue = 0;
-               }
-               
-               for(int i=1;i<nRows;i++){                               //      we initialize the dynamic programming matrix by setting the pointers in
-                       alignment[i][0].prevCell = 'u';         //      the first column upward
-                       alignment[i][0].cValue = 0;
-                       alignment[i][0].iValue = 0;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GotohOverlap", "GotohOverlap");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void GotohOverlap::align(string A, string B){
-       try {
-               seqA = ' ' + A; lA = seqA.length();             //      the algorithm requires that the first character be a dummy value
-               seqB = ' ' + B; lB = seqB.length();             //      the algorithm requires that the first character be a dummy value
-               
-               for(int i=1;i<lB;i++){                                  //      the recursion here is shown in Webb and Miller, Fig. 1A.  Note that 
-                       for(int j=1;j<lA;j++){                          //      if we need to conserve on space we should see Fig. 1B, which is linear
-                               //      in space, which I think is unnecessary
-                               float diagonal;
-                               if(seqB[i] == seqA[j])  {       diagonal = alignment[i-1][j-1].cValue + match;          }
-                               else                                    {       diagonal = alignment[i-1][j-1].cValue + mismatch;       }
-                               
-                               alignment[i][j].iValue = max(alignment[i][j-1].iValue, alignment[i][j-1].cValue + gapOpen) + gapExtend;
-                               alignment[i][j].dValue = max(alignment[i-1][j].dValue, alignment[i-1][j].cValue + gapOpen) + gapExtend;
-                               
-                               if(alignment[i][j].iValue > alignment[i][j].dValue){
-                                       if(alignment[i][j].iValue > diagonal){
-                                               alignment[i][j].cValue = alignment[i][j].iValue;
-                                               alignment[i][j].prevCell = 'l';
-                                       }
-                                       else{
-                                               alignment[i][j].cValue = diagonal;
-                                               alignment[i][j].prevCell = 'd';
-                                       }
-                               }
-                               else{
-                                       if(alignment[i][j].dValue > diagonal){
-                                               alignment[i][j].cValue = alignment[i][j].dValue;
-                                               alignment[i][j].prevCell = 'u';
-                                       }
-                                       else{
-                                               alignment[i][j].cValue = diagonal;
-                                               alignment[i][j].prevCell = 'd';
-                                       }
-                               }
-                               
-                       }
-               }
-               Overlap over;
-               over.setOverlap(alignment, lA, lB, 0);  //      Fix the gaps at the ends of the sequences
-               traceBack();                                                    //      Construct the alignment and set seqAaln and seqBaln
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GotohOverlap", "align");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
diff --git a/gotohoverlap.hpp b/gotohoverlap.hpp
deleted file mode 100644 (file)
index 0b7d8ea..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef GOTOHOVERLAP_H
-#define GOTOHOVERLAP_H
-
-/*
- *  gotohoverlap.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is an Alignment child class that implements the Gotoh pairwise alignment algorithm as described in:
- *             
- *             Gotoh O. 1982.  An improved algorithm for matching biological sequences.  J. Mol. Biol.  162:705-8.
- *             Myers, EW & Miller, W.  1988.  Optimal alignments in linear space.  Comput Appl Biosci. 4:11-7.
- *
- *     This method is nice because it allows for an affine gap penalty to be assessed, which is analogous to what is used
- *     in blast and is an alternative to Needleman-Wunsch, which only charges the same penalty for each gap position.
- *     Because this method typically has problems at the ends when two sequences do not full overlap, we employ a separate
- *     method to fix the ends (see Overlap class documentation)
- *
- */
-
-#include "mothur.h"
-#include "alignment.hpp"
-
-/**************************************************************************************************/
-
-class GotohOverlap : public Alignment {
-       
-public:
-       GotohOverlap(float, float, float, float, int);
-       void align(string, string);
-       
-       ~GotohOverlap() {}
-       
-private:
-       float gapOpen;
-       float gapExtend;
-       float match;
-       float mismatch;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/gower.cpp b/gower.cpp
deleted file mode 100644 (file)
index 5f0bf68..0000000
--- a/gower.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *  gower.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "gower.h"
-
-/***********************************************************************/
-EstOutput Gower::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               vector<int> maxOtus; maxOtus.resize(shared[0]->getNumBins());
-               vector<int> minOtus; minOtus.resize(shared[0]->getNumBins());
-               //for each otu
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       
-                       //set otus min and max to first one
-                       minOtus[i] = shared[0]->getAbundance(i);
-                       maxOtus[i] = shared[0]->getAbundance(i);
-                       
-                       //for each group
-                       for (int j = 1; j < shared.size(); j++) { 
-                               maxOtus[i] = max(shared[j]->getAbundance(i), maxOtus[i]);
-                               minOtus[i] = min(shared[j]->getAbundance(i), minOtus[i]);
-                       }
-               }
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       double numerator = abs(A - B);
-                       double denominator = maxOtus[i] - minOtus[i];
-                               
-                       if (denominator != 0) { sum += (numerator / denominator); }
-               }
-               
-               data[0] = sum;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Gower", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/gower.h b/gower.h
deleted file mode 100644 (file)
index a04ef10..0000000
--- a/gower.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef GOWER_H
-#define GOWER_H
-
-/*
- *  gower.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Gower : public Calculator  {
-       
-public:
-       Gower() :  Calculator("gower", 1, false, true) {};  //the true means this calculator needs all groups to calculate the pair value
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Gower"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/groupmap.cpp b/groupmap.cpp
deleted file mode 100644 (file)
index 481fd1d..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- *  groupmap.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/1/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "groupmap.h"
-
-/************************************************************/
-
- GroupMap::GroupMap(string filename) {
-       m = MothurOut::getInstance();
-       groupFileName = filename;
-       m->openInputFile(filename, fileHandle);
-       index = 0;
-}
-
-/************************************************************/
- GroupMap::~GroupMap(){}
-
-/************************************************************/
-int GroupMap::readMap() {
-               string seqName, seqGroup;
-               int error = 0;
-
-               while(fileHandle){
-                       fileHandle >> seqName;  m->gobble(fileHandle);          //read from first column
-                       fileHandle >> seqGroup;                 //read from second column
-                       
-                       if (m->control_pressed) {  fileHandle.close();  return 1; }
-       
-                       setNamesOfGroups(seqGroup);
-                       
-                       it = groupmap.find(seqName);
-                       
-                       if (it != groupmap.end()) { error = 1; m->mothurOut("Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-                       else {
-                               groupmap[seqName] = seqGroup;   //store data in map
-                               seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
-                       }
-                       m->gobble(fileHandle);
-               }
-               fileHandle.close();
-               m->setAllGroups(namesOfGroups);
-               return error;
-}
-/************************************************************/
-int GroupMap::readDesignMap() {
-               string seqName, seqGroup;
-               int error = 0;
-
-               while(fileHandle){
-                       fileHandle >> seqName;  m->gobble(fileHandle);          //read from first column
-                       fileHandle >> seqGroup;                 //read from second column
-                       
-                       if (m->control_pressed) {  fileHandle.close();  return 1; }
-       
-                       setNamesOfGroups(seqGroup);
-                       
-                       it = groupmap.find(seqName);
-                       
-                       if (it != groupmap.end()) { error = 1; m->mothurOut("Your designfile contains more than 1 group named " + seqName + ", group names must be unique. Please correct."); m->mothurOutEndLine();  }
-                       else {
-                               groupmap[seqName] = seqGroup;   //store data in map
-                               seqsPerGroup[seqGroup]++;  //increment number of seqs in that group
-                       }
-                       m->gobble(fileHandle);
-               }
-               fileHandle.close();
-               m->setAllGroups(namesOfGroups);
-               return error;
-}
-
-/************************************************************/
-int GroupMap::getNumGroups() { return namesOfGroups.size();    }
-/************************************************************/
-
-string GroupMap::getGroup(string sequenceName) {
-                       
-       it = groupmap.find(sequenceName);
-       if (it != groupmap.end()) { //sequence name was in group file
-               return it->second;      
-       }else {
-               return "not found";
-       }
-}
-
-/************************************************************/
-
-void GroupMap::setGroup(string sequenceName, string groupN) {
-       setNamesOfGroups(groupN);
-       
-       it = groupmap.find(sequenceName);
-       
-       if (it != groupmap.end()) {  m->mothurOut("Your groupfile contains more than 1 sequence named " + sequenceName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-       else {
-               groupmap[sequenceName] = groupN;        //store data in map
-               seqsPerGroup[groupN]++;  //increment number of seqs in that group
-       }
-}
-
-/************************************************************/
-void GroupMap::setNamesOfGroups(string seqGroup) {
-       int i, count;
-       count = 0;
-       for (i=0; i<namesOfGroups.size(); i++) {
-               if (namesOfGroups[i] != seqGroup) {
-                       count++; //you have not found this group
-               }else {
-                       break; //you already have it
-               }
-       }
-       if (count == namesOfGroups.size()) {
-               namesOfGroups.push_back(seqGroup); //new group
-               seqsPerGroup[seqGroup] = 0;
-               groupIndex[seqGroup] = index;
-               index++;
-       }
-}
-/************************************************************/
-bool GroupMap::isValidGroup(string groupname) {
-       try {
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       if (groupname == namesOfGroups[i]) { return true; }
-               }
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GroupMap", "isValidGroup");
-               exit(1);
-       }
-}
-/************************************************************/
-int GroupMap::getNumSeqs(string group) {
-       try {
-               
-               map<string, int>::iterator itNum;
-               
-               itNum = seqsPerGroup.find(group);
-               
-               if (itNum == seqsPerGroup.end()) { return 0; }
-               
-               return seqsPerGroup[group];
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GroupMap", "getNumSeqs");
-               exit(1);
-       }
-}
-
-/************************************************************/
-vector<string> GroupMap::getNamesSeqs(){
-       try {
-       
-               vector<string> names;
-               
-               for (it = groupmap.begin(); it != groupmap.end(); it++) {
-                       names.push_back(it->first);
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GroupMap", "getNamesSeqs");
-               exit(1);
-       }
-}
-/************************************************************/
-vector<string> GroupMap::getNamesSeqs(vector<string> picked){
-       try {
-               
-               vector<string> names;
-               
-               for (it = groupmap.begin(); it != groupmap.end(); it++) {
-                       //if you are belong to one the the groups in the picked vector add you
-                       if (m->inUsersGroups(it->second, picked)) {
-                               names.push_back(it->first);
-                       }
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "GroupMap", "getNamesSeqs");
-               exit(1);
-       }
-}
-
-/************************************************************/
-
diff --git a/groupmap.h b/groupmap.h
deleted file mode 100644 (file)
index 29c1741..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef GROUPMAP_H
-#define GROUPMAP_H
-/*
- *  groupmap.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 12/1/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/* This class is a representation of the groupfile.  It is used by all the shared commands to determine what group a 
-       certain sequence belongs to. */
-
-class GroupMap {
-public:
-       GroupMap() {};
-       GroupMap(string);
-       ~GroupMap();
-       int readMap();
-       int readDesignMap();
-       int getNumGroups();
-       bool isValidGroup(string);  //return true if string is a valid group
-       string getGroup(string);
-       void setGroup(string, string);
-       vector<string> getNamesOfGroups() {
-               sort(namesOfGroups.begin(), namesOfGroups.end());
-               groupIndex.clear();
-               for (int i = 0; i < namesOfGroups.size(); i++) { groupIndex[namesOfGroups[i]] = i; }
-               return namesOfGroups;
-       }
-       void setNamesOfGroups(vector<string> sn) { namesOfGroups = sn; }
-       map<string, int> groupIndex;  //groupname, vectorIndex in namesOfGroups. - used by collectdisplays and libshuff commands.
-       int getNumSeqs()  {  return groupmap.size();  }
-       vector<string> getNamesSeqs();
-       vector<string> getNamesSeqs(vector<string>); //get names of seqs belonging to a group or set of groups
-       int getNumSeqs(string); //return the number of seqs in a given group
-                       
-private:
-       vector<string> namesOfGroups;
-       MothurOut* m;
-       ifstream fileHandle;
-       string groupFileName;
-       int index;
-       map<string, string>::iterator it;
-       void setNamesOfGroups(string); 
-       map<string, string> groupmap; //sequence name and groupname
-       map<string, int> seqsPerGroup;  //maps groupname to number of seqs in that group
-};
-
-#endif
diff --git a/hamming.cpp b/hamming.cpp
deleted file mode 100644 (file)
index 6131bfc..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- *  hamming.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "hamming.h"
-
-/***********************************************************************/
-EstOutput Hamming::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               int numA = 0;
-               int numB = 0;
-               int numShared = 0;
-               
-               //calc the 2 denominators
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       if (A != 0) { numA++; }
-                       if (B != 0) { numB++; }
-                       if ((A != 0) && (B != 0)) { numShared++; }
-               }
-               
-               data[0] = numA + numB - (2 * numShared);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Hamming", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/hamming.h b/hamming.h
deleted file mode 100644 (file)
index 77eb51d..0000000
--- a/hamming.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef HAMMING_H
-#define HAMMING_H
-
-/*
- *  hamming.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Hamming : public Calculator  {
-       
-public:
-       Hamming() :  Calculator("hamming", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Hamming"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/hcluster.cpp b/hcluster.cpp
deleted file mode 100644 (file)
index 6cd4531..0000000
+++ /dev/null
@@ -1,808 +0,0 @@
-/*
- *  hcluster.cpp
- *  Mothur
- *
- *  Created by westcott on 10/13/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "hcluster.h"
-#include "rabundvector.hpp"
-#include "listvector.hpp"
-#include "sparsematrix.hpp"
-
-/***********************************************************************/
-HCluster::HCluster(RAbundVector* rav, ListVector* lv, string ms, string d, NameAssignment* n, float c) :  rabund(rav), list(lv), method(ms), distfile(d), nameMap(n), cutoff(c) {
-       try {
-               m = MothurOut::getInstance();
-               mapWanted = false;
-               exitedBreak = false; 
-               numSeqs = list->getNumSeqs();
-               
-               //initialize cluster array
-               for (int i = 0; i < numSeqs; i++) {
-                       clusterNode temp(1, -1, i);
-                       clusterArray.push_back(temp);
-               }
-               
-               if ((method == "furthest") || (method == "nearest")) {
-                       m->openInputFile(distfile, filehandle);
-               }else{  
-                       processFile();  
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "HCluster");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void HCluster::clusterBins(){
-       try {
-               //cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << rabund->get(clusterArray[smallRow].smallChild) << '\t' << rabund->get(clusterArray[smallCol].smallChild);
-
-               rabund->set(clusterArray[smallCol].smallChild, rabund->get(clusterArray[smallRow].smallChild)+rabund->get(clusterArray[smallCol].smallChild));  
-               rabund->set(clusterArray[smallRow].smallChild, 0);      
-               rabund->setLabel(toString(smallDist));
-
-               //cout << '\t' << rabund->get(clusterArray[smallRow].smallChild) << '\t' << rabund->get(clusterArray[smallCol].smallChild) << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "clusterBins");
-               exit(1);
-       }
-
-
-}
-
-/***********************************************************************/
-
-void HCluster::clusterNames(){
-       try {
-               ///cout << smallCol << '\t' << smallRow << '\t' << smallDist << '\t' << list->get(clusterArray[smallRow].smallChild) << '\t' << list->get(clusterArray[smallCol].smallChild);
-               if (mapWanted) {  updateMap();  }
-               
-               list->set(clusterArray[smallCol].smallChild, list->get(clusterArray[smallRow].smallChild)+','+list->get(clusterArray[smallCol].smallChild));
-               list->set(clusterArray[smallRow].smallChild, "");       
-               list->setLabel(toString(smallDist));
-       
-               //cout << '\t' << list->get(clusterArray[smallRow].smallChild) << '\t' << list->get(clusterArray[smallCol].smallChild) << endl;
-
-    }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "clusterNames");
-               exit(1);
-       }
-
-}
-/***********************************************************************/
-int HCluster::getUpmostParent(int node){
-       try {
-               while (clusterArray[node].parent != -1) {
-                       node = clusterArray[node].parent;
-               }
-               
-               return node;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getUpmostParent");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void HCluster::printInfo(){
-       try {
-               
-               cout << "link table" << endl;
-               for (itActive = activeLinks.begin(); itActive!= activeLinks.end(); itActive++) {
-                       cout << itActive->first << " = " << itActive->second << endl;
-               }
-               cout << endl;
-               for (int i = 0; i < linkTable.size(); i++) {
-                       cout << i << '\t';
-                       for (it = linkTable[i].begin(); it != linkTable[i].end(); it++) {
-                               cout << it->first << '-' << it->second << '\t' ;
-                       }
-                       cout << endl;
-               }
-               cout << endl << "clusterArray" << endl;
-               
-               for (int i = 0; i < clusterArray.size(); i++) {
-                       cout << i << '\t' << clusterArray[i].numSeq << '\t' << clusterArray[i].parent << '\t' << clusterArray[i].smallChild << endl;
-               }
-               cout << endl;
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getUpmostParent");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int HCluster::makeActive() {
-       try {
-               int linkValue = 1; 
-
-               itActive = activeLinks.find(smallRow);
-               it2Active = activeLinks.find(smallCol);
-               
-               if ((itActive == activeLinks.end()) && (it2Active == activeLinks.end())) { //both are not active so add them
-                       int size = linkTable.size();
-                       map<int, int> temp; map<int, int> temp2;
-                       
-                       //add link to eachother
-                       temp[smallRow] = 1;                                                     //         1    2                                                               
-                       temp2[smallCol] = 1;                                            // 1   0        1 
-                                                                                                               // 2   1        0                               
-                       linkTable.push_back(temp);
-                       linkTable.push_back(temp2);
-                       
-                       //add to activeLinks
-                       activeLinks[smallRow] = size;
-                       activeLinks[smallCol] = size+1;
-
-               }else if ((itActive != activeLinks.end()) && (it2Active == activeLinks.end())) {  //smallRow is active, smallCol is not
-                        int size = linkTable.size();
-                        int alreadyActiveRow = itActive->second;
-                        map<int, int> temp; 
-                       
-                       //add link to eachother
-                       temp[smallRow] = 1;                                                                     //         6    2       3       5
-                       linkTable.push_back(temp);                                                      // 6   0        1       2       0
-                       linkTable[alreadyActiveRow][smallCol] = 1;                      // 2   1        0       1       1
-                                                                                                                               // 3   2        1       0       0
-                                                                                                                               // 5   0    1   0   0   
-                       //add to activeLinks
-                       activeLinks[smallCol] = size;
-       
-               }else if ((itActive == activeLinks.end()) && (it2Active != activeLinks.end())) {  //smallCol is active, smallRow is not
-                        int size = linkTable.size();
-                        int alreadyActiveCol = it2Active->second;
-                        map<int, int> temp; 
-                       
-                       //add link to eachother
-                       temp[smallCol] = 1;                                                                     //         6    2       3       5
-                       linkTable.push_back(temp);                                                      // 6   0        1       2       0
-                       linkTable[alreadyActiveCol][smallRow] = 1;                      // 2   1        0       1       1
-                                                                                                                               // 3   2        1       0       0
-                                                                                                                               // 5   0    1   0   0   
-                       //add to activeLinks
-                       activeLinks[smallRow] = size;
-
-               }else { //both are active so add one
-                       int row = itActive->second;
-                       int col = it2Active->second;
-                       
-                       
-                       linkTable[row][smallCol]++;
-                       linkTable[col][smallRow]++;
-                       linkValue = linkTable[row][smallCol];
-               }
-               
-               return linkValue;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "makeActive");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void HCluster::updateArrayandLinkTable() {
-       try {
-               //if cluster was made update clusterArray and linkTable
-               int size = clusterArray.size();
-               
-               //add new node
-               clusterNode temp(clusterArray[smallRow].numSeq + clusterArray[smallCol].numSeq, -1, clusterArray[smallCol].smallChild);
-               clusterArray.push_back(temp);
-               
-               //update child nodes
-               clusterArray[smallRow].parent = size;
-               clusterArray[smallCol].parent = size;
-               
-               if (method == "furthest") {
-                       
-                       //update linkTable by merging clustered rows and columns
-                       int rowSpot = activeLinks[smallRow];
-                       int colSpot = activeLinks[smallCol];
-                       
-                       //fix old rows
-                       for (int i = 0; i < linkTable.size(); i++) {
-                               //check if they are in map
-                               it = linkTable[i].find(smallRow);
-                               it2 = linkTable[i].find(smallCol);
-                               
-                               if ((it!=linkTable[i].end()) && (it2!=linkTable[i].end())) { //they are both there
-                                       linkTable[i][size] = linkTable[i][smallRow]+linkTable[i][smallCol];
-                                       linkTable[i].erase(smallCol); //delete col row
-                                       linkTable[i].erase(smallRow); //delete col row
-                               }else if ((it==linkTable[i].end()) && (it2!=linkTable[i].end())) { //only col
-                                       linkTable[i][size] = linkTable[i][smallCol];
-                                       linkTable[i].erase(smallCol); //delete col 
-                               }else if ((it!=linkTable[i].end()) && (it2==linkTable[i].end())) { //only row
-                                       linkTable[i][size] = linkTable[i][smallRow];
-                                       linkTable[i].erase(smallRow); //delete col 
-                               }
-                       }
-                       
-                       //merge their values
-                       for (it = linkTable[rowSpot].begin(); it != linkTable[rowSpot].end(); it++) {
-                               it2 = linkTable[colSpot].find(it->first);  //does the col also have this
-                               
-                               if (it2 == linkTable[colSpot].end()) { //not there so add it
-                                       linkTable[colSpot][it->first] = it->second;
-                               }else { //merge them
-                                       linkTable[colSpot][it->first] = it->second + it2->second;
-                               }
-                       }
-                       
-                       linkTable[colSpot].erase(size);
-                       linkTable.erase(linkTable.begin()+rowSpot);  //delete row
-                       
-                       //update activerows
-                       activeLinks.erase(smallRow);
-                       activeLinks.erase(smallCol);
-                       activeLinks[size] = colSpot;
-                       
-                       //adjust everybody elses spot since you deleted - time vs. space
-                       for (itActive = activeLinks.begin(); itActive != activeLinks.end(); itActive++) {
-                               if (itActive->second > rowSpot) {  activeLinks[itActive->first]--;      }
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "updateArrayandLinkTable");
-               exit(1);
-       }
-}
-/***********************************************************************/
-double HCluster::update(int row, int col, float distance){
-       try {
-               bool cluster = false;
-               smallRow = row;
-               smallCol = col;
-               smallDist = distance;
-               
-               //find upmost parent of row and col
-               smallRow = getUpmostParent(smallRow);
-               smallCol = getUpmostParent(smallCol);
-
-               //you don't want to cluster with yourself
-               if (smallRow != smallCol) {
-                       
-                       if ((method == "furthest") || (method == "nearest")) {
-                               //can we cluster???
-                               if (method == "nearest") { cluster = true;  }
-                               else{ //assume furthest
-                                       //are they active in the link table
-                                       int linkValue = makeActive(); //after this point this nodes info is active in linkTable
-                                       if (linkValue == (clusterArray[smallRow].numSeq * clusterArray[smallCol].numSeq)) {             cluster = true;         }
-                               }
-                               
-                               if (cluster) { 
-                                       updateArrayandLinkTable();
-                                       clusterBins();
-                                       clusterNames();
-                               }
-                       }else {
-                               cluster = true;
-                               updateArrayandLinkTable();
-                               clusterBins();
-                               clusterNames();
-                               combineFile();
-                       }
-               }
-               
-               return cutoff;
-               //printInfo();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "update");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void HCluster::setMapWanted(bool ms)  {  
-       try {
-               mapWanted = ms;
-               
-               //initialize map
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       
-                       //parse bin 
-                       string names = list->get(i);
-                       while (names.find_first_of(',') != -1) { 
-                               //get name from bin
-                               string name = names.substr(0,names.find_first_of(','));
-                               //save name and bin number
-                               seq2Bin[name] = i;
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                       }
-                       
-                       //get last name
-                       seq2Bin[names] = i;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "setMapWanted");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void HCluster::updateMap() {
-try {
-               //update location of seqs in smallRow since they move to smallCol now
-               string names = list->get(clusterArray[smallRow].smallChild);
-               while (names.find_first_of(',') != -1) { 
-                       //get name from bin
-                       string name = names.substr(0,names.find_first_of(','));
-                       //save name and bin number
-                       seq2Bin[name] = clusterArray[smallCol].smallChild;
-                       names = names.substr(names.find_first_of(',')+1, names.length());
-               }
-                       
-               //get last name
-               seq2Bin[names] = clusterArray[smallCol].smallChild;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "updateMap");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<seqDist> HCluster::getSeqs(){
-       try {
-               vector<seqDist> sameSeqs;
-               
-               if ((method == "furthest") || (method == "nearest")) {
-                       sameSeqs = getSeqsFNNN();
-               }else{
-                       sameSeqs = getSeqsAN(); 
-               }
-                               
-               return sameSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getSeqs");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<seqDist> HCluster::getSeqsFNNN(){
-       try {
-               string firstName, secondName;
-               float distance, prevDistance;
-               vector<seqDist> sameSeqs;
-               prevDistance = -1;
-       
-               //if you are not at the beginning of the file
-               if (exitedBreak) { 
-                       sameSeqs.push_back(next);
-                       prevDistance = next.dist;
-                       exitedBreak = false;
-               }
-       
-               //get entry
-               while (!filehandle.eof()) {
-                       
-                       filehandle >> firstName >> secondName >> distance;    m->gobble(filehandle); 
-       
-                       //save first one
-                       if (prevDistance == -1) { prevDistance = distance; }
-                       
-                       map<string,int>::iterator itA = nameMap->find(firstName);
-                       map<string,int>::iterator itB = nameMap->find(secondName);
-                       if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                       if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-               
-                       //using cutoff
-                       if (distance > cutoff) { break; }
-               
-                       if (distance != -1) { //-1 means skip me
-                       
-                               //are the distances the same
-                               if (distance == prevDistance) { //save in vector
-                                       seqDist temp(itA->second, itB->second, distance);
-                                       sameSeqs.push_back(temp);
-                                       exitedBreak = false;
-                               }else{ 
-                                       next.seq1 = itA->second;
-                                       next.seq2 = itB->second;
-                                       next.dist = distance;
-                                       exitedBreak = true;
-                                       break;
-                               }
-                       }
-               }
-               
-               //rndomize matching dists
-               random_shuffle(sameSeqs.begin(), sameSeqs.end());
-               
-               return sameSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getSeqsFNNN");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<seqDist> HCluster::getSeqsAN(){
-       try {
-               int firstName, secondName;
-               float prevDistance;
-               vector<seqDist> sameSeqs;
-               prevDistance = -1;
-               
-               m->openInputFile(distfile, filehandle, "no error"); 
-               
-               //is the smallest value in mergedMin or the distfile?
-               float mergedMinDist = 10000;
-               float distance = 10000;
-               if (mergedMin.size() > 0) { mergedMinDist = mergedMin[0].dist;  }
-                       
-               if (!filehandle.eof()) {  
-                       filehandle >> firstName >> secondName >> distance;    m->gobble(filehandle);
-                       //save first one
-                       if (prevDistance == -1) { prevDistance = distance; } 
-                       if (distance != -1) { //-1 means skip me
-                               seqDist temp(firstName, secondName, distance);
-                               sameSeqs.push_back(temp);
-                       }else{ distance = 10000; }
-               }
-               
-               if (mergedMinDist < distance) { //get minimum distance from mergedMin
-                       //remove distance we saved from file
-                       sameSeqs.clear();
-                       prevDistance = mergedMinDist;
-                       
-                       for (int i = 0; i < mergedMin.size(); i++) {
-                               if (mergedMin[i].dist == prevDistance) {
-                                       sameSeqs.push_back(mergedMin[i]);
-                               }else { break; }
-                       }
-               }else{ //get minimum from file
-                       //get entry
-                       while (!filehandle.eof()) {
-                               
-                               filehandle >> firstName >> secondName >> distance;    m->gobble(filehandle); 
-                               
-                               if (prevDistance == -1) { prevDistance = distance; }
-                               
-                               if (distance != -1) { //-1 means skip me
-                                       //are the distances the same
-                                       if (distance == prevDistance) { //save in vector
-                                               seqDist temp(firstName, secondName, distance);
-                                               sameSeqs.push_back(temp);
-                                       }else{  
-                                               break;
-                                       }
-                               }
-                       }
-               }
-               filehandle.close();
-               
-               //randomize matching dists
-               random_shuffle(sameSeqs.begin(), sameSeqs.end());
-               
-               //can only return one value since once these are merged the other distances in sameSeqs may have changed
-               vector<seqDist> temp;
-               if (sameSeqs.size() > 0) {  temp.push_back(sameSeqs[0]);  }
-               
-               return temp;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getSeqsAN");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-int HCluster::combineFile() {
-       try {
-               //int bufferSize = 64000;  //512k - this should be a variable that the user can set to optimize code to their hardware
-               //char* inputBuffer;
-               //inputBuffer = new char[bufferSize];
-               //size_t numRead;
-               
-               string tempDistFile = distfile + ".temp";
-               ofstream out;
-               m->openOutputFile(tempDistFile, out);
-               
-               //FILE* in;
-               //in = fopen(distfile.c_str(), "rb");
-       
-               ifstream in;
-               m->openInputFile(distfile, in, "no error");
-               
-               int first, second;
-               float dist;
-               
-               vector< map<int, float> > smallRowColValues;
-               smallRowColValues.resize(2);  //0 = row, 1 = col
-               int count = 0;
-                               
-               //go through file pulling out distances related to rows merging
-               //if mergedMin contains distances add those back into file
-               //bool done = false;
-               //partialDist = "";
-               //while ((numRead = fread(inputBuffer, 1, bufferSize, in)) != 0) {
-//cout << "number of char read = " << numRead << endl;
-//cout << inputBuffer << endl;
-                       //if (numRead < bufferSize) { done = true; }
-                       
-                       //parse input into individual distances
-                       //int spot = 0;
-                       //string outputString = "";
-                       //while(spot < numRead) {
-       //cout << "spot = " << spot << endl;
-                        //  seqDist nextDist = getNextDist(inputBuffer, spot, bufferSize);
-                          
-                          //you read a partial distance
-                         // if (nextDist.seq1 == -1) { break;  }
-                       while (!in.eof()) {
-                               //first = nextDist.seq1; second = nextDist.seq2; dist = nextDist.dist;
-       //cout << "next distance = " << first << '\t' << second << '\t' << dist << endl;                   
-                          //since file is sorted and mergedMin is sorted 
-                          //you can put the smallest distance from each through the code below and keep the file sorted
-                          
-                          in >> first >> second >> dist; m->gobble(in);
-                          
-                          if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempDistFile); return 0; }
-                          
-                          //while there are still values in mergedMin that are smaller than the distance read from file
-                          while (count < mergedMin.size())  {
-                          
-                                       //is the distance in mergedMin smaller than from the file
-                                       if (mergedMin[count].dist < dist) {
-                                       //is this a distance related to the columns merging?
-                                       //if yes, save in memory
-                                               if ((mergedMin[count].seq1 == smallRow) && (mergedMin[count].seq2 == smallCol)) { //do nothing this is the smallest distance from last time
-                                               }else if (mergedMin[count].seq1 == smallCol) {
-                                                       smallRowColValues[1][mergedMin[count].seq2] = mergedMin[count].dist;
-                                               }else if (mergedMin[count].seq2 == smallCol) {
-                                                       smallRowColValues[1][mergedMin[count].seq1] = mergedMin[count].dist;
-                                               }else if (mergedMin[count].seq1 == smallRow) {
-                                                       smallRowColValues[0][mergedMin[count].seq2] = mergedMin[count].dist;
-                                               }else if (mergedMin[count].seq2 == smallRow) {
-                                                       smallRowColValues[0][mergedMin[count].seq1] = mergedMin[count].dist;
-                                               }else { //if no, write to temp file
-                                                       //outputString += toString(mergedMin[count].seq1) + '\t' + toString(mergedMin[count].seq2) + '\t' + toString(mergedMin[count].dist) + '\n';
-                                                       //if (mergedMin[count].dist < cutoff) { 
-                                                               out << mergedMin[count].seq1 << '\t' << mergedMin[count].seq2 << '\t' << mergedMin[count].dist << endl;
-                                                       //}
-                                               }
-                                               count++;
-                                       }else{   break; }
-                          }
-                          
-                          //is this a distance related to the columns merging?
-                          //if yes, save in memory
-                          if ((first == smallRow) && (second == smallCol)) { //do nothing this is the smallest distance from last time
-                          }else if (first == smallCol) {
-                                       smallRowColValues[1][second] = dist;
-                          }else if (second == smallCol) {
-                                       smallRowColValues[1][first] = dist;
-                          }else if (first == smallRow) {
-                                       smallRowColValues[0][second] = dist;
-                          }else if (second == smallRow) {
-                                       smallRowColValues[0][first] = dist;
-                          
-                          }else { //if no, write to temp file
-                                       //outputString += toString(first) + '\t' + toString(second) + '\t' + toString(dist) + '\n';
-                                  //if (dist < cutoff) {
-                                          out << first << '\t' << second << '\t' << dist << endl;
-                                  //}
-                          }
-                       }
-                       
-                       //out << outputString;
-                       //if(done) { break; }
-               //}
-               //fclose(in);
-               in.close();
-               
-               //if values in mergedMin are larger than the the largest in file then
-               while (count < mergedMin.size())  {  
-                       //is this a distance related to the columns merging?
-                       //if yes, save in memory
-                       if ((mergedMin[count].seq1 == smallRow) && (mergedMin[count].seq2 == smallCol)) { //do nothing this is the smallest distance from last time
-                       }else if (mergedMin[count].seq1 == smallCol) {
-                               smallRowColValues[1][mergedMin[count].seq2] = mergedMin[count].dist;
-                       }else if (mergedMin[count].seq2 == smallCol) {
-                               smallRowColValues[1][mergedMin[count].seq1] = mergedMin[count].dist;
-                       }else if (mergedMin[count].seq1 == smallRow) {
-                               smallRowColValues[0][mergedMin[count].seq2] = mergedMin[count].dist;
-                       }else if (mergedMin[count].seq2 == smallRow) {
-                               smallRowColValues[0][mergedMin[count].seq1] = mergedMin[count].dist;
-                               
-                       }else { //if no, write to temp file
-                               //if (mergedMin[count].dist < cutoff) {
-                                       out << mergedMin[count].seq1 << '\t' << mergedMin[count].seq2 << '\t' << mergedMin[count].dist << endl;
-                               //}
-                       }
-                       count++;
-               }
-               out.close();
-               mergedMin.clear();
-                       
-               //rename tempfile to distfile
-               m->mothurRemove(distfile);
-               rename(tempDistFile.c_str(), distfile.c_str());
-//cout << "remove = "<< renameOK << " rename = " << ok << endl;        
-
-               //merge clustered rows averaging the distances
-               map<int, float>::iterator itMerge;
-               map<int, float>::iterator it2Merge;
-               for(itMerge = smallRowColValues[0].begin(); itMerge != smallRowColValues[0].end(); itMerge++) {                 
-                       //does smallRowColValues[1] have a distance to this seq too?
-                       it2Merge = smallRowColValues[1].find(itMerge->first);
-                       
-                       float average;
-                       if (it2Merge != smallRowColValues[1].end()) { //if yes, then average
-                               //average
-                               if (method == "average") {
-                                       int total = clusterArray[smallRow].numSeq + clusterArray[smallCol].numSeq;
-                                       average = ((clusterArray[smallRow].numSeq * itMerge->second) + (clusterArray[smallCol].numSeq * it2Merge->second)) / (float) total;
-                               }else { //weighted
-                                       average = ((itMerge->second * 1.0) + (it2Merge->second * 1.0)) / (float) 2.0;                           
-                               }
-                               
-                               smallRowColValues[1].erase(it2Merge);
-                               
-                               seqDist temp(clusterArray[smallRow].parent, itMerge->first, average);
-                               mergedMin.push_back(temp);
-                       }else {  
-                               //can't find value so update cutoff
-                               if (cutoff > itMerge->second) { cutoff = itMerge->second; }
-                       }
-               }
-               
-               //update cutoff
-               for(itMerge = smallRowColValues[1].begin(); itMerge != smallRowColValues[1].end(); itMerge++) { 
-                       if (cutoff > itMerge->second) { cutoff = itMerge->second; }
-               }
-               
-               //sort merged values
-               sort(mergedMin.begin(), mergedMin.end(), compareSequenceDistance);      
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "combineFile");
-               exit(1);
-       }
-}
-/***********************************************************************
-seqDist HCluster::getNextDist(char* buffer, int& index, int size){
-       try {
-               seqDist next;
-               int indexBefore = index;
-               string first, second, distance;
-               first = ""; second = ""; distance = "";
-               int tabCount = 0;
-//cout << "partial = " << partialDist << endl;         
-               if (partialDist != "") { //read what you can, you know it is less than a whole distance.
-                       for (int i = 0; i < partialDist.size(); i++) {
-                               if (tabCount == 0) {
-                                       if (partialDist[i] == '\t') { tabCount++; }
-                                       else {  first += partialDist[i];        }
-                               }else if (tabCount == 1) {
-                                       if (partialDist[i] == '\t') { tabCount++; }
-                                       else {  second += partialDist[i];       }
-                               }else if (tabCount == 2) {
-                                       distance +=  partialDist[i];
-                               }
-                       }
-                       partialDist = "";
-               }
-       
-               //try to get another distance
-               bool gotDist = false;
-               while (index < size) {
-                       if ((buffer[index] == 10) || (buffer[index] == 13)) { //newline in unix or windows
-                               gotDist = true;
-                               
-                               //m->gobble space
-                               while (index < size) {          
-                                       if (isspace(buffer[index])) { index++; }
-                                       else { break; }         
-                               }
-                               break;
-                       }else{
-                               if (tabCount == 0) {
-                                       if (buffer[index] == '\t') { tabCount++; }
-                                       else {  first += buffer[index]; }
-                               }else if (tabCount == 1) {
-                                       if (buffer[index] == '\t') { tabCount++; }
-                                       else {  second += buffer[index];        }
-                               }else if (tabCount == 2) {
-                                       distance +=  buffer[index];
-                               }
-                               index++;
-                       }
-               }
-               
-               //there was not a whole distance in the buffer, ie. buffer = "1 2       0.01    2       3       0."
-               //then you want to save the partial distance.
-               if (!gotDist) {
-                       for (int i = indexBefore; i < size; i++) {
-                               partialDist += buffer[i];
-                       }
-                       index = size + 1;
-                       next.seq1 = -1; next.seq2 = -1; next.dist = 0.0;
-               }else{
-                       int firstname, secondname;
-                       float dist;
-                       
-                       convert(first, firstname);
-                       convert(second, secondname);
-                       convert(distance, dist);
-                       
-                       next.seq1 = firstname; next.seq2 = secondname; next.dist = dist;
-               }
-                                               
-               return next;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "getNextDist");
-               exit(1);
-       }
-}
-***********************************************************************/
-int HCluster::processFile() {
-       try {
-               string firstName, secondName;
-               float distance;
-               
-               ifstream in;
-               m->openInputFile(distfile, in, "no error");
-               
-               ofstream out;
-               string outTemp = distfile + ".temp";
-               m->openOutputFile(outTemp, out);
-       
-               //get entry
-               while (!in.eof()) {
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outTemp); return 0; }
-                       
-                       in >> firstName >> secondName >> distance;    m->gobble(in);            
-                       
-                       map<string,int>::iterator itA = nameMap->find(firstName);
-                       map<string,int>::iterator itB = nameMap->find(secondName);
-                       if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                       if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-               
-                       //using cutoff
-                       if (distance > cutoff) { break; }
-               
-                       if (distance != -1) { //-1 means skip me
-                               out << itA->second << '\t' << itB->second << '\t' << distance << endl;
-                       }
-               }
-               
-               in.close();
-               out.close();
-               
-               m->mothurRemove(distfile);
-               rename(outTemp.c_str(), distfile.c_str());
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HCluster", "processFile");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
-
-
-
-
-
-
diff --git a/hcluster.h b/hcluster.h
deleted file mode 100644 (file)
index d859886..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef HCLUSTER_H
-#define HCLUSTER_H
-
-/*
- *  hcluster.h
- *  Mothur
- *
- *  Created by westcott on 10/13/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "nameassignment.hpp"
-
-class RAbundVector;
-class ListVector;
-
-/***********************************************************************/
-class HCluster {
-       
-public:
-       HCluster(RAbundVector*, ListVector*, string, string, NameAssignment*, float);
-       ~HCluster(){};
-    double update(int, int, float);
-       void setMapWanted(bool m); 
-       map<string, int> getSeqtoBin()  {  return seq2Bin;      }
-       vector<seqDist> getSeqs();
-
-protected:     
-       void clusterBins();
-       void clusterNames();
-       int getUpmostParent(int);
-       int makeActive();
-       void printInfo();
-       void updateArrayandLinkTable();
-       void updateMap();
-       vector<seqDist> getSeqsFNNN();
-       vector<seqDist> getSeqsAN();
-       int combineFile();
-       int processFile();
-       //seqDist getNextDist(char*, int&, int);
-               
-       RAbundVector* rabund;
-       ListVector* list;
-       NameAssignment* nameMap;
-       
-       vector<clusterNode> clusterArray;
-       
-       //note: the nearest and average neighbor method do not use the link table or active links
-       vector< map<int, int> > linkTable;  // vector of maps - linkTable[1][6] = 2  would mean sequence in spot 1 has 2 links with sequence in 6
-       map<int, int> activeLinks;  //maps sequence to index in linkTable
-       map<int, int>::iterator it;
-       map<int, int>::iterator itActive;
-       map<int, int>::iterator it2Active;
-       map<int, int>::iterator it2;
-       
-       int numSeqs;
-       int smallRow;
-       int smallCol;
-       float smallDist, cutoff;
-       map<string, int> seq2Bin;
-       bool mapWanted, exitedBreak;
-       seqDist next;
-       string method, distfile;
-       ifstream filehandle;
-       
-       vector<seqDist> mergedMin;
-       string partialDist;
-       MothurOut* m;
-       
-       
-};
-
-/***********************************************************************/
-
-
-
-
-
-
-
-#endif
-
-
diff --git a/hclustercommand.cpp b/hclustercommand.cpp
deleted file mode 100644 (file)
index 4713693..0000000
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- *  hclustercommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/13/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "hclustercommand.h"
-
-//**********************************************************************************************************************
-vector<string> HClusterCommand::setParameters(){       
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "ColumnName",false,false); parameters.push_back(pcolumn);
-               CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter psorted("sorted", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pshowabund);
-               CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ptiming);          
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-                       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string HClusterCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The hcluster command parameter options are cutoff, precision, method, phylip, column, name, showabund, timing and sorted. Phylip or column and name are required, unless you have valid current files.\n";
-               helpString += "The phylip and column parameter allow you to enter your distance file, and sorted indicates whether your column distance file is already sorted. \n";
-               helpString += "The name parameter allows you to enter your name file and is required if your distance file is in column format. \n";
-               helpString += "The hcluster command should be in the following format: \n";
-               helpString += "hcluster(column=youDistanceFile, name=yourNameFile, method=yourMethod, cutoff=yourCutoff, precision=yourPrecision) \n";
-               helpString += "The acceptable hcluster methods are furthest, nearest, weighted and average.\n"; 
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-HClusterCommand::HClusterCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "HClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
-HClusterCommand::HClusterCommand(string option)  {
-       try{
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {
-                                       abort = true;
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  distfile = phylipfile;  format = "phylip";      m->setPhylipFile(phylipfile); }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { abort = true; } 
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  distfile = columnfile; format = "column";       m->setColumnFile(columnfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to column, then phylip
-                               columnfile = m->getColumnFile(); 
-                               if (columnfile != "") {  m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       phylipfile = m->getPhylipFile(); 
-                                       if (phylipfile != "") {  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a phylip or column file before you can use the hcluster command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a hcluster command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-               
-                       if (columnfile != "") {
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       //get user cutoff and precision or use defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);
-                       if (temp == "not found") { temp = "100"; }
-                       //saves precision legnth for formatting below
-                       length = temp.length();
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
-                       hard = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);
-                       if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0)); 
-                       
-                       method = validParameter.validFile(parameters, "method", false);
-                       if (method == "not found") { method = "average"; }
-                       
-                       if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest, average or weighted."); m->mothurOutEndLine(); abort = true; }
-
-                       showabund = validParameter.validFile(parameters, "showabund", false);
-                       if (showabund == "not found") { showabund = "T"; }
-                       
-                       sort = validParameter.validFile(parameters, "sorted", false);
-                       if (sort == "not found") { sort = "F"; }
-                       sorted = m->isTrue(sort);
-
-                       timing = validParameter.validFile(parameters, "timing", false);
-                       if (timing == "not found") { timing = "F"; }
-                       
-                               
-                       if (abort == false) {
-                               
-                               if (outputDir == "") {  outputDir += m->hasPath(distfile); }
-                               fileroot = outputDir + m->getRootName(m->getSimpleName(distfile));
-                               
-                               if (method == "furthest")               { tag = "fn";  }
-                               else if (method == "nearest")   { tag = "nn";  }
-                               else if (method == "weighted")  { tag = "wn";  }
-                               else                                                    { tag = "an";  }
-                       
-                               m->openOutputFile(fileroot+ tag + ".sabund",    sabundFile);
-                               m->openOutputFile(fileroot+ tag + ".rabund",    rabundFile);
-                               m->openOutputFile(fileroot+ tag + ".list",              listFile);
-                               
-                               outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-                               outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-                               outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "HClusterCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int HClusterCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               NameAssignment* nameMap = NULL;
-               if(namefile != ""){     
-                       nameMap = new NameAssignment(namefile);
-                       nameMap->readMap();
-               }               
-               
-               time_t estart = time(NULL);
-               
-               if (!sorted) {
-                       read = new ReadCluster(distfile, cutoff, outputDir, true);      
-                       read->setFormat(format);
-                       read->read(nameMap);
-                       
-                       if (m->control_pressed) {  
-                               delete read; 
-                               sabundFile.close();
-                               rabundFile.close();
-                               listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                               return 0;  
-                       }
-                       
-                       distfile = read->getOutputFile();
-               
-                       list = read->getListVector();
-                       delete read;
-               }else {
-                       list = new ListVector(nameMap->getListVector());
-               }
-               
-               if (m->control_pressed) {  
-                       sabundFile.close();
-                       rabundFile.close();
-                       listFile.close();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                       return 0;  
-               }
-
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to sort. "); m->mothurOutEndLine();
-               estart = time(NULL);
-       
-               //list vector made by read contains all sequence names
-               if(list != NULL){
-                       rabund = new RAbundVector(list->getRAbundVector());
-               }else{
-                       m->mothurOut("Error: no list vector!"); m->mothurOutEndLine(); return 0;
-               }
-               
-               float previousDist = 0.00000;
-               float rndPreviousDist = 0.00000;
-               oldRAbund = *rabund;
-               oldList = *list;
-               
-               print_start = true;
-               start = time(NULL);
-                               
-               cluster = new HCluster(rabund, list, method, distfile, nameMap, cutoff);
-               vector<seqDist> seqs; seqs.resize(1); // to start loop
-               
-               if (m->control_pressed) {  
-                               delete cluster;
-                               sabundFile.close();
-                               rabundFile.close();
-                               listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                               return 0;  
-               }
-
-               float saveCutoff = cutoff;
-               
-               while (seqs.size() != 0){
-               
-                       seqs = cluster->getSeqs();
-                       
-                       //to account for cutoff change in average neighbor
-                       if (seqs.size() != 0) {
-                               if (seqs[0].dist > cutoff) { break; }
-                       }
-                       
-                       if (m->control_pressed) {  
-                               delete cluster;
-                               sabundFile.close();
-                               rabundFile.close();
-                               listFile.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                               return 0;  
-                       }
-
-                       for (int i = 0; i < seqs.size(); i++) {  //-1 means skip me
-                               
-                               if (seqs[i].seq1 != seqs[i].seq2) {
-                                       cutoff = cluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
-                                       
-                                       if (m->control_pressed) {  
-                                               delete cluster;
-                                               sabundFile.close();
-                                               rabundFile.close();
-                                               listFile.close();
-                                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                                               return 0;  
-                                       }
-
-                       
-                                       float rndDist;
-                                       if (hard) {
-                                               rndDist = m->ceilDist(seqs[i].dist, precision); 
-                                       }else{
-                                               rndDist = m->roundDist(seqs[i].dist, precision); 
-                                       }
-
-                                       
-                                       if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
-                                               printData("unique");
-                                       }
-                                       else if((rndDist != rndPreviousDist)){
-                                               printData(toString(rndPreviousDist,  length-1));
-                                       }
-                               
-                                       previousDist = seqs[i].dist;
-                                       rndPreviousDist = rndDist;
-                                       oldRAbund = *rabund;
-                                       oldList = *list;
-                               }
-                       }
-               }
-
-               if (m->control_pressed) {  
-                       delete cluster;
-                       sabundFile.close();
-                       rabundFile.close();
-                       listFile.close();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                       return 0;  
-               }
-                                       
-               if(previousDist <= 0.0000){
-                       printData("unique");
-               }
-               else if(rndPreviousDist<cutoff){
-                       printData(toString(rndPreviousDist, length-1));
-               }
-                               
-               sabundFile.close();
-               rabundFile.close();
-               listFile.close();
-               delete cluster;
-               
-               if (m->control_pressed) {  
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } outputTypes.clear();
-                       return 0;  
-               }
-               
-               
-               if (saveCutoff != cutoff) { 
-                       if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-                       else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-                       
-                       m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
-               }
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               m->mothurOut("It took " + toString(time(NULL) - estart) + " seconds to cluster. "); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void HClusterCommand::printData(string label){
-       try {
-               if (m->isTrue(timing)) {
-                       m->mothurOut("\tTime: " + toString(time(NULL) - start) + "\tsecs for " + toString(oldRAbund.getNumBins()) 
-                    + "\tclusters. Updates: " + toString(loops)); m->mothurOutEndLine();
-               }
-               print_start = true;
-               loops = 0;
-               start = time(NULL);
-
-               oldRAbund.setLabel(label);
-               if (m->isTrue(showabund)) {
-                       oldRAbund.getSAbundVector().print(cout);
-               }
-               oldRAbund.print(rabundFile);
-               oldRAbund.getSAbundVector().print(sabundFile);
-       
-               oldList.setLabel(label);
-               oldList.print(listFile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HClusterCommand", "printData");
-               exit(1);
-       }
-
-
-}
-//**********************************************************************************************************************
-
diff --git a/hclustercommand.h b/hclustercommand.h
deleted file mode 100644 (file)
index aeeb3bc..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef HCLUSTERCOMMAND_H
-#define HCLUSTERCOMMAND_H
-
-/*
- *  hclustercommand.h
- *  Mothur
- *
- *  Created by westcott on 10/13/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "hcluster.h"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "listvector.hpp"
-#include "readcluster.h"
-
-/******************************************************************/
-//This command is an implementation of the HCluster algorythmn described in 
-//ESPRIT: estimating species richness using large collections of 16S rRNA pyrosequences by
-//Yijun Sun1,2,*, Yunpeng Cai2, Li Liu1, Fahong Yu1, Michael L. Farrell3, William McKendree3 
-//and William Farmerie1 1 
-
-//Interdisciplinary Center for Biotechnology Research, 2Department of Electrical and Computer Engineering, 
-//University of Florida, Gainesville, FL 32610-3622 and 3Materials Technology Directorate, Air Force Technical 
-//Applications Center, 1030 S. Highway A1A, Patrick AFB, FL 32925-3002, USA 
-//Received January 28, 2009; Revised April 14, 2009; Accepted April 15, 2009 
-/************************************************************/
-class HClusterCommand : public Command {
-       
-public:
-       HClusterCommand(string);
-       HClusterCommand();      
-       ~HClusterCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "hcluster";    }
-       string getCommandCategory()             { return "Clustering";  }
-       string getHelpString(); 
-       string getCitation() { return "Sun Y, Cai Y, Liu L, Yu F, Farrell ML, Mckendree W, Farmerie W (2009). ESPRIT: estimating species richness using large collections of 16S rRNA pyrosequences. Nucleic Acids Res 37: e76. \nhttp://www.mothur.org/wiki/Hcluster"; }
-       string getDescription()         { return "cluster your sequences into OTUs using a distance matrix"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       HCluster* cluster;
-       ListVector* list;
-       RAbundVector* rabund;
-       RAbundVector oldRAbund;
-       ListVector oldList;
-       ReadCluster* read;
-       
-       bool abort, sorted, print_start, hard;
-       string method, fileroot, tag, distfile, format, phylipfile, columnfile, namefile, sort, showabund, timing, outputDir;
-       double cutoff;
-       int precision, length;
-       ofstream sabundFile, rabundFile, listFile;
-       time_t start;
-       unsigned long loops;
-       vector<string> outputNames;
-       
-       void printData(string label);
-};
-
-/************************************************************/
-
-#endif
diff --git a/heatmap.cpp b/heatmap.cpp
deleted file mode 100644 (file)
index 36665ff..0000000
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- *  heatmap.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/25/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "heatmap.h"
-
-//**********************************************************************************************************************
-HeatMap::HeatMap(string sort, string scale, int num, int fsize, string dir, string i){
-       try {
-               m = MothurOut::getInstance();
-//             format = globaldata->getFormat();
-               sorted = sort;
-               scaler = scale;
-               outputDir = dir;
-               numOTU = num;
-               fontSize = fsize;
-               inputfile = i;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "HeatMap");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-string HeatMap::getPic(RAbundVector* rabund) {
-       try {
-               
-               int numBinsToDisplay = rabund->getNumBins();
-               
-               if (numOTU != 0) { //user want to display a portion of the otus
-                       if (numOTU < numBinsToDisplay) {  numBinsToDisplay = numOTU; }
-               }
-               
-               //sort lookup so shared bins are on top
-               if (sorted != "none") {  sortRabund(rabund);  }
-               
-               float maxRelAbund = 0.0;                
-               
-               for(int i=0;i<rabund->size();i++){                              
-                       float relAbund = rabund->get(i) / (float)rabund->getNumSeqs();
-                       if(relAbund > maxRelAbund){     maxRelAbund = relAbund; }
-               }
-               
-               vector<string> scaleRelAbund(numBinsToDisplay, "");
-               
-               for(int i=0;i<numBinsToDisplay;i++){
-                       float relAbund = rabund->get(i) / (float)rabund->getNumSeqs();
-                       
-                       if (m->control_pressed) { return "control"; }
-                       
-                       if (rabund->get(i) != 0) { //don't want log value of 0.
-                               if (scaler == "log10") {
-                                       scaleRelAbund[i] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund))) + "0000";  
-                               }else if (scaler == "log2") {
-                                       scaleRelAbund[i] = toHex(int(255 * log2(relAbund) / log2(maxRelAbund))) + "0000";  
-                               }else if (scaler == "linear") {
-                                       scaleRelAbund[i] = toHex(int(255 * relAbund / maxRelAbund)) + "0000";  
-                               }else {  //if user enters invalid scaler option.
-                                       scaleRelAbund[i] = toHex(int(255 * log10(relAbund / log10(maxRelAbund))))  + "0000"; 
-                               } 
-                       }
-                       else { scaleRelAbund[i] = "FFFFFF";  }
-               }
-               
-               
-               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + rabund->getLabel() + ".heatmap.bin.svg";
-               m->openOutputFile(filenamesvg, outsvg);
-               
-               //svg image
-               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(300) + " " + toString((numBinsToDisplay*5 + 120))  + "\">\n";
-               outsvg << "<g>\n";
-               
-               //white backround
-               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(300) + "\" height=\"" + toString((numBinsToDisplay*5 + 120))  + "\"/>"; 
-               outsvg << "<text fill=\"black\" class=\"seri\" text-anchor=\"middle\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString((150) - 40) + "\" y=\"25\">Heatmap at distance " + rabund->getLabel() + "</text>\n";
-                               
-               //output legend and color labels
-               string color;
-               int x = 0;
-               int y = 103 + (numBinsToDisplay*5);
-               printLegend(y, maxRelAbund);
-               
-               y = 70;
-
-               for (int i = 0; i < scaleRelAbund.size(); i++) {
-                       if (m->control_pressed) { outsvg.close(); return "control"; }
-                       
-                       outsvg << "<rect fill=\"#" + scaleRelAbund[i] + "\" stroke=\"#" + scaleRelAbund[i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
-                       y += 5;
-               }
-               
-               outsvg << "</g>\n</svg>\n";
-               outsvg.close();
-               
-               return filenamesvg;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "getPic");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-string HeatMap::getPic(vector<SharedRAbundVector*> lookup) {
-       try {
-       
-               int numBinsToDisplay = lookup[0]->size();
-               
-               if (numOTU != 0) { //user want to display a portion of the otus
-                       if (numOTU < numBinsToDisplay) {  numBinsToDisplay = numOTU; }
-               }
-               
-               //sort lookup so shared bins are on top
-               if (sorted != "none") {  sortSharedVectors(lookup);  }
-               
-               vector<vector<string> > scaleRelAbund;
-               vector<float> maxRelAbund(lookup[0]->size(), 0.0);              
-               float superMaxRelAbund = 0;
-               
-               for(int i = 0; i < lookup.size(); i++){
-                       for(int j=0; j<lookup[i]->size(); j++){
-                               
-                               float relAbund = lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs();
-                               if(relAbund > maxRelAbund[i]){  maxRelAbund[i] = relAbund;      }
-                       }
-                       if(maxRelAbund[i] > superMaxRelAbund){  superMaxRelAbund = maxRelAbund[i];      }
-               }
-               
-               scaleRelAbund.resize(lookup.size());
-               for(int i=0;i<lookup.size();i++){
-                       scaleRelAbund[i].assign(numBinsToDisplay, "");
-                       for(int j=0;j<numBinsToDisplay;j++){
-                               if (m->control_pressed) {  return "control"; }
-                               float relAbund = lookup[i]->getAbundance(j) / (float)lookup[i]->getNumSeqs();
-                               
-                               if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0.
-                                       if (scaler == "log10") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund[i]))) + "0000";  
-                                       }else if (scaler == "log2") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * log2(relAbund) / log2(maxRelAbund[i]))) + "0000";  
-                                       }else if (scaler == "linear") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000";  
-                                       }else {  //if user enters invalid scaler option.
-                                               scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund / log10(maxRelAbund[i]))))  + "0000"; 
-                                       } 
-                               }else { scaleRelAbund[i][j] = "FFFFFF";  }
-
-                       }
-               }
-
-               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
-               m->openOutputFile(filenamesvg, outsvg);
-               
-               //svg image
-               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((numBinsToDisplay*5 + 120))  + "\">\n";
-               outsvg << "<g>\n";
-               
-               //white backround
-               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * 300) + "\" height=\"" + toString((numBinsToDisplay*5 + 120))  + "\"/>"; 
-               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" text-anchor=\"middle\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
-               
-               //column labels
-               for (int h = 0; h < lookup.size(); h++) {
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((300 * (h+1)) - 150) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n"; 
-               }
-
-               //output legend and color labels
-               string color;
-               int x = 0;
-               int y = 103 + (numBinsToDisplay*5);
-               printLegend(y, superMaxRelAbund);
-               
-               y = 70;
-               for (int i = 0; i < numBinsToDisplay; i++) {
-                       for (int j = 0; j < scaleRelAbund.size(); j++) {
-                               if (m->control_pressed) { outsvg.close(); return "control"; }
-                               
-                               outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
-                               x += 300;
-                       }
-                       x = 0;
-                       y += 5;
-               }
-               
-               outsvg << "</g>\n</svg>\n";
-               outsvg.close();
-               
-               return filenamesvg;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "getPic");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int HeatMap::sortSharedVectors(vector<SharedRAbundVector*>& lookup){
-       try {
-                               
-               vector<SharedRAbundVector*> looktemp;
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               /****************** find order of otus **********************/
-               if (sorted == "shared") {
-                       place = orderShared(lookup);    
-               }else if (sorted == "topotu") {
-                       place = orderTopOtu(lookup);    
-               }else if (sorted == "topgroup") {
-                       place = orderTopGroup(lookup);  
-               }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine();  return 1; }
-                               
-               
-               /******************* create copy of lookup *********************/
-               //create and initialize looktemp as a copy of lookup
-               for (int i = 0; i < lookup.size(); i++) { 
-                       SharedRAbundVector* temp = new SharedRAbundVector(lookup[i]->getNumBins());
-                       temp->setLabel(lookup[i]->getLabel());
-                       temp->setGroup(lookup[i]->getGroup());
-                       //copy lookup i's info
-                       for (int j = 0; j < lookup[i]->size(); j++) {
-                               temp->set(j, lookup[i]->getAbundance(j), lookup[i]->getGroup());
-                       }
-                       looktemp.push_back(temp);
-               }
-       
-               /************************ fill lookup in order given by place *********************/
-               //for each bin
-               for (int i = 0; i < looktemp[0]->size(); i++) {                                                                                                         //place
-                       //fill lookup                                                                                                                                                                   // 2 -> 1
-                       for (int j = 0; j < looktemp.size(); j++) {                                                                                                             // 3 -> 2
-                               int newAbund = looktemp[j]->getAbundance(i);                                                                                            // 1 -> 3
-                               lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
-                       }
-               }
-               
-               //delete looktemp -- Sarah look at - this is causing segmentation faults
-               for (int j = 0; j < looktemp.size(); j++) {
-//                     delete looktemp[j];
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "sortSharedVectors");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderShared(vector<SharedRAbundVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector<int> sharedBins;
-               vector<int> uniqueBins;
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       int count = 0;                                                                                          
-                       
-                       //is this bin shared
-                       for (int j = 0; j < lookup.size(); j++) {               if (lookup[j]->getAbundance(i) != 0) { count++; }       }
-                       
-                       if (count < 2)  {  uniqueBins.push_back(i); }
-                       else                    {  sharedBins.push_back(i); }
-               }
-               
-               //fill place
-               for (int i = 0; i < sharedBins.size(); i++) { place[sharedBins[i]] = i; }
-               for (int i = 0; i < uniqueBins.size(); i++) { place[uniqueBins[i]] = (sharedBins.size() + i); }
-               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderTopOtu(vector<SharedRAbundVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector<binCount> totals;
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       int total = 0;                                                                                          
-                       
-                       for (int j = 0; j < lookup.size(); j++) {       total += lookup[j]->getAbundance(i);    }
-                       
-                       binCount temp(i, total);
-                       
-                       totals.push_back(temp);
-               }
-               
-               sort(totals.begin(), totals.end(), comparebinCounts);
-               
-               //fill place
-               for (int i = 0; i < totals.size(); i++) {   place[totals[i].bin] = i;  }
-                               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderTopOtu");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderTopGroup(vector<SharedRAbundVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector < vector<binCount> > totals; //totals[0] = bin totals for group 0, totals[1] = bin totals for group 1, ...
-               totals.resize(lookup.size());
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       for (int j = 0; j < lookup.size(); j++) {
-                               binCount temp(i, (lookup[j]->getAbundance(i)));
-                               totals[j].push_back(temp);
-                       }
-               }
-               
-               for (int i = 0; i < totals.size(); i++) { sort(totals[i].begin(), totals[i].end(), comparebinCounts);  }
-               
-               //fill place
-               //grab the top otu for each group adding it if its not already added
-               int count = 0;
-               for (int i = 0; i < totals[0].size(); i++) { 
-               
-                       for (int j = 0; j < totals.size(); j++) {  
-                               it = place.find(totals[j][i].bin);
-                               
-                               if (it == place.end()) { //not added yet
-                                       place[totals[j][i].bin] = count;
-                                       count++;
-                               }
-                       }
-               }
-                               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderTopGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-void HeatMap::printLegend(int y, float maxbin) {
-       try {
-               
-               //output legend and color labels
-               //go through map and give each score a color value
-               string color;
-               int x = 10;
-               
-               //prints legend
-               for (int i = 1; i < 255; i++) {
-                       color = toHex(int((float)(i)));
-                       outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"1\" height=\"10\"/>\n";
-                       x += 1;
-               }
-               
-               //prints legend labels
-               x = 10;
-               for (int i = 1; i<=5; i++) {
-                       float label;
-                       if(scaler== "log10")            {       label = maxbin * log10(51*i) / log10(255);      }
-                       else if(scaler== "log2")        {       label = maxbin * log2(51*i) / log2(255);        }
-                       else if(scaler== "linear")      {       label = maxbin * 51 * i / 255;                          }
-                       else                                            {       label = maxbin * log10(51*i) / log10(255);      }
-                       label = int(label * 1000 + 0.5);
-                       label /= 1000.0;
-                       string text = toString(label, 3);
-                       
-                       outsvg << "<text fill=\"black\" class=\"seri\" x=\"" + toString(x) + "\" y=\"" + toString(y-3) + "\">" + text + "</text>\n";
-                       x += 60;
-               }
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "printLegend");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-string HeatMap::getPic(vector<SharedRAbundFloatVector*> lookup) {
-       try {
-       
-               int numBinsToDisplay = lookup[0]->size();
-               
-               if (numOTU != 0) { //user want to display a portion of the otus
-                       if (numOTU < numBinsToDisplay) {  numBinsToDisplay = numOTU; }
-               }
-               
-               //sort lookup so shared bins are on top
-               if (sorted != "none") {  sortSharedVectors(lookup);  }
-               
-               vector<vector<string> > scaleRelAbund;
-               vector<float> maxRelAbund(lookup.size(), 0.0);          
-               float superMaxRelAbund = 0;
-               
-               for(int i = 0; i < lookup.size(); i++){
-                       for(int j=0; j<lookup[i]->size(); j++){
-                               
-                               float relAbund = lookup[i]->getAbundance(j);
-                               if(relAbund > maxRelAbund[i]){  maxRelAbund[i] = relAbund;      }
-                       }
-                       if(maxRelAbund[i] > superMaxRelAbund){  superMaxRelAbund = maxRelAbund[i];      }
-               }
-               
-               scaleRelAbund.resize(lookup.size());
-               for(int i=0;i<lookup.size();i++){
-                       scaleRelAbund[i].assign(numBinsToDisplay, "");
-                       for(int j=0;j<numBinsToDisplay;j++){
-                               if (m->control_pressed) {  return "control"; }
-                               float relAbund = lookup[i]->getAbundance(j);
-                               
-                               if (lookup[i]->getAbundance(j) != 0) { //don't want log value of 0.
-                                       if (scaler == "log10") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund) / log10(maxRelAbund[i]))) + "0000";  
-                                       }else if (scaler == "log2") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * log2(relAbund) / log2(maxRelAbund[i]))) + "0000";  
-                                       }else if (scaler == "linear") {
-                                               scaleRelAbund[i][j] = toHex(int(255 * relAbund / maxRelAbund[i])) + "0000";  
-                                       }else {  //if user enters invalid scaler option.
-                                               scaleRelAbund[i][j] = toHex(int(255 * log10(relAbund / log10(maxRelAbund[i]))))  + "0000"; 
-                                       } 
-                               }else { scaleRelAbund[i][j] = "FFFFFF";  }
-
-                       }
-               }
-
-               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + ".heatmap.bin.svg";
-               m->openOutputFile(filenamesvg, outsvg);
-               
-               //svg image
-               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString(lookup.size() * 300) + " " + toString((numBinsToDisplay*5 + 120))  + "\">\n";
-               outsvg << "<g>\n";
-               
-               //white backround
-               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString(lookup.size() * 300) + "\" height=\"" + toString((numBinsToDisplay*5 + 120))  + "\"/>"; 
-               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" text-anchor=\"middle\" x=\"" + toString((lookup.size() * 150) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
-               
-               //column labels
-               for (int h = 0; h < lookup.size(); h++) {
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((300 * (h+1)) - 150) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n"; 
-               }
-
-               //output legend and color labels
-               string color;
-               int x = 0;
-               int y = 103 + (numBinsToDisplay*5);
-               printLegend(y, superMaxRelAbund);
-               
-               y = 70;
-               for (int i = 0; i < numBinsToDisplay; i++) {
-                       for (int j = 0; j < scaleRelAbund.size(); j++) {
-                               if (m->control_pressed) { outsvg.close(); return "control"; }
-                               
-                               outsvg << "<rect fill=\"#" + scaleRelAbund[j][i] + "\" stroke=\"#" + scaleRelAbund[j][i] + "\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"300\" height=\"5\"/>\n";
-                               x += 300;
-                       }
-                       x = 0;
-                       y += 5;
-               }
-               
-               outsvg << "</g>\n</svg>\n";
-               outsvg.close();
-               
-               return filenamesvg;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "getPic");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int HeatMap::sortSharedVectors(vector<SharedRAbundFloatVector*>& lookup){
-       try {
-                               
-               vector<SharedRAbundFloatVector*> looktemp;
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               /****************** find order of otus **********************/
-               if (sorted == "shared") {
-                       place = orderShared(lookup);    
-               }else if (sorted == "topotu") {
-                       place = orderTopOtu(lookup);    
-               }else if (sorted == "topgroup") {
-                       place = orderTopGroup(lookup);  
-               }else { m->mothurOut("Error: invalid sort option."); m->mothurOutEndLine();  return 1; }
-                               
-               
-               /******************* create copy of lookup *********************/
-               //create and initialize looktemp as a copy of lookup
-               for (int i = 0; i < lookup.size(); i++) { 
-                       SharedRAbundFloatVector* temp = new SharedRAbundFloatVector(lookup[i]->getNumBins());
-                       temp->setLabel(lookup[i]->getLabel());
-                       temp->setGroup(lookup[i]->getGroup());
-                       //copy lookup i's info
-                       for (int j = 0; j < lookup[i]->size(); j++) {
-                               temp->set(j, lookup[i]->getAbundance(j), lookup[i]->getGroup());
-                       }
-                       looktemp.push_back(temp);
-               }
-       
-               /************************ fill lookup in order given by place *********************/
-               //for each bin
-               for (int i = 0; i < looktemp[0]->size(); i++) {                                                                                                         //place
-                       //fill lookup                                                                                                                                                                   // 2 -> 1
-                       for (int j = 0; j < looktemp.size(); j++) {                                                                                                             // 3 -> 2
-                               float newAbund = looktemp[j]->getAbundance(i);                                                                                          // 1 -> 3
-                               lookup[j]->set(place[i], newAbund, looktemp[j]->getGroup()); //binNumber, abundance, group
-                       }
-               }
-               
-               //delete looktemp -- Sarah look at - this is causing segmentation faults
-               for (int j = 0; j < looktemp.size(); j++) {
-//                     delete looktemp[j];
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "sortSharedVectors");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int HeatMap::sortRabund(RAbundVector*& r){
-       try {
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               /****************** find order of otus **********************/
-               vector<binCount> totals;
-               
-               //for each bin
-               for (int i = 0; i < r->getNumBins(); i++) {     
-                       binCount temp(i, r->get(i));
-                       
-                       totals.push_back(temp);
-               }
-               
-               sort(totals.begin(), totals.end(), comparebinCounts);
-               
-               //fill place
-               for (int i = 0; i < totals.size(); i++) {   place[totals[i].bin] = i;  }
-               
-               /******************* create copy of lookup *********************/
-               //create and initialize rtemp as a copy of r
-               
-               RAbundVector* rtemp = new RAbundVector(r->getNumBins());
-               for (int i = 0; i < r->size(); i++) {  rtemp->set(i, r->get(i)); }
-               rtemp->setLabel(r->getLabel());
-                       
-               /************************ fill lookup in order given by place *********************/
-               //for each bin
-               for (int i = 0; i < rtemp->size(); i++) {                                                                               //place
-                       //fill lookup                                                                                                                           // 2 -> 1
-                                                                                                                                                                               // 3 -> 2
-                       int newAbund = rtemp->get(i);                                                                                           // 1 -> 3
-                       r->set(place[i], newAbund); //binNumber, abundance
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "sortRabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderShared(vector<SharedRAbundFloatVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector<int> sharedBins;
-               vector<int> uniqueBins;
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       int count = 0;                                                                                          
-                       
-                       //is this bin shared
-                       for (int j = 0; j < lookup.size(); j++) {               if (lookup[j]->getAbundance(i) != 0) { count++; }       }
-                       
-                       if (count < 2)  {  uniqueBins.push_back(i); }
-                       else                    {  sharedBins.push_back(i); }
-               }
-               
-               //fill place
-               for (int i = 0; i < sharedBins.size(); i++) { place[sharedBins[i]] = i; }
-               for (int i = 0; i < uniqueBins.size(); i++) { place[uniqueBins[i]] = (sharedBins.size() + i); }
-               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderTopOtu(vector<SharedRAbundFloatVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector<binCountFloat> totals;
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       int total = 0;                                                                                          
-                       
-                       for (int j = 0; j < lookup.size(); j++) {       total += lookup[j]->getAbundance(i);    }
-                       
-                       binCountFloat temp(i, total);
-                       
-                       totals.push_back(temp);
-               }
-               
-               sort(totals.begin(), totals.end(), comparebinFloatCounts);
-               
-               //fill place
-               for (int i = 0; i < totals.size(); i++) {   place[totals[i].bin] = i;  }
-                               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderTopOtu");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-map<int, int> HeatMap::orderTopGroup(vector<SharedRAbundFloatVector*>& lookup){
-       try {
-                               
-               map<int, int> place; //spot in lookup where you insert shared by, ie, 3 -> 2 if they are shared by 3 inset into location 2.
-               map<int, int>::iterator it;
-               
-               vector < vector<binCountFloat> > totals; //totals[0] = bin totals for group 0, totals[1] = bin totals for group 1, ...
-               totals.resize(lookup.size());
-               
-               //for each bin
-               for (int i = 0; i < lookup[0]->size(); i++) {   
-                       for (int j = 0; j < lookup.size(); j++) {
-                               binCountFloat temp(i, (lookup[j]->getAbundance(i)));
-                               totals[j].push_back(temp);
-                       }
-               }
-               
-               for (int i = 0; i < totals.size(); i++) { sort(totals[i].begin(), totals[i].end(), comparebinFloatCounts);  }
-               
-               //fill place
-               //grab the top otu for each group adding it if its not already added
-               int count = 0;
-               for (int i = 0; i < totals[0].size(); i++) { 
-               
-                       for (int j = 0; j < totals.size(); j++) {  
-                               it = place.find(totals[j][i].bin);
-                               
-                               if (it == place.end()) { //not added yet
-                                       place[totals[j][i].bin] = count;
-                                       count++;
-                               }
-                       }
-               }
-                               
-               return place;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMap", "orderTopGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
-
diff --git a/heatmap.h b/heatmap.h
deleted file mode 100644 (file)
index 2b49176..0000000
--- a/heatmap.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef HEATMAP_H
-#define HEATMAP_H
-/*
- *  heatmap.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/25/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "rabundvector.hpp"
-#include "sharedrabundvector.h"
-#include "sharedrabundfloatvector.h"
-#include "datavector.hpp"
-
-
-/***********************************************************************/
-struct binCount {
-               int bin;
-               int abund;
-               binCount(int i, int j) : bin(i), abund(j) {}
-};
-/***********************************************************************/
-struct binCountFloat {
-               int bin;
-               float abund;
-               binCountFloat(int i, float j) : bin(i), abund(j) {}
-};
-
-/***********************************************************************/
-//sorts highest abund to lowest
-inline bool comparebinCounts(binCount left, binCount right){
-       return (left.abund > right.abund);      
-}
-/***********************************************************************/
-//sorts highest abund to lowest
-inline bool comparebinFloatCounts(binCountFloat left, binCountFloat right){
-       return (left.abund > right.abund);      
-}
-/***********************************************************************/
-
-class HeatMap {
-       
-       public:
-               HeatMap(string, string, int, int, string, string);
-               ~HeatMap(){};
-       
-               string getPic(RAbundVector*);
-               string getPic(vector<SharedRAbundVector*>);
-               string getPic(vector<SharedRAbundFloatVector*>);
-
-       private:
-               int sortSharedVectors(vector<SharedRAbundVector*>& );
-               int sortSharedVectors(vector<SharedRAbundFloatVector*>& );
-               int sortRabund(RAbundVector*&);
-               void printLegend(int, float);
-
-               string format, sorted, groupComb, scaler, outputDir, inputfile;
-               ofstream outsvg;
-               MothurOut* m;
-               int numOTU, fontSize;
-               
-               map<int, int> orderTopGroup(vector<SharedRAbundVector*>&);
-               map<int, int> orderTopOtu(vector<SharedRAbundVector*>&);
-               map<int, int> orderShared(vector<SharedRAbundVector*>&);
-               map<int, int> orderTopGroup(vector<SharedRAbundFloatVector*>&);
-               map<int, int> orderTopOtu(vector<SharedRAbundFloatVector*>&);
-               map<int, int> orderShared(vector<SharedRAbundFloatVector*>&);
-
-                       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
-
diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp
deleted file mode 100644 (file)
index 7d9b482..0000000
+++ /dev/null
@@ -1,540 +0,0 @@
-/*
- *  heatmapcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/25/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "heatmapcommand.h"
-
-//**********************************************************************************************************************
-vector<string> HeatMapCommand::setParameters(){        
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pscale("scale", "Multiple", "log10-log2-linear", "log10", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter psorted("sorted", "Multiple", "none-shared-topotu-topgroup", "shared", "", "", "",false,false); parameters.push_back(psorted);
-               CommandParameter pnumotu("numotu", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnumotu);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string HeatMapCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The heatmap.bin command parameters are shared, relabund, list, rabund, sabund, groups, sorted, scale, numotu, fontsize and label.  shared, relabund, list, rabund or sabund is required unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n";
-               helpString += "The sorted parameter allows you to order the otus displayed, default=shared, meaning display the shared otus first. Other options for sorted are none, meaning the exact representation of your otus, \n";
-               helpString += "topotu, meaning the otus with the greatest abundance when totaled across groups, topgroup, meaning the top otus for each group. \n";
-               helpString += "The scale parameter allows you to choose the range of color your bin information will be displayed with.\n";
-               helpString += "The numotu parameter allows you to display only the top N otus, by default all the otus are displayed. You could choose to look at the top 10, by setting numotu=10. The default for sorted is topotu when numotu is used.\n";
-               helpString += "The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and are also separated by dashes.\n";
-               helpString += "The fontsize parameter allows you to adjust the font size of the picture created, default=24.\n";
-               helpString += "The heatmap.bin command should be in the following format: heatmap.bin(groups=yourGroups, sorted=yourSorted, label=yourLabels).\n";
-               helpString += "Example heatmap.bin(groups=A-B-C, sorted=none, scale=log10).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "The default value for scale is log10; your other options are log2 and linear.\n";
-               helpString += "The heatmap.bin command outputs a .svg file for each label you specify.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-HeatMapCommand::HeatMapCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["svg"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-HeatMapCommand::HeatMapCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["svg"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { relabundfile = ""; abort = true; }    
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else {  format = "relabund"; inputfile = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       
-                       if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "") && (relabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               rabundfile = m->getRabundFile(); 
-                                               if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       sabundfile = m->getSabundFile(); 
-                                                       if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                                       else { 
-                                                               relabundfile = m->getRelAbundFile(); 
-                                                               if (relabundfile != "") { inputfile = relabundfile; format = "relabund"; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                                               else { 
-                                                                       m->mothurOut("No valid current files. You must provide a list, sabund, rabund, relabund or shared file."); m->mothurOutEndLine(); 
-                                                                       abort = true;
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "numotu", false);            if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, numOTU);
-                       
-                       temp = validParameter.validFile(parameters, "fontsize", false);                         if (temp == "not found") { temp = "24"; }
-                       m->mothurConvert(temp, fontSize);
-                       
-                       sorted = validParameter.validFile(parameters, "sorted", false);                         
-                       if (sorted == "not found") { 
-                               //if numOTU is used change default
-                               if (numOTU != 0) { sorted = "topotu"; }
-                               else { sorted = "shared"; }
-                       }
-                
-                       scale = validParameter.validFile(parameters, "scale", false);                           if (scale == "not found") { scale = "log10"; }
-                       
-                       if ((sorted != "none") && (sorted != "shared") && (sorted != "topotu") && (sorted != "topgroup")) { m->mothurOut(sorted + " is not a valid sorting option. Sorted options are: none, shared, topotu, topgroup"); m->mothurOutEndLine(); abort=true;  }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "HeatMapCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int HeatMapCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               heatmap = new HeatMap(sorted, scale, numOTU, fontSize, outputDir, inputfile);
-
-               string lastLabel;
-               input = new InputData(inputfile, format);
-               
-               if (format == "sharedfile") {
-                       //you have groups
-                       lookup = input->getSharedRAbundVectors();
-                       lastLabel = lookup[0]->getLabel();
-       
-               }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
-                       //you are using just a list file and have only one group
-                       rabund = input->getRAbundVector();
-                       lastLabel = rabund->getLabel();
-               }else if (format == "relabund") {
-                       //you have groups
-                       lookupFloat = input->getSharedRAbundFloatVectors();
-                       lastLabel = lookupFloat[0]->getLabel();
-               }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-               if (format == "sharedfile") {   
-               
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               if (m->control_pressed) {
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                                       m->clearGroups(); 
-                                       delete input; delete heatmap; return 0;
-                               }
-               
-                               if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-       
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       string outputFileName = heatmap->getPic(lookup);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookup[0]->getLabel();
-                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                       
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       
-                                       string outputFileName = heatmap->getPic(lookup);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookup[0]->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = lookup[0]->getLabel();
-                               //prevent memory leak
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                                                       
-                               //get next line to process
-                               lookup = input->getSharedRAbundVectors();                               
-                       }
-                       
-                       
-                       if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                               m->clearGroups(); 
-                               delete input; delete heatmap; return 0;
-                       }
-
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-               
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               string outputFileName = heatmap->getPic(lookup);
-                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                       }
-               
-                       //reset groups parameter
-                       m->clearGroups();  
-                       
-               }else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
-       
-                       while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               if (m->control_pressed) {   
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                                       delete rabund;  delete input; delete heatmap; return 0; 
-                               }
-
-                               if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
-       
-                                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       string outputFileName = heatmap->getPic(rabund);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(rabund->getLabel());
-                                       userLabels.erase(rabund->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = rabund->getLabel();
-                                       
-                                       delete rabund;
-                                       rabund = input->getRAbundVector(lastLabel);
-                                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       
-                                       string outputFileName = heatmap->getPic(rabund);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(rabund->getLabel());
-                                       userLabels.erase(rabund->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       rabund->setLabel(saveLabel);
-                               }               
-                               
-                                                               
-                                                               
-                               lastLabel = rabund->getLabel();                 
-                               delete rabund;
-                               rabund = input->getRAbundVector();
-                       }
-                       
-                       if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                               delete input; delete heatmap; return 0;
-                       }
-
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-               
-                       //run last label if you need to
-                       if (needToRun == true)  {
-               
-                               if (rabund != NULL) {   delete rabund;  }
-                               rabund = input->getRAbundVector(lastLabel);
-                               m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                                       
-                               string outputFileName = heatmap->getPic(rabund);
-                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                               delete rabund; 
-                       }
-               
-               }else {
-               
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               if (m->control_pressed) {
-                                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                                       m->clearGroups(); 
-                                       delete input; delete heatmap; return 0;
-                               }
-               
-                               if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){                     
-       
-                                       m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                                       string outputFileName = heatmap->getPic(lookupFloat);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(lookupFloat[0]->getLabel());
-                                       userLabels.erase(lookupFloat[0]->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookupFloat[0]->getLabel();
-                               
-                                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  
-                                       lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                                       m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                                       
-                                       string outputFileName = heatmap->getPic(lookupFloat);
-                                       outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                                       
-                                       processedLabels.insert(lookupFloat[0]->getLabel());
-                                       userLabels.erase(lookupFloat[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookupFloat[0]->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = lookupFloat[0]->getLabel();
-                               //prevent memory leak
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i]; lookupFloat[i] = NULL; }
-                                                       
-                               //get next line to process
-                               lookupFloat = input->getSharedRAbundFloatVectors();                             
-                       }
-                       
-                       
-                       if (m->control_pressed) {
-                               for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear();
-                               m->clearGroups(); 
-                               delete input; delete heatmap; return 0;
-                       }
-
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-               
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               for (int i = 0; i < lookupFloat.size(); i++) { if (lookupFloat[i] != NULL) { delete lookupFloat[i]; } }  
-                               lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                               string outputFileName = heatmap->getPic(lookupFloat);
-                               outputNames.push_back(outputFileName); outputTypes["svg"].push_back(outputFileName);
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
-                       }
-               
-                       //reset groups parameter
-                       m->clearGroups();  
-
-               }
-               
-               delete input; 
-               delete heatmap;
-               
-               if (m->control_pressed) {
-                       for (int i = 0; i < outputNames.size(); i++) {  if (outputNames[i] != "control") {  m->mothurRemove(outputNames[i]);  } } outputTypes.clear(); return 0;
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/heatmapcommand.h b/heatmapcommand.h
deleted file mode 100644 (file)
index ccd5f48..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef HEATMAPCOMMAND_H
-#define HEATMAPCOMMAND_H
-
-/*
- *  heatmapcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/25/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedlistvector.h"
-#include "heatmap.h"
-#include "rabundvector.hpp"
-
-
-class HeatMapCommand : public Command {
-
-public:
-       HeatMapCommand(string);
-       HeatMapCommand();
-       ~HeatMapCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "heatmap.bin";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Heatmap.bin"; }
-       string getDescription()         { return "generate a heatmap where the color represents the relative abundanceof an OTU"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       InputData* input;
-       RAbundVector* rabund;
-       vector<SharedRAbundVector*> lookup;
-       vector<SharedRAbundFloatVector*> lookupFloat;
-       HeatMap* heatmap;
-
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string format, groups, sorted, scale, label, outputDir, sharedfile, relabundfile, listfile, rabundfile, sabundfile, inputfile;
-       vector<string> Groups, outputNames;
-       int numOTU, fontSize;
-
-
-};
-
-#endif
-
diff --git a/heatmapsim.cpp b/heatmapsim.cpp
deleted file mode 100644 (file)
index 62965f9..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *  heatmapsim.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "heatmapsim.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-
-//**********************************************************************************************************************
-HeatMapSim::HeatMapSim(string dir, string i, int f) : outputDir(dir), inputfile(i), fontSize(f) {
-               m = MothurOut::getInstance();
-}
-//**********************************************************************************************************************
-vector<string> HeatMapSim::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> calcs) {
-       try {
-               EstOutput data;
-               vector<double> sims;
-               vector<string> outputNames;
-                               
-               //make file for each calculator selected
-               for (int k = 0; k < calcs.size(); k++) {
-               
-                       if (m->control_pressed) { return outputNames; }
-               
-                       string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + calcs[k]->getName() + ".heatmap.sim.svg";
-                       m->openOutputFile(filenamesvg, outsvg);
-                       outputNames.push_back(filenamesvg);
-                       
-                       //svg image
-                       outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString((lookup.size() * 150) + 160) + " " + toString((lookup.size() * 150) + 160)  + "\">\n";
-                       outsvg << "<g>\n";
-               
-                       //white backround
-                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString((lookup.size() * 150) + 160) + "\" height=\"" + toString((lookup.size() * 150) + 160)  + "\"/>"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString((lookup.size() * 75) - 40) + "\" y=\"25\">Heatmap at distance " + lookup[0]->getLabel() + "</text>\n";
-               
-                       //column labels
-                       for (int h = 0; h < lookup.size(); h++) {
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((150 * (h+1)) ) - ((int)lookup[h]->getGroup().length() / 2)) + "\" y=\"50\">" + lookup[h]->getGroup() + "</text>\n"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" y=\"" + toString(((150 * (h+1)) ) - ((int)lookup[h]->getGroup().length() / 2)) + "\" x=\"50\">" + lookup[h]->getGroup() + "</text>\n";
-                       }
-                       
-                       sims.clear();
-//                     double biggest = -1;
-                       double biggest = 1;
-                       float scaler;
-
-                       //get sim for each comparison and save them so you can find the relative similairity
-                       for(int i = 0; i < (lookup.size()-1); i++){
-                               for(int j = (i+1); j < lookup.size(); j++){
-                                               
-                                               if (m->control_pressed) { outsvg.close(); return outputNames; }
-                                               
-                                               vector<SharedRAbundVector*> subset;
-                                               subset.push_back(lookup[i]);  subset.push_back(lookup[j]); 
-                                       
-                                               //get similairity between groups
-                                               data = calcs[k]->getValues(subset);
-                                               sims.push_back(1.0 - data[0]);
-                                       
-                                               //save biggest similairity to set relative sim
-//                                             if (data[0] > biggest) { biggest = data[0]; }
-                               }
-                       }
-                       
-                       //map biggest similairity found to red
-                       scaler = 255.0 / biggest;
-                       
-                       int count = 0;
-                       //output similairites to file
-                       for(int i = 0; i < (lookup.size()-1); i++){
-                               for(int j = (i+1); j < lookup.size(); j++){
-                               
-                                               //find relative color
-                                               int color = scaler * sims[count];                                       
-                                               //draw box
-                                               outsvg << "<rect fill=\"rgb(" + toString(color) + ",0,0)\" stroke=\"rgb(" + toString(color) + ",0,0)\" x=\"" + toString((i*150)+80) + "\" y=\"" + toString((j*150)+75) + "\" width=\"150\" height=\"150\"/>\n";
-                                               count++;
-                               }
-                       }
-                       
-                       int y = ((lookup.size() * 150) + 120);
-                       printLegend(y, biggest);
-               
-                       outsvg << "</g>\n</svg>\n";
-                       outsvg.close();
-
-               }
-               
-               return outputNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSim", "getPic");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string HeatMapSim::getPic(vector< vector<double> > dists, vector<string> groups) {
-       try {
-               
-               vector<double> sims;
-               
-               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "heatmap.sim.svg";
-               m->openOutputFile(filenamesvg, outsvg);
-                       
-               //svg image
-               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " + toString((dists.size() * 150) + 160) + " " + toString((dists.size() * 150) + 160)  + "\">\n";
-               outsvg << "<g>\n";
-               
-               //white backround
-               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" + toString((dists.size() * 150) + 160) + "\" height=\"" + toString((dists.size() * 150) + 160)  + "\"/>"; 
-               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString((dists.size() * 75) - 40) + "\" y=\"25\">Heatmap for " + inputfile + "</text>\n";
-               
-               //column labels
-               for (int h = 0; h < groups.size(); h++) {
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(((150 * (h+1)) ) - ((int)groups[h].length() / 2)) + "\" y=\"50\">" + groups[h] + "</text>\n"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" y=\"" + toString(((150 * (h+1)) ) - ((int)groups[h].length() / 2)) + "\" x=\"50\">" + groups[h] + "</text>\n";
-               }
-                       
-               double biggest = -1;
-               float scaler;
-
-               //get sim for each comparison and save them so you can find the relative similairity
-               for(int i = 0; i < (dists.size()-1); i++){
-                       for(int j = (i+1); j < dists.size(); j++){
-                       
-                               if (m->control_pressed) { outsvg.close(); return filenamesvg; }
-                               
-                               float sim = 1.0 - dists[i][j];
-                               sims.push_back(sim);
-                                       
-                               //save biggest similairity to set relative sim
-                               if (sim > biggest) { biggest = sim; }
-                       }
-               }
-                       
-               //map biggest similairity found to red
-               scaler = 255.0 / biggest;
-                       
-               int count = 0;
-               //output similairites to file
-               for(int i = 0; i < (dists.size()-1); i++){
-                       for(int j = (i+1); j < dists.size(); j++){
-                               
-                                       //find relative color
-                                       int color = scaler * sims[count];                                       
-                                       //draw box
-                                       outsvg << "<rect fill=\"rgb(" + toString(color) + ",0,0)\" stroke=\"rgb(" + toString(color) + ",0,0)\" x=\"" + toString((i*150)+80) + "\" y=\"" + toString((j*150)+75) + "\" width=\"150\" height=\"150\"/>\n";
-                                       count++;
-                       }
-               }
-                       
-               int y = ((dists.size() * 150) + 120);
-               printLegend(y, biggest);
-               
-               outsvg << "</g>\n</svg>\n";
-               outsvg.close();
-               
-               return filenamesvg;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSim", "getPic");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void HeatMapSim::printLegend(int y, float maxSim) {
-       try {
-               maxSim = 1;
-               
-               //output legend and color labels
-               //go through map and give each score a color value
-               string color;
-               int x = 10;
-               
-               //prints legend
-               for (int i = 1; i < 255; i++) {
-                       color = toHex(int((float)(i)));
-                       outsvg << "<rect fill=\"#" + color + "0000\" stroke=\"#" + color + "0000\" x=\"" + toString(x) + "\" y=\"" + toString(y) + "\" width=\"3\" height=\"30\"/>\n";
-                       x += 3;
-               }
-               
-               float scaler = maxSim / 5.0;
-               
-               //prints legend labels
-               x = 0;
-               for (int i = 0; i<=5; i++) {
-                       float label = scaler*i;
-                       label = int(label * 1000 + 0.5);
-                       label /= 1000.0;
-                       string text = toString(label, 1);
-                       
-                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(x) + "\" y=\"" + toString(y-3) + "\">" + text + "</text>\n";
-                       x += 153;
-               }
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSim", "printLegend");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
-
diff --git a/heatmapsim.h b/heatmapsim.h
deleted file mode 100644 (file)
index aa23c18..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef HEATMAPSIM_H
-#define HEATMAPSIM_H
-/*
- *  heatmapsim.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "sharedrabundvector.h"
-#include "datavector.hpp"
-#include "calculator.h"
-
-/***********************************************************************/
-
-class HeatMapSim {
-       
-       public:
-               HeatMapSim(string, string, int);
-               ~HeatMapSim(){};
-       
-               vector<string> getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
-               string getPic(vector< vector<double> >, vector<string>);
-
-       private:
-               void printLegend(int, float);
-
-               string format, groupComb, outputDir, inputfile;
-               int fontSize;
-               ofstream outsvg;
-               MothurOut* m;
-                       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/heatmapsimcommand.cpp b/heatmapsimcommand.cpp
deleted file mode 100644 (file)
index de35075..0000000
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- *  heatmapsimcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "heatmapsimcommand.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-
-
-//**********************************************************************************************************************
-vector<string> HeatMapSimCommand::setParameters(){     
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pshared);        
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName",false,false); parameters.push_back(pcolumn);          
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "Multiple", "jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-morisitahorn-braycurtis", "jest-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string HeatMapSimCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The heatmap.sim command parameters are shared, phylip, column, name, groups, calc, fontsize and label.  shared or phylip or column and name are required unless valid current files exist.\n";
-               helpString += "There are two ways to use the heatmap.sim command. The first is with the read.otu command. \n";
-               helpString += "With the read.otu command you may use the groups, label and calc parameters. \n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your heatmap.\n";
-               helpString += "The group names are separated by dashes. The label parameter allows you to select what distance levels you would like a heatmap created for, and is also separated by dashes.\n";
-               helpString += "The fontsize parameter allows you to adjust the font size of the picture created, default=24.\n";
-               helpString += "The heatmap.sim command should be in the following format: heatmap.sim(groups=yourGroups, calc=yourCalc, label=yourLabels).\n";
-               helpString += "Example heatmap.sim(groups=A-B-C, calc=jabund).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString +=  validCalculator.printCalc("heat");
-               helpString += "The default value for calc is jclass-thetayc.\n";
-               helpString += "The heatmap.sim command outputs a .svg file for each calculator you choose at each label you specify.\n";
-               helpString += "The second way to use the heatmap.sim command is with a distance file representing the distance bewteen your groups. \n";
-               helpString += "Using the command this way, the phylip or column parameter are required, and only one may be used.  If you use a column file the name filename is required. \n";
-               helpString += "The heatmap.sim command should be in the following format: heatmap.sim(phylip=yourDistanceFile).\n";
-               helpString += "Example heatmap.sim(phylip=amazonGroups.dist).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-HeatMapSimCommand::HeatMapSimCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["svg"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-HeatMapSimCommand::HeatMapSimCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                       
-               //allow user to run help
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["svg"] = tempOutNames;
-                       
-                       format = "";
-                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-
-                       //required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  format = "phylip";      inputfile = phylipfile; m-> setPhylipFile(phylipfile); if (outputDir == "") { outputDir += m->hasPath(phylipfile); }  }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { abort = true; } 
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  format = "column";      inputfile = columnfile; m->setColumnFile(columnfile); if (outputDir == "") { outputDir += m->hasPath(columnfile); } }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; } 
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "shared";      inputfile = sharedfile; m->setSharedFile(sharedfile); if (outputDir == "") { outputDir += m->hasPath(sharedfile); } }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       
-                       //error checking on files                       
-                       if ((sharedfile == "") && ((phylipfile == "") && (columnfile == "")))   { 
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { format = "shared"; inputfile = sharedfile; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       //is there are current file available for either of these?
-                                       //give priority to column, then phylip
-                                       columnfile = m->getColumnFile(); 
-                                       if (columnfile != "") {  format = "column"; inputfile = columnfile; m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               phylipfile = m->getPhylipFile(); 
-                                               if (phylipfile != "") { format = "phylip";  inputfile = phylipfile; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("No valid current files. You must provide a shared or phylip or column file."); m->mothurOutEndLine(); 
-                                                       abort = true;
-                                               }
-                                       }
-                               }
-                       }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the heatmap.sim command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if (columnfile != "") {
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                                                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "jest-thetayc";  }
-                       else { 
-                               if (calc == "default")  {  calc = "jest-thetayc";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-                               
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "fontsize", false);                          if (temp == "not found") { temp = "24"; }
-                       m->mothurConvert(temp, fontsize);
-                       
-                       if (abort == false) {
-                               ValidCalculators validCalculator;
-                       
-                               int i;
-                               for (i=0; i<Estimators.size(); i++) {
-                                       if (validCalculator.isValidCalculator("heat", Estimators[i]) == true) { 
-                                               if (Estimators[i] == "jabund") {        
-                                                       heatCalculators.push_back(new JAbund());
-                                               }else if (Estimators[i] == "sorabund") { 
-                                                       heatCalculators.push_back(new SorAbund());
-                                               }else if (Estimators[i] == "jclass") { 
-                                                       heatCalculators.push_back(new Jclass());
-                                               }else if (Estimators[i] == "sorclass") { 
-                                                       heatCalculators.push_back(new SorClass());
-                                               }else if (Estimators[i] == "jest") { 
-                                                       heatCalculators.push_back(new Jest());
-                                               }else if (Estimators[i] == "sorest") { 
-                                                       heatCalculators.push_back(new SorEst());
-                                               }else if (Estimators[i] == "thetayc") { 
-                                                       heatCalculators.push_back(new ThetaYC());
-                                               }else if (Estimators[i] == "thetan") { 
-                                                       heatCalculators.push_back(new ThetaN());
-                                               }else if (Estimators[i] == "morisitahorn") { 
-                                                       heatCalculators.push_back(new MorHorn());
-                                               }else if (Estimators[i] == "braycurtis") { 
-                                                       heatCalculators.push_back(new BrayCurtis());
-                                               }
-                                       }
-                               }
-                               
-                       }
-               }
-
-                               
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "HeatMapSimCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int HeatMapSimCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               heatmap = new HeatMapSim(outputDir, inputfile, fontsize);
-               
-               if (format == "shared") {
-                       runCommandShared();
-               }else{  runCommandDist();       }
-               
-               delete heatmap;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } outputTypes.clear(); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int HeatMapSimCommand::runCommandShared() {
-       try {
-               //if the users entered no valid calculators don't execute command
-               if (heatCalculators.size() == 0) { m->mothurOut("No valid calculators."); m->mothurOutEndLine(); return 0; }
-               
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-                       
-               if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); return 0;}
-                               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (m->control_pressed) {  delete input;  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  m->clearGroups(); return 0; }
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { delete input;  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups(); return 0; }
-
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-       
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }
-                                       
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                               
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                       
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);                              
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
-                                       
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                               
-                       //prevent memory leak
-                        
-                       lastLabel = lookup[0]->getLabel();                      
-
-                       //get next line to process
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-
-               }
-               
-                       
-               if (m->control_pressed) {  delete input;  m->clearGroups();  return 0; }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) {  delete input;  m->clearGroups(); return 0; }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) { delete lookup[i]; } } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);                              
-
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       vector<string> outfilenames = heatmap->getPic(lookup, heatCalculators);
-                       for(int i = 0; i < outfilenames.size(); i++) { outputNames.push_back(outfilenames[i]); outputTypes["svg"].push_back(outfilenames[i]);  }
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               }
-               
-               if (m->control_pressed) {  delete input;  m->clearGroups(); return 0; }
-                       
-               //reset groups parameter
-               m->clearGroups();  
-                       
-               delete input;  
-       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "runCommandShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int HeatMapSimCommand::runCommandDist() {
-       try {
-       
-               vector< vector<double> > matrix;
-               vector<string> names;
-               ifstream in;
-               
-               //read distance file and create distance vector and names vector
-               if (format == "phylip") {
-                       //read phylip file
-                       m->openInputFile(phylipfile, in);
-                       
-                       string name;
-                       int numSeqs;
-                       in >> numSeqs >> name; 
-                       
-                       //save name
-                       names.push_back(name);
-               
-                       //resize the matrix and fill with zeros
-                       matrix.resize(numSeqs); 
-                       for(int i = 0; i < numSeqs; i++) {
-                               matrix[i].resize(numSeqs, 0.0);
-                       }
-                                       
-                       //determine if matrix is square or lower triangle
-                       //if it is square read the distances for the first sequence
-                       char d;
-                       bool square;
-                       while((d=in.get()) != EOF){
-                               
-                               //is d a number meaning its square
-                               if(isalnum(d)){ 
-                                       square = true;
-                                       in.putback(d);
-                                       
-                                       for(int i=0;i<numSeqs;i++){
-                                               in >> matrix[0][i];
-                                       }
-                                       break;
-                               }
-                               
-                               //is d a line return meaning its lower triangle
-                               if(d == '\n'){
-                                       square = false;
-                                       break;
-                               }
-                       }
-                       
-                       //read rest of matrix
-                       if (square == true) { 
-                               for(int i=1;i<numSeqs;i++){
-                                       in >> name;             
-                                       names.push_back(name);
-                                       
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       for(int j=0;j<numSeqs;j++) { in >> matrix[i][j];  }
-                                       m->gobble(in);
-                               }
-                       }else { 
-                               double dist;
-                               for(int i=1;i<numSeqs;i++){
-                                       in >> name;     
-                                       names.push_back(name);  
-                                       
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       for(int j=0;j<i;j++){
-                                               in >> dist;
-                                               matrix[i][j] = dist;  matrix[j][i] = dist;
-                                       }
-                                       m->gobble(in);
-                               }
-                       }
-                       in.close();
-               }else {
-                       //read names file
-                       NameAssignment* nameMap = new NameAssignment(namefile);
-                       nameMap->readMap();
-                       
-                       //put names in order in vector
-                       for (int i = 0; i < nameMap->size(); i++) {
-                               names.push_back(nameMap->get(i));
-                       }
-                       
-                       //resize matrix
-                       matrix.resize(nameMap->size());
-                       for (int i = 0; i < nameMap->size(); i++) {
-                               matrix[i].resize(nameMap->size(), 0.0);
-                       }
-                       
-                       //read column file
-                       string first, second;
-                       double dist;
-                       m->openInputFile(columnfile, in);
-                       
-                       while (!in.eof()) {
-                               in >> first >> second >> dist; m->gobble(in);
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               map<string, int>::iterator itA = nameMap->find(first);
-                               map<string, int>::iterator itB = nameMap->find(second);
-                               
-                               if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + first + "' was not found in the names file, please correct\n"); exit(1);  }
-                               if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + second + "' was not found in the names file, please correct\n"); exit(1);  }
-                               
-                               //save distance
-                               matrix[itA->second][itB->second] = dist;
-                               matrix[itB->second][itA->second] = dist;
-                       }
-                       in.close();
-                       
-                       delete nameMap;
-               }
-               
-               
-               string outputFileName = heatmap->getPic(matrix, names);
-               outputNames.push_back(outputFileName); //vector<vector<double>>, vector<string>
-               outputTypes["svg"].push_back(outputFileName);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HeatMapSimCommand", "runCommandDist");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
-
-
diff --git a/heatmapsimcommand.h b/heatmapsimcommand.h
deleted file mode 100644 (file)
index 74e20be..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef HEATMAPSIMCOMMAND_H
-#define HEATMAPSIMCOMMAND_H
-
-/*
- *  heatmapsimcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "validcalculator.h"
-#include "heatmapsim.h"
-#include "nameassignment.hpp"
-
-class HeatMapSimCommand : public Command {
-
-public:
-       HeatMapSimCommand(string);
-       HeatMapSimCommand();
-       ~HeatMapSimCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "heatmap.sim";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Heatmap.sim"; }
-       string getDescription()         { return "generate a heatmap indicating the pairwise distance between multiple samples using a variety of calculators"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       InputData* input;
-       vector<SharedRAbundVector*> lookup;
-       vector<Calculator*> heatCalculators;
-       HeatMapSim* heatmap;
-       OptionParser* parser;
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-       string format, groups, label, calc, sharedfile, phylipfile, columnfile, namefile, outputDir, inputfile;
-       vector<string> Estimators, Groups, outputNames;
-       int fontsize;
-       
-       int runCommandShared();
-       int runCommandDist();
-
-
-};
-
-#endif
-
diff --git a/heip.cpp b/heip.cpp
deleted file mode 100644 (file)
index 7ae285d..0000000
--- a/heip.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *  heip.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "heip.h"
-#include "shannon.h"
-
-/***********************************************************************/
-
-EstOutput Heip::getValues(SAbundVector* rank){
-       try {
-               data.resize(1,0.0000);
-               vector<double> shanData(3,0);
-               Shannon* shannon = new Shannon();
-               shanData = shannon->getValues(rank);
-               
-               long int sobs = rank->getNumBins();
-               if(sobs > 1){
-                       data[0] = (exp(shanData[0])-1) / (sobs - 1);;
-               }
-               else{
-                       data[0] = 1;
-               }
-               
-               delete shannon;
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Heip", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/heip.h b/heip.h
deleted file mode 100644 (file)
index 806b299..0000000
--- a/heip.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef HEIP
-#define HEIP
-
-/*
- *  heip.h
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Heip : public Calculator  {
-       
-public:
-       Heip() : Calculator("heip", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Heip"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/hellinger.cpp b/hellinger.cpp
deleted file mode 100644 (file)
index 43d33de..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  hellinger.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "hellinger.h"
-
-/***********************************************************************/
-EstOutput Hellinger::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumA = 0.0;
-               double sumB = 0.0;
-               
-               //calc the 2 denominators
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       sumA += shared[0]->getAbundance(i);
-                       sumB += shared[1]->getAbundance(i);
-               }
-               
-               
-               //calc sum
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       double term1 = sqrt((Aij / sumA));
-                       double term2 = sqrt((Bij / sumB));
-                       
-                       sum += ((term1 - term2) * (term1 - term2));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Hellinger", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
diff --git a/hellinger.h b/hellinger.h
deleted file mode 100644 (file)
index a06cfce..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef HELLINGER_H
-#define HELLINGER_H
-
-/*
- *  hellinger.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Hellinger : public Calculator  {
-       
-public:
-       Hellinger() :  Calculator("hellinger", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Hellinger"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
diff --git a/helpcommand.cpp b/helpcommand.cpp
deleted file mode 100644 (file)
index 47d04f9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *  helpcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "helpcommand.h"
-
-//**********************************************************************************************************************
-
-HelpCommand::HelpCommand(string option)  {     
-       validCommands = CommandFactory::getInstance();  
-}
-//**********************************************************************************************************************
-int HelpCommand::execute(){
-       try {
-               validCommands->printCommands(cout);
-               m->mothurOut("For more information about a specific command type 'commandName(help)' i.e. 'read.dist(help)'"); m->mothurOutEndLine();
-       
-               m->mothurOutEndLine(); m->mothurOut("For further assistance please refer to the Mothur manual on our wiki at http://www.mothur.org/wiki, or contact Pat Schloss at mothur.bugs@gmail.com.\n");
-       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HelpCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************/
diff --git a/helpcommand.h b/helpcommand.h
deleted file mode 100644 (file)
index cba0708..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef HELPCOMMAND_H
-#define HELPCOMMAND_H
-/*
- *  helpcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class is designed to aid the user in running mothur. */
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-class HelpCommand : public Command {
-       
-public:
-       HelpCommand(string);
-       HelpCommand() {}
-       ~HelpCommand(){}
-       
-       vector<string> setParameters()  { return outputNames;   } //dummy, doesn't really do anything   
-       string getCommandName()                 { return "help";                }
-       string getCommandCategory()             { return "Hidden";              }
-       string getHelpString() { return "For more information about a specific command type 'commandName(help)' i.e. 'cluster(help)'"; }        
-       string getCitation() { return "no citation"; }
-       string getDescription()         { return "help"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       CommandFactory* validCommands;
-       vector<string> outputNames;     
-               
-};
-#endif
diff --git a/homovacommand.cpp b/homovacommand.cpp
deleted file mode 100644 (file)
index 9b7ec9f..0000000
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- *  homovacommand.cpp
- *  mothur
- *
- *  Created by westcott on 2/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "homovacommand.h"
-#include "groupmap.h"
-#include "readphylipvector.h"
-
-//**********************************************************************************************************************
-vector<string> HomovaCommand::setParameters(){ 
-       try {
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter palpha("alpha", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(palpha);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string HomovaCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "Referenced: Stewart CN, Excoffier L (1996). Assessing population genetic structure and variability with RAPD data: Application to Vaccinium macrocarpon (American Cranberry). J Evol Biol 9: 153-71.\n";
-               helpString += "The homova command outputs a .homova file. \n";
-               helpString += "The homova command parameters are phylip, iters, and alpha.  The phylip and design parameters are required, unless valid current files exist.\n";
-               helpString += "The design parameter allows you to assign your samples to groups when you are running homova. It is required. \n";
-               helpString += "The design file looks like the group file.  It is a 2 column tab delimited file, where the first column is the sample name and the second column is the group the sample belongs to.\n";
-               helpString += "The iters parameter allows you to set number of randomization for the P value.  The default is 1000. \n";
-               helpString += "The homova command should be in the following format: homova(phylip=file.dist, design=file.design).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e. 1000).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-HomovaCommand::HomovaCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["homova"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "HomovaCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-HomovaCommand::HomovaCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["homova"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       phylipFileName = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipFileName == "not open") { phylipFileName = ""; abort = true; }
-                       else if (phylipFileName == "not found") { 
-                               //if there is a current phylip file, use it
-                               phylipFileName = m->getPhylipFile(); 
-                               if (phylipFileName != "") { m->mothurOut("Using " + phylipFileName + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                               
-                       }else { m->setPhylipFile(phylipFileName); }     
-                       
-                       //check for required parameters
-                       designFileName = validParameter.validFile(parameters, "design", true);
-                       if (designFileName == "not open") { abort = true; }
-                       else if (designFileName == "not found") {
-                               //if there is a current design file, use it
-                               designFileName = m->getDesignFile(); 
-                               if (designFileName != "") { m->mothurOut("Using " + designFileName + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current design file and the design parameter is required."); m->mothurOutEndLine(); abort = true; }                                                           
-                       }else { m->setDesignFile(designFileName); }     
-                       
-                       string temp = validParameter.validFile(parameters, "iters", false);
-                       if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "alpha", false);
-                       if (temp == "not found") { temp = "0.05"; }
-                       m->mothurConvert(temp, experimentwiseAlpha); 
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "HomovaCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int HomovaCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read design file
-               designMap = new GroupMap(designFileName);
-               designMap->readDesignMap();
-               
-               if (outputDir == "") { outputDir = m->hasPath(phylipFileName); }
-               
-               //read in distance matrix and square it
-               ReadPhylipVector readMatrix(phylipFileName);
-               vector<string> sampleNames = readMatrix.read(distanceMatrix);
-               
-               for(int i=0;i<distanceMatrix.size();i++){
-                       for(int j=0;j<i;j++){
-                               distanceMatrix[i][j] *= distanceMatrix[i][j];   
-                       }
-               }
-               
-               //link designMap to rows/columns in distance matrix
-               map<string, vector<int> > origGroupSampleMap;
-               for(int i=0;i<sampleNames.size();i++){
-                       string group = designMap->getGroup(sampleNames[i]);
-                       
-                       if (group == "not found") {
-                               m->mothurOut("[ERROR]: " + sampleNames[i] + " is not in your design file, please correct."); m->mothurOutEndLine(); m->control_pressed = true;
-                       }else { origGroupSampleMap[group].push_back(i); }
-               }
-               int numGroups = origGroupSampleMap.size();
-               
-               if (m->control_pressed) { delete designMap; return 0; }
-               
-               //create a new filename
-               ofstream HOMOVAFile;
-               string HOMOVAFileName = outputDir + m->getRootName(m->getSimpleName(phylipFileName))  + "homova";                               
-               m->openOutputFile(HOMOVAFileName, HOMOVAFile);
-               outputNames.push_back(HOMOVAFileName); outputTypes["homova"].push_back(HOMOVAFileName);
-               
-               HOMOVAFile << "HOMOVA\tBValue\tP-value\tSSwithin/(Ni-1)_values" << endl;
-               m->mothurOut("HOMOVA\tBValue\tP-value\tSSwithin/(Ni-1)_values\n");
-               
-               double fullHOMOVAPValue = runHOMOVA(HOMOVAFile, origGroupSampleMap, experimentwiseAlpha);
-
-               if(fullHOMOVAPValue <= experimentwiseAlpha && numGroups > 2){
-                       
-                       int numCombos = numGroups * (numGroups-1) / 2;
-                       double pairwiseAlpha = experimentwiseAlpha / (double) numCombos;
-                       
-                       map<string, vector<int> >::iterator itA;
-                       map<string, vector<int> >::iterator itB;
-                       
-                       for(itA=origGroupSampleMap.begin();itA!=origGroupSampleMap.end();itA++){
-                               itB = itA;itB++;
-                               for(;itB!=origGroupSampleMap.end();itB++){
-                                       map<string, vector<int> > pairwiseGroupSampleMap;
-                                       pairwiseGroupSampleMap[itA->first] = itA->second;
-                                       pairwiseGroupSampleMap[itB->first] = itB->second;
-                                       
-                                       runHOMOVA(HOMOVAFile, pairwiseGroupSampleMap, pairwiseAlpha);
-                               }                       
-                       }
-                       HOMOVAFile << endl;
-                       m->mothurOutEndLine();
-                       
-                       m->mothurOut("Experiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-                       m->mothurOut("Pair-wise error rate (Bonferroni): " + toString(pairwiseAlpha) + '\n');
-               }
-               else{
-                       m->mothurOut("Experiment-wise error rate: " + toString(experimentwiseAlpha) + '\n');
-               }
-               
-               m->mothurOut("If you have borderline P-values, you should try increasing the number of iterations\n");
-               
-               delete designMap;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double HomovaCommand::runHOMOVA(ofstream& HOMOVAFile, map<string, vector<int> > groupSampleMap, double alpha){
-       try {
-               map<string, vector<int> >::iterator it;
-               int numGroups = groupSampleMap.size();
-               
-               vector<double> ssWithinOrigVector;
-               double bValueOrig = calcBValue(groupSampleMap, ssWithinOrigVector);
-               
-               double counter = 0;
-               for(int i=0;i<iters;i++){
-                       vector<double> ssWithinRandVector;
-                       map<string, vector<int> > randomizedGroup = getRandomizedGroups(groupSampleMap);
-                       double bValueRand = calcBValue(randomizedGroup, ssWithinRandVector);
-                       if(bValueRand > bValueOrig){    counter++;      }
-               }
-               
-               double pValue = (double) counter / (double) iters;
-               string pString = "";
-               if(pValue < 1/(double)iters){   pString = '<' + toString(1/(double)iters);      }
-               else                                            {       pString = toString(pValue);                                     }
-               
-               
-               //print homova table
-               it = groupSampleMap.begin();
-               HOMOVAFile << it->first;
-               m->mothurOut(it->first);
-               it++;
-               for(;it!=groupSampleMap.end();it++){
-                       HOMOVAFile << '-' << it->first;
-                       m->mothurOut('-' + it->first);
-               }
-
-               HOMOVAFile << '\t' << bValueOrig << '\t' << pString;
-               m->mothurOut('\t' + toString(bValueOrig) + '\t' + pString);
-               
-               if(pValue < alpha){
-                       HOMOVAFile << "*";
-                       m->mothurOut("*");
-               }
-
-               for(int i=0;i<numGroups;i++){
-                       HOMOVAFile << '\t' << ssWithinOrigVector[i];
-                       m->mothurOut('\t' + toString(ssWithinOrigVector[i]));
-               }
-               HOMOVAFile << endl;
-               m->mothurOutEndLine();
-               
-               return pValue;  
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "runHOMOVA");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double HomovaCommand::calcSigleSSWithin(vector<int> sampleIndices) {
-       try {
-               double ssWithin = 0.0;
-               int numSamplesInGroup = sampleIndices.size();
-               
-               for(int i=0;i<numSamplesInGroup;i++){
-                       int row = sampleIndices[i];
-                       
-                       for(int j=0;j<numSamplesInGroup;j++){
-                               int col = sampleIndices[j];
-                               
-                               if(col < row){
-                                       ssWithin += distanceMatrix[row][col];
-                               }
-                               
-                       }
-               }
-               
-               ssWithin /= numSamplesInGroup;
-               return ssWithin;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "calcSigleSSWithin");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-double HomovaCommand::calcBValue(map<string, vector<int> > groupSampleMap, vector<double>& ssWithinVector) {
-       try {
-
-               map<string, vector<int> >::iterator it;
-               
-               double numGroups = (double)groupSampleMap.size();
-               ssWithinVector.resize(numGroups, 0);
-               
-               double totalNumSamples = 0;
-               double ssWithinFull;
-               double secondTermSum = 0;
-               double inverseOneMinusSum = 0;
-               int index = 0;
-               
-               ssWithinVector.resize(numGroups, 0);
-               for(it = groupSampleMap.begin();it!=groupSampleMap.end();it++){
-                       int numSamplesInGroup = it->second.size();
-                       totalNumSamples += numSamplesInGroup;
-                       
-                       ssWithinVector[index] = calcSigleSSWithin(it->second);
-                       ssWithinFull += ssWithinVector[index];
-                       
-                       secondTermSum += (numSamplesInGroup - 1) * log(ssWithinVector[index] / (double)(numSamplesInGroup - 1));
-                       inverseOneMinusSum += 1.0 / (double)(numSamplesInGroup - 1);
-                       
-                       ssWithinVector[index] /= (double)(numSamplesInGroup - 1); //this line is only for output purposes to scale SSw by the number of samples in the group
-                       index++;
-               }
-               
-               double B = (totalNumSamples - numGroups) * log(ssWithinFull/(totalNumSamples-numGroups)) - secondTermSum;
-               double denomintor = 1 + 1.0/(3.0 * (numGroups - 1.0)) * (inverseOneMinusSum - 1.0 / (double) (totalNumSamples - numGroups));
-               B /= denomintor;
-               
-               return B;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "HomovaCommand", "calcBValue");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-map<string, vector<int> > HomovaCommand::getRandomizedGroups(map<string, vector<int> > origMapping){
-       try{
-               vector<int> sampleIndices;
-               vector<int> samplesPerGroup;
-               
-               map<string, vector<int> >::iterator it;
-               for(it=origMapping.begin();it!=origMapping.end();it++){
-                       vector<int> indices = it->second;
-                       samplesPerGroup.push_back(indices.size());
-                       sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
-               }
-               
-               random_shuffle(sampleIndices.begin(), sampleIndices.end());
-               
-               int index = 0;
-               map<string, vector<int> > randomizedGroups = origMapping;
-               for(it=randomizedGroups.begin();it!=randomizedGroups.end();it++){
-                       for(int i=0;i<it->second.size();i++){
-                               it->second[i] = sampleIndices[index++];                         
-                       }
-               }
-               
-               return randomizedGroups;                
-       }
-       catch (exception& e) {
-               m->errorOut(e, "AmovaCommand", "randomizeGroups");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/homovacommand.h b/homovacommand.h
deleted file mode 100644 (file)
index 4afaeb8..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef HOMOVACOMMAND_H
-#define HOMOVACOMMAND_H
-
-/*
- *  homovacommand.h
- *  mothur
- *
- *  Created by westcott on 2/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-//class GlobalData;
-class GroupMap;
-
-class HomovaCommand : public Command {
-       
-public:
-       HomovaCommand(string);
-       HomovaCommand();
-       ~HomovaCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "homova";                                      }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Stewart CN, Excoffier L (1996). Assessing population genetic structure and variability with RAPD data: Application to Vaccinium macrocarpon (American Cranberry). J Evol Biol 9: 153-71. \nhttp://www.mothur.org/wiki/Homova"; }
-       string getDescription()         { return "homova"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       double runHOMOVA(ofstream& , map<string, vector<int> >, double);
-       double calcSigleSSWithin(vector<int>);
-       double calcBValue(map<string, vector<int> >, vector<double>&);
-       map<string, vector<int> > getRandomizedGroups(map<string, vector<int> >);
-
-       bool abort;
-       vector<string> outputNames;
-
-       string outputDir, inputDir, designFileName, phylipFileName;
-       GroupMap* designMap;
-       vector< vector<double> > distanceMatrix;
-       int iters;
-       double experimentwiseAlpha;
-};
-
-#endif
diff --git a/ignoregaps.h b/ignoregaps.h
deleted file mode 100644 (file)
index 894f92d..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef IGNOREGAPS_H
-#define IGNOREGAPS_H
-/*
- *  ignoregaps.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "dist.h"
-
-/**************************************************************************************************/
-
-//     this class calculates distances by ignoring all gap characters.  so if seq a has an "A" and seq
-//     b has a '-', there is no penalty
-
-class ignoreGaps : public Dist {
-       
-public:
-       
-       ignoreGaps() {}
-       
-       void calcDist(Sequence A, Sequence B){          
-               int diff = 0;
-               int length = 0;
-               int start = 0;
-               bool overlap = false;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-               int alignLength = seqA.length();
-               
-               for(int i=0;i<alignLength;i++){
-                       if(seqA[i] != '.' && seqB[i] != '.'){
-                               start = i;
-                               overlap = true;
-                               break;
-                       }
-               }
-               
-               for(int i=start; i<alignLength; i++){
-                       if(seqA[i] == '.' || seqB[i] == '.'){
-                               break;
-                       }
-                       else if((seqA[i] != '-' && seqB[i] != '-')){
-                               if(seqA[i] != seqB[i]){
-                                       diff++;
-                               }
-                               length++;
-                       }
-               }
-               
-               //non-overlapping sequences
-               if (!overlap) { length = 0; }
-
-               if(length == 0)         {       dist = 1.0000;                                                          }
-               else                            {       dist = ((double)diff  / (double)length);        }
-               
-       }
-       
-};
-
-/**************************************************************************************************/
-#endif
-
diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp
deleted file mode 100644 (file)
index 97f480e..0000000
+++ /dev/null
@@ -1,1388 +0,0 @@
-/*
- *  indicatorcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "indicatorcommand.h"
-#include "sharedutilities.h"
-
-
-//**********************************************************************************************************************
-vector<string> IndicatorCommand::setParameters(){      
-       try {
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pdesign("design", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none",false,false); parameters.push_back(pdesign);
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(pshared);  
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRel", "SharedRel", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter ptree("tree", "InputTypes", "", "", "TreeDesign", "TreeDesign", "none",false,false); parameters.push_back(ptree);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string IndicatorCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The indicator command can be run in 3 ways: with a shared or relabund file and a design file, or with a shared or relabund file and a tree file, or with a shared or relabund file, tree file and design file. \n";
-               helpString += "The indicator command outputs a .indicator.summary file and a .indicator.tre if a tree is given. \n";
-               helpString += "The new tree contains labels at each internal node.  The label is the node number so you can relate the tree to the summary file.\n";
-               helpString += "The summary file lists the indicator value for each OTU for each node.\n";
-               helpString += "The indicator command parameters are tree, groups, shared, relabund, design and label. \n";
-               helpString += "The design parameter allows you to relate the tree to the shared or relabund file, if your tree contains the grouping names, or if no tree is provided to group your groups into groupings.\n";                  
-               helpString += "The groups parameter allows you to specify which of the groups in your shared or relabund you would like analyzed, or if you provide a design file the groups in your design file.  The groups may be entered separated by dashes.\n";
-               helpString += "The label parameter indicates at what distance your tree relates to the shared or relabund.\n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-               helpString += "The iters parameter allows you to set number of randomization for the P value.  The default is 1000.";
-               helpString += "The indicator command should be used in the following format: indicator(tree=test.tre, shared=test.shared, label=0.03)\n";
-               helpString += "Note: No spaces between parameter labels (i.e. tree), '=' and parameters (i.e.yourTreefile).\n"; 
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-IndicatorCommand::IndicatorCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["tree"] = tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "IndicatorCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-IndicatorCommand::IndicatorCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       m->runParse = true;
-                       m->clearGroups();
-                       m->clearAllGroups();
-                       m->Treenames.clear();
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["tree"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { treefile = ""; abort = true; }
-                       else if (treefile == "not found") { treefile = "";      }               
-                       else { m->setTreeFile(treefile); }      
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; }
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else { inputFileName = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { abort = true; }
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else { inputFileName = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { designfile = ""; abort = true; }
-                       else if (designfile == "not found") { designfile = ""; }
-                       else { m->setDesignFile(designfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "";  Groups.push_back("all"); }
-                       else { m->splitAtDash(groups, Groups);  }                       
-                       m->setGroups(Groups);
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }  
-                       
-                       string temp = validParameter.validFile(parameters, "iters", false);             if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       if ((relabundfile == "") && (sharedfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to shared, then relabund
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") {  inputFileName = sharedfile; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       relabundfile = m->getRelAbundFile(); 
-                                       if (relabundfile != "") {  inputFileName = relabundfile; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a shared or relabund."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       
-                       if ((designfile == "") && (treefile == "")) { 
-                               treefile = m->getTreeFile(); 
-                               if (treefile != "") {  m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       designfile = m->getDesignFile(); 
-                                       if (designfile != "") {  m->mothurOut("Using " + designfile + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("[ERROR]: You must provide either a tree or design file."); m->mothurOutEndLine(); abort = true; 
-                                       }
-                               }
-                       }
-                       
-                       if ((relabundfile != "") && (sharedfile != "")) { m->mothurOut("[ERROR]: You may not use both a shared and relabund file."); m->mothurOutEndLine(); abort = true;  }
-                       
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "IndicatorCommand");         
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int IndicatorCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               
-               int start = time(NULL);
-       
-               //read designfile if given and set up groups for read of sharedfiles
-               if (designfile != "") {
-                       designMap = new GroupMap(designfile);
-                       designMap->readDesignMap();
-                       
-                       //fill Groups - checks for "all" and for any typo groups
-                       SharedUtil util;
-                       vector<string> nameGroups = designMap->getNamesOfGroups();
-                       util.setGroups(Groups, nameGroups);
-                       designMap->setNamesOfGroups(nameGroups);
-                       
-                       //loop through the Groups and fill Globaldata's Groups with the design file info
-                       vector<string> namesSeqs = designMap->getNamesSeqs(Groups);
-                       m->setGroups(namesSeqs);
-               }
-       
-               /***************************************************/
-               // use smart distancing to get right sharedRabund  //
-               /***************************************************/
-               if (sharedfile != "") {  
-                       getShared(); 
-                       if (m->control_pressed) { if (designfile != "") { delete designMap; } for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } return 0; }
-                       if (lookup[0] == NULL) { m->mothurOut("[ERROR] reading shared file."); m->mothurOutEndLine(); return 0; }
-               }else { 
-                       getSharedFloat(); 
-                       if (m->control_pressed) {  if (designfile != "") { delete designMap; } for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } return 0; }
-                       if (lookupFloat[0] == NULL) { m->mothurOut("[ERROR] reading relabund file."); m->mothurOutEndLine(); return 0; }
-               }
-               
-               //reset groups if needed
-               if (designfile != "") { m->setGroups(Groups); }
-                       
-               /***************************************************/
-               //    reading tree info                                                    //
-               /***************************************************/
-               if (treefile != "") {
-                       string groupfile = ""; 
-                       m->setTreeFile(treefile);
-                       Tree* tree = new Tree(treefile); delete tree;  //extracts names from tree to make faked out groupmap
-                       treeMap = new TreeMap();
-                       bool mismatch = false;
-                               
-                       for (int i = 0; i < m->Treenames.size(); i++) { 
-                               //sanity check - is this a group that is not in the sharedfile?
-                               if (designfile == "") {
-                                       if (!(m->inUsersGroups(m->Treenames[i], m->getAllGroups()))) {
-                                               m->mothurOut("[ERROR]: " + m->Treenames[i] + " is not a group in your shared or relabund file."); m->mothurOutEndLine();
-                                               mismatch = true;
-                                       }
-                                       treeMap->addSeq(m->Treenames[i], "Group1"); 
-                               }else{
-                                       vector<string> myGroups; myGroups.push_back(m->Treenames[i]);
-                                       vector<string> myNames = designMap->getNamesSeqs(myGroups);
-                                       
-                                       for(int k = 0; k < myNames.size(); k++) {
-                                               if (!(m->inUsersGroups(myNames[k], m->getAllGroups()))) {
-                                                       m->mothurOut("[ERROR]: " + myNames[k] + " is not a group in your shared or relabund file."); m->mothurOutEndLine();
-                                                       mismatch = true;
-                                               }
-                                       }
-                                       treeMap->addSeq(m->Treenames[i], "Group1");
-                               }
-                       }
-                       
-                       if ((designfile != "") && (m->Treenames.size() != Groups.size())) { cout << Groups.size() << '\t' << m->Treenames.size() << endl; m->mothurOut("[ERROR]: You design file does not match your tree, aborting."); m->mothurOutEndLine(); mismatch = true; }
-                                       
-                       if (mismatch) { //cleanup and exit
-                               if (designfile != "") { delete designMap; }
-                               if (sharedfile != "") {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } }
-                               else { for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } }
-                               delete treeMap;
-                               return 0;
-                       }
-                
-                       read = new ReadNewickTree(treefile);
-                       int readOk = read->read(treeMap); 
-                       
-                       if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine(); delete treeMap; delete read; return 0; }
-                       
-                       vector<Tree*> T = read->getTrees();
-                       
-                       delete read;
-                       
-                       if (m->control_pressed) { 
-                               if (designfile != "") { delete designMap; }
-                               if (sharedfile != "") {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } }
-                               else { for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } }
-                               for (int i = 0; i < T.size(); i++) {  delete T[i];  }  delete treeMap; return 0; 
-                       }
-            
-                       map<string, string> nameMap;    
-                       T[0]->assembleTree(nameMap);
-                                       
-                       /***************************************************/
-                       //    create ouptut tree - respecting pickedGroups //
-                       /***************************************************/
-                       Tree* outputTree = new Tree(m->getNumGroups(), treeMap); 
-                       
-                       outputTree->getSubTree(T[0], m->getGroups());
-                       outputTree->assembleTree(nameMap);
-                               
-                       //no longer need original tree, we have output tree to use and label
-                       for (int i = 0; i < T.size(); i++) {  delete T[i];  } 
-                       
-                       if (m->control_pressed) { 
-                               if (designfile != "") { delete designMap; }
-                               if (sharedfile != "") {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } }
-                               else { for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } }
-                               delete outputTree; delete treeMap;  return 0; 
-                       }
-                       
-                       /***************************************************/
-                       //              get indicator species values                       //
-                       /***************************************************/
-                       GetIndicatorSpecies(outputTree);
-                       delete outputTree; delete treeMap;
-                       
-               }else { //run with design file only
-                       //get indicator species
-                       GetIndicatorSpecies();
-               }
-               
-               if (designfile != "") { delete designMap; }
-               if (sharedfile != "") {  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } }
-               else { for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               //set tree file as new current treefile
-               if (treefile != "") {
-                       string current = "";
-                       itTypes = outputTypes.find("tree");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); }
-                       }
-               }
-               
-               m->mothurOutEndLine(); m->mothurOutEndLine(); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to find the indicator species."); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "execute");  
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//divide shared or relabund file by groupings in the design file
-//report all otu values to file
-int IndicatorCommand::GetIndicatorSpecies(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary";
-               outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               m->mothurOutEndLine(); m->mothurOut("Species\tIndicatorValue\tpValue\n");
-               
-               int numBins = 0;
-               if (sharedfile != "") { numBins = lookup[0]->getNumBins(); }
-               else { numBins = lookupFloat[0]->getNumBins(); }
-               
-               if (m->control_pressed) { out.close(); return 0; }
-                       
-               /*****************************************************/
-               //create vectors containing rabund info                          //
-               /*****************************************************/
-                       
-               vector<float> indicatorValues; //size of numBins
-               vector<float> pValues;
-               map< vector<int>, vector<int> > randomGroupingsMap; //maps location in groupings to location in groupings, ie, [0][0] -> [1][2]. This is so we don't have to actually move the sharedRabundVectors.
-                       
-               if (sharedfile != "") {
-                       vector< vector<SharedRAbundVector*> > groupings;
-                       set<string> groupsAlreadyAdded;
-                       vector<SharedRAbundVector*> subset;
-                       
-                       //for each grouping
-                       for (int i = 0; i < (designMap->getNamesOfGroups()).size(); i++) {
-                               
-                               for (int k = 0; k < lookup.size(); k++) {
-                                       //are you from this grouping?
-                                       if (designMap->getGroup(lookup[k]->getGroup()) == (designMap->getNamesOfGroups())[i]) {
-                                               subset.push_back(lookup[k]);
-                                               groupsAlreadyAdded.insert(lookup[k]->getGroup());
-                                       }
-                               }
-                               if (subset.size() != 0) { groupings.push_back(subset); }
-                               subset.clear();
-                       }
-                               
-                       if (groupsAlreadyAdded.size() != lookup.size()) {  m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); }
-                               
-                       indicatorValues = getValues(groupings, randomGroupingsMap);
-                       
-                       pValues = getPValues(groupings, randomGroupingsMap, lookup.size(), indicatorValues);                            
-               }else {
-                       vector< vector<SharedRAbundFloatVector*> > groupings;
-                       set<string> groupsAlreadyAdded;
-                       vector<SharedRAbundFloatVector*> subset;
-                       
-                       //for each grouping
-                       for (int i = 0; i < (designMap->getNamesOfGroups()).size(); i++) {
-                               for (int k = 0; k < lookupFloat.size(); k++) {
-                                       //are you from this grouping?
-                                       if (designMap->getGroup(lookupFloat[k]->getGroup()) == (designMap->getNamesOfGroups())[i]) {
-                                               subset.push_back(lookupFloat[k]);
-                                               groupsAlreadyAdded.insert(lookupFloat[k]->getGroup());
-                                       }
-                               }
-                               if (subset.size() != 0) { groupings.push_back(subset); }
-                               subset.clear();
-                       }
-                       
-                       if (groupsAlreadyAdded.size() != lookupFloat.size()) {  m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); }
-                       
-                       indicatorValues = getValues(groupings, randomGroupingsMap);
-                       
-                       pValues = getPValues(groupings, randomGroupingsMap, lookupFloat.size(), indicatorValues);
-               }
-                       
-               if (m->control_pressed) { out.close(); return 0; }
-                       
-                       
-               /******************************************************/
-               //output indicator values to table form               //
-               /*****************************************************/
-               out << "OTU\tIndicator_Value\tpValue" << endl;
-               for (int j = 0; j < indicatorValues.size(); j++) {
-                               
-                       if (m->control_pressed) { out.close(); return 0; }
-                       
-                       out << m->currentBinLabels[j] << '\t' << indicatorValues[j] << '\t'; 
-                       
-                       if (pValues[j] > (1/(float)iters)) { out << pValues[j] << endl; } 
-                       else { out << "<" << (1/(float)iters) << endl; }
-                       
-                       if (pValues[j] <= 0.05) {
-                               cout << m->currentBinLabels[j] << '\t' << indicatorValues[j]  << '\t';
-                               string pValueString = "<" + toString((1/(float)iters)); 
-                               if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
-                               else { cout << "<" << (1/(float)iters); }
-                               m->mothurOutJustToLog(m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); 
-                               m->mothurOutEndLine(); 
-                       }
-               }
-               
-               out.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "GetIndicatorSpecies");      
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//traverse tree finding indicator species values for each otu at each node
-//label node with otu number that has highest indicator value
-//report all otu values to file
-int IndicatorCommand::GetIndicatorSpecies(Tree*& T){
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(inputFileName);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(inputFileName)) + "indicator.summary";
-               outputNames.push_back(outputFileName); outputTypes["summary"].push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               int numBins = 0;
-               if (sharedfile != "") { numBins = lookup[0]->getNumBins(); }
-               else { numBins = lookupFloat[0]->getNumBins(); }
-               
-               //print headings
-               out << "TreeNode\t";
-               for (int i = 0; i < numBins; i++) { out << m->currentBinLabels[i] << "_IndValue" << '\t' << "pValue" << '\t'; }
-               out << endl;
-               
-               m->mothurOutEndLine(); m->mothurOut("Node\tSpecies\tIndicatorValue\tpValue\n");
-               
-               string treeOutputDir = outputDir;
-               if (outputDir == "") {  treeOutputDir += m->hasPath(treefile);  }
-               string outputTreeFileName = treeOutputDir + m->getRootName(m->getSimpleName(treefile)) + "indicator.tre";
-               
-               
-               //create a map from tree node index to names of descendants, save time later to know which sharedRabund you need
-               map<int, set<string> > nodeToDescendants;
-               map<int, set<int> > descendantNodes;
-               for (int i = 0; i < T->getNumNodes(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       nodeToDescendants[i] = getDescendantList(T, i, nodeToDescendants, descendantNodes);
-               }
-               
-               //you need the distances to leaf to decide grouping below
-               //this will also set branch lengths if the tree does not include them
-               map<int, float> distToRoot = getDistToRoot(T);
-                       
-               //for each node
-               for (int i = T->getNumLeaves(); i < T->getNumNodes(); i++) {
-                       //cout << endl << i+1 << endl;  
-                       if (m->control_pressed) { out.close(); return 0; }
-                       
-                       /*****************************************************/
-                       //create vectors containing rabund info                          //
-                       /*****************************************************/
-                       
-                       vector<float> indicatorValues; //size of numBins
-                       vector<float> pValues;
-                       map< vector<int>, vector<int> > randomGroupingsMap; //maps location in groupings to location in groupings, ie, [0][0] -> [1][2]. This is so we don't have to actually move the sharedRabundVectors.
-                       
-                       if (sharedfile != "") {
-                               vector< vector<SharedRAbundVector*> > groupings;
-                               
-                               //get nodes that will be a valid grouping
-                               //you are valid if you are not one of my descendants
-                               //AND your distToRoot is >= mine
-                               //AND you were not added as part of a larger grouping. Largest nodes are added first.
-                               
-                               set<string> groupsAlreadyAdded;
-                               //create a grouping with my grouping
-                               vector<SharedRAbundVector*> subset;
-                               int count = 0;
-                               int doneCount = nodeToDescendants[i].size();
-                               for (int k = 0; k < lookup.size(); k++) {
-                                       //is this descendant of i
-                                       if ((nodeToDescendants[i].count(lookup[k]->getGroup()) != 0)) { 
-                                               subset.push_back(lookup[k]);
-                                               groupsAlreadyAdded.insert(lookup[k]->getGroup());
-                                               count++;
-                                       }
-                                       if (count == doneCount) { break; } //quit once you get the rabunds for this grouping
-                               }
-                               if (subset.size() != 0) { groupings.push_back(subset); }
-                               
-                               
-                               for (int j = (T->getNumNodes()-1); j >= 0; j--) {
-       
-                                       
-                                       if ((descendantNodes[i].count(j) == 0) && (distToRoot[j] >= distToRoot[i])) { 
-                                               vector<SharedRAbundVector*> subset;
-                                               int count = 0;
-                                               int doneCount = nodeToDescendants[j].size();
-                                               for (int k = 0; k < lookup.size(); k++) {
-                                                       //is this descendant of j, and we didn't already add this as part of a larger grouping
-                                                       if ((nodeToDescendants[j].count(lookup[k]->getGroup()) != 0) && (groupsAlreadyAdded.count(lookup[k]->getGroup()) == 0)) { 
-                                                               subset.push_back(lookup[k]);
-                                                               groupsAlreadyAdded.insert(lookup[k]->getGroup());
-                                                               count++;
-                                                       }
-                                                       if (count == doneCount) { break; } //quit once you get the rabunds for this grouping
-                                               }
-                                               
-                                               //if subset.size == 0 then the node was added as part of a larger grouping
-                                               if (subset.size() != 0) { groupings.push_back(subset); }
-                                       }
-                               }
-                               
-                               if (groupsAlreadyAdded.size() != lookup.size()) {  m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); }
-                                                               
-                               indicatorValues = getValues(groupings, randomGroupingsMap);
-                               
-                               pValues = getPValues(groupings, randomGroupingsMap, lookup.size(), indicatorValues);                            
-                       }else {
-                               vector< vector<SharedRAbundFloatVector*> > groupings;
-                               
-                               //get nodes that will be a valid grouping
-                               //you are valid if you are not one of my descendants
-                               //AND your distToRoot is >= mine
-                               //AND you were not added as part of a larger grouping. Largest nodes are added first.
-                               
-                               set<string> groupsAlreadyAdded;
-                               //create a grouping with my grouping
-                               vector<SharedRAbundFloatVector*> subset;
-                               int count = 0;
-                               int doneCount = nodeToDescendants[i].size();
-                               for (int k = 0; k < lookupFloat.size(); k++) {
-                                       //is this descendant of i
-                                       if ((nodeToDescendants[i].count(lookupFloat[k]->getGroup()) != 0)) { 
-                                               subset.push_back(lookupFloat[k]);
-                                               groupsAlreadyAdded.insert(lookupFloat[k]->getGroup());
-                                               count++;
-                                       }
-                                       if (count == doneCount) { break; } //quit once you get the rabunds for this grouping
-                               }
-                               if (subset.size() != 0) { groupings.push_back(subset); }
-                               
-                               for (int j = (T->getNumNodes()-1); j >= 0; j--) {
-                                       if ((descendantNodes[i].count(j) == 0) && (distToRoot[j] >= distToRoot[i])) {
-                                               vector<SharedRAbundFloatVector*> subset;
-                                               int count = 0;
-                                               int doneCount = nodeToDescendants[j].size();
-                                               for (int k = 0; k < lookupFloat.size(); k++) {
-                                                       //is this descendant of j, and we didn't already add this as part of a larger grouping
-                                                       if ((nodeToDescendants[j].count(lookupFloat[k]->getGroup()) != 0) && (groupsAlreadyAdded.count(lookupFloat[k]->getGroup()) == 0)) { 
-                                                               subset.push_back(lookupFloat[k]);
-                                                               groupsAlreadyAdded.insert(lookupFloat[k]->getGroup());
-                                                               count++;
-                                                       }
-                                                       if (count == doneCount) { break; } //quit once you get the rabunds for this grouping
-                                               }
-                                               
-                                               //if subset.size == 0 then the node was added as part of a larger grouping
-                                               if (subset.size() != 0) { groupings.push_back(subset); }
-                                       }
-                               }
-                               
-                               if (groupsAlreadyAdded.size() != lookupFloat.size()) { m->mothurOut("[ERROR]: could not make proper groupings."); m->mothurOutEndLine(); }
-                               
-                               indicatorValues = getValues(groupings, randomGroupingsMap);
-                               
-                               pValues = getPValues(groupings, randomGroupingsMap, lookupFloat.size(), indicatorValues);
-                       }
-                       
-                       if (m->control_pressed) { out.close(); return 0; }
-                       
-                       
-                       /******************************************************/
-                       //output indicator values to table form + label tree  //
-                       /*****************************************************/
-                       out << (i+1) << '\t';
-                       for (int j = 0; j < indicatorValues.size(); j++) {
-                               
-                               if (m->control_pressed) { out.close(); return 0; }
-                               
-                               if (pValues[j] < (1/(float)iters)) {
-                                       out << indicatorValues[j] << '\t' << '<' << (1/(float)iters) << '\t';
-                               }else {
-                                       out << indicatorValues[j] << '\t' << pValues[j] << '\t';
-                               }
-                               
-                               if (pValues[j] <= 0.05) {
-                                       cout << i+1 << '\t' << m->currentBinLabels[j] << '\t' << indicatorValues[j]  << '\t';
-                                       string pValueString = "<" + toString((1/(float)iters)); 
-                                       if (pValues[j] > (1/(float)iters)) { pValueString = toString(pValues[j]); cout << pValues[j];} 
-                                       else { cout << "<" << (1/(float)iters); }
-                                       m->mothurOutJustToLog(toString(i) + "\t" + m->currentBinLabels[j] + "\t" + toString(indicatorValues[j]) + "\t" + pValueString); 
-                                       m->mothurOutEndLine(); 
-                               }
-                       }
-                       out << endl;
-                       
-                       T->tree[i].setLabel((i+1));
-               }
-               out.close();
-       
-               ofstream outTree;
-               m->openOutputFile(outputTreeFileName, outTree);
-               outputNames.push_back(outputTreeFileName); outputTypes["tree"].push_back(outputTreeFileName);
-               
-               T->print(outTree, "both");
-               outTree.close();
-       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "GetIndicatorSpecies");      
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<float> IndicatorCommand::getValues(vector< vector<SharedRAbundFloatVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap){
-       try {
-               vector<float> values;
-               map< vector<int>, vector<int> >::iterator it;
-               
-               //for each otu
-               for (int i = 0; i < groupings[0][0]->getNumBins(); i++) {
-                       
-                       if (m->control_pressed) { return values; }
-                       
-                       vector<float> terms; 
-                       float AijDenominator = 0.0;
-                       vector<float> Bij;
-                       
-                       //get overall abundance of each grouping
-                       for (int j = 0; j < groupings.size(); j++) {
-                               
-                               float totalAbund = 0;
-                               int numNotZero = 0;
-                               for (int k = 0; k < groupings[j].size(); k++) { 
-                                       vector<int> temp; temp.push_back(j); temp.push_back(k);
-                                       it = groupingsMap.find(temp);
-                                       
-                                       if (it == groupingsMap.end()) { //this one didnt get moved
-                                               totalAbund += groupings[j][k]->getAbundance(i); 
-                                               if (groupings[j][k]->getAbundance(i) != 0.0) { numNotZero++; }
-                                       }else {
-                                               totalAbund += groupings[(it->second)[0]][(it->second)[1]]->getAbundance(i); 
-                                               if (groupings[(it->second)[0]][(it->second)[1]]->getAbundance(i) != 0.0) { numNotZero++; }
-                                       }
-                                       
-                               }
-                               
-                               //mean abundance
-                               float Aij = (totalAbund / (float) groupings[j].size());
-                               terms.push_back(Aij);
-                               
-                               //percentage of sites represented
-                               Bij.push_back(numNotZero / (float) groupings[j].size());
-                               
-                               AijDenominator += Aij;
-                       }
-                       
-                       float maxIndVal = 0.0;
-                       for (int j = 0; j < terms.size(); j++) { 
-                               float thisAij = (terms[j] / AijDenominator); //relative abundance
-                               float thisValue = thisAij * Bij[j] * 100.0;
-                               
-                               //save largest
-                               if (thisValue > maxIndVal) { maxIndVal = thisValue; }
-                       }
-                       
-                       values.push_back(maxIndVal);
-               }
-               
-               return values;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getValues");        
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//same as above, just data type difference
-vector<float> IndicatorCommand::getValues(vector< vector<SharedRAbundVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap){
-       try {
-               vector<float> values;
-               
-       /*for (int j = 0; j < groupings.size(); j++) {          
-               cout << "grouping " << j << endl;
-               for (int k = 0; k < groupings[j].size(); k++) { 
-                       cout << groupings[j][k]->getGroup() << endl;
-               }
-       }*/
-               map< vector<int>, vector<int> >::iterator it;
-               
-               //for each otu
-               for (int i = 0; i < groupings[0][0]->getNumBins(); i++) {
-                       vector<float> terms; 
-                       float AijDenominator = 0.0;
-                       vector<float> Bij;
-                       //get overall abundance of each grouping
-                       for (int j = 0; j < groupings.size(); j++) {
-       
-                               int totalAbund = 0.0;
-                               int numNotZero = 0;
-                               for (int k = 0; k < groupings[j].size(); k++) { 
-                                       vector<int> temp; temp.push_back(j); temp.push_back(k);
-                                       it = groupingsMap.find(temp);
-                                       
-                                       if (it == groupingsMap.end()) { //this one didnt get moved
-                                               totalAbund += groupings[j][k]->getAbundance(i); 
-                                               if (groupings[j][k]->getAbundance(i) != 0.0) { numNotZero++; }
-                                       }else {
-                                               totalAbund += groupings[(it->second)[0]][(it->second)[1]]->getAbundance(i); 
-                                               if (groupings[(it->second)[0]][(it->second)[1]]->getAbundance(i) != 0.0) { numNotZero++; }
-                                       }
-                                       
-                               }
-                               
-                               //mean abundance        
-                               float Aij = (totalAbund / (float) groupings[j].size());
-                               terms.push_back(Aij);
-                               
-                               //percentage of sites represented
-                               Bij.push_back(numNotZero / (float) groupings[j].size());
-                               
-                               AijDenominator += Aij;
-                       }
-                       
-                       float maxIndVal = 0.0;
-                       for (int j = 0; j < terms.size(); j++) { 
-                               float thisAij = (terms[j] / AijDenominator); //relative abundance
-                               float thisValue = thisAij * Bij[j] * 100.0;
-                                       
-                               //save largest
-                               if (thisValue > maxIndVal) { maxIndVal = thisValue; }
-                       }
-                       
-                       values.push_back(maxIndVal);
-               }
-               
-               return values;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getValues");        
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//you need the distances to root to decide groupings
-//this will also set branch lengths if the tree does not include them
-map<int, float> IndicatorCommand::getDistToRoot(Tree*& T){
-       try {
-               map<int, float> dists;
-               
-               bool hasBranchLengths = false;
-               for (int i = 0; i < T->getNumNodes(); i++) { 
-                       if (T->tree[i].getBranchLength() > 0.0) {  hasBranchLengths = true; break; }
-               }
-               
-               //set branchlengths if needed
-               if (!hasBranchLengths) { 
-                       for (int i = 0; i < T->getNumNodes(); i++) {
-                               
-                               int lc = T->tree[i].getLChild();
-                               int rc = T->tree[i].getRChild();
-                               
-                               if (lc == -1) { // you are a leaf
-                                       //if you are a leaf set you priliminary length to 1.0, this may adjust later
-                                       T->tree[i].setBranchLength(1.0);
-                                       dists[i] = 1.0;
-                               }else{ // you are an internal node
-                                       //look at your children's length to leaf
-                                       float ldist = dists[lc];
-                                       float rdist = dists[rc];
-                                       
-                                       float greater = ldist;
-                                       if (rdist > greater) { greater = rdist; dists[i] = ldist + 1.0;}
-                                       else { dists[i] = rdist + 1.0; }
-                                       
-                                       
-                                       //branch length = difference + 1
-                                       T->tree[lc].setBranchLength((abs(ldist-greater) + 1.0));
-                                       T->tree[rc].setBranchLength((abs(rdist-greater) + 1.0));
-                               }
-                       }
-               }
-                       
-               dists.clear();
-               
-               for (int i = 0; i < T->getNumNodes(); i++) {
-                       
-                       double sum = 0.0;
-                       int index = i;
-                       
-                       while(T->tree[index].getParent() != -1){
-                               if (T->tree[index].getBranchLength() != -1) {
-                                       sum += abs(T->tree[index].getBranchLength()); 
-                               }
-                               index = T->tree[index].getParent();
-                       }
-                       
-                       dists[i] = sum;
-               }
-               
-               return dists;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getLengthToLeaf");  
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-set<string> IndicatorCommand::getDescendantList(Tree*& T, int i, map<int, set<string> > descendants, map<int, set<int> >& nodes){
-       try {
-               set<string> names;
-               
-               set<string>::iterator it;
-               
-               int lc = T->tree[i].getLChild();
-               int rc = T->tree[i].getRChild();
-               
-               if (lc == -1) { //you are a leaf your only descendant is yourself
-                       set<int> temp; temp.insert(i);
-                       nodes[i] = temp;
-                       
-                       if (designfile == "") {
-                               names.insert(T->tree[i].getName());
-                       }else {
-                               vector<string> myGroup; myGroup.push_back(T->tree[i].getName());
-                               vector<string> myReps = designMap->getNamesSeqs(myGroup);
-                               for (int k = 0; k < myReps.size(); k++) {
-                                       names.insert(myReps[k]);
-                               }
-                       }
-                       
-               }else{ //your descedants are the combination of your childrens descendants
-                       names = descendants[lc];
-                       nodes[i] = nodes[lc];
-                       for (it = descendants[rc].begin(); it != descendants[rc].end(); it++) {
-                               names.insert(*it);
-                       }
-                       for (set<int>::iterator itNum = nodes[rc].begin(); itNum != nodes[rc].end(); itNum++) {
-                               nodes[i].insert(*itNum);
-                       }
-                       //you are your own descendant
-                       nodes[i].insert(i);
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getDescendantList");        
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int IndicatorCommand::getShared(){
-       try {
-               InputData* input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               if (label == "") { label = lastLabel; delete input; return 0; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && (userLabels.size() != 0)) {
-                       if (m->control_pressed) {  delete input; return 0;  }
-                       
-                       if(labels.count(lookup[0]->getLabel()) == 1){
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               break;
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                               break;
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               
-               if (m->control_pressed) { delete input; return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i];       } } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-               }       
-               
-               delete input;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getShared");        
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int IndicatorCommand::getSharedFloat(){
-       try {
-               InputData* input = new InputData(relabundfile, "relabund");
-               lookupFloat = input->getSharedRAbundFloatVectors();
-               string lastLabel = lookupFloat[0]->getLabel();
-               
-               if (label == "") { label = lastLabel; delete input; return 0; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookupFloat[0] != NULL) && (userLabels.size() != 0)) {
-                       
-                       if (m->control_pressed) {  delete input; return 0;  }
-                       
-                       if(labels.count(lookupFloat[0]->getLabel()) == 1){
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               break;
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookupFloat[0]->getLabel();
-                               
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } 
-                               lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookupFloat[0]->setLabel(saveLabel);
-                               break;
-                       }
-                       
-                       lastLabel = lookupFloat[0]->getLabel();                 
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } 
-                       lookupFloat = input->getSharedRAbundFloatVectors();
-               }
-               
-               
-               if (m->control_pressed) { delete input; return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookupFloat.size(); i++) {  if (lookupFloat[i] != NULL) {   delete lookupFloat[i];  } } 
-                       lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-               }       
-               
-               delete input;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getShared");        
-       exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<float> IndicatorCommand::driver(vector< vector<SharedRAbundFloatVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap, int num, vector<float> indicatorValues, int numIters){
-       try {
-               vector<float> pvalues;
-               pvalues.resize(indicatorValues.size(), 0);
-               
-               for(int i=0;i<numIters;i++){
-                       if (m->control_pressed) { break; }
-                       groupingsMap = randomizeGroupings(groupings, num);
-                       vector<float> randomIndicatorValues = getValues(groupings, groupingsMap);
-                       
-                       for (int j = 0; j < indicatorValues.size(); j++) {
-                               if (randomIndicatorValues[j] >= indicatorValues[j]) { pvalues[j]++; }
-                       }
-               }
-               
-               return pvalues;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "driver");   
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<float> IndicatorCommand::getPValues(vector< vector<SharedRAbundFloatVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap, int num, vector<float> indicatorValues){
-       try {
-               vector<float> pvalues;
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               if(processors == 1){
-                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters);
-                       for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; }
-               }else{
-                       
-                       //divide iters between processors
-                       int numItersPerProcessor = iters / processors;
-                       
-                       vector<int> processIDS;
-                       int process = 1;
-                       int num = 0;
-                       
-                       //loop through and create all the processes you want
-                       while (process != processors) {
-                               int pid = fork();
-                               
-                               if (pid > 0) {
-                                       processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                                       process++;
-                               }else if (pid == 0){
-                                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, numItersPerProcessor);
-                                       
-                                       //pass pvalues to parent
-                                       ofstream out;
-                                       string tempFile = toString(getpid()) + ".pvalues.temp";
-                                       m->openOutputFile(tempFile, out);
-                                       
-                                       //pass values
-                                       for (int i = 0; i < pvalues.size(); i++) {
-                                               out << pvalues[i] << '\t';
-                                       }
-                                       out << endl;
-                                       
-                                       out.close();
-                                       
-                                       exit(0);
-                               }else { 
-                                       m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                                       for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                                       exit(0);
-                               }
-                       }
-                       
-                       //do my part
-                       //special case for last processor in case it doesn't divide evenly
-                       numItersPerProcessor = iters - ((processors-1) * numItersPerProcessor);         
-                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, numItersPerProcessor);
-                       
-                       //force parent to wait until all the processes are done
-                       for (int i=0;i<processIDS.size();i++) { 
-                               int temp = processIDS[i];
-                               wait(&temp);
-                       }
-                       
-                       //combine results                       
-                       for (int i = 0; i < processIDS.size(); i++) {
-                               ifstream in;
-                               string tempFile =  toString(processIDS[i]) + ".pvalues.temp";
-                               m->openInputFile(tempFile, in);
-                               
-                               ////// to do ///////////
-                               int numTemp; numTemp = 0; 
-                               for (int j = 0; j < pvalues.size(); j++) {
-                                       in >> numTemp; m->gobble(in);
-                                       pvalues[j] += numTemp;
-                               }
-                               in.close(); m->mothurRemove(tempFile);
-                       }
-                       for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } 
-               }
-#else
-               pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters);
-               for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; }
-#endif
-               
-               return pvalues;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getPValues");       
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-//same as above, just data type difference
-vector<float> IndicatorCommand::driver(vector< vector<SharedRAbundVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap, int num, vector<float> indicatorValues, int numIters){
-       try {
-               vector<float> pvalues;
-               pvalues.resize(indicatorValues.size(), 0);
-               
-               for(int i=0;i<numIters;i++){
-                       if (m->control_pressed) { break; }
-                       groupingsMap = randomizeGroupings(groupings, num);
-                       vector<float> randomIndicatorValues = getValues(groupings, groupingsMap);
-                       
-                       for (int j = 0; j < indicatorValues.size(); j++) {
-                               if (randomIndicatorValues[j] >= indicatorValues[j]) { pvalues[j]++; }
-                       }
-               }
-               
-               return pvalues;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "driver");   
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//same as above, just data type difference
-vector<float> IndicatorCommand::getPValues(vector< vector<SharedRAbundVector*> >& groupings, map< vector<int>, vector<int> > groupingsMap, int num, vector<float> indicatorValues){
-       try {
-               vector<float> pvalues;
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               if(processors == 1){
-                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters);
-                       for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; }
-               }else{
-                       
-                       //divide iters between processors
-                       int numItersPerProcessor = iters / processors;
-                       
-                       vector<int> processIDS;
-                       int process = 1;
-                       
-                       //loop through and create all the processes you want
-                       while (process != processors) {
-                               int pid = fork();
-                               
-                               if (pid > 0) {
-                                       processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                                       process++;
-                               }else if (pid == 0){
-                                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, numItersPerProcessor);
-                                       
-                                       //pass pvalues to parent
-                                       ofstream out;
-                                       string tempFile = toString(getpid()) + ".pvalues.temp";
-                                       m->openOutputFile(tempFile, out);
-                                       
-                                       //pass values
-                                       for (int i = 0; i < pvalues.size(); i++) {
-                                               out << pvalues[i] << '\t';
-                                       }
-                                       out << endl;
-                                       
-                                       out.close();
-                                       
-                                       exit(0);
-                               }else { 
-                                       m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                                       for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                                       exit(0);
-                               }
-                       }
-                       
-                       //do my part
-                       //special case for last processor in case it doesn't divide evenly
-                       numItersPerProcessor = iters - ((processors-1) * numItersPerProcessor);         
-                       pvalues = driver(groupings, groupingsMap, num, indicatorValues, numItersPerProcessor);
-                       
-                       //force parent to wait until all the processes are done
-                       for (int i=0;i<processIDS.size();i++) { 
-                               int temp = processIDS[i];
-                               wait(&temp);
-                       }
-                       
-                       //combine results                       
-                       for (int i = 0; i < processIDS.size(); i++) {
-                               ifstream in;
-                               string tempFile =  toString(processIDS[i]) + ".pvalues.temp";
-                               m->openInputFile(tempFile, in);
-                               
-                               ////// to do ///////////
-                               int numTemp; numTemp = 0; 
-                               for (int j = 0; j < pvalues.size(); j++) {
-                                       in >> numTemp; m->gobble(in);
-                                       pvalues[j] += numTemp;
-                               }
-                               in.close(); m->mothurRemove(tempFile);
-                       }
-                       for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } 
-               }
-#else
-               pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters);
-               for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; }
-#endif
-               
-               return pvalues;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "getPValues");       
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//swap groups between groupings, in essence randomizing the second column of the design file
-map< vector<int>, vector<int> > IndicatorCommand::randomizeGroupings(vector< vector<SharedRAbundVector*> >& groupings, int numLookupGroups){
-       try {
-               
-               map< vector<int>, vector<int> > randomGroupings; 
-               
-               for (int i = 0; i < numLookupGroups; i++) {
-                       if (m->control_pressed) {break;}
-                       
-                       //get random groups to swap to switch with
-                       //generate random int between 0 and groupings.size()-1
-                       int z = m->getRandomIndex(groupings.size()-1);
-                       int x = m->getRandomIndex(groupings.size()-1);
-                       int a = m->getRandomIndex(groupings[z].size()-1);
-                       int b = m->getRandomIndex(groupings[x].size()-1);
-                       //cout << i << '\t' << z << '\t' << x << '\t' << a << '\t' << b << endl;        
-                       //if ((z < 0) || (z > 1) || x<0 || x>1 || a <0 || a>groupings[z].size()-1 || b<0 || b>groupings[x].size()-1) { cout << "probelm" << i << '\t' << z << '\t' << x << '\t' << a << '\t' << b << endl;      }
-                       
-                       vector<int> from;
-                       vector<int> to;
-                       
-                       from.push_back(z); from.push_back(a);
-                       to.push_back(x); to.push_back(b);
-                       
-                       randomGroupings[from] = to;
-               }
-               //cout << "done" << endl;       
-               return randomGroupings;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "randomizeGroupings");       
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-//swap groups between groupings, in essence randomizing the second column of the design file
-map< vector<int>, vector<int> > IndicatorCommand::randomizeGroupings(vector< vector<SharedRAbundFloatVector*> >& groupings, int numLookupGroups){
-       try {
-               
-               map< vector<int>, vector<int> > randomGroupings; 
-               
-               for (int i = 0; i < numLookupGroups; i++) {
-                       
-                       //get random groups to swap to switch with
-                       //generate random int between 0 and groupings.size()-1
-                       int z = m->getRandomIndex(groupings.size()-1);
-                       int x = m->getRandomIndex(groupings.size()-1);
-                       int a = m->getRandomIndex(groupings[z].size()-1);
-                       int b = m->getRandomIndex(groupings[x].size()-1);
-                       //cout << i << '\t' << z << '\t' << x << '\t' << a << '\t' << b << endl;                
-                       
-                       vector<int> from;
-                       vector<int> to;
-                       
-                       from.push_back(z); from.push_back(a);
-                       to.push_back(x); to.push_back(b);
-                       
-                       randomGroupings[from] = to;
-               }
-               
-               return randomGroupings;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "IndicatorCommand", "randomizeGroupings");       
-               exit(1);
-       }
-}                      
-                                                               
-/*****************************************************************/
-
-
diff --git a/indicatorcommand.h b/indicatorcommand.h
deleted file mode 100644 (file)
index c5112e6..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef INDICATORCOMMAND_H
-#define INDICATORCOMMAND_H
-
-/*
- *  indicatorcommand.h
- *  Mothur
- *
- *  Created by westcott on 11/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readtree.h"
-#include "treemap.h"
-#include "sharedrabundvector.h"
-#include "sharedrabundfloatvector.h"
-#include "inputdata.h"
-
-class IndicatorCommand : public Command {
-public:
-       IndicatorCommand(string);
-       IndicatorCommand();
-       ~IndicatorCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "indicator";                           }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Dufrene M, Legendre P (1997). Species assemblages and indicator species: The need for a flexible asymmetrical approach. Ecol Monogr 67: 345-66.\n McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Indicator"; }
-       string getDescription()         { return "calculate the indicator value for each OTU"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       ReadTree* read;
-       TreeMap* treeMap;
-       GroupMap* designMap;
-       string treefile, sharedfile, relabundfile, groups, label, inputFileName, outputDir, designfile;
-       bool abort;
-       int iters, processors;
-       vector<string> outputNames, Groups;
-       vector<SharedRAbundVector*> lookup;
-       vector<SharedRAbundFloatVector*> lookupFloat;
-       
-       int getShared();
-       int getSharedFloat();
-       int GetIndicatorSpecies(Tree*&);
-       int GetIndicatorSpecies();
-       set<string> getDescendantList(Tree*&, int, map<int, set<string> >, map<int, set<int> >&);
-       vector<float> getValues(vector< vector<SharedRAbundVector*> >&, map< vector<int>, vector<int> >);
-       vector<float> getValues(vector< vector<SharedRAbundFloatVector*> >&, map< vector<int>, vector<int> >);
-       map<int, float> getDistToRoot(Tree*&);
-       map< vector<int>, vector<int> > randomizeGroupings(vector< vector<SharedRAbundVector*> >&, int);
-       map< vector<int>, vector<int> > randomizeGroupings(vector< vector<SharedRAbundFloatVector*> >&, int);
-       vector<float> driver(vector< vector<SharedRAbundFloatVector*> >&, map< vector<int>, vector<int> >, int, vector<float>, int);
-       vector<float> driver(vector< vector<SharedRAbundVector*> >&, map< vector<int>, vector<int> >, int, vector<float>, int);
-       vector<float> getPValues(vector< vector<SharedRAbundFloatVector*> >&, map< vector<int>, vector<int> >, int, vector<float>);
-       vector<float> getPValues(vector< vector<SharedRAbundVector*> >&, map< vector<int>, vector<int> >, int, vector<float>);
-
-       
-};
-
-
-#endif
-
diff --git a/inputdata.cpp b/inputdata.cpp
deleted file mode 100644 (file)
index 8b1829a..0000000
+++ /dev/null
@@ -1,888 +0,0 @@
-/*
- *  inputdata.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "inputdata.h"
-#include "ordervector.hpp"
-#include "listvector.hpp"
-#include "rabundvector.hpp"
-
-/***********************************************************************/
-
-InputData::InputData(string fName, string f) : format(f){
-       m = MothurOut::getInstance();
-       m->openInputFile(fName, fileHandle);
-       filename = fName;
-       m->saveNextLabel = "";
-}
-/***********************************************************************/
-
-InputData::~InputData(){
-       fileHandle.close();
-       m->saveNextLabel = "";
-}
-
-/***********************************************************************/
-
-InputData::InputData(string fName, string orderFileName, string f) : format(f){
-       try {
-               m = MothurOut::getInstance();
-               ifstream ofHandle;
-               m->openInputFile(orderFileName, ofHandle);
-               string name;
-
-               int count = 0;
-       
-               while(ofHandle){
-                       ofHandle >> name;
-                       orderMap[name] = count;
-                       count++;
-                       m->gobble(ofHandle);
-               }
-               ofHandle.close();
-       
-               m->openInputFile(fName, fileHandle);
-               m->saveNextLabel = "";
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "InputData");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-ListVector* InputData::getListVector(){
-       try {
-               if(!fileHandle.eof()){
-                       if(format == "list") {
-                               list = new ListVector(fileHandle);
-                       }else{ list = NULL;  }
-                                       
-                       m->gobble(fileHandle);
-                       return list;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getListVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-ListVector* InputData::getListVector(string label){
-       try {
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-
-                       if (format == "list") {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       list = new ListVector(in);
-                                       thisLabel = list->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete list;    }
-                                       m->gobble(in);
-                               }
-                       }else{ list = NULL;  }
-                       
-                       in.close();
-                       return list;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getListVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-ListVector* InputData::getListVector(string label, bool resetFP){
-       try {
-               string  thisLabel;
-               fileHandle.clear();
-               fileHandle.seekg(0);
-               
-               if(fileHandle){
-
-                       if (format == "list") {
-                       
-                               while (fileHandle.eof() != true) {
-                                       
-                                       list = new ListVector(fileHandle); m->gobble(fileHandle);
-                                       thisLabel = list->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete list;    }
-                               }
-                       }else{ list = NULL;  }
-               
-                       return list;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getListVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SharedListVector* InputData::getSharedListVector(){
-       try {
-               if(fileHandle){
-                       if (format == "shared")  {
-                               SharedList = new SharedListVector(fileHandle);
-                       }else{ SharedList = NULL;  }
-                                       
-                       m->gobble(fileHandle);
-                       return SharedList;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedListVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-SharedListVector* InputData::getSharedListVector(string label){
-       try {
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-
-                       if (format == "shared")  {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       SharedList = new SharedListVector(in);
-                                       thisLabel = SharedList->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete SharedList;      }
-                                       m->gobble(in);
-                               }
-
-                       }else{ SharedList = NULL;  }
-                               
-                       in.close();
-                       return SharedList;
-                       
-               }else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedListVector");
-               exit(1);
-       }
-}
-
-
-
-/***********************************************************************/
-
-SharedOrderVector* InputData::getSharedOrderVector(){
-       try {
-               if(fileHandle){
-                       if (format == "sharedfile")  {
-                               SharedOrder = new SharedOrderVector(fileHandle);
-                       }else{ SharedOrder = NULL;  }
-                               
-                       m->gobble(fileHandle);
-                       return SharedOrder;
-                       
-               }else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SharedOrderVector* InputData::getSharedOrderVector(string label){
-       try {
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-
-                       if (format == "sharedfile")  {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       SharedOrder = new SharedOrderVector(in);
-                                       thisLabel = SharedOrder->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete SharedOrder;     }
-                                       m->gobble(in);
-                               }
-
-                       }else{ SharedOrder = NULL;  }
-                               
-                       in.close();
-                       return SharedOrder;
-                       
-               }else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedOrderVector");
-               exit(1);
-       }
-}
-
-
-
-/***********************************************************************/
-
-OrderVector* InputData::getOrderVector(){
-       try {
-               if(fileHandle){
-                       if((format == "list") || (format == "listorder")) {
-                               input = new ListVector(fileHandle);
-                       }
-                       else if (format == "shared")  {
-                               input = new SharedListVector(fileHandle);
-                       }
-                       else if(format == "rabund"){
-                               input = new RAbundVector(fileHandle);
-                       }
-                       else if(format == "order"){             
-                               input = new OrderVector(fileHandle);
-                       }
-                       else if(format == "sabund"){
-                               input = new SAbundVector(fileHandle);
-                       }
-                                               
-                       m->gobble(fileHandle);
-                       
-                       output = new OrderVector();     
-                       *output = (input->getOrderVector());
-               
-                       return output;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-OrderVector* InputData::getOrderVector(string label){
-       try {
-       
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-                       if((format == "list") || (format == "listorder")) {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       input = new ListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-                       }
-                       else if (format == "shared")  {
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SharedListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "rabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new RAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "order"){                     
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new OrderVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "sabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                                       
-                               }
-
-                       }
-                                               
-                       in.close();             
-
-                       output = new OrderVector();
-                       *output = (input->getOrderVector());
-                       
-                       return output;
-
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//this is used when you don't need the order vector
-vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(){
-       try {
-               if(fileHandle){
-                       if (format == "sharedfile")  {
-                               SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
-                               if (SharedRAbund != NULL) {
-                                       return SharedRAbund->getSharedRAbundVectors();
-                               }
-                       }else if (format == "shared") {
-                               SharedList = new SharedListVector(fileHandle);
-                               
-                               if (SharedList != NULL) {
-                                       return SharedList->getSharedRAbundVector();
-                               }
-                       }
-                       m->gobble(fileHandle);
-               }
-                               
-               //this is created to signal to calling function that the input file is at eof
-               vector<SharedRAbundVector*> null;  null.push_back(NULL);
-               return null;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedRAbundVectors");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<SharedRAbundVector*> InputData::getSharedRAbundVectors(string label){
-       try {
-               ifstream in;
-               string  thisLabel;
-               
-               m->openInputFile(filename, in);
-               m->saveNextLabel = "";
-       
-               if(in){
-                       if (format == "sharedfile")  {
-                               while (in.eof() != true) {
-                                       
-                                       SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
-                                       if (SharedRAbund != NULL) {
-                                               thisLabel = SharedRAbund->getLabel();
-                                       
-                                               //if you are at the last label
-                                               if (thisLabel == label) {  in.close(); return SharedRAbund->getSharedRAbundVectors();  }
-                                               else {
-                                                       //so you don't loose this memory
-                                                       vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
-                                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                                                       delete SharedRAbund;
-                                               }
-                                       }else{  break;  }
-                                       m->gobble(in);
-                                       
-                               }
-                       }else if (format == "shared") {
-                               while (in.eof() != true) {
-                                       
-                                       SharedList = new SharedListVector(in);
-                                       
-                                       if (SharedList != NULL) {
-                                               thisLabel = SharedList->getLabel();
-                                               //if you are at the last label
-                                               if (thisLabel == label) {  in.close(); return SharedList->getSharedRAbundVector();  }
-                                               else {
-                                                       //so you don't loose this memory
-                                                       delete SharedList;
-                                               }
-                                       }else{  break;  }
-                                       m->gobble(in);
-                                       
-                               }
-                       
-                       }
-               }
-                               
-               //this is created to signal to calling function that the input file is at eof
-               vector<SharedRAbundVector*> null;  null.push_back(NULL);
-               in.close();
-               return null;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedRAbundVectors");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//this is used when you don't need the order vector
-vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(){
-       try {
-               if(fileHandle){
-                       if (format == "relabund")  {
-                               SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(fileHandle);
-                               if (SharedRelAbund != NULL) {
-                                       return SharedRelAbund->getSharedRAbundFloatVectors();
-                               }
-                       }else if (format == "sharedfile")  {
-                               SharedRAbundVector* SharedRAbund = new SharedRAbundVector(fileHandle);
-                               if (SharedRAbund != NULL) {
-                                       vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
-                                       vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup); 
-                                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
-                                       return lookupFloat;  
-                               }
-                                               
-                       }
-                       m->gobble(fileHandle);
-               }
-                               
-               //this is created to signal to calling function that the input file is at eof
-               vector<SharedRAbundFloatVector*> null;  null.push_back(NULL);
-               return null;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<SharedRAbundFloatVector*> InputData::getSharedRAbundFloatVectors(string label){
-       try {
-               ifstream in;
-               string  thisLabel;
-               
-               m->openInputFile(filename, in);
-               m->saveNextLabel = "";
-               
-               if(in){
-                       if (format == "relabund")  {
-                               while (in.eof() != true) {
-                                       
-                                       SharedRAbundFloatVector* SharedRelAbund = new SharedRAbundFloatVector(in);
-                                       if (SharedRelAbund != NULL) {
-                                               thisLabel = SharedRelAbund->getLabel();
-                                               //if you are at the last label
-                                               if (thisLabel == label) {  in.close(); return SharedRelAbund->getSharedRAbundFloatVectors();  }
-                                               else {
-                                                       //so you don't loose this memory
-                                                       vector<SharedRAbundFloatVector*> lookup = SharedRelAbund->getSharedRAbundFloatVectors(); 
-                                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                                                       delete SharedRelAbund;
-                                               }
-                                       }else{  break;  }
-                                       m->gobble(in);
-                               }
-                       }else if (format == "sharedfile")  {
-                               while (in.eof() != true) {
-                                       
-                                       SharedRAbundVector* SharedRAbund = new SharedRAbundVector(in);
-                                       if (SharedRAbund != NULL) {
-                                               thisLabel = SharedRAbund->getLabel();
-                                               
-                                               //if you are at the last label
-                                               if (thisLabel == label) {  
-                                                       in.close(); 
-                                                       vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
-                                                       vector<SharedRAbundFloatVector*> lookupFloat = SharedRAbund->getSharedRAbundFloatVectors(lookup); 
-                                                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
-                                                       return lookupFloat;  
-                                               }else {
-                                                       //so you don't loose this memory
-                                                       vector<SharedRAbundVector*> lookup = SharedRAbund->getSharedRAbundVectors(); 
-                                                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } lookup.clear();
-                                                       delete SharedRAbund;
-                                               }
-                                       }else{  break;  }
-                                       m->gobble(in);
-                               }
-                       }       
-               }
-               
-                               
-               //this is created to signal to calling function that the input file is at eof
-               vector<SharedRAbundFloatVector*> null;  null.push_back(NULL);
-               in.close();
-               return null;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSharedRAbundFloatVectors");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-SAbundVector* InputData::getSAbundVector(){
-       try {
-               if(fileHandle){
-                       if (format == "list") {
-                               input = new ListVector(fileHandle);
-                       }
-                       else if (format == "shared")  {
-                               input = new SharedListVector(fileHandle);
-                       }
-                       else if(format == "rabund"){
-                               input = new RAbundVector(fileHandle);
-                       }
-                       else if(format == "order"){                     
-                               input = new OrderVector(fileHandle);
-                       }
-                       else if(format == "sabund"){
-                               input = new SAbundVector(fileHandle);
-                       }                                       
-                       m->gobble(fileHandle);
-
-                       sabund = new SAbundVector();
-                       *sabund = (input->getSAbundVector());
-
-                       return sabund;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-SAbundVector* InputData::getSAbundVector(string label){
-       try {
-       
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-                       if (format == "list") {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       input = new ListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-                       }
-                       else if (format == "shared")  {
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SharedListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "rabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new RAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "order"){                     
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new OrderVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "sabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                                       
-                               }
-
-                       }
-                       
-                       in.close();             
-
-                       sabund = new SAbundVector();
-                       *sabund = (input->getSAbundVector());
-
-                       return sabund;
-
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-RAbundVector* InputData::getRAbundVector(){
-       try {
-               if(fileHandle){
-                       if (format == "list") {
-                               input = new ListVector(fileHandle);
-                       }
-                       else if (format == "shared")  {
-                               input = new SharedListVector(fileHandle);
-                       }
-                       else if(format == "rabund"){
-                               input = new RAbundVector(fileHandle);
-                       }
-                       else if(format == "order"){                     
-                               input = new OrderVector(fileHandle);
-                       }
-                       else if(format == "sabund"){
-                               input = new SAbundVector(fileHandle);
-                       }
-                       
-                       m->gobble(fileHandle);
-
-                       rabund = new RAbundVector();
-                       *rabund = (input->getRAbundVector());
-
-                       return rabund;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-RAbundVector* InputData::getRAbundVector(string label){
-       try {
-       
-               ifstream in;
-               string  thisLabel;
-               m->openInputFile(filename, in);
-               
-               if(in){
-                       if (format == "list") {
-                       
-                               while (in.eof() != true) {
-                                       
-                                       input = new ListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-                       }
-                       else if (format == "shared")  {
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SharedListVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "rabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new RAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "order"){                     
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new OrderVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                               }
-
-                       }
-                       else if(format == "sabund"){
-                               
-                               while (in.eof() != true) {
-                                       
-                                       input = new SAbundVector(in);
-                                       thisLabel = input->getLabel();
-                                       
-                                       //if you are at the last label
-                                       if (thisLabel == label) {  break;  }
-                                       //so you don't loose this memory
-                                       else {  delete input;   }
-                                       m->gobble(in);
-                                       
-                               }
-
-                       }                       
-                       
-                       
-                       in.close();             
-
-                       rabund = new RAbundVector();
-                       *rabund = (input->getRAbundVector());
-
-                       return rabund;
-               }
-               else{
-                       return NULL;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InputData", "getRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-
diff --git a/inputdata.h b/inputdata.h
deleted file mode 100644 (file)
index 658b21d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef INPUTDATA_H
-#define INPUTDATA_H
-
-#include "mothur.h"
-#include "ordervector.hpp"
-#include "sharedlistvector.h"
-#include "sharedordervector.h"
-#include "listvector.hpp"
-#include "sharedrabundfloatvector.h"
-
-
-class InputData {
-       
-public:
-       InputData(string, string);
-       InputData(string, string, string);
-       ~InputData();
-       ListVector* getListVector();
-       ListVector* getListVector(string);  //pass the label you want
-       ListVector* getListVector(string, bool);  //pass the label you want, reset filepointer
-       SharedListVector* getSharedListVector();
-       SharedListVector* getSharedListVector(string);  //pass the label you want
-       OrderVector* getOrderVector(); 
-       OrderVector* getOrderVector(string); //pass the label you want
-       SharedOrderVector* getSharedOrderVector();
-       SharedOrderVector* getSharedOrderVector(string);  //pass the label you want
-       SAbundVector* getSAbundVector();
-       SAbundVector* getSAbundVector(string);  //pass the label you want
-       RAbundVector* getRAbundVector();
-       RAbundVector* getRAbundVector(string);  //pass the label you want
-       vector<SharedRAbundVector*> getSharedRAbundVectors();
-       vector<SharedRAbundVector*> getSharedRAbundVectors(string);  //pass the label you want
-       vector<SharedRAbundFloatVector*> getSharedRAbundFloatVectors();
-       vector<SharedRAbundFloatVector*> getSharedRAbundFloatVectors(string);  //pass the label you want
-       
-private:
-       string format;
-       ifstream fileHandle;
-       DataVector* input;
-       ListVector* list;
-       SharedListVector* SharedList;
-       OrderVector* output;
-       SharedOrderVector* SharedOrder;
-       SAbundVector* sabund;
-       RAbundVector* rabund;
-       map<string,int> orderMap;
-       string filename;
-       MothurOut* m;
-};
-
-
-#endif
diff --git a/interv.f b/interv.f
deleted file mode 100644 (file)
index d65a914..0000000
--- a/interv.f
+++ /dev/null
@@ -1,102 +0,0 @@
-      subroutine interv ( xt, lxt, x, left, mflag )
-c  from  * a practical guide to splines *  by C. de Boor    
-computes  left = max( i :  xt(i) .lt. xt(lxt) .and.  xt(i) .le. x )  .
-c
-c******  i n p u t  ******
-c  xt.....a real sequence, of length  lxt , assumed to be nondecreasing
-c  lxt.....number of terms in the sequence  xt .
-c  x.....the point whose location with respect to the sequence  xt  is
-c        to be determined.
-c
-c******  o u t p u t  ******
-c  left, mflag.....both integers, whose value is
-c
-c   1     -1      if               x .lt.  xt(1)
-c   i      0      if   xt(i)  .le. x .lt. xt(i+1)
-c   i      0      if   xt(i)  .lt. x .eq. xt(i+1) .eq. xt(lxt)
-c   i      1      if   xt(i)  .lt.        xt(i+1) .eq. xt(lxt) .lt. x
-c
-c        In particular,  mflag = 0  is the 'usual' case.  mflag .ne. 0
-c        indicates that  x  lies outside the CLOSED interval
-c        xt(1) .le. y .le. xt(lxt) . The asymmetric treatment of the
-c        intervals is due to the decision to make all pp functions cont-
-c        inuous from the right, but, by returning  mflag = 0  even if
-C        x = xt(lxt), there is the option of having the computed pp function
-c        continuous from the left at  xt(lxt) .
-c
-c******  m e t h o d  ******
-c  The program is designed to be efficient in the common situation that
-c  it is called repeatedly, with  x  taken from an increasing or decrea-
-c  sing sequence. This will happen, e.g., when a pp function is to be
-c  graphed. The first guess for  left  is therefore taken to be the val-
-c  ue returned at the previous call and stored in the  l o c a l  varia-
-c  ble  ilo . A first check ascertains that  ilo .lt. lxt (this is nec-
-c  essary since the present call may have nothing to do with the previ-
-c  ous call). Then, if  xt(ilo) .le. x .lt. xt(ilo+1), we set  left =
-c  ilo  and are done after just three comparisons.
-c     Otherwise, we repeatedly double the difference  istep = ihi - ilo
-c  while also moving  ilo  and  ihi  in the direction of  x , until
-c                      xt(ilo) .le. x .lt. xt(ihi) ,
-c  after which we use bisection to get, in addition, ilo+1 = ihi .
-c  left = ilo  is then returned.
-c
-      integer left,lxt,mflag,   ihi,ilo,istep,middle
-      double precision x,xt(lxt)
-      data ilo /1/
-      save ilo  
-      ihi = ilo + 1
-      if (ihi .lt. lxt)                 go to 20
-         if (x .ge. xt(lxt))            go to 110
-         if (lxt .le. 1)                go to 90
-         ilo = lxt - 1
-         ihi = lxt
-c
-   20 if (x .ge. xt(ihi))               go to 40
-      if (x .ge. xt(ilo))               go to 100
-c
-c              **** now x .lt. xt(ilo) . decrease  ilo  to capture  x .
-      istep = 1
-   31    ihi = ilo
-         ilo = ihi - istep
-         if (ilo .le. 1)                go to 35
-         if (x .ge. xt(ilo))            go to 50
-         istep = istep*2
-                                        go to 31
-   35 ilo = 1
-      if (x .lt. xt(1))                 go to 90
-                                        go to 50
-c              **** now x .ge. xt(ihi) . increase  ihi  to capture  x .
-   40 istep = 1
-   41    ilo = ihi
-         ihi = ilo + istep
-         if (ihi .ge. lxt)              go to 45
-         if (x .lt. xt(ihi))            go to 50
-         istep = istep*2
-                                        go to 41
-   45 if (x .ge. xt(lxt))               go to 110
-      ihi = lxt
-c
-c           **** now xt(ilo) .le. x .lt. xt(ihi) . narrow the interval.
-   50 middle = (ilo + ihi)/2
-      if (middle .eq. ilo)              go to 100
-c     note. it is assumed that middle = ilo in case ihi = ilo+1 .
-      if (x .lt. xt(middle))            go to 53
-         ilo = middle
-                                        go to 50
-   53    ihi = middle
-                                        go to 50
-c**** set output and return.
-   90 mflag = -1
-      left = 1
-                                        return
-  100 mflag = 0
-      left = ilo
-                                        return
-  110 mflag = 1
-         if (x .eq. xt(lxt)) mflag = 0
-      left = lxt
-  111 if (left .eq. 1)                  return
-         left = left - 1
-         if (xt(left) .lt. xt(lxt))        return
-                                                                               go to 111
-      end
diff --git a/intrv.f b/intrv.f
deleted file mode 100644 (file)
index 827b5bd..0000000
--- a/intrv.f
+++ /dev/null
@@ -1,117 +0,0 @@
-*DECK INTRV
-      SUBROUTINE INTRV (XT, LXT, X, ILO, ILEFT, MFLAG)
-C***BEGIN PROLOGUE  INTRV
-C***PURPOSE  Compute the largest integer ILEFT in 1 .LE. ILEFT .LE. LXT
-C            such that XT(ILEFT) .LE. X where XT(*) is a subdivision
-C            of the X interval.
-C***LIBRARY   SLATEC
-C***CATEGORY  E3, K6
-C***TYPE      SINGLE PRECISION (INTRV-S, DINTRV-D)
-C***KEYWORDS  B-SPLINE, DATA FITTING, INTERPOLATION, SPLINES
-C***AUTHOR  Amos, D. E., (SNLA)
-C***DESCRIPTION
-C
-C     Written by Carl de Boor and modified by D. E. Amos
-C
-C     Abstract
-C         INTRV is the INTERV routine of the reference.
-C
-C         INTRV computes the largest integer ILEFT in 1 .LE. ILEFT .LE.
-C         LXT such that XT(ILEFT) .LE. X where XT(*) is a subdivision of
-C         the X interval.  Precisely,
-C
-C                      X .LT. XT(1)                1         -1
-C         if  XT(I) .LE. X .LT. XT(I+1)  then  ILEFT=I  , MFLAG=0
-C           XT(LXT) .LE. X                         LXT        1,
-C
-C         That is, when multiplicities are present in the break point
-C         to the left of X, the largest index is taken for ILEFT.
-C
-C     Description of Arguments
-C         Input
-C          XT      - XT is a knot or break point vector of length LXT
-C          LXT     - length of the XT vector
-C          X       - argument
-C          ILO     - an initialization parameter which must be set
-C                    to 1 the first time the spline array XT is
-C                    processed by INTRV.
-C
-C         Output
-C          ILO     - ILO contains information for efficient process-
-C                    ing after the initial call, and ILO must not be
-C                    changed by the user.  Distinct splines require
-C                    distinct ILO parameters.
-C          ILEFT   - largest integer satisfying XT(ILEFT) .LE. X
-C          MFLAG   - signals when X lies out of bounds
-C
-C     Error Conditions
-C         None
-C
-C***REFERENCES  Carl de Boor, Package for calculating with B-splines,
-C                 SIAM Journal on Numerical Analysis 14, 3 (June 1977),
-C                 pp. 441-472.
-C***ROUTINES CALLED  (NONE)
-C***REVISION HISTORY  (YYMMDD)
-C   800901  DATE WRITTEN
-C   890831  Modified array declarations.  (WRB)
-C   890831  REVISION DATE from Version 3.2
-C   891214  Prologue converted to Version 4.0 format.  (BAB)
-C   920501  Reformatted the REFERENCES section.  (WRB)
-C***END PROLOGUE  INTRV
-C
-      INTEGER IHI, ILEFT, ILO, ISTEP, LXT, MFLAG, MIDDLE
-      Double precision X, XT
-      DIMENSION XT(*)
-C***FIRST EXECUTABLE STATEMENT  INTRV
-      IHI = ILO + 1
-      IF (IHI.LT.LXT) GO TO 10
-      IF (X.GE.XT(LXT)) GO TO 110
-      IF (LXT.LE.1) GO TO 90
-      ILO = LXT - 1
-      IHI = LXT
-C
-   10 IF (X.GE.XT(IHI)) GO TO 40
-      IF (X.GE.XT(ILO)) GO TO 100
-C
-C *** NOW X .LT. XT(IHI) . FIND LOWER BOUND
-      ISTEP = 1
-   20 IHI = ILO
-      ILO = IHI - ISTEP
-      IF (ILO.LE.1) GO TO 30
-      IF (X.GE.XT(ILO)) GO TO 70
-      ISTEP = ISTEP*2
-      GO TO 20
-   30 ILO = 1
-      IF (X.LT.XT(1)) GO TO 90
-      GO TO 70
-C *** NOW X .GE. XT(ILO) . FIND UPPER BOUND
-   40 ISTEP = 1
-   50 ILO = IHI
-      IHI = ILO + ISTEP
-      IF (IHI.GE.LXT) GO TO 60
-      IF (X.LT.XT(IHI)) GO TO 70
-      ISTEP = ISTEP*2
-      GO TO 50
-   60 IF (X.GE.XT(LXT)) GO TO 110
-      IHI = LXT
-C
-C *** NOW XT(ILO) .LE. X .LT. XT(IHI) . NARROW THE INTERVAL
-   70 MIDDLE = (ILO+IHI)/2
-      IF (MIDDLE.EQ.ILO) GO TO 100
-C     NOTE. IT IS ASSUMED THAT MIDDLE = ILO IN CASE IHI = ILO+1
-      IF (X.LT.XT(MIDDLE)) GO TO 80
-      ILO = MIDDLE
-      GO TO 70
-   80 IHI = MIDDLE
-      GO TO 70
-C *** SET OUTPUT AND RETURN
-   90 MFLAG = -1
-      ILEFT = 1
-      RETURN
-  100 MFLAG = 0
-      ILEFT = ILO
-      RETURN
-  110 MFLAG = 1
-      ILEFT = LXT
-      RETURN
-      END
diff --git a/invsimpson.cpp b/invsimpson.cpp
deleted file mode 100644 (file)
index 238dea6..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  invsimpson.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 8/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "invsimpson.h"
-#include "simpson.h"
-
-/***********************************************************************/
-
-EstOutput InvSimpson::getValues(SAbundVector* rank){
-       try {
-               //vector<double> simpsonData(3,0);
-               data.resize(3,0);
-               vector<double> simpData(3,0);
-               Simpson* simp = new Simpson();
-               simpData = simp->getValues(rank);
-               
-               if(simpData[0] != 0){
-                       data[0] = 1/simpData[0];
-                       data[1] = 1/simpData[2];
-                       data[2] = 1/simpData[1];
-               }
-               else{
-                       data.assign(3,1);
-               }
-               
-               delete simp;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InvSimpson", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/invsimpson.h b/invsimpson.h
deleted file mode 100644 (file)
index 1471a6c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef INVSIMPSON
-#define INVSIMPSON
-
-/*
- *  invsimpson.h
- *  Mothur
- *
- *  Created by Pat Schloss on 8/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class InvSimpson : public Calculator  {
-       
-public:
-       InvSimpson() : Calculator("invsimpson", 3, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/InvSimpson"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/jackknife.cpp b/jackknife.cpp
deleted file mode 100644 (file)
index 8f06298..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- *  jacknife.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "jackknife.h"
-
-/***********************************************************************/
-void Jackknife::getAMatrix(void){
-       try {
-               vector<vector<double> > B = m->binomial(maxOrder);
-
-               aMat.resize(maxOrder+1);
-
-               for(int i=0;i<=maxOrder;i++){
-                       aMat[i].resize(maxOrder+1);
-                       for(int j=1;j<=maxOrder;j++){
-                       
-                               aMat[i][j] = 1 + B[i][j] * (int)(pow(-1.0,j+1));
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Jackknife", "getAMatrix");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double Jackknife::CN(double z){
-       try {
-               if(z>6.0)       {       return 0.0;             }
-               if(z<-6.0)      {       return 0.0;             }
-       
-               const double b1=  0.31938153;
-               const double b2= -0.356563782;
-               const double b3=  1.781477937;
-               const double b4= -1.821255978;
-               const double b5=  1.330274429;
-               const double p=   0.2316419;
-               const double c2=  0.3989423;
-       
-               double a=abs(z);
-               double t=1.0/(1.0+a*p);
-               double b=c2*exp((-z)*(z/2.0));
-               double n=((((b5*t+b4)*t+b3)*t+b2)*t+b1)*t;
-               n = 2*b*n;
-               return n;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Jackknife", "CN");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-EstOutput Jackknife::getValues(SAbundVector* rank){
-       try {
-               //EstOutput jackData(3,0);
-               data.resize(3,0);
-       
-               double jack, jacklci, jackhci;
-       
-               int maxRank = (double)rank->getMaxRank();
-               int S = rank->getNumBins();
-
-               double N[maxOrder+1];
-               double variance[maxOrder+1];
-               double p[maxOrder+1];
-       
-               int k = 0;
-
-               for(int i=0;i<=maxOrder;i++){
-                       N[i]=0.0000;
-                       variance[i]=0.0000;
-                       for(int j=1;j<=maxRank;j++){
-                               if(j<=i){
-                                       N[i] += aMat[i][j]*rank->get(j);
-                                       variance[i] += aMat[i][j]*aMat[i][j]*rank->get(j);
-                               }
-                               else{
-                                       N[i] += rank->get(j);
-                                       variance[i] += rank->get(j);
-                               }
-                       }
-                       variance[i] = variance[i]-N[i];
-                       double var = 0.0000;
-                       if(i>0){
-                               for(int j=1;j<=maxRank;j++){
-                                       if(j<=i){       var += rank->get(j)*pow((aMat[i][j]-aMat[i-1][j]),2.0); }
-                                       else    {       var += 0.0000;  }
-                               }
-                               var -= ((N[i]-N[i-1])*(N[i]-N[i-1]))/S;
-                               var = var * S / (S-1);
-                               double T = (N[i]-N[i-1])/sqrt(var);
-                               if(T<=0.00){    p[i-1] = 1.00000;               }
-                               else{                   p[i-1] = CN(T);                 }
-                       
-                               if(p[i-1]>=0.05){
-                                       k = i-1;
-                                       break;
-                               }
-                       }
-                       if(i == maxOrder){      k=1;    }
-               }
-
-               double ci = 0;
-       
-               if(k>1){
-                       double c = (0.05-p[k-1])/(p[k]-p[k-1]);
-                       ci = 0.0000;
-                       jack = c*N[k]+(1-c)*N[k-1];
-                       for(int j=1;j<=maxRank;j++){
-                               if(j<=k){       ci += rank->get(j)*pow((c*aMat[k][j]+(1-c)*aMat[k-1][j]),2.0);  }
-                               else    {       ci += rank->get(j);     }
-                       }
-                       ci = 1.96 * sqrt(ci - jack);
-               }
-               else if(k==1){
-                       jack = N[1];
-                       ci = 1.96*sqrt(variance[1]);
-               }else{
-                       jack = 0.0;
-                       ci = 0.0;
-               }
-       
-               jacklci = jack-ci;
-               jackhci = jack+ci;
-               
-               data[0] = jack;
-               data[1] = jacklci;
-               data[2] = jackhci;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-       
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Jackknife", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/jackknife.h b/jackknife.h
deleted file mode 100644 (file)
index fe9f6b6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef JACKKNIFE_H
-#define JACKKNIFE_H
-
-/*
- *  jacknife.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the JackKnife estimator on single group. 
-It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Jackknife : public Calculator  {
-       
-public:
-       Jackknife() : Calculator("jackknife", 3, false) {       getAMatrix(); };
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Jackknife"; }
-
-private:
-       static const int maxOrder = 30;
-       vector<vector<double> > aMat;
-
-       void getAMatrix();
-       double CN(double);
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/kmer.cpp b/kmer.cpp
deleted file mode 100644 (file)
index 50574f4..0000000
--- a/kmer.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- *  kmer.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "kmer.hpp"
-
-/**************************************************************************************************/
-
-Kmer::Kmer(int size) : kmerSize(size) {        //      The constructor sets the size of the kmer
-       
-       int power4s[14] = { 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864 };
-                                                                                                                                               //      No reason to waste the time of recalculating
-       maxKmer = power4s[kmerSize]+1;// (int)pow(4.,k)+1;                                      //      powers of 4 everytime through.  We need an
-                                                                                                                                               //      extra kmer if we get a non-ATGCU base
-}
-
-/**************************************************************************************************/
-
-string Kmer::getKmerString(string sequence){   //      Calculate kmer for each position in the sequence, count the freq
-       int length = sequence.length();                         //      of each kmer, and convert it to an ascii character with base '!'.
-       int nKmers = length - kmerSize + 1;                     //      Export the string of characters as a string
-       vector<int> counts(maxKmer, 0);
-       
-       for(int i=0;i<nKmers;i++){                                      //      Go though sequence and get the number between 0 and maxKmer for that
-               int kmerNumber = getKmerNumber(sequence, i);//  kmer.  Increase the count for the kmer in the counts vector
-               counts[kmerNumber]++;
-       }
-       
-       string kmerString = "";                                         
-       for(int i=0;i<maxKmer;i++){                                     //      Scan through the vector of counts and convert each element of the 
-               kmerString += getASCII(counts[i]);              //      vector to an ascii character that is equal to or greater than '!'
-       }               
-       
-       return kmerString;      
-}
-/**************************************************************************************************/
-
-vector< map<int, int> > Kmer::getKmerCounts(string sequence){  //      Calculate kmer for each position in the sequence, save info in a map
-       int length = sequence.length();                         //      so you know at each spot in the sequence what kmers were found
-       int nKmers = length - kmerSize + 1;                     //      
-       vector< map<int, int> > counts; counts.resize(nKmers);  // a map kmer counts for each spot
-        map<int, int>::iterator it;
-       
-       for(int i=0;i<nKmers;i++){                                      //      Go though sequence and get the number between 0 and maxKmer for that
-               if (i == 0) {
-                       int kmerNumber = getKmerNumber(sequence, i);//  kmer. 
-                       counts[i][kmerNumber] = 1;                      // add this kmer if not already there
-               }else { 
-                       //your count is everything that came before and whatever you find now
-                       counts[i] = counts[i-1];
-                       int kmerNumber = getKmerNumber(sequence, i);//  kmer.  
-                       
-                       it = counts[i].find(kmerNumber);
-                       if (it!= counts[i].end()) {   counts[i][kmerNumber]++;  }  //increment number of times you have seen this kmer
-                       else {   counts[i][kmerNumber] = 1;   }  // add this kmer since not already there
-               }
-       }
-       
-       return counts;  
-}
-       
-       
-/**************************************************************************************************/
-
-int Kmer::getKmerNumber(string sequence, int index){
-       
-//     Here we convert a kmer to a number between 0 and maxKmer.  For example, AAAA would equal 0 and TTTT would equal 255.
-//     If there's an N in the kmer, it is set to 256 (if we are looking at 4mers).  The largest we can look at are 8mers,
-//     this could be easily increased.
-//     
-//     Example:   ATGCAT (kSize = 6)
-//               i:   012345
-//
-//             Score   = 0*4^(6-0-1) + 3*4^(6-1-1) + 2*4^(6-2-1) + 1*4^(6-3-1) + 0*4^(6-4-1) + 3*4^(6-5-1)
-//                             = 0*4^5 +       3*4^4   +       2*4^3   +       1*4^2   +       0*4^1   +       3*4^0
-//                             = 0 + 3*256 + 2*64 + 1*16 + 0*4 + 3*1
-//                             = 0 + 768 + 128 + 16 + 0 + 3
-//                             = 915
-       
-       int power4s[14] = { 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864 };
-       
-       int kmer = 0;
-       
-       for(int i=0;i<kmerSize;i++){
-               if(toupper(sequence[i+index]) == 'A')           {       kmer += (0 * power4s[kmerSize-i-1]);    }
-               else if(toupper(sequence[i+index]) == 'C')      {       kmer += (1 * power4s[kmerSize-i-1]);    }
-               else if(toupper(sequence[i+index]) == 'G')      {       kmer += (2 * power4s[kmerSize-i-1]);    }
-               else if(toupper(sequence[i+index]) == 'U')      {       kmer += (3 * power4s[kmerSize-i-1]);    }
-               else if(toupper(sequence[i+index]) == 'T')      {       kmer += (3 * power4s[kmerSize-i-1]);    }
-               else if(toupper(sequence[i+index]) == 'N')      {       return (int)power4s[kmerSize];                  }
-       }
-       return kmer;    
-}
-       
-/**************************************************************************************************/
-       
-string Kmer::getKmerBases(int kmerNumber){
-       
-//     Here we convert the kmer number into the kmer in terms of bases.
-//
-//     Example:        Score = 915 (for a 6-mer)
-//                             Base6 = (915 / 4^0) % 4 = 915 % 4 = 3 => T      [T]
-//                             Base5 = (915 / 4^1) % 4 = 228 % 4 = 0 => A      [AT]
-//                             Base4 = (915 / 4^2) % 4 = 57 % 4 = 1 => C       [CAT]
-//                             Base3 = (915 / 4^3) % 4 = 14 % 4 = 2 => G       [GCAT]
-//                             Base2 = (915 / 4^4) % 4 = 3 % 4 = 3 => T        [TGCAT]
-//                             Base1 = (915 / 4^5) % 4 = 0 % 4 = 0 => A        [ATGCAT] -> this checks out with the previous method
-       
-       int power4s[14] = { 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864 };
-       
-       string kmer = "";
-       
-       if(kmerNumber == power4s[kmerSize]){//pow(4.,7)){       //      if the kmer number is the same as the maxKmer then it must
-               for(int i=0;i<kmerSize;i++){                                    //      have had an N in it and so we'll just call it N x kmerSize
-                       kmer += 'N';
-               }
-       }
-       else{
-               for(int i=0;i<kmerSize;i++){
-                       int nt = (int)(kmerNumber / (float)power4s[i]) % 4;             //      the '%' operator returns the remainder 
-                       if(nt == 0)             {       kmer = 'A' + kmer;      }                               //      from int-based division ]
-                       else if(nt == 1){       kmer = 'C' + kmer;      }
-                       else if(nt == 2){       kmer = 'G' + kmer;      }
-                       else if(nt == 3){       kmer = 'T' + kmer;      }
-               }
-       }
-       return kmer;
-}
-/**************************************************************************************************/
-
-int Kmer::getReverseKmerNumber(int kmerNumber){
-               
-       string kmerString = getKmerBases(kmerNumber);
-       
-       //get Reverse
-       string reverse = "";
-       for(int i=kmerString.length()-1;i>=0;i--){
-               if(kmerString[i] == 'A')                {       reverse += 'T'; }
-               else if(kmerString[i] == 'T'){  reverse += 'A'; }
-               else if(kmerString[i] == 'G'){  reverse += 'C'; }
-               else if(kmerString[i] == 'C'){  reverse += 'G'; }
-               else                                            {       reverse += 'N'; }
-       }
-       
-       int reverseNumber = getKmerNumber(reverse, 0);
-       
-       return reverseNumber;
-       
-}
-
-/**************************************************************************************************/
-
-char Kmer::getASCII(int number)                {       return (char)(33+number);                       }       // '!' is the first printable char and
-                                                                                                                                                               // has the int value of 33
-/**************************************************************************************************/
-
-int Kmer::getNumber(char character)    {       return ((int)(character-'!'));          }       // '!' has the value of 33
-
-/**************************************************************************************************/
diff --git a/kmer.hpp b/kmer.hpp
deleted file mode 100644 (file)
index 9a3c5a0..0000000
--- a/kmer.hpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef KMER_HPP
-#define KMER_HPP
-
-/*
- *  kmer.hpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-/**************************************************************************************************/
-
-class Kmer {
-       
-public:
-       Kmer(int);
-       string getKmerString(string);
-       int getKmerNumber(string, int);
-       string getKmerBases(int);
-       int getReverseKmerNumber(int);
-       vector< map<int, int> > getKmerCounts(string sequence);  //for use in chimeraCheck
-       
-private:
-       char getASCII(int);
-       int getNumber(char);
-       int kmerSize;
-       int maxKmer;
-       int nKmers;
-};
-
-/**************************************************************************************************/
-
-
-#endif
diff --git a/kmerdb.cpp b/kmerdb.cpp
deleted file mode 100644 (file)
index 9a5d235..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *  kmerdb.cpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is a child class of the Database class, which stores the template sequences as a kmer table and provides
- *     a method of searching the kmer table for the sequence with the most kmers in common with a query sequence.
- *     kmerLocations is the primary storage variable that is a two-dimensional vector where each row represents the
- *     different number of kmers and each column contains the index to sequences that use that kmer.
- *
- *     Construction of an object of this type will first look for an appropriately named database file and if it is found
- *     then will read in the database file (readKmerDB), otherwise it will generate one and store the data in memory
- *     (generateKmerDB)
- *
- *     The search method used here is roughly the same as that used in the SimRank program that is found at the
- *     greengenes website.  The default kmer size is 7.  The speed complexity is between O(L) and O(LN).  When I use 7mers
- *     on average a kmer is found in ~100 other sequences with a database of ~5000 sequences.  If this is the case then the
- *     time would be on the order of O(0.1LN) -> fast.
- *
-
- */
-
-#include "sequence.hpp"
-#include "kmer.hpp"
-#include "database.hpp"
-#include "kmerdb.hpp"
-
-/**************************************************************************************************/
-
-KmerDB::KmerDB(string fastaFileName, int kSize) : Database(), kmerSize(kSize) {
-       try { 
-       
-               kmerDBName = fastaFileName.substr(0,fastaFileName.find_last_of(".")+1) + char('0'+ kmerSize) + "mer";
-               
-               int power4s[14] = { 1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864 };
-               count = 0;
-               
-               maxKmer = power4s[kmerSize];
-               kmerLocations.resize(maxKmer+1);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "KmerDB");
-               exit(1);
-       }       
-
-}
-/**************************************************************************************************/
-KmerDB::KmerDB() : Database() {}
-/**************************************************************************************************/
-
-KmerDB::~KmerDB(){}
-
-/**************************************************************************************************/
-
-vector<int> KmerDB::findClosestSequences(Sequence* candidateSeq, int num){
-       try {
-               if (num > numSeqs) { m->mothurOut("[WARNING]: you requested " + toString(num) + " closest sequences, but the template only contains " + toString(numSeqs) + ", adjusting."); m->mothurOutEndLine(); num = numSeqs; }
-               
-               vector<int> topMatches;
-               Kmer kmer(kmerSize);
-               searchScore = 0;
-               Scores.clear();
-               
-               vector<int> matches(numSeqs, 0);                                                //      a record of the sequences with shared kmers
-               vector<int> timesKmerFound(kmerLocations.size()+1, 0);  //      a record of the kmers that we have already found
-               
-               int numKmers = candidateSeq->getNumBases() - kmerSize + 1;      
-       
-               for(int i=0;i<numKmers;i++){
-                       int kmerNumber = kmer.getKmerNumber(candidateSeq->getUnaligned(), i);           //      go through the query sequence and get a kmer number
-                       if(timesKmerFound[kmerNumber] == 0){                            //      if we haven't seen it before...
-                               for(int j=0;j<kmerLocations[kmerNumber].size();j++){//increase the count for each sequence that also has
-                                       matches[kmerLocations[kmerNumber][j]]++;        //      that kmer
-                               }
-                       }
-                       timesKmerFound[kmerNumber] = 1;                                         //      ok, we've seen the kmer now
-               }
-               
-               if (num != 1) {
-                       vector<seqMatch> seqMatches; seqMatches.resize(numSeqs);
-                       for(int i=0;i<numSeqs;i++){             
-                               seqMatches[i].seq = i;
-                               seqMatches[i].match = matches[i];
-                       }
-                       
-                       //sorts putting largest matches first
-                       sort(seqMatches.begin(), seqMatches.end(), compareSeqMatches);
-                       
-                       searchScore = seqMatches[0].match;
-                       searchScore = 100 * searchScore / (float) numKmers;             //      return the Sequence object corresponding to the db
-               
-                       //save top matches
-                       for (int i = 0; i < num; i++) {
-                               topMatches.push_back(seqMatches[i].seq);
-                               float thisScore = 100 * seqMatches[i].match / (float) numKmers;
-                               Scores.push_back(thisScore);
-                       }
-               }else{
-                       int bestIndex = 0;
-                       int bestMatch = -1;
-                       for(int i=0;i<numSeqs;i++){     
-                               
-                               if (matches[i] > bestMatch) {
-                                       bestIndex = i;
-                                       bestMatch = matches[i];
-                               }
-                       }
-                       
-                       searchScore = bestMatch;
-                       searchScore = 100 * searchScore / (float) numKmers;             //      return the Sequence object corresponding to the db
-                       topMatches.push_back(bestIndex);
-                       Scores.push_back(searchScore);
-               }
-               return topMatches;              
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "findClosestSequences");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-void KmerDB::generateDB(){
-       try {
-               
-               ofstream kmerFile;                                                                              //      once we have the kmerLocations folder print it out
-               m->openOutputFile(kmerDBName, kmerFile);                                        //      to a file
-               
-               //output version
-               kmerFile << "#" << m->getVersion() << endl;
-               
-               for(int i=0;i<maxKmer;i++){                                                             //      step through all of the possible kmer numbers
-                       kmerFile << i << ' ' << kmerLocations[i].size();        //      print the kmer number and the number of sequences with
-                       for(int j=0;j<kmerLocations[i].size();j++){                     //      that kmer.  then print out the indices of the sequences
-                               kmerFile << ' ' << kmerLocations[i][j];                 //      with that kmer.
-                       }
-                       kmerFile << endl;
-               }
-               kmerFile.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "generateDB");
-               exit(1);
-       }       
-       
-}
-/**************************************************************************************************/
-void KmerDB::addSequence(Sequence seq) {
-       try {
-               Kmer kmer(kmerSize);
-               
-               string unaligned = seq.getUnaligned();  //      ...take the unaligned sequence...
-               int numKmers = unaligned.length() - kmerSize + 1;
-                       
-               vector<int> seenBefore(maxKmer+1,0);
-               for(int j=0;j<numKmers;j++){                                            //      ...step though the sequence and get each kmer...
-                       int kmerNumber = kmer.getKmerNumber(unaligned, j);
-                       if(seenBefore[kmerNumber] == 0){
-                               kmerLocations[kmerNumber].push_back(count);             //      ...insert the sequence index into kmerLocations for
-                       }                                                                                               //      the appropriate kmer number
-                       seenBefore[kmerNumber] = 1;
-               }                                                                                                       
-       
-               count++;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "addSequence");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-
-void KmerDB::readKmerDB(ifstream& kmerDBFile){
-       try {
-                                       
-               kmerDBFile.seekg(0);                                                                    //      start at the beginning of the file
-               
-               //read version
-               string line = m->getline(kmerDBFile); m->gobble(kmerDBFile);
-               
-               string seqName;
-               int seqNumber;
-
-               for(int i=0;i<maxKmer;i++){
-                       int numValues = 0;      
-                       kmerDBFile >> seqName >> numValues;
-                       
-                       for(int j=0;j<numValues;j++){                                           //      for each kmer number get the...
-                               kmerDBFile >> seqNumber;                                                //              1. number of sequences with the kmer number
-                               kmerLocations[i].push_back(seqNumber);                  //              2. sequence indices
-                       }
-               }
-               kmerDBFile.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "readKmerDB");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-int KmerDB::getCount(int kmer) {
-       try {
-               if (kmer < 0) { return 0; }  //if user gives negative number
-               else if (kmer > maxKmer) {      return 0;       }  //or a kmer that is bigger than maxkmer
-               else {  return kmerLocations[kmer].size();      }  // kmer is in vector range
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "getCount");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-int KmerDB::getReversed(int kmerNumber) {
-       try {
-               Kmer kmer(kmerSize);
-               
-               if (kmerNumber < 0) { return 0; }  //if user gives negative number
-               else if (kmerNumber > maxKmer) {        return 0;       }  //or a kmer that is bigger than maxkmer
-               else {  return kmer.getReverseKmerNumber(kmerNumber);   }  // kmer is in vector range
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "getReversed");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-vector<int> KmerDB::getSequencesWithKmer(int kmer) {
-       try {
-               
-               vector<int> seqs;
-       
-               if (kmer < 0) { }  //if user gives negative number
-               else if (kmer > maxKmer) {      }  //or a kmer that is bigger than maxkmer
-               else {  seqs = kmerLocations[kmer];     }
-               
-               return seqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KmerDB", "getSequencesWithKmer");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-
-
-/**************************************************************************************************/
-
-
diff --git a/kmerdb.hpp b/kmerdb.hpp
deleted file mode 100644 (file)
index ead3d7e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef KMERDB_HPP
-#define KMERDB_HPP
-
-/*
- *  kmerdb.h
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is a child class of the Database class, which stores the template sequences as a kmer table and provides
- *     a method of searching the kmer table for the sequence with the most kmers in common with a query sequence.
- *     kmerLocations is the primary storage variable that is a two-dimensional vector where each row represents the
- *     different number of kmers and each column contains the index to sequences that use that kmer.
- *
- *     Construction of an object of this type will first look for an appropriately named database file and if it is found
- *     then will read in the database file (readKmerDB), otherwise it will generate one and store the data in memory
- *     (generateKmerDB)
-
- */
-
-#include "mothur.h"
-#include "database.hpp"
-
-class KmerDB : public Database {
-       
-public:
-       KmerDB(string, int);
-       KmerDB();
-       ~KmerDB();
-       
-       void generateDB();
-       void addSequence(Sequence);
-       vector<int> findClosestSequences(Sequence*, int);
-       void readKmerDB(ifstream&);
-       int getCount(int);  //returns number of sequences with that kmer number
-       vector<int> getSequencesWithKmer(int);  //returns vector of sequences that contain kmer passed in
-       int getReversed(int);  //returns reverse compliment kmerNumber 
-       int getMaxKmer() { return maxKmer; }
-       
-private:
-       
-       int kmerSize;
-       int maxKmer, count;
-       string kmerDBName;
-       vector<vector<int> > kmerLocations;
-};
-
-#endif
diff --git a/knn.cpp b/knn.cpp
deleted file mode 100644 (file)
index 837fa6d..0000000
--- a/knn.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *  knn.cpp
- *  Mothur
- *
- *  Created by westcott on 11/4/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "knn.h"
-
-/**************************************************************************************************/
-Knn::Knn(string tfile, string tempFile, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int n, int tid) 
-: Classify(), num(n), search(method) {
-       try {
-               threadID = tid;
-               
-               //create search database and names vector
-               generateDatabaseAndNames(tfile, tempFile, method, kmerSize, gapOpen, gapExtend, match, misMatch);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Knn", "Knn");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Knn::setDistName(string s) {
-       try {
-               outDistName = s;
-               ofstream outDistance;
-               m->openOutputFile(outDistName, outDistance);
-               outDistance << "Name\tBestMatch\tDistance" << endl;
-               outDistance.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Knn", "setDistName");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-Knn::~Knn() {
-       try {
-                delete phyloTree; 
-                if (database != NULL) {  delete database; }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Knn", "~Knn");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string Knn::getTaxonomy(Sequence* seq) {
-       try {
-               string tax;
-               
-               //use database to find closest seq
-               vector<int> closest = database->findClosestSequences(seq, num);
-       
-               if (search == "distance") { ofstream outDistance; m->openOutputFileAppend(outDistName, outDistance); outDistance << seq->getName() << '\t' << database->getName(closest[0]) << '\t' << database->getSearchScore() << endl; outDistance.close();  }
-       
-               if (m->control_pressed) { return tax; }
-
-               vector<string> closestNames;
-               for (int i = 0; i < closest.size(); i++) {
-                       //find that sequences taxonomy in map
-                       it = taxonomy.find(names[closest[i]]);
-               
-                       //is this sequence in the taxonomy file
-                       if (it == taxonomy.end()) { //error not in file
-                               m->mothurOut("Error: sequence " + names[closest[i]] + " is not in the taxonomy file.  It will be eliminated as a match to sequence " + seq->getName() + "."); m->mothurOutEndLine();
-                       }else{   closestNames.push_back(it->first);     }
-               }
-               
-               if (closestNames.size() == 0) {
-                       m->mothurOut("Error: All the matches for sequence " + seq->getName() + " have been eliminated. "); m->mothurOutEndLine();
-                       tax = "unknown;";
-               }else{
-                       tax = findCommonTaxonomy(closestNames);
-                       if (tax == "") { m->mothurOut("There are no common levels for sequence " + seq->getName() + ". "); m->mothurOutEndLine(); tax = "unknown;"; }
-               }
-               
-               simpleTax = tax;
-               return tax;     
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Knn", "getTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string Knn::findCommonTaxonomy(vector<string> closest)  {
-       try {
-               /*vector< vector<string> > taxons;  //taxon[0] = vector of taxonomy info for closest[0].
-                                                                               //so if closest[0] taxonomy is Bacteria;Alphaproteobacteria;Rhizobiales;Azorhizobium_et_rel.;Methylobacterium_et_rel.;Bosea;
-                                                                               //taxon[0][0] = Bacteria, taxon[0][1] = Alphaproteobacteria....
-                                                                               
-               taxons.resize(closest.size());
-               int smallest = 100;
-               
-               for (int i = 0; i < closest.size(); i++) {
-                       if (m->control_pressed) { return "control"; }
-               
-                       string tax = taxonomy[closest[i]];  //we know its there since we checked in getTaxonomy
-                       cout << tax << endl;
-               
-                       taxons[i] = parseTax(tax);
-               
-                       //figure out who has the shortest taxonomy info. so you can start comparing there
-                       if (taxons[i].size() < smallest) {
-                               smallest = taxons[i].size();
-                       }
-               }
-       
-               //start at the highest level all the closest seqs have
-               string common = "";
-               for (int i = (smallest-1); i >= 0; i--) {
-                       if (m->control_pressed) { return "control"; }
-
-                       string thistax = taxons[0][i];
-                       int num = 0;
-                       for (int j = 1; j < taxons.size(); j++) {
-                               if (taxons[j][i] != thistax) { break; }
-                               num = j;
-                       }
-               
-                       if (num == (taxons.size()-1)) { //they all match at this level
-                               for (int k = 0; k <= i; k++) {
-                                       common += taxons[0][k] + ';';
-                               }
-                               break;
-                       }
-               }*/
-               
-               string conTax;
-               
-               //create a tree containing sequences from this bin
-               PhyloTree* p = new PhyloTree();
-               
-               for (int i = 0; i < closest.size(); i++) {
-                       p->addSeqToTree(closest[i], taxonomy[closest[i]]);
-               }
-               
-               //build tree
-               p->assignHeirarchyIDs(0);
-               
-               TaxNode currentNode = p->get(0);
-               
-               //at each level
-               while (currentNode.children.size() != 0) { //you still have more to explore
-                       
-                       TaxNode bestChild;
-                       int bestChildSize = 0;
-                       
-                       //go through children
-                       for (map<string, int>::iterator itChild = currentNode.children.begin(); itChild != currentNode.children.end(); itChild++) {
-                               
-                               TaxNode temp = p->get(itChild->second);
-                               
-                               //select child with largest accessions - most seqs assigned to it
-                               if (temp.accessions.size() > bestChildSize) {
-                                       bestChild = p->get(itChild->second);
-                                       bestChildSize = temp.accessions.size();
-                               }
-                               
-                       }
-                       
-                       if (bestChildSize == closest.size()) { //if yes, add it
-                               conTax += bestChild.name + ";";
-                       }else{ //if no, quit
-                               break;
-                       }
-                       
-                       //move down a level
-                       currentNode = bestChild;
-               }
-               
-               delete p;       
-               
-               return conTax;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Knn", "findCommonTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
diff --git a/knn.h b/knn.h
deleted file mode 100644 (file)
index c544235..0000000
--- a/knn.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef KNN_H
-#define KNN_H
-
-/*
- *  knn.h
- *  Mothur
- *
- *  Created by westcott on 11/4/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-#include "mothur.h"
-#include "classify.h"
-
-/**************************************************************************************************/
-
-class Knn : public Classify {
-       
-public:
-       Knn(string, string, string, int, float, float, float, float, int, int);
-       ~Knn();
-       
-       void setDistName(string s);
-       string getTaxonomy(Sequence*);
-       
-private:
-       int num;
-       string findCommonTaxonomy(vector<string>);
-       string search, outDistName;
-       
-};
-
-/**************************************************************************************************/
-
-#endif
-
-
diff --git a/libshuff.cpp b/libshuff.cpp
deleted file mode 100644 (file)
index 5f1bdef..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *  libshuffform.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "libshuff.h"
-
-/***********************************************************************/
-
-void swap(int& i,int& j){      int t = i;  i = j;  j = t;      }
-
-/***********************************************************************/
-
-Libshuff::Libshuff(FullMatrix* D, int it, float step, float co) : matrix(D), iters(it), stepSize(step), cutOff(co){
-       try{
-               m = MothurOut::getInstance();
-               groupNames = matrix->getGroups();
-               groupSizes = matrix->getSizes();
-               numGroups = matrix->getNumGroups();
-               initializeGroups(matrix);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Libshuff", "Libshuff");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Libshuff::initializeGroups(FullMatrix* matrix){
-       try{
-               groups.resize(numGroups);
-               savedGroups.resize(numGroups);
-               
-               savedGroups.resize(numGroups);
-               for(int i=0;i<numGroups;i++) {
-                       groups[i].resize(groupSizes[i]);
-                       savedGroups[i].resize(groupSizes[i]);
-               }
-               int index=0;
-               for(int i=0;i<numGroups;i++){
-
-                       for(int j=0;j<groupSizes[i];j++){
-                               savedGroups[i][j] = groups[i][j] = index++;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Libshuff", "initializeGroups");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-vector<vector<vector<double> > > Libshuff::getSavedMins(){
-       return savedMins;
-}
-
-/***********************************************************************/
-
-vector<double> Libshuff::getMinX(int x){
-       try{
-               vector<double> minX(groupSizes[x], 0);
-               for(int i=0;i<groupSizes[x];i++){
-                       minX[i] = (groupSizes[x] > 1 ? (i==0 ? matrix->get(groups[x][0], groups[x][1]) : matrix->get(groups[x][i], groups[x][0])) : 0.0); //get the first value in row i of this block
-                       //minX[i] = matrix->get(groups[x][i], groups[x][0]);
-                       for(int j=0;j<groupSizes[x];j++){
-                               if(i != j)      {
-                                       double dx = matrix->get(groups[x][i], groups[x][j]);
-                                       if(dx < minX[i]){       minX[i] = dx;   }
-                               }
-                       }
-               }
-               return minX;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Libshuff", "getMinX");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-vector<double> Libshuff::getMinXY(int x, int y){
-       try{
-               vector<double> minXY(groupSizes[x], 0);
-
-               for(int i=0;i<groupSizes[x];i++){
-                       minXY[i] = matrix->get(groups[x][i], groups[y][0]);
-                       for(int j=0;j<groupSizes[y];j++){
-                               double dxy = matrix->get(groups[x][i], groups[y][j]);
-                               if(dxy<minXY[i]){       minXY[i] = dxy; }
-                       }
-               }
-               return minXY;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Libshuff", "getMinXY");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Libshuff::randomizeGroups(int x, int y){
-       try{
-               int nv = groupSizes[x]+groupSizes[y];
-               vector<int> v(nv);
-               
-               int index=0;
-               for(int k=0;k<groupSizes[x];k++)        {       v[index++] = groups[x][k];      }
-               for(int k=0;k<groupSizes[y];k++)        {       v[index++] = groups[y][k];      }
-               
-               for(int k=nv-1;k>0;k--){
-                       int z = (int)(rand() % k);
-                       swap(v[z],v[k]);
-               }
-               
-               index=0;
-               for(int k=0;k<groupSizes[x];k++)        {       groups[x][k]=v[index++];        }
-               for(int k=0;k<groupSizes[y];k++)        {       groups[y][k]=v[index++];        }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Libshuff", "randomizeGroups");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Libshuff::resetGroup(int x){
-       
-       for(int k=0;k<groupSizes[x];k++)        {       groups[x][k] = savedGroups[x][k];       }
-       
-}
-
-/***********************************************************************/
diff --git a/libshuff.h b/libshuff.h
deleted file mode 100644 (file)
index ef0e1b0..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef LIBSHUFF
-#define LIBSHUFF
-
-/*
- *  libshuff.h
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "fullmatrix.h"
-
-class Libshuff {
-       
-public:
-       Libshuff(FullMatrix*, int, float, float);
-       virtual vector<vector<double> > evaluateAll() = 0;
-       virtual float evaluatePair(int,int) = 0;
-       void randomizeGroups(int, int);
-       void resetGroup(int);
-       vector<vector<vector<double> > > getSavedMins();
-
-protected:
-       void initializeGroups(FullMatrix*);
-       vector<double> getMinX(int);
-       vector<double> getMinXY(int, int);
-       
-       vector<vector<vector<double> > > savedMins;
-       
-       
-       FullMatrix* matrix;
-       vector<int> groupSizes;
-       vector<string> groupNames;
-       vector<vector<int> > groups;
-       vector<vector<int> > savedGroups;
-       vector<double> minX;
-       vector<double> minXY;
-       float cutOff;
-       int iters;
-       float stepSize;
-       
-       int numGroups;
-       MothurOut* m;
-};
-
-#endif
diff --git a/libshuffcommand.cpp b/libshuffcommand.cpp
deleted file mode 100644 (file)
index 1d1d41f..0000000
+++ /dev/null
@@ -1,548 +0,0 @@
-/*
- *  libshuffcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class is designed to implement an integral form of the Cramer-von Mises statistic.
-       you may refer to the "Integration of Microbial Ecology and Statistics: A Test To Compare Gene Libraries" 
-       paper in Applied and Environmental Microbiology, Sept. 2004, p. 5485-5492 0099-2240/04/$8.00+0  
-       DOI: 10.1128/AEM.70.9.5485-5492.2004 Copyright 2004 American Society for Microbiology for more information. */
-
-
-#include "libshuffcommand.h"
-#include "libshuff.h"
-#include "slibshuff.h"
-#include "dlibshuff.h"
-
-
-
-//**********************************************************************************************************************
-vector<string> LibShuffCommand::setParameters(){       
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "10000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pstep("step", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pstep);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pform("form", "Multiple", "discrete-integral", "integral", "", "", "",false,false); parameters.push_back(pform);
-               CommandParameter psim("sim", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psim);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string LibShuffCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The libshuff command parameters are phylip, group, sim, groups, iters, step, form and cutoff.  phylip and group parameters are required, unless you have valid current files.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "The group names are separated by dashes.  The iters parameter allows you to specify how many random matrices you would like compared to your matrix.\n";
-               helpString += "The step parameter allows you to specify change in distance you would like between each output if you are using the discrete form.\n";
-               helpString += "The form parameter allows you to specify if you would like to analyze your matrix using the discrete or integral form. Your options are integral or discrete.\n";
-               helpString += "The libshuff command should be in the following format: libshuff(groups=yourGroups, iters=yourIters, cutOff=yourCutOff, form=yourForm, step=yourStep).\n";
-               helpString += "Example libshuff(groups=A-B-C, iters=500, form=discrete, step=0.01, cutOff=2.0).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, iters is 10000, cutoff is 1.0, form is integral and step is 0.01.\n";
-               helpString += "The libshuff command output two files: .coverage and .slsummary their descriptions are in the manual.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. iters), '=' and parameters (i.e.yourIters).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-LibShuffCommand::LibShuffCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["coverage"] = tempOutNames;
-               outputTypes["libshuffsummary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "LibShuffCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-LibShuffCommand::LibShuffCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["coverage"] = tempOutNames;
-                       outputTypes["libshuffsummary"] = tempOutNames;
-                       
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { phylipfile = ""; abort = true; }
-                       else if (phylipfile == "not found") { 
-                               phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") {  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("You must provide a phylip file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               } 
-                       }else { m->setPhylipFile(phylipfile); } 
-                       
-                       //check for required parameters
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") { 
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") {  m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("You must provide a group file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               } 
-                       }else { m->setGroupFile(groupfile); }   
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(phylipfile); //if user entered a file with a path then preserve it      
-                       }
-                                               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; savegroups = groups; }
-                       else { 
-                               savegroups = groups;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                               
-                       string temp;
-                       temp = validParameter.validFile(parameters, "iters", false);                            if (temp == "not found") { temp = "10000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                           if (temp == "not found") { temp = "1.0"; }
-                       m->mothurConvert(temp, cutOff); 
-                       
-                       temp = validParameter.validFile(parameters, "step", false);                             if (temp == "not found") { temp = "0.01"; }
-                       m->mothurConvert(temp, step); 
-                       
-                       temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
-                       sim = m->isTrue(temp); 
-                       
-                       userform = validParameter.validFile(parameters, "form", false);                 if (userform == "not found") { userform = "integral"; }
-                       
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "LibShuffCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int LibShuffCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read files
-               groupMap = new GroupMap(groupfile);
-               int error = groupMap->readMap();
-               if (error == 1) { delete groupMap; return 0; }
-               
-               ifstream in;
-               m->openInputFile(phylipfile, in);
-               matrix = new FullMatrix(in, groupMap, sim); //reads the matrix file
-               in.close();
-               
-               if (m->control_pressed) { delete groupMap; delete matrix; return 0; }
-               
-               //if files don't match...
-               if (matrix->getNumSeqs() < groupMap->getNumSeqs()) {  
-                       m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences.");  m->mothurOutEndLine();                         
-                       //create new group file
-                       if(outputDir == "") { outputDir += m->hasPath(groupfile); }
-                       
-                       string newGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "editted.groups";
-                       outputNames.push_back(newGroupFile);
-                       ofstream outGroups;
-                       m->openOutputFile(newGroupFile, outGroups);
-                       
-                       for (int i = 0; i < matrix->getNumSeqs(); i++) {
-                               if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; }
-                               
-                               Names temp = matrix->getRowInfo(i);
-                               outGroups << temp.seqName << '\t' << temp.groupName << endl;
-                       }
-                       outGroups.close();
-                       
-                       m->mothurOut(newGroupFile + " is a new group file containing only the sequence that are in your distance file. I will read this file instead."); m->mothurOutEndLine();
-                       
-                       //read new groupfile
-                       delete groupMap; 
-                       groupfile = newGroupFile;
-                       
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-                       
-                       if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; }
-               }
-               
-                       
-               setGroups();                                                            //set the groups to be analyzed and sorts them
-               
-               if (numGroups < 2) { m->mothurOut("[ERROR]: libshuff requires at least 2 groups, you only have " + toString(numGroups) + ", aborting."); m->mothurOutEndLine(); m->control_pressed = true; }
-               
-               if (m->control_pressed) { delete groupMap; delete matrix; return 0; }
-               
-               /********************************************************************************************/
-               //this is needed because when we read the matrix we sort it into groups in alphabetical order
-               //the rest of the command and the classes used in this command assume specific order
-               /********************************************************************************************/
-               matrix->setGroups(groupMap->getNamesOfGroups());
-               vector<int> sizes;
-               for (int i = 0; i < (groupMap->getNamesOfGroups()).size(); i++) {   sizes.push_back(groupMap->getNumSeqs((groupMap->getNamesOfGroups())[i]));  }
-               matrix->setSizes(sizes);
-                       
-                       
-               if(userform == "discrete"){
-                       form = new DLibshuff(matrix, iters, step, cutOff);
-               }
-               else{
-                       form = new SLibshuff(matrix, iters, cutOff);
-               }
-       
-               savedDXYValues = form->evaluateAll();
-               savedMinValues = form->getSavedMins();
-               
-               if (m->control_pressed) {  delete form; m->clearGroups(); delete matrix; delete groupMap; return 0; }
-       
-               pValueCounts.resize(numGroups);
-               for(int i=0;i<numGroups;i++){
-                       pValueCounts[i].assign(numGroups, 0);
-               }
-       
-               if (m->control_pressed) {  outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; return 0; }
-                               
-               Progress* reading = new Progress();
-               
-               for(int i=0;i<numGroups-1;i++) {
-                       for(int j=i+1;j<numGroups;j++) {
-                               
-                               if (m->control_pressed) {  outputTypes.clear();  delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
-
-                               reading->newLine(groupNames[i]+'-'+groupNames[j], iters);
-                               int spoti = groupMap->groupIndex[groupNames[i]]; //neccessary in case user selects groups so you know where they are in the matrix
-                               int spotj = groupMap->groupIndex[groupNames[j]];
-       
-                               for(int p=0;p<iters;p++) {      
-                                       
-                                       if (m->control_pressed) {  outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
-                                       
-                                       form->randomizeGroups(spoti,spotj); 
-                                       if(form->evaluatePair(spoti,spotj) >= savedDXYValues[spoti][spotj])     {       pValueCounts[i][j]++;   }
-                                       if(form->evaluatePair(spotj,spoti) >= savedDXYValues[spotj][spoti])     {       pValueCounts[j][i]++;   }
-                                       
-                                       if (m->control_pressed) {  outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
-                                       
-                                       reading->update(p);                     
-                               }
-                               form->resetGroup(spoti);
-                               form->resetGroup(spotj);
-                       }
-               }
-               
-               if (m->control_pressed) { outputTypes.clear();  delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
-       
-               reading->finish();
-               delete reading;
-
-               m->mothurOutEndLine();
-               printSummaryFile();
-               printCoverageFile();
-                               
-               //clear out users groups
-               m->clearGroups();
-               delete form;
-               
-               delete matrix; delete groupMap;
-               
-               if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0; }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int LibShuffCommand::printCoverageFile() {
-       try {
-
-               ofstream outCov;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "libshuff.coverage";
-               m->openOutputFile(summaryFile, outCov);
-               outputNames.push_back(summaryFile); outputTypes["coverage"].push_back(summaryFile);
-               outCov.setf(ios::fixed, ios::floatfield); outCov.setf(ios::showpoint);
-               //cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               
-               map<double,vector<int> > allDistances;
-               map<double,vector<int> >::iterator it;
-
-               vector<vector<int> > indices(numGroups);
-               int numIndices = numGroups * numGroups;
-               
-               int index = 0;
-               for(int i=0;i<numGroups;i++){
-                       indices[i].assign(numGroups,0);
-                       for(int j=0;j<numGroups;j++){
-                               indices[i][j] = index++;
-                               
-                               int spoti = groupMap->groupIndex[groupNames[i]]; //neccessary in case user selects groups so you know where they are in the matrix
-                               int spotj = groupMap->groupIndex[groupNames[j]];
-                               
-                               for(int k=0;k<savedMinValues[spoti][spotj].size();k++){
-                                       
-                                       if(m->control_pressed)  { outCov.close(); return 0; }
-                                       
-                                       if(allDistances[savedMinValues[spoti][spotj][k]].size() != 0){
-                                               allDistances[savedMinValues[spoti][spotj][k]][indices[i][j]]++;
-                                       }
-                                       else{
-                                               allDistances[savedMinValues[spoti][spotj][k]].assign(numIndices, 0);
-                                               allDistances[savedMinValues[spoti][spotj][k]][indices[i][j]] = 1;
-                                       }
-                               }
-                       }
-               }
-               it=allDistances.begin();
-               
-               //cout << setprecision(8);
-
-               vector<int> prevRow = it->second;
-               it++;
-               
-               for(;it!=allDistances.end();it++){
-                       for(int i=0;i<it->second.size();i++){
-                               it->second[i] += prevRow[i];
-                       }
-                       prevRow = it->second;
-               }
-               
-               vector<int> lastRow = allDistances.rbegin()->second;
-               outCov << setprecision(8);
-               
-               outCov << "dist";
-               for (int i = 0; i < numGroups; i++){
-                       outCov << '\t' << groupNames[i];
-               }
-               for (int i=0;i<numGroups;i++){
-                       for(int j=i+1;j<numGroups;j++){
-                               if(m->control_pressed)  { outCov.close(); return 0; }
-                               outCov << '\t' << groupNames[i] << '-' << groupNames[j] << '\t';
-                               outCov << groupNames[j] << '-' << groupNames[i];
-                       }
-               }
-               outCov << endl;
-               
-               for(it=allDistances.begin();it!=allDistances.end();it++){
-                       outCov << it->first << '\t';
-                       for(int i=0;i<numGroups;i++){
-                               outCov << it->second[indices[i][i]]/(float)lastRow[indices[i][i]] << '\t';
-                       }
-                       for(int i=0;i<numGroups;i++){
-                               for(int j=i+1;j<numGroups;j++){
-                                       if(m->control_pressed)  { outCov.close(); return 0; }
-                                       
-                                       outCov << it->second[indices[i][j]]/(float)lastRow[indices[i][j]] << '\t';
-                                       outCov << it->second[indices[j][i]]/(float)lastRow[indices[j][i]] << '\t';
-                               }
-                       }
-                       outCov << endl;
-               }
-               outCov.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "printCoverageFile");
-               exit(1);
-       }
-} 
-
-//**********************************************************************************************************************
-
-int LibShuffCommand::printSummaryFile() {
-       try {
-
-               ofstream outSum;
-               summaryFile = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "libshuff.summary";
-               m->openOutputFile(summaryFile, outSum);
-               outputNames.push_back(summaryFile); outputTypes["libshuffsummary"].push_back(summaryFile);
-
-               outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               
-               cout << setw(20) << left << "Comparison" << '\t' << setprecision(8) << "dCXYScore" << '\t' << "Significance" << endl;
-               m->mothurOutJustToLog("Comparison\tdCXYScore\tSignificance"); m->mothurOutEndLine();
-               outSum << setw(20) << left << "Comparison" << '\t' << setprecision(8) << "dCXYScore" << '\t' << "Significance" << endl;
-       
-               int precision = (int)log10(iters);
-               for(int i=0;i<numGroups;i++){
-                       for(int j=i+1;j<numGroups;j++){
-                               if(m->control_pressed)  { outSum.close(); return 0; }
-                               
-                               int spoti = groupMap->groupIndex[groupNames[i]]; //neccessary in case user selects groups so you know where they are in the matrix
-                               int spotj = groupMap->groupIndex[groupNames[j]];
-                               
-                               if(pValueCounts[i][j]){
-                                       cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
-                                       m->mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((pValueCounts[i][j]/(float)iters))); m->mothurOutEndLine();
-                                       outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << setprecision(precision) << pValueCounts[i][j]/(float)iters << endl;
-                               }
-                               else{
-                                       cout << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
-                                       m->mothurOutJustToLog(groupNames[i]+"-"+groupNames[j] + "\t" + toString(savedDXYValues[spoti][spotj]) + "\t" + toString((1/(float)iters))); m->mothurOutEndLine();
-                                       outSum << setw(20) << left << groupNames[i]+'-'+groupNames[j] << '\t' << setprecision(8) << savedDXYValues[spoti][spotj] << '\t' << '<' <<setprecision(precision) << 1/(float)iters << endl;
-                               }
-                               if(pValueCounts[j][i]){
-                                       cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
-                                       m->mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((pValueCounts[j][i]/(float)iters))); m->mothurOutEndLine();
-                                       outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << setprecision (precision) << pValueCounts[j][i]/(float)iters << endl;
-                               }
-                               else{
-                                       cout << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
-                                       m->mothurOutJustToLog(groupNames[j]+"-"+groupNames[i] + "\t" + toString(savedDXYValues[spotj][spoti]) + "\t" + toString((1/(float)iters))); m->mothurOutEndLine();
-                                       outSum << setw(20) << left << groupNames[j]+'-'+groupNames[i] << '\t' << setprecision(8) << savedDXYValues[spotj][spoti] << '\t' << '<' <<setprecision (precision) << 1/(float)iters << endl;
-                               }
-                       }
-               }
-               
-               outSum.close();
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "printSummaryFile");
-               exit(1);
-       }
-} 
-
-//**********************************************************************************************************************
-
-void LibShuffCommand::setGroups() {
-       try {
-               vector<string> myGroups = m->getGroups();
-               //if the user has not entered specific groups to analyze then do them all
-               if (m->getNumGroups() == 0) {
-                       numGroups = groupMap->getNumGroups();
-                       for (int i=0; i < numGroups; i++) { 
-                               myGroups.push_back((groupMap->getNamesOfGroups())[i]);
-                       }
-               } else {
-                       if (savegroups != "all") {
-                               //check that groups are valid
-                               for (int i = 0; i < myGroups.size(); i++) {
-                                       if (groupMap->isValidGroup(myGroups[i]) != true) {
-                                               m->mothurOut(myGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
-                                               // erase the invalid group from globaldata->Groups
-                                               myGroups.erase(myGroups.begin()+i);
-                                       }
-                               }
-                       
-                               //if the user only entered invalid groups
-                               if ((myGroups.size() == 0) || (myGroups.size() == 1)) { 
-                                       numGroups = groupMap->getNumGroups();
-                                       for (int i=0; i < numGroups; i++) { 
-                                               myGroups.push_back((groupMap->getNamesOfGroups())[i]);
-                                       }
-                                       m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                               } else { numGroups = myGroups.size(); }
-                       } else { //users wants all groups
-                               numGroups = groupMap->getNumGroups();
-                               myGroups.clear();
-                               for (int i=0; i < numGroups; i++) { 
-                                       myGroups.push_back((groupMap->getNamesOfGroups())[i]);
-                               }
-                       }
-               }
-
-               //sort so labels match
-               sort(myGroups.begin(), myGroups.end());
-               
-               //sort
-               //sort(groupMap->namesOfGroups.begin(), groupMap->namesOfGroups.end());
-               
-               for (int i = 0; i < (groupMap->getNamesOfGroups()).size(); i++) {  groupMap->groupIndex[(groupMap->getNamesOfGroups())[i]] = i;  }
-
-               groupNames = myGroups;
-               m->setGroups(myGroups);
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LibShuffCommand", "setGroups");
-               exit(1);
-       }
-}
-
-/***********************************************************/
diff --git a/libshuffcommand.h b/libshuffcommand.h
deleted file mode 100644 (file)
index 465a67f..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef LIBSHUFFCOMMAND_H
-#define LIBSHUFFCOMMAND_H
-
-/*
- *  libshuffcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "fullmatrix.h"
-#include "libshuff.h"
-#include "groupmap.h"
-
-
-class LibShuffCommand : public Command {
-       
-public:
-       LibShuffCommand(string);
-       LibShuffCommand();      
-       ~LibShuffCommand(){};
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "libshuff";                            }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Singleton DR, Furlong MA, Rathbun SL, Whitman WB (2001). Quantitative comparisons of 16S rRNA gene sequence libraries from environmental samples. Appl Environ Microbiol 67: 4374-6. \nSchloss PD, Larget BR, Handelsman J (2004). Integration of microbial ecology and statistics: a test to compare gene libraries. Appl Environ Microbiol 70: 5485-92. \nhttp://www.mothur.org/wiki/Libshuff"; }
-       string getDescription()         { return "a generic test that describes whether two or more communities have the same structure using the Cramer-von Mises test statistic"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       vector<string> groupNames;
-       
-       void setGroups();
-       int printCoverageFile();
-       int printSummaryFile();
-       
-       GroupMap* groupMap;
-       FullMatrix* matrix;
-       Libshuff* form;
-       float cutOff, step;
-       int numGroups, numComp, iters;
-       string coverageFile, summaryFile, phylipfile, groupfile;
-       vector<vector<int> > pValueCounts;
-       vector<vector<double> > savedDXYValues;
-       vector<vector<vector<double> > > savedMinValues;
-
-       bool abort, sim;
-       string outputFile, groups, userform, savegroups, outputDir;
-       vector<string> Groups, outputNames; //holds groups to be used
-};
-
-#endif
diff --git a/linearalgebra.cpp b/linearalgebra.cpp
deleted file mode 100644 (file)
index effb1ad..0000000
+++ /dev/null
@@ -1,1507 +0,0 @@
-/*
- *  linearalgebra.cpp
- *  mothur
- *
- *  Created by westcott on 1/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "linearalgebra.h"
-
-// This class references functions used from "Numerical Recipes in C++" //
-
-/*********************************************************************************************************************************/
-inline double SQR(const double a)
-{
-    return a*a;
-}
-/*********************************************************************************************************************************/
-
-inline double SIGN(const double a, const double b)
-{
-    return b>=0 ? (a>=0 ? a:-a) : (a>=0 ? -a:a);
-}
-/*********************************************************************************************************************************/
-//NUmerical recipes pg. 245 - Returns the complementary error function erfc(x) with fractional error everywhere less than 1.2 × 10−7.
-double LinearAlgebra::erfcc(double x){
-    try {
-        double t,z,ans;
-        z=fabs(x);
-        t=1.0/(1.0+0.5*z); 
-        
-        ans=t*exp(-z*z-1.26551223+t*(1.00002368+t*(0.37409196+t*(0.09678418+
-            t*(-0.18628806+t*(0.27886807+t*(-1.13520398+t*(1.48851587+
-            t*(-0.82215223+t*0.17087277))))))))); 
-        
-        //cout << "in erfcc " << t << '\t' << ans<< endl;
-        return (x >= 0.0 ? ans : 2.0 - ans);
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "betai");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 232
-double LinearAlgebra::betai(const double a, const double b, const double x) {
-    try {
-        double bt;
-        double result = 0.0;
-        
-        if (x < 0.0 || x > 1.0) { m->mothurOut("[ERROR]: bad x in betai.\n"); m->control_pressed = true; return 0.0; }
-        
-        if (x == 0.0 || x == 1.0)  { bt = 0.0; }
-        else { bt = exp(gammln(a+b)-gammln(a)-gammln(b)+a*log(x)+b*log(1.0-x));  }
-        
-        if (x < (a+1.0) / (a+b+2.0)) { result = bt*betacf(a,b,x)/a; }
-        else { result = 1.0-bt*betacf(b,a,1.0-x)/b; }
-        
-        return result;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "betai");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 219
-double LinearAlgebra::gammln(const double xx) {
-    try {
-        int j;
-        double x,y,tmp,ser;
-        static const double cof[6]={76.18009172947146,-86.50532032941677,24.01409824083091,
-            -1.231739572450155,0.120858003e-2,-0.536382e-5};
-        
-        y=x=xx;
-        tmp=x+5.5;
-        tmp -= (x+0.5)*log(tmp);
-        ser=1.0;
-        for (j=0;j<6;j++) {
-            ser += cof[j]/++y;
-        }
-        return -tmp+log(2.5066282746310005*ser/x);
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "gammln");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 223
-double LinearAlgebra::gammp(const double a, const double x) {
-    try {
-        double gamser,gammcf,gln;
-        
-        if (x < 0.0 || a <= 0.0) { m->mothurOut("[ERROR]: Invalid arguments in routine GAMMP\n"); m->control_pressed = true; return 0.0;}
-        if (x < (a+1.0)) {
-            gser(gamser,a,x,gln);
-            return gamser;
-        } else {
-            gcf(gammcf,a,x,gln);
-            return 1.0-gammcf;
-        }
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "gammp");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 223
-double LinearAlgebra::gammq(const double a, const double x) {
-    try {
-        double gamser,gammcf,gln;
-        
-        if (x < 0.0 || a <= 0.0) { m->mothurOut("[ERROR]: Invalid arguments in routine GAMMQ\n"); m->control_pressed = true; return 0.0; }
-        if (x < (a+1.0)) {
-            gser(gamser,a,x,gln);
-            return 1.0-gamser;
-        } else {
-            gcf(gammcf,a,x,gln);
-            return gammcf;
-        }   
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "gammp");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 224
-double LinearAlgebra::gcf(double& gammcf, const double a, const double x, double& gln){
-    try {
-        const int ITMAX=100;
-        const double EPS=numeric_limits<double>::epsilon();
-        const double FPMIN=numeric_limits<double>::min()/EPS;
-        int i;
-        double an,b,c,d,del,h;
-        
-        gln=gammln(a);
-        b=x+1.0-a;
-        c=1.0/FPMIN;
-        d=1.0/b;
-        h=d;
-        for (i=1;i<=ITMAX;i++) {
-            an = -i*(i-a);
-            b += 2.0;
-            d=an*d+b;
-            if (fabs(d) < FPMIN) { d=FPMIN; }
-            c=b+an/c;
-            if (fabs(c) < FPMIN) { c=FPMIN; }
-            d=1.0/d;
-            del=d*c;
-            h *= del;
-            if (fabs(del-1.0) <= EPS) break;
-        }
-        if (i > ITMAX)  { m->mothurOut("[ERROR]: a too large, ITMAX too small in gcf\n"); m->control_pressed = true; }
-        gammcf=exp(-x+a*log(x)-gln)*h;
-        
-        return 0.0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "gcf");
-               exit(1);
-       }
-
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 223
-double LinearAlgebra::gser(double& gamser, const double a, const double x, double& gln) {
-    try {
-        int n;
-        double sum,del,ap;
-        const double EPS = numeric_limits<double>::epsilon();
-        
-        gln=gammln(a);
-        if (x <= 0.0) { 
-            if (x < 0.0) {  m->mothurOut("[ERROR]: x less than 0 in routine GSER\n"); m->control_pressed = true;  }
-            gamser=0.0; return 0.0;
-        } else {
-            ap=a;
-            del=sum=1.0/a;
-            for (n=0;n<100;n++) {
-                ++ap;
-                del *= x/ap;
-                sum += del;
-                if (fabs(del) < fabs(sum)*EPS) {
-                    gamser=sum*exp(-x+a*log(x)-gln);
-                    return 0.0;
-                }
-            }
-            
-            m->mothurOut("[ERROR]: a too large, ITMAX too small in routine GSER\n");
-            return 0.0;
-        }
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "gser");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//Numerical Recipes pg. 233
-double LinearAlgebra::betacf(const double a, const double b, const double x) {
-    try {
-        const int MAXIT = 100;
-        const double EPS = numeric_limits<double>::epsilon();
-        const double FPMIN = numeric_limits<double>::min() / EPS;
-        int m1, m2;
-        double aa, c, d, del, h, qab, qam, qap;
-        
-        qab=a+b;
-        qap=a+1.0;
-        qam=a-1.0;
-        c=1.0;
-        d=1.0-qab*x/qap;
-        if (fabs(d) < FPMIN) d=FPMIN;
-        d=1.0/d;
-        h=d;
-        for (m1=1;m1<=MAXIT;m1++) {
-            m2=2*m1;
-            aa=m1*(b-m1)*x/((qam+m2)*(a+m2));
-            d=1.0+aa*d;
-            if (fabs(d) < FPMIN) d=FPMIN;
-            c=1.0+aa/c;
-            if (fabs(c) < FPMIN) c=FPMIN;
-            d=1.0/d;
-            h *= d*c;
-            aa = -(a+m1)*(qab+m1)*x/((a+m2)*(qap+m2));
-            d=1.0+aa*d;
-            if (fabs(d) < FPMIN) d=FPMIN;
-            c=1.0+aa/c;
-            if (fabs(c) < FPMIN) c=FPMIN;
-            d=1.0/d;
-            del=d*c;
-            h *= del;
-            if (fabs(del-1.0) < EPS) break;
-        }
-        
-        if (m1 > MAXIT) { m->mothurOut("[ERROR]: a or b too big or MAXIT too small in betacf."); m->mothurOutEndLine(); m->control_pressed = true; }
-        return h;
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "betacf");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-
-vector<vector<double> > LinearAlgebra::matrix_mult(vector<vector<double> > first, vector<vector<double> > second){
-       try {
-               vector<vector<double> > product;
-               
-               int first_rows = first.size();
-               int first_cols = first[0].size();
-               int second_cols = second[0].size();
-               
-               product.resize(first_rows);
-               for(int i=0;i<first_rows;i++){
-                       product[i].resize(second_cols);
-               }
-               
-               for(int i=0;i<first_rows;i++){
-                       for(int j=0;j<second_cols;j++){
-                               
-                               if (m->control_pressed) { return product; }
-                                       
-                               product[i][j] = 0.0;
-                               for(int k=0;k<first_cols;k++){
-                                       product[i][j] += first[i][k] * second[k][j];
-                               }
-                       }
-               }
-               
-               return product;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "matrix_mult");
-               exit(1);
-       }
-       
-}
-
-/*********************************************************************************************************************************/
-
-void LinearAlgebra::recenter(double offset, vector<vector<double> > D, vector<vector<double> >& G){
-       try {
-               int rank = D.size();
-               
-               vector<vector<double> > A(rank);
-               vector<vector<double> > C(rank);
-               for(int i=0;i<rank;i++){
-                       A[i].resize(rank);
-                       C[i].resize(rank);
-               }
-               
-               double scale = -1.0000 / (double) rank;
-               
-               for(int i=0;i<rank;i++){
-                       A[i][i] = 0.0000;
-                       C[i][i] = 1.0000 + scale;
-                       for(int j=i+1;j<rank;j++){
-                               A[i][j] = A[j][i] = -0.5 * D[i][j] * D[i][j] + offset;
-                               C[i][j] = C[j][i] = scale;
-                       }
-               }
-               
-               A = matrix_mult(C,A);
-               G = matrix_mult(A,C);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "recenter");
-               exit(1);
-       }
-       
-}
-/*********************************************************************************************************************************/
-
-//  This function is taken from Numerical Recipes in C++ by Press et al., 2nd edition, pg. 479
-
-int LinearAlgebra::tred2(vector<vector<double> >& a, vector<double>& d, vector<double>& e){
-       try {
-               double scale, hh, h, g, f;
-               
-               int n = a.size();
-               
-               d.resize(n);
-               e.resize(n);
-               
-               for(int i=n-1;i>0;i--){
-                       int l=i-1;
-                       h = scale = 0.0000;
-                       if(l>0){
-                               for(int k=0;k<l+1;k++){
-                                       scale += fabs(a[i][k]);
-                               }
-                               if(scale == 0.0){
-                                       e[i] = a[i][l];
-                               }
-                               else{
-                                       for(int k=0;k<l+1;k++){
-                                               a[i][k] /= scale;
-                                               h += a[i][k] * a[i][k];
-                                       }
-                                       f = a[i][l];
-                                       g = (f >= 0.0 ? -sqrt(h) : sqrt(h));
-                                       e[i] = scale * g;
-                                       h -= f * g;
-                                       a[i][l] = f - g;
-                                       f = 0.0;
-                                       for(int j=0;j<l+1;j++){
-                                               a[j][i] = a[i][j] / h;
-                                               g = 0.0;
-                                               for(int k=0;k<j+1;k++){
-                                                       g += a[j][k] * a[i][k];
-                                               }
-                                               for(int k=j+1;k<l+1;k++){
-                                                       g += a[k][j] * a[i][k];
-                                               }
-                                               e[j] = g / h;
-                                               f += e[j] * a[i][j];
-                                       }
-                                       hh = f / (h + h);
-                                       for(int j=0;j<l+1;j++){
-                                               f = a[i][j];
-                                               e[j] = g = e[j] - hh * f;
-                                               for(int k=0;k<j+1;k++){
-                                                       a[j][k] -= (f * e[k] + g * a[i][k]);
-                                               }
-                                       }
-                               }
-                       }
-                       else{
-                               e[i] = a[i][l];
-                       }
-                       
-                       d[i] = h;
-               }
-               
-               d[0] = 0.0000;
-               e[0] = 0.0000;
-               
-               for(int i=0;i<n;i++){
-                       int l = i;
-                       if(d[i] != 0.0){
-                               for(int j=0;j<l;j++){
-                                       g = 0.0000;
-                                       for(int k=0;k<l;k++){
-                                               g += a[i][k] * a[k][j];
-                                       }
-                                       for(int k=0;k<l;k++){
-                                               a[k][j] -= g * a[k][i];
-                                       }
-                               }
-                       }
-                       d[i] = a[i][i];
-                       a[i][i] = 1.0000;
-                       for(int j=0;j<l;j++){
-                               a[j][i] = a[i][j] = 0.0;
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "tred2");
-               exit(1);
-       }
-       
-}
-/*********************************************************************************************************************************/
-
-double LinearAlgebra::pythag(double a, double b)       {       return(pow(a*a+b*b,0.5));       }
-
-/*********************************************************************************************************************************/
-
-//  This function is taken from Numerical Recipes in C++ by Press et al., 2nd edition, pg. 479
-
-int LinearAlgebra::qtli(vector<double>& d, vector<double>& e, vector<vector<double> >& z) {
-       try {
-               int myM, i, iter;
-               double s, r, p, g, f, dd, c, b;
-               
-               int n = d.size();
-               for(int i=1;i<=n;i++){
-                       e[i-1] = e[i];
-               }
-               e[n-1] = 0.0000;
-               
-               for(int l=0;l<n;l++){
-                       iter = 0;
-                       do {
-                               for(myM=l;myM<n-1;myM++){
-                                       dd = fabs(d[myM]) + fabs(d[myM+1]);
-                                       if(fabs(e[myM])+dd == dd) break;
-                               }
-                               if(myM != l){
-                                       if(iter++ == 3000) cerr << "Too many iterations in tqli\n";
-                                       g = (d[l+1]-d[l]) / (2.0 * e[l]);
-                                       r = pythag(g, 1.0);
-                                       g = d[myM] - d[l] + e[l] / (g + SIGN(r,g));
-                                       s = c = 1.0;
-                                       p = 0.0000;
-                                       for(i=myM-1;i>=l;i--){
-                                               f = s * e[i];
-                                               b = c * e[i];
-                                               e[i+1] = (r=pythag(f,g));
-                                               if(r==0.0){
-                                                       d[i+1] -= p;
-                                                       e[myM] = 0.0000;
-                                                       break;
-                                               }
-                                               s = f / r;
-                                               c = g / r;
-                                               g = d[i+1] - p;
-                                               r = (d[i] - g) * s + 2.0 * c * b;
-                                               d[i+1] = g + ( p = s * r);
-                                               g = c * r - b;
-                                               for(int k=0;k<n;k++){
-                                                       f = z[k][i+1];
-                                                       z[k][i+1] = s * z[k][i] + c * f;
-                                                       z[k][i] = c * z[k][i] - s * f;
-                                               }
-                                       }
-                                       if(r == 0.00 && i >= l) continue;
-                                       d[l] -= p;
-                                       e[l] = g;
-                                       e[myM] = 0.0;
-                               }
-                       } while (myM != l);
-               }
-               
-               int k;
-               for(int i=0;i<n;i++){
-                       p=d[k=i];
-                       for(int j=i;j<n;j++){
-                               if(d[j] >= p){
-                                       p=d[k=j];
-                               }
-                       }
-                       if(k!=i){
-                               d[k]=d[i];
-                               d[i]=p;
-                               for(int j=0;j<n;j++){
-                                       p=z[j][i];
-                                       z[j][i] = z[j][k];
-                                       z[j][k] = p;
-                               }
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "qtli");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//groups by dimension
-vector< vector<double> > LinearAlgebra::calculateEuclidianDistance(vector< vector<double> >& axes, int dimensions){
-       try {
-               //make square matrix
-               vector< vector<double> > dists; dists.resize(axes.size());
-               for (int i = 0; i < dists.size(); i++) {  dists[i].resize(axes.size(), 0.0); }
-               
-               if (dimensions == 1) { //one dimension calc = abs(x-y)
-                       
-                       for (int i = 0; i < dists.size(); i++) {
-                               
-                               if (m->control_pressed) { return dists; }
-                               
-                               for (int j = 0; j < i; j++) {
-                                       dists[i][j] = abs(axes[i][0] - axes[j][0]);
-                                       dists[j][i] = dists[i][j];
-                               }
-                       }
-                       
-               }else if (dimensions > 1) { //two dimension calc = sqrt ((x1 - y1)^2 + (x2 - y2)^2)...
-                       
-                       for (int i = 0; i < dists.size(); i++) {
-                               
-                               if (m->control_pressed) { return dists; }
-                               
-                               for (int j = 0; j < i; j++) {
-                                       double sum = 0.0;
-                                       for (int k = 0; k < dimensions; k++) {
-                                               sum += ((axes[i][k] - axes[j][k]) * (axes[i][k] - axes[j][k]));
-                                       }
-                                       
-                                       dists[i][j] = sqrt(sum);
-                                       dists[j][i] = dists[i][j];
-                               }
-                       }
-                       
-               }
-               
-               return dists;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calculateEuclidianDistance");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//returns groups by dimensions from dimensions by groups
-vector< vector<double> > LinearAlgebra::calculateEuclidianDistance(vector< vector<double> >& axes){
-       try {
-               //make square matrix
-               vector< vector<double> > dists; dists.resize(axes[0].size());
-               for (int i = 0; i < dists.size(); i++) {  dists[i].resize(axes[0].size(), 0.0); }
-               
-               if (axes.size() == 1) { //one dimension calc = abs(x-y)
-                       
-                       for (int i = 0; i < dists.size(); i++) {
-                               
-                               if (m->control_pressed) { return dists; }
-                               
-                               for (int j = 0; j < i; j++) {
-                                       dists[i][j] = abs(axes[0][i] - axes[0][j]);
-                                       dists[j][i] = dists[i][j];
-                               }
-                       }
-                       
-               }else if (axes.size() > 1) { //two dimension calc = sqrt ((x1 - y1)^2 + (x2 - y2)^2)...
-                       
-                       for (int i = 0; i < dists[0].size(); i++) {
-                               
-                               if (m->control_pressed) { return dists; }
-                               
-                               for (int j = 0; j < i; j++) {
-                                       double sum = 0.0;
-                                       for (int k = 0; k < axes.size(); k++) {
-                                               sum += ((axes[k][i] - axes[k][j]) * (axes[k][i] - axes[k][j]));
-                                       }
-                                       
-                                       dists[i][j] = sqrt(sum);
-                                       dists[j][i] = dists[i][j];
-                               }
-                       }
-                       
-               }
-               
-               return dists;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calculateEuclidianDistance");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//assumes both matrices are square and the same size
-double LinearAlgebra::calcPearson(vector< vector<double> >& euclidDists, vector< vector<double> >& userDists){
-       try {
-               
-               //find average for - X
-               int count = 0;
-               float averageEuclid = 0.0; 
-               for (int i = 0; i < euclidDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               averageEuclid += euclidDists[i][j];  
-                               count++;
-                       }
-               }
-               averageEuclid = averageEuclid / (float) count;   
-                       
-               //find average for - Y
-               count = 0;
-               float averageUser = 0.0; 
-               for (int i = 0; i < userDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               averageUser += userDists[i][j]; 
-                               count++;
-                       }
-               }
-               averageUser = averageUser / (float) count;  
-
-               double numerator = 0.0;
-               double denomTerm1 = 0.0;
-               double denomTerm2 = 0.0;
-               
-               for (int i = 0; i < euclidDists.size(); i++) {
-                       
-                       for (int k = 0; k < i; k++) { //just lt dists
-                               
-                               float Yi = userDists[i][k];
-                               float Xi = euclidDists[i][k];
-                               
-                               numerator += ((Xi - averageEuclid) * (Yi - averageUser));
-                               denomTerm1 += ((Xi - averageEuclid) * (Xi - averageEuclid));
-                               denomTerm2 += ((Yi - averageUser) * (Yi - averageUser));
-                       }
-               }
-               
-               double denom = (sqrt(denomTerm1) * sqrt(denomTerm2));
-               double r = numerator / denom;
-               
-               //divide by zero error
-               if (isnan(r) || isinf(r)) { r = 0.0; }
-               
-               return r;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcPearson");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-//assumes both matrices are square and the same size
-double LinearAlgebra::calcSpearman(vector< vector<double> >& euclidDists, vector< vector<double> >& userDists){
-       try {
-               double r; 
-               
-               //format data
-               map<float, int> tableX; 
-               map<float, int>::iterator itTable;
-               vector<spearmanRank> scores; 
-               
-               for (int i = 0; i < euclidDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               spearmanRank member(toString(scores.size()), euclidDists[i][j]);
-                               scores.push_back(member);  
-                               
-                               //count number of repeats
-                               itTable = tableX.find(euclidDists[i][j]);
-                               if (itTable == tableX.end()) { 
-                                       tableX[euclidDists[i][j]] = 1;
-                               }else {
-                                       tableX[euclidDists[i][j]]++;
-                               }
-                       }
-               }
-               
-               //sort scores
-               sort(scores.begin(), scores.end(), compareSpearman); 
-
-               //calc LX
-               double Lx = 0.0; 
-               for (itTable = tableX.begin(); itTable != tableX.end(); itTable++) {
-                       double tx = (double) itTable->second;
-                       Lx += ((pow(tx, 3.0) - tx) / 12.0);
-               }
-               
-               //find ranks of xi
-               map<string, float> rankEuclid;
-               vector<spearmanRank> ties;
-               int rankTotal = 0;
-               for (int j = 0; j < scores.size(); j++) {
-                       rankTotal += (j+1);
-                       ties.push_back(scores[j]);
-                       
-                       if (j != (scores.size()-1)) { // you are not the last so you can look ahead
-                               if (scores[j].score != scores[j+1].score) { // you are done with ties, rank them and continue
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankEuclid[ties[k].name] = thisrank;
-                                       }
-                                       ties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               
-                               for (int k = 0; k < ties.size(); k++) {
-                                       float thisrank = rankTotal / (float) ties.size();
-                                       rankEuclid[ties[k].name] = thisrank;
-                               }
-                       }
-               }
-               
-               
-               //format data
-               map<float, int> tableY; 
-               scores.clear(); 
-               
-               for (int i = 0; i < userDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               spearmanRank member(toString(scores.size()), userDists[i][j]);
-                               scores.push_back(member);  
-                               
-                               //count number of repeats
-                               itTable = tableY.find(userDists[i][j]);
-                               if (itTable == tableY.end()) { 
-                                       tableY[userDists[i][j]] = 1;
-                               }else {
-                                       tableY[userDists[i][j]]++;
-                               }
-                       }
-               }
-               
-               //sort scores
-               sort(scores.begin(), scores.end(), compareSpearman); 
-               
-               //calc LX
-               double Ly = 0.0; 
-               for (itTable = tableY.begin(); itTable != tableY.end(); itTable++) {
-                       double ty = (double) itTable->second;
-                       Ly += ((pow(ty, 3.0) - ty) / 12.0);
-               }
-               
-               //find ranks of yi
-               map<string, float> rankUser;
-               ties.clear();
-               rankTotal = 0;
-               for (int j = 0; j < scores.size(); j++) {
-                       rankTotal += (j+1);
-                       ties.push_back(scores[j]);
-                       
-                       if (j != (scores.size()-1)) { // you are not the last so you can look ahead
-                               if (scores[j].score != scores[j+1].score) { // you are done with ties, rank them and continue
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankUser[ties[k].name] = thisrank;
-                                       }
-                                       ties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               
-                               for (int k = 0; k < ties.size(); k++) {
-                                       float thisrank = rankTotal / (float) ties.size();
-                                       rankUser[ties[k].name] = thisrank;
-                               }
-                       }
-               }
-               
-                       
-               double di = 0.0;        
-               int count = 0;
-               for (int i = 0; i < userDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                       
-                               float xi = rankEuclid[toString(count)];
-                               float yi = rankUser[toString(count)];
-                       
-                               di += ((xi - yi) * (xi - yi));
-                               
-                               count++;
-                       }
-               }
-               
-               double n = (double) count;
-               
-               double SX2 = ((pow(n, 3.0) - n) / 12.0) - Lx;
-               double SY2 = ((pow(n, 3.0) - n) / 12.0) - Ly;
-               
-               r = (SX2 + SY2 - di) / (2.0 * sqrt((SX2*SY2)));
-               
-               //divide by zero error
-               if (isnan(r) || isinf(r)) { r = 0.0; }
-       
-               return r;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcSpearman");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************************************************/
-//assumes both matrices are square and the same size
-double LinearAlgebra::calcKendall(vector< vector<double> >& euclidDists, vector< vector<double> >& userDists){
-       try {
-               double r;
-               
-               //format data
-               vector<spearmanRank> scores; 
-               for (int i = 0; i < euclidDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               spearmanRank member(toString(scores.size()), euclidDists[i][j]);
-                               scores.push_back(member);
-                       }
-               }
-                       
-               //sort scores
-               sort(scores.begin(), scores.end(), compareSpearman);    
-               
-               //find ranks of xi
-               map<string, float> rankEuclid;
-               vector<spearmanRank> ties;
-               int rankTotal = 0;
-               for (int j = 0; j < scores.size(); j++) {
-                       rankTotal += (j+1);
-                       ties.push_back(scores[j]);
-                       
-                       if (j != (scores.size()-1)) { // you are not the last so you can look ahead
-                               if (scores[j].score != scores[j+1].score) { // you are done with ties, rank them and continue
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankEuclid[ties[k].name] = thisrank;
-                                       }
-                                       ties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               
-                               for (int k = 0; k < ties.size(); k++) {
-                                       float thisrank = rankTotal / (float) ties.size();
-                                       rankEuclid[ties[k].name] = thisrank;
-                               }
-                       }
-               }
-               
-               vector<spearmanRank> scoresUser; 
-               for (int i = 0; i < userDists.size(); i++) {
-                       for (int j = 0; j < i; j++) {
-                               spearmanRank member(toString(scoresUser.size()), userDists[i][j]);
-                               scoresUser.push_back(member);  
-                       }
-               }
-               
-               //sort scores
-               sort(scoresUser.begin(), scoresUser.end(), compareSpearman);    
-               
-               //find ranks of yi
-               map<string, float> rankUser;
-               ties.clear();
-               rankTotal = 0;
-               for (int j = 0; j < scoresUser.size(); j++) {
-                       rankTotal += (j+1);
-                       ties.push_back(scoresUser[j]);
-                       
-                       if (j != (scoresUser.size()-1)) { // you are not the last so you can look ahead
-                               if (scoresUser[j].score != scoresUser[j+1].score) { // you are done with ties, rank them and continue
-                                       
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               rankUser[ties[k].name] = thisrank;
-                                       }
-                                       ties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               
-                               for (int k = 0; k < ties.size(); k++) {
-                                       float thisrank = rankTotal / (float) ties.size();
-                                       rankUser[ties[k].name] = thisrank;
-                               }
-                       }
-               }
-               
-               int numCoor = 0;
-               int numDisCoor = 0;
-               
-               //order user ranks
-               vector<spearmanRank> user; 
-               for (int l = 0; l < scores.size(); l++) {   
-                       spearmanRank member(scores[l].name, rankUser[scores[l].name]);
-                       user.push_back(member);
-               }
-                               
-               int count = 0;
-               for (int l = 0; l < scores.size(); l++) {
-                                       
-                       int numWithHigherRank = 0;
-                       int numWithLowerRank = 0;
-                       float thisrank = user[l].score;
-                                       
-                       for (int u = l+1; u < scores.size(); u++) {
-                               if (user[u].score > thisrank) { numWithHigherRank++; }
-                               else if (user[u].score < thisrank) { numWithLowerRank++; }
-                               count++;
-                       }
-                                       
-                       numCoor += numWithHigherRank;
-                       numDisCoor += numWithLowerRank;
-               }
-                               
-               r = (numCoor - numDisCoor) / (float) count;
-               
-               //divide by zero error
-               if (isnan(r) || isinf(r)) { r = 0.0; }
-               
-               return r;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcKendall");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcKendall(vector<double>& x, vector<double>& y, double& sig){
-       try {
-               if (x.size() != y.size()) { m->mothurOut("[ERROR]: vector size mismatch."); m->mothurOutEndLine(); return 0.0; }
-               
-               //format data
-               vector<spearmanRank> xscores; 
-               for (int i = 0; i < x.size(); i++) {
-                       spearmanRank member(toString(i), x[i]);
-                       xscores.push_back(member);  
-               }
-               
-               //sort xscores
-               sort(xscores.begin(), xscores.end(), compareSpearman);
-               
-               //convert scores to ranks of x
-               vector<spearmanRank*> ties;
-               int rankTotal = 0;
-               for (int j = 0; j < xscores.size(); j++) {
-                       rankTotal += (j+1);
-                       ties.push_back(&(xscores[j]));
-                               
-                       if (j != xscores.size()-1) { // you are not the last so you can look ahead
-                               if (xscores[j].score != xscores[j+1].score) { // you are done with ties, rank them and continue
-                                       for (int k = 0; k < ties.size(); k++) {
-                                               float thisrank = rankTotal / (float) ties.size();
-                                               (*ties[k]).score = thisrank;
-                                       }
-                                       ties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               for (int k = 0; k < ties.size(); k++) {
-                                       float thisrank = rankTotal / (float) ties.size();
-                                       (*ties[k]).score = thisrank;
-                               }
-                       }
-               }
-               
-                       
-               //format data
-               vector<spearmanRank> yscores;
-               for (int j = 0; j < y.size(); j++) {
-                       spearmanRank member(toString(j), y[j]);
-                       yscores.push_back(member);
-               }
-               
-               //sort yscores
-               sort(yscores.begin(), yscores.end(), compareSpearman);
-               
-               //convert to ranks
-               map<string, float> rank;
-               vector<spearmanRank> yties;
-               rankTotal = 0;
-               for (int j = 0; j < yscores.size(); j++) {
-                       rankTotal += (j+1);
-                       yties.push_back(yscores[j]);
-                               
-                       if (j != yscores.size()-1) { // you are not the last so you can look ahead
-                               if (yscores[j].score != yscores[j+1].score) { // you are done with ties, rank them and continue
-                                       for (int k = 0; k < yties.size(); k++) {
-                                               float thisrank = rankTotal / (float) yties.size();
-                                               rank[yties[k].name] = thisrank;
-                                       }
-                                       yties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               for (int k = 0; k < yties.size(); k++) {
-                                       float thisrank = rankTotal / (float) yties.size();
-                                       rank[yties[k].name] = thisrank;
-                               }
-                       }
-               }
-                       
-                       
-               int numCoor = 0;
-               int numDisCoor = 0;
-               
-               //associate x and y
-               vector<spearmanRank> otus; 
-               for (int l = 0; l < xscores.size(); l++) {   
-                       spearmanRank member(xscores[l].name, rank[xscores[l].name]);
-                       otus.push_back(member);
-               }
-                               
-               int count = 0;
-               for (int l = 0; l < xscores.size(); l++) {
-                                       
-                       int numWithHigherRank = 0;
-                       int numWithLowerRank = 0;
-                       float thisrank = otus[l].score;
-                                       
-                       for (int u = l+1; u < xscores.size(); u++) {
-                               if (otus[u].score > thisrank) { numWithHigherRank++; }
-                               else if (otus[u].score < thisrank) { numWithLowerRank++; }
-                               count++;
-                       }
-                                       
-                       numCoor += numWithHigherRank;
-                       numDisCoor += numWithLowerRank;
-               }
-                               
-               double p = (numCoor - numDisCoor) / (float) count;
-               
-               sig = calcKendallSig(x.size(), p);
-               
-               return p;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcKendall");
-               exit(1);
-       }
-}
-double LinearAlgebra::ran0(int& idum)
-{
-    const int IA=16807,IM=2147483647,IQ=127773;
-    const int IR=2836,MASK=123459876;
-    const double AM=1.0/double(IM);
-    int k;
-    double ans;
-    
-    idum ^= MASK;
-    k=idum/IQ;
-    idum=IA*(idum-k*IQ)-IR*k;
-    if (idum < 0) idum += IM;
-    ans=AM*idum;
-    idum ^= MASK;
-    return ans;
-}
-
-double LinearAlgebra::ran1(int &idum)
-{
-       const int IA=16807,IM=2147483647,IQ=127773,IR=2836,NTAB=32;
-       const int NDIV=(1+(IM-1)/NTAB);
-       const double EPS=3.0e-16,AM=1.0/IM,RNMX=(1.0-EPS);
-       static int iy=0;
-       static vector<int> iv(NTAB);
-       int j,k;
-       double temp;
-    
-       if (idum <= 0 || !iy) {
-               if (-idum < 1) idum=1;
-               else idum = -idum;
-               for (j=NTAB+7;j>=0;j--) {
-                       k=idum/IQ;
-                       idum=IA*(idum-k*IQ)-IR*k;
-                       if (idum < 0) idum += IM;
-                       if (j < NTAB) iv[j] = idum;
-               }
-               iy=iv[0];
-       }
-       k=idum/IQ;
-       idum=IA*(idum-k*IQ)-IR*k;
-       if (idum < 0) idum += IM;
-       j=iy/NDIV;
-       iy=iv[j];
-       iv[j] = idum;
-       if ((temp=AM*iy) > RNMX) return RNMX;
-       else return temp;
-}
-
-double LinearAlgebra::ran2(int &idum)
-{
-       const int IM1=2147483563,IM2=2147483399;
-       const int IA1=40014,IA2=40692,IQ1=53668,IQ2=52774;
-       const int IR1=12211,IR2=3791,NTAB=32,IMM1=IM1-1;
-       const int NDIV=1+IMM1/NTAB;
-       const double EPS=3.0e-16,RNMX=1.0-EPS,AM=1.0/double(IM1);
-       static int idum2=123456789,iy=0;
-       static vector<int> iv(NTAB);
-       int j,k;
-       double temp;
-    
-       if (idum <= 0) {
-               idum=(idum==0 ? 1 : -idum);
-               idum2=idum;
-               for (j=NTAB+7;j>=0;j--) {
-                       k=idum/IQ1;
-                       idum=IA1*(idum-k*IQ1)-k*IR1;
-                       if (idum < 0) idum += IM1;
-                       if (j < NTAB) iv[j] = idum;
-               }
-               iy=iv[0];
-       }
-       k=idum/IQ1;
-       idum=IA1*(idum-k*IQ1)-k*IR1;
-       if (idum < 0) idum += IM1;
-       k=idum2/IQ2;
-       idum2=IA2*(idum2-k*IQ2)-k*IR2;
-       if (idum2 < 0) idum2 += IM2;
-       j=iy/NDIV;
-       iy=iv[j]-idum2;
-       iv[j] = idum;
-       if (iy < 1) iy += IMM1;
-       if ((temp=AM*iy) > RNMX) return RNMX;
-       else return temp;
-}
-
-double LinearAlgebra::ran3(int &idum)
-{
-       static int inext,inextp;
-       static int iff=0;
-       const int MBIG=1000000000,MSEED=161803398,MZ=0;
-       const double FAC=(1.0/MBIG);
-       static vector<int> ma(56);
-       int i,ii,k,mj,mk;
-    
-       if (idum < 0 || iff == 0) {
-               iff=1;
-               mj=labs(MSEED-labs(idum));
-               mj %= MBIG;
-               ma[55]=mj;
-               mk=1;
-               for (i=1;i<=54;i++) {
-                       ii=(21*i) % 55;
-                       ma[ii]=mk;
-                       mk=mj-mk;
-                       if (mk < int(MZ)) mk += MBIG;
-                       mj=ma[ii];
-               }
-               for (k=0;k<4;k++)
-                       for (i=1;i<=55;i++) {
-                               ma[i] -= ma[1+(i+30) % 55];
-                               if (ma[i] < int(MZ)) ma[i] += MBIG;
-                       }
-               inext=0;
-               inextp=31;
-               idum=1;
-       }
-       if (++inext == 56) inext=1;
-       if (++inextp == 56) inextp=1;
-       mj=ma[inext]-ma[inextp];
-       if (mj < int(MZ)) mj += MBIG;
-       ma[inext]=mj;
-       return mj*FAC;
-}
-
-double LinearAlgebra::ran4(int &idum)
-{
-#if defined(vax) || defined(_vax_) || defined(__vax__) || defined(VAX)
-       static const unsigned long jflone = 0x00004080;
-       static const unsigned long jflmsk = 0xffff007f;
-#else
-       static const unsigned long jflone = 0x3f800000;
-       static const unsigned long jflmsk = 0x007fffff;
-#endif
-       unsigned long irword,itemp,lword;
-       static int idums = 0;
-    
-       if (idum < 0) {
-               idums = -idum;
-               idum=1;
-       }
-       irword=idum;
-       lword=idums;
-       psdes(lword,irword);
-       itemp=jflone | (jflmsk & irword);
-       ++idum;
-       return (*(float *)&itemp)-1.0;
-}
-
-void LinearAlgebra::psdes(unsigned long &lword, unsigned long &irword)
-{
-       const int NITER=4;
-       static const unsigned long c1[NITER]={
-               0xbaa96887L, 0x1e17d32cL, 0x03bcdc3cL, 0x0f33d1b2L};
-       static const unsigned long c2[NITER]={
-               0x4b0f3b58L, 0xe874f0c3L, 0x6955c5a6L, 0x55a7ca46L};
-       unsigned long i,ia,ib,iswap,itmph=0,itmpl=0;
-    
-       for (i=0;i<NITER;i++) {
-               ia=(iswap=irword) ^ c1[i];
-               itmpl = ia & 0xffff;
-               itmph = ia >> 16;
-               ib=itmpl*itmpl+ ~(itmph*itmph);
-               irword=lword ^ (((ia = (ib >> 16) |
-                          ((ib & 0xffff) << 16)) ^ c2[i])+itmpl*itmph);
-               lword=iswap;
-       }
-}
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcKendallSig(double n, double r){
-    try {
-        
-        double sig = 0.0;
-        double svar=(4.0*n+10.0)/(9.0*n*(n-1.0)); 
-        double z= r/sqrt(svar); 
-        sig=erfcc(fabs(z)/1.4142136);
-
-               if (isnan(sig) || isinf(sig)) { sig = 0.0; }
-        
-        return sig;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcKendallSig");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcSpearman(vector<double>& x, vector<double>& y, double& sig){
-       try {
-               if (x.size() != y.size()) { m->mothurOut("[ERROR]: vector size mismatch."); m->mothurOutEndLine(); return 0.0; }
-               
-               //format data
-        double sf = 0.0; //f^3 - f where f is the number of ties in x;
-        double sg = 0.0; //f^3 - f where f is the number of ties in y;
-               map<float, int> tableX; 
-               map<float, int>::iterator itTable;
-               vector<spearmanRank> xscores; 
-               
-               for (int i = 0; i < x.size(); i++) {
-                       spearmanRank member(toString(i), x[i]);
-                       xscores.push_back(member);  
-                               
-                       //count number of repeats
-                       itTable = tableX.find(x[i]);
-                       if (itTable == tableX.end()) { 
-                               tableX[x[i]] = 1;
-                       }else {
-                               tableX[x[i]]++;
-                       }
-               }
-               
-               
-               //calc LX
-               double Lx = 0.0;
-               for (itTable = tableX.begin(); itTable != tableX.end(); itTable++) {
-                       double tx = (double) itTable->second;
-                       Lx += ((pow(tx, 3.0) - tx) / 12.0);
-               }
-               
-               
-               //sort x
-               sort(xscores.begin(), xscores.end(), compareSpearman);
-               
-               //convert scores to ranks of x
-               //convert to ranks
-               map<string, float> rankx;
-               vector<spearmanRank> xties;
-               int rankTotal = 0;
-               for (int j = 0; j < xscores.size(); j++) {
-                       rankTotal += (j+1);
-                       xties.push_back(xscores[j]);
-                       
-                       if (j != xscores.size()-1) { // you are not the last so you can look ahead
-                               if (xscores[j].score != xscores[j+1].score) { // you are done with ties, rank them and continue
-                                       for (int k = 0; k < xties.size(); k++) {
-                                               float thisrank = rankTotal / (float) xties.size();
-                                               rankx[xties[k].name] = thisrank;
-                                       }
-                    int t = xties.size();
-                    sf += (t*t*t-t);
-                                       xties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               for (int k = 0; k < xties.size(); k++) {
-                                       float thisrank = rankTotal / (float) xties.size();
-                                       rankx[xties[k].name] = thisrank;
-                               }
-                       }
-               }               
-                       
-               //format x
-               vector<spearmanRank> yscores;
-               map<float, int> tableY;
-               for (int j = 0; j < y.size(); j++) {
-                       spearmanRank member(toString(j), y[j]);
-                       yscores.push_back(member);
-                               
-                       itTable = tableY.find(member.score);
-                       if (itTable == tableY.end()) { 
-                               tableY[member.score] = 1;
-                       }else {
-                               tableY[member.score]++;
-                       }
-                               
-               }
-                       
-               //calc Ly
-               double Ly = 0.0;
-               for (itTable = tableY.begin(); itTable != tableY.end(); itTable++) {
-                       double ty = (double) itTable->second;
-                       Ly += ((pow(ty, 3.0) - ty) / 12.0);
-               }
-                       
-               sort(yscores.begin(), yscores.end(), compareSpearman);
-                       
-               //convert to ranks
-               map<string, float> rank;
-               vector<spearmanRank> yties;
-               rankTotal = 0;
-               for (int j = 0; j < yscores.size(); j++) {
-                       rankTotal += (j+1);
-                       yties.push_back(yscores[j]);
-                       
-                       if (j != yscores.size()-1) { // you are not the last so you can look ahead
-                               if (yscores[j].score != yscores[j+1].score) { // you are done with ties, rank them and continue
-                                       for (int k = 0; k < yties.size(); k++) {
-                                               float thisrank = rankTotal / (float) yties.size();
-                                               rank[yties[k].name] = thisrank;
-                                       }
-                    int t = yties.size();
-                    sg += (t*t*t-t);
-                                       yties.clear();
-                                       rankTotal = 0;
-                               }
-                       }else { // you are the last one
-                               for (int k = 0; k < yties.size(); k++) {
-                                       float thisrank = rankTotal / (float) yties.size();
-                                       rank[yties[k].name] = thisrank;
-                               }
-                       }
-               }
-               
-               double di = 0.0;
-               for (int k = 0; k < x.size(); k++) {
-                                       
-                       float xi = rankx[toString(k)];
-                       float yi = rank[toString(k)];
-                                       
-                       di += ((xi - yi) * (xi - yi));
-               }
-                               
-               double p = 0.0;
-                               
-               double n = (double) x.size();
-               double SX2 = ((pow(n, 3.0) - n) / 12.0) - Lx;
-               double SY2 = ((pow(n, 3.0) - n) / 12.0) - Ly;
-                               
-               p = (SX2 + SY2 - di) / (2.0 * sqrt((SX2*SY2)));
-               
-               //Numerical Recipes 646
-        sig = calcSpearmanSig(n, sf, sg, di);
-               
-               return p;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcSpearman");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcSpearmanSig(double n, double sf, double sg, double d){
-    try {
-        
-        double sig = 0.0;
-        double probrs = 0.0;
-        double en=n;
-        double en3n=en*en*en-en;
-        double aved=en3n/6.0-(sf+sg)/12.0;
-        double fac=(1.0-sf/en3n)*(1.0-sg/en3n);
-        double vard=((en-1.0)*en*en*SQR(en+1.0)/36.0)*fac;
-        double zd=(d-aved)/sqrt(vard);
-        double probd=erfcc(fabs(zd)/1.4142136);
-        double rs=(1.0-(6.0/en3n)*(d+(sf+sg)/12.0))/sqrt(fac);
-        fac=(rs+1.0)*(1.0-rs);
-        if (fac > 0.0) {
-            double t=rs*sqrt((en-2.0)/fac);
-            double df=en-2.0;
-            probrs=betai(0.5*df,0.5,df/(df+t*t));
-        }else {
-            probrs = 0.0;
-        }
-        
-        //smaller of probd and probrs is sig
-        sig = probrs;
-        if (probd < probrs) { sig = probd; }
-        
-               if (isnan(sig) || isinf(sig)) { sig = 0.0; }
-               
-        return sig;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcSpearmanSig");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcPearson(vector<double>& x, vector<double>& y, double& sig){
-       try {
-               if (x.size() != y.size()) { m->mothurOut("[ERROR]: vector size mismatch."); m->mothurOutEndLine(); return 0.0; }
-               
-               //find average X
-               float averageX = 0.0; 
-               for (int i = 0; i < x.size(); i++) { averageX += x[i];  }
-               averageX = averageX / (float) x.size(); 
-               
-               //find average Y
-               float sumY = 0.0;
-               for (int j = 0; j < y.size(); j++) { sumY += y[j]; }
-               float Ybar = sumY / (float) y.size();
-                       
-               double r = 0.0;
-               double numerator = 0.0;
-               double denomTerm1 = 0.0;
-               double denomTerm2 = 0.0;
-                               
-               for (int j = 0; j < x.size(); j++) {
-                       float Yi = y[j];
-                       float Xi = x[j];
-                                       
-                       numerator += ((Xi - averageX) * (Yi - Ybar));
-                       denomTerm1 += ((Xi - averageX) * (Xi - averageX));
-                       denomTerm2 += ((Yi - Ybar) * (Yi - Ybar));
-               }
-                               
-               double denom = (sqrt(denomTerm1) * sqrt(denomTerm2));
-                               
-               r = numerator / denom;
-               
-               //Numerical Recipes pg.644
-        sig = calcPearsonSig(x.size(), r);
-               
-               return r;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcPearson");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-double LinearAlgebra::calcPearsonSig(double n, double r){
-    try {
-        
-        double sig = 0.0;
-        const double TINY = 1.0e-20;
-        double z = 0.5*log((1.0+r+TINY)/(1.0-r+TINY)); //Fisher's z transformation
-    
-        //code below was giving an error in betacf with sop files
-        //int df = n-2;
-        //double t = r*sqrt(df/((1.0-r+TINY)*(1.0+r+TINY)));
-        //sig = betai(0.5+df, 0.5, df/(df+t*t));
-        
-        //Numerical Recipes says code below gives approximately the same result
-        sig = erfcc(fabs(z*sqrt(n-1.0))/1.4142136);
-               if (isnan(sig) || isinf(sig)) { sig = 0.0; }
-               
-        return sig;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "LinearAlgebra", "calcPearsonSig");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-
-vector<vector<double> > LinearAlgebra::getObservedEuclideanDistance(vector<vector<double> >& relAbundData){
-
-       int numSamples = relAbundData.size();
-       int numOTUs = relAbundData[0].size();
-       
-       vector<vector<double> > dMatrix(numSamples);
-       for(int i=0;i<numSamples;i++){
-               dMatrix[i].resize(numSamples);
-       }
-       
-       for(int i=0;i<numSamples;i++){
-               for(int j=0;j<numSamples;j++){
-                       
-                       double d = 0;
-                       for(int k=0;k<numOTUs;k++){
-                               d += pow((relAbundData[i][k] - relAbundData[j][k]), 2.0000);
-                       }
-                       dMatrix[i][j] = pow(d, 0.50000);
-                       dMatrix[j][i] = dMatrix[i][j];
-                       
-               }
-       }
-       return dMatrix;
-       
-}
-
-/*********************************************************************************************************************************/
diff --git a/linearalgebra.h b/linearalgebra.h
deleted file mode 100644 (file)
index ecb635f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef LINEARALGEBRA
-#define LINEARALGEBRA
-
-/*
- *  linearalgebra.h
- *  mothur
- *
- *  Created by westcott on 1/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-
-
-class LinearAlgebra {
-       
-public:
-       LinearAlgebra() { m = MothurOut::getInstance(); }
-       ~LinearAlgebra() {}
-       
-       vector<vector<double> > matrix_mult(vector<vector<double> >, vector<vector<double> >);
-       void recenter(double, vector<vector<double> >, vector<vector<double> >&);
-       int tred2(vector<vector<double> >&, vector<double>&, vector<double>&);
-       int qtli(vector<double>&, vector<double>&, vector<vector<double> >&);
-       vector< vector<double> > calculateEuclidianDistance(vector<vector<double> >&, int); //pass in axes and number of dimensions
-       vector< vector<double> > calculateEuclidianDistance(vector<vector<double> >&); //pass in axes
-       vector<vector<double> > getObservedEuclideanDistance(vector<vector<double> >&);
-       double calcPearson(vector<vector<double> >&, vector<vector<double> >&);
-       double calcSpearman(vector<vector<double> >&, vector<vector<double> >&);
-       double calcKendall(vector<vector<double> >&, vector<vector<double> >&);
-       
-       double calcPearson(vector<double>&, vector<double>&, double&);
-       double calcSpearman(vector<double>&, vector<double>&, double&);
-       double calcKendall(vector<double>&, vector<double>&, double&);
-    
-       double calcSpearmanSig(double, double, double, double); //length, f^3 - f where f is the number of ties in x, f^3 - f where f is the number of ties in y, sum of squared diffs in ranks. - designed to find the sif of one score.
-    double calcPearsonSig(double, double); //length, coeff.
-    double calcKendallSig(double, double); //length, coeff.
-    
-    
-private:
-       MothurOut* m;
-       
-       double pythag(double, double);
-    double betacf(const double, const double, const double);
-    double betai(const double, const double, const double);
-    double gammln(const double);
-    double gammp(const double, const double);
-    double gammq(const double, const double);
-    double gser(double&, const double, const double, double&);
-    double gcf(double&, const double, const double, double&);
-    double erfcc(double);
-    
-    double ran0(int&); //for testing 
-    double ran1(int&); //for testing
-    double ran2(int&); //for testing
-    double ran3(int&); //for testing
-    double ran4(int&); //for testing
-    void psdes(unsigned long &, unsigned long &); //for testing
-    
-};
-
-#endif
-
diff --git a/listseqscommand.cpp b/listseqscommand.cpp
deleted file mode 100644 (file)
index afbacc0..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- *  listseqscommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "listseqscommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-
-
-//**********************************************************************************************************************
-vector<string> ListSeqsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "FNGLT", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ListSeqsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The list.seqs command reads a fasta, name, group, list, taxonomy or alignreport file and outputs a .accnos file containing sequence names.\n";
-               helpString += "The list.seqs command parameters are fasta, name, group, list, taxonomy and alignreport.  You must provide one of these parameters.\n";
-               helpString += "The list.seqs command should be in the following format: list.seqs(fasta=yourFasta).\n";
-               helpString += "Example list.seqs(fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ListSeqsCommand::ListSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "ListSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-ListSeqsCommand::ListSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       alignfile = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignfile == "not open") { abort = true; }
-                       else if (alignfile == "not found") {  alignfile = "";  }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       if ((fastafile == "") && (namefile == "") && (listfile == "") && (groupfile == "") && (alignfile == "") && (taxfile == ""))  { m->mothurOut("You must provide a file."); m->mothurOutEndLine(); abort = true; }
-                       
-                       int okay = 1;
-                       if (outputDir != "") { okay++; }
-                       if (inputDir != "") { okay++; }
-                       
-                       if (parameters.size() > okay) { m->mothurOut("You may only enter one file."); m->mothurOutEndLine(); abort = true;  }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "ListSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ListSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read functions fill names vector
-               if (fastafile != "")            {       inputFileName = fastafile;      readFasta();    }
-               else if (namefile != "")        {       inputFileName = namefile;       readName();             }
-               else if (groupfile != "")       {       inputFileName = groupfile;      readGroup();    }
-               else if (alignfile != "")       {       inputFileName = alignfile;      readAlign();    }
-               else if (listfile != "")        {       inputFileName = listfile;       readList();             }
-               else if (taxfile != "")         {       inputFileName = taxfile;        readTax();              }
-               
-               if (m->control_pressed) { outputTypes.clear();  return 0; }
-               
-               //sort in alphabetical order
-               sort(names.begin(), names.end());
-               
-               if (outputDir == "") {  outputDir += m->hasPath(inputFileName);  }
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + "accnos";
-
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
-               
-               //output to .accnos file
-               for (int i = 0; i < names.size(); i++) {
-                       
-                       if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; }
-                       
-                       out << names[i] << endl;
-               }
-               out.close();
-               
-               if (m->control_pressed) { outputTypes.clear();  m->mothurRemove(outputFileName); return 0; }
-               
-               m->setAccnosFile(outputFileName);
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               m->mothurOutEndLine();
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ListSeqsCommand::readFasta(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               //ofstream out;
-               //string newFastaName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "numsAdded.fasta";
-               //m->openOutputFile(newFastaName, out);
-               //int count = 1;
-               //string lastName = "";
-               
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       //if (lastName == "") { lastName = name; }
-                       //if (name != lastName) { count = 1; }
-               //      lastName = name;
-                       
-                       //Sequence newSeq(name+"_"+toString(count), currSeq.getAligned());
-                       //newSeq.printSequence(out);
-                       
-                       if (name != "") {  names.push_back(name);  }
-                       
-                       m->gobble(in);
-                       //count++;
-               }
-               in.close();     
-               //out.close();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ListSeqsCommand::readList(){
-       try {
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               if(!in.eof()){
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                               string binnames = list.get(i);
-                               
-                               if (m->control_pressed) { in.close(); return 0; }
-                               
-                               m->splitAtComma(binnames, names);
-                       }
-               }
-               in.close();     
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readList");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ListSeqsCommand::readName(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); return 0; }
-
-                       in >> firstCol;                         
-                       in >> secondCol;                        
-                       
-                       //parse second column saving each name
-                       m->splitAtComma(secondCol, names);
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int ListSeqsCommand::readGroup(){
-       try {
-       
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       in >> name;     m->gobble(in);                  //read from first column
-                       in >> group;                    //read from second column
-                       
-                       names.push_back(name);
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readGroup");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-//alignreport file has a column header line then all other lines contain 16 columns.  we just want the first column since that contains the name
-int ListSeqsCommand::readAlign(){
-       try {
-       
-               ifstream in;
-               m->openInputFile(alignfile, in);
-               string name, junk;
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!in.eof())  {       in >> junk;             }
-                       else                    {       break;                  }
-               }
-               //m->getline(in);
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); return 0; }
-
-                       in >> name;                             //read from first column
-                       //m->getline(in);
-                       //read rest
-                       for (int i = 0; i < 15; i++) {  
-                               if (!in.eof())  {       in >> junk;             }
-                               else                    {       break;                  }
-                       }
-                       
-                       names.push_back(name);
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               
-               return 0;
-
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readAlign");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ListSeqsCommand::readTax(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, firstCol, secondCol;
-               
-               while(!in.eof()){
-               
-                       if (m->control_pressed) { in.close(); return 0; }
-
-                       in >> firstCol;                         
-                       in >> secondCol;                        
-                       
-                       names.push_back(firstCol);
-                       
-                       m->gobble(in);
-                       
-               }
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListSeqsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/listseqscommand.h b/listseqscommand.h
deleted file mode 100644 (file)
index f814d84..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef LISTSEQSCOMMAND_H
-#define LISTSEQSCOMMAND_H
-
-/*
- *  listseqscommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class ListSeqsCommand : public Command {
-       
-       public:
-       
-               ListSeqsCommand(string);
-               ListSeqsCommand();      
-               ~ListSeqsCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "list.seqs";                           }
-               string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/List.seqs"; }
-               string getDescription()         { return "lists sequences from a list, fasta, name, group, alignreport or taxonomy file"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       private:
-               vector<string> names, outputNames;
-               string fastafile, namefile, groupfile, alignfile, inputFileName, outputDir, listfile, taxfile;
-               bool abort;
-               
-               int readFasta();
-               int readName();
-               int readGroup();
-               int readAlign();
-               int readList();
-               int readTax();
-               
-};
-
-#endif
-
diff --git a/listvector.cpp b/listvector.cpp
deleted file mode 100644 (file)
index 9369a12..0000000
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- *  list.cpp
- *  
- *
- *  Created by Pat Schloss on 8/8/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
-#include "ordervector.hpp"
-#include "listvector.hpp"
-
-
-/***********************************************************************/
-
-ListVector::ListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){}
-
-/***********************************************************************/
-
-ListVector::ListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){}
-
-/***********************************************************************/
-
-ListVector::ListVector(string id, vector<string> lv) : DataVector(id), data(lv){
-       try {
-               for(int i=0;i<data.size();i++){
-                       if(data[i] != ""){
-                               int binSize = m->getNumNames(data[i]);
-                               numBins = i+1;
-                               if(binSize > maxRank)   {       maxRank = binSize;      }
-                               numSeqs += binSize;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "ListVector");
-               exit(1);
-       }
-}
-
-/**********************************************************************/
-
-ListVector::ListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               int hold;
-               f >> label >> hold;
-       
-               data.assign(hold, "");
-               string inputData = "";
-       
-               for(int i=0;i<hold;i++){
-                       f >> inputData;
-                       set(i, inputData);
-               }
-               m->gobble(f);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "ListVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ListVector::set(int binNumber, string seqNames){
-       try {
-               int nNames_old = m->getNumNames(data[binNumber]);
-               data[binNumber] = seqNames;
-               int nNames_new = m->getNumNames(seqNames);
-       
-               if(nNames_old == 0)                     {       numBins++;                              }
-               if(nNames_new == 0)                     {       numBins--;                              }
-               if(nNames_new > maxRank)        {       maxRank = nNames_new;   }
-       
-               numSeqs += (nNames_new - nNames_old);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-string ListVector::get(int index){
-       return data[index];
-}
-
-/***********************************************************************/
-
-void ListVector::push_back(string seqNames){
-       try {
-               data.push_back(seqNames);
-               int nNames = m->getNumNames(seqNames);
-       
-               numBins++;
-       
-               if(nNames > maxRank)    {       maxRank = nNames;       }
-       
-               numSeqs += nNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void ListVector::resize(int size){
-       data.resize(size);              
-}
-
-/***********************************************************************/
-
-int ListVector::size(){
-       return data.size();
-}
-/***********************************************************************/
-
-void ListVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       return data.clear();
-       
-}
-
-/***********************************************************************/
-
-void ListVector::print(ostream& output){
-       try {
-               output << label << '\t' << numBins << '\t';
-       
-               for(int i=0;i<data.size();i++){
-                       if(data[i] != ""){
-                               output << data[i] << '\t';
-                       }
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "print");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-RAbundVector ListVector::getRAbundVector(){
-       try {
-               RAbundVector rav;
-       
-               for(int i=0;i<data.size();i++){
-                       int binSize = m->getNumNames(data[i]);
-                       rav.push_back(binSize);
-               }
-       
-       //  This was here before to output data in a nice format, but it screws up the name mapping steps
-       //      sort(rav.rbegin(), rav.rend());
-       //      
-       //      for(int i=data.size()-1;i>=0;i--){
-       //              if(rav.get(i) == 0){    rav.pop_back(); }
-       //              else{
-       //                      break;
-       //              }
-       //      }
-               rav.setLabel(label);
-       
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "getRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SAbundVector ListVector::getSAbundVector(){
-       try {
-               SAbundVector sav(maxRank+1);
-       
-               for(int i=0;i<data.size();i++){
-                       int binSize = m->getNumNames(data[i]);  
-                       sav.set(binSize, sav.get(binSize) + 1); 
-               }
-               sav.set(0, 0);
-               sav.setLabel(label);
-       
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "getSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-OrderVector ListVector::getOrderVector(map<string,int>* orderMap = NULL){
-       
-       try {
-               if(orderMap == NULL){
-                       OrderVector ov;
-               
-                       for(int i=0;i<data.size();i++){
-                               int binSize = m->getNumNames(data[i]);          
-                               for(int j=0;j<binSize;j++){
-                                       ov.push_back(i);
-                               }
-                       }
-                       random_shuffle(ov.begin(), ov.end());
-                       ov.setLabel(label);
-                       ov.getNumBins();
-               
-                       return ov;
-               
-               }
-               else{
-                       OrderVector ov(numSeqs);
-               
-                       for(int i=0;i<data.size();i++){
-                               string listOTU = data[i];
-                               int length = listOTU.size();
-                               
-                               string seqName="";
-                       
-                               for(int j=0;j<length;j++){
-                               
-                                       if(listOTU[j] != ','){
-                                               seqName += listOTU[j];
-                                       }
-                                       else{
-                                               if(orderMap->count(seqName) == 0){
-                                                       m->mothurOut(seqName + " not found, check *.names file\n");
-                                                       exit(1);
-                                               }
-                                       
-                                               ov.set((*orderMap)[seqName], i);
-                                               seqName = "";
-                                       }                                               
-                               }
-                       
-                               if(orderMap->count(seqName) == 0){
-                                       m->mothurOut(seqName + " not found, check *.names file\n");
-                                       exit(1);
-                               }
-                               ov.set((*orderMap)[seqName], i);        
-                       }
-               
-                       ov.setLabel(label);
-                       ov.getNumBins();
-               
-                       return ov;              
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ListVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/listvector.hpp b/listvector.hpp
deleted file mode 100644 (file)
index dcf01a0..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef LIST_H
-#define LIST_H
-
-#include "datavector.hpp"
-
-/*     DataStructure for a list file.
-       This class is a child to datavector.  It represents OTU information at a certain distance. 
-       A list vector can be converted into and ordervector, rabundvector or sabundvector.
-       Each member of the internal container "data" represents an individual OTU.
-       So data[0] = "a,b,c,d,e,f".
-       example: listvector             =       a,b,c,d,e,f             g,h,i           j,k             l               m  
-                        rabundvector   =       6                               3                       2               1               1
-                        sabundvector   =       2               1               1               0               0               1
-                        ordervector    =       1       1       1       1       1       1       2       2       2       3       3       4       5 */
-
-class ListVector : public DataVector {
-       
-public:
-       ListVector();
-       ListVector(int);
-//     ListVector(const ListVector&);
-       ListVector(string, vector<string>);
-       ListVector(const ListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){};
-       ListVector(ifstream&);
-       ~ListVector(){};
-       
-       int getNumBins()                                                        {       return numBins;         }
-       int getNumSeqs()                                                        {       return numSeqs;         }
-       int getMaxRank()                                                        {       return maxRank;         }
-
-       void set(int, string);  
-       string get(int);
-       void push_back(string);
-       void resize(int);
-       void clear();
-       int size();
-       void print(ostream&);
-       
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       
-private:
-       vector<string> data;  //data[i] is a list of names of sequences in the ith OTU.
-       int maxRank;
-       int numBins;
-       int numSeqs;
-
-};
-
-#endif
diff --git a/logsd.cpp b/logsd.cpp
deleted file mode 100644 (file)
index 6a79541..0000000
--- a/logsd.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *  logsd.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "logsd.h"
-
-/***********************************************************************/
-
-double LogSD::logS(double x){
-       return -(1-x)*log(1-x)/x;
-}
-/***********************************************************************/
-EstOutput LogSD::getValues(SAbundVector* rank){
-       try {
-               
-               /*test data VVV
-               int dstring[] = {0,37,22,12,12,11,11,6,4,3,5,2,4,2,3,2,2,4,2,0,4,4,1,1,0,1,0,0,2,2,0,0,0,2,2,0,0,0,1,1,3,0,2,0,0,0,0,0,2,0,0,1,1,1,0,0,0,0,1,0,0,1,0,0,2,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
-               vector<int> dvec;
-               for(int i = 0; i < 1800; i++)
-                       dvec.push_back(dstring[i]);
-               int mr = 1799;
-               int nb = 197;
-               int ns = 6815;
-               SAbundVector rankw = SAbundVector(dvec, mr,nb,ns);
-               SAbundVector *rank = &rankw;*/
-               
-               data.resize(3,0);
-               double numInd = rank->getNumSeqs();
-               double numSpec = rank->getNumBins();
-               double snRatio = (double)numSpec/numInd;
-               double x = .5;
-               double step = .4999999999;
-               
-               while(fabs(snRatio - logS(x)) > .00001) { //This uses a binary search to find the value of x.
-                       if(logS(x) > snRatio)
-                               x += step;
-                       else
-                               x -= step;
-                       step /= 2;
-               }
-               double alpha = numInd*(1-x)/x;
-
-               double oct = 1;
-               double octSumObs = 0;
-               double sumObs = 0;
-               double octSumExp = 0;
-               double sumExp = 0;
-               double maxDiff = 0;
-               for(int y = 1; y < rank->size(); y++) {
-                       if(y - .5 < pow(2.0, oct)) {
-                               octSumObs += rank->get(y);
-                               octSumExp += alpha*pow(x,y)/(y);
-                       }       
-                       else {
-                               sumObs += octSumObs;
-                               octSumObs = rank->get(y);
-
-                               sumExp += octSumExp;
-                               octSumExp = alpha*pow(x,y)/(y);
-                               oct++;
-                       }
-       
-                       if(y == rank->size()-1) {
-                               sumObs += octSumObs;
-                               sumExp += octSumExp;
-                       }
-                       
-                       double diff = fabs(sumObs - .5 - sumExp);
-                       if(diff > maxDiff)
-                               maxDiff = diff;
-               }
-
-               data[0] = (maxDiff + .5)/numSpec;
-               data[1] = 0.886/sqrt(numSpec);
-               data[2] = 1.031/sqrt(numSpec);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "LogSD", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/logsd.h b/logsd.h
deleted file mode 100644 (file)
index c9e7088..0000000
--- a/logsd.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef LOGSD_H
-#define LOGSD_H
-
-/*
- *  logsd.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 2/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/*This class implements the LogSD estimator on single group. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class LogSD : public Calculator  {
-       
-public:
-
-       LogSD() : Calculator("logseries", 3, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/LogSeries"; }
-
-private:
-       double logS(double);
-       RAbundVector rdata;
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
-
-
diff --git a/makebiomcommand.cpp b/makebiomcommand.cpp
deleted file mode 100644 (file)
index acd0500..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-//
-//  makebiomcommand.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/16/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "makebiomcommand.h"
-#include "sharedrabundvector.h"
-#include "inputdata.h"
-
-//taken from http://biom-format.org/documentation/biom_format.html
-/* Minimal Sparse 
- {
- "id":null,
- "format": "Biological Observation Matrix 0.9.1",
- "format_url": "http://biom-format.org",
- "type": "OTU table",
- "generated_by": "QIIME revision 1.4.0-dev",
- "date": "2011-12-19T19:00:00",
- "rows":[
- {"id":"GG_OTU_1", "metadata":null},
- {"id":"GG_OTU_2", "metadata":null},
- {"id":"GG_OTU_3", "metadata":null},
- {"id":"GG_OTU_4", "metadata":null},
- {"id":"GG_OTU_5", "metadata":null}
- ],
- "columns": [
- {"id":"Sample1", "metadata":null},
- {"id":"Sample2", "metadata":null},
- {"id":"Sample3", "metadata":null},
- {"id":"Sample4", "metadata":null},
- {"id":"Sample5", "metadata":null},
- {"id":"Sample6", "metadata":null}
- ],
- "matrix_type": "sparse",
- "matrix_element_type": "int",
- "shape": [5, 6],
- "data":[[0,2,1],
- [1,0,5],
- [1,1,1],
- [1,3,2],
- [1,4,3],
- [1,5,1],
- [2,2,1],
- [2,3,4],
- [2,4,2],
- [3,0,2],
- [3,1,1],
- [3,2,1],
- [3,5,1],
- [4,1,1],
- [4,2,1]
- ]
- }
- */
-/* Minimal dense
- {
- "id":null,
- "format": "Biological Observation Matrix 0.9.1",
- "format_url": "http://biom-format.org",
- "type": "OTU table",
- "generated_by": "QIIME revision 1.4.0-dev",
- "date": "2011-12-19T19:00:00",
- "rows":[
- {"id":"GG_OTU_1", "metadata":null},
- {"id":"GG_OTU_2", "metadata":null},
- {"id":"GG_OTU_3", "metadata":null},
- {"id":"GG_OTU_4", "metadata":null},
- {"id":"GG_OTU_5", "metadata":null}
- ],
- "columns": [
- {"id":"Sample1", "metadata":null},
- {"id":"Sample2", "metadata":null},
- {"id":"Sample3", "metadata":null},
- {"id":"Sample4", "metadata":null},
- {"id":"Sample5", "metadata":null},
- {"id":"Sample6", "metadata":null}
- ],
- "matrix_type": "dense",
- "matrix_element_type": "int",
- "shape": [5,6],
- "data":  [[0,0,1,0,0,0],
- [5,1,0,2,3,1],
- [0,0,1,4,2,0],
- [2,1,1,0,0,1],
- [0,1,1,0,0,0]]
- }
- */
-//**********************************************************************************************************************
-vector<string> MakeBiomCommand::setParameters(){       
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-        CommandParameter pcontaxonomy("contaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcontaxonomy);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-        CommandParameter pmatrixtype("matrixtype", "Multiple", "sparse-dense", "sparse", "", "", "",false,false); parameters.push_back(pmatrixtype);
-
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MakeBiomCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The make.biom command parameters are shared, contaxonomy, groups, matrixtype and label.  shared is required, unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The matrixtype parameter allows you to select what type you would like to make. Choices are sparse and dense, default is sparse.\n";
-        helpString += "The contaxonomy file is the taxonomy file outputted by classify.otu(list=yourListfile, taxonomy=yourTaxonomyFile). Be SURE that the you are the constaxonomy file distance matches the shared file distance.  ie, for *.0.03.cons.taxonomy set label=0.03. Mothur is smart enough to handle shared files that have been subsampled.\n";
-               helpString += "The make.biom command should be in the following format: make.biom(shared=yourShared, groups=yourGroups, label=yourLabels).\n";
-               helpString += "Example make.biom(shared=abrecovery.an.shared, groups=A-B-C).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "The make.biom command outputs a .biom file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MakeBiomCommand::MakeBiomCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["biom"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "MakeBiomCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MakeBiomCommand::MakeBiomCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-        
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["biom"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                
-                it = parameters.find("contaxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["contaxonomy"] = inputDir + it->second;              }
-                               }
-                       }
-            
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-            
-            contaxonomyfile = validParameter.validFile(parameters, "contaxonomy", true);
-                       if (contaxonomyfile == "not found") {  contaxonomyfile = "";  }
-                       else if (contaxonomyfile == "not open") { contaxonomyfile = ""; abort = true; }
-
-            
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-            if ((contaxonomyfile != "") && (labels.size() > 1)) { m->mothurOut("[ERROR]: the contaxonomy parameter cannot be used with multiple labels."); m->mothurOutEndLine(); abort = true; }
-            
-                       format = validParameter.validFile(parameters, "matrixtype", false);                             if (format == "not found") { format = "sparse"; }
-                       
-                       if ((format != "sparse") && (format != "dense")) {
-                               m->mothurOut(format + " is not a valid option for the matrixtype parameter. Options are sparse and dense."); m->mothurOutEndLine(); abort = true; 
-                       }
-               }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "MakeBiomCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MakeBiomCommand::execute(){
-       try {
-        
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-            
-               InputData input(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-        
-        //if user did not specify a label, then use first one
-        if ((contaxonomyfile != "") && (labels.size() == 0)) {
-            allLines = 0;
-            labels.insert(lastLabel);
-        }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-        
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  return 0; }
-            
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               getBiom(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               lookup = input.getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               getBiom(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-            
-                       //prevent memory leak and get next set
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       lookup = input.getSharedRAbundVectors();                                
-               }
-               
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  return 0; }     
-        
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-        
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input.getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-            getBiom(lookup);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-               
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  return 0; }     
-               
-        //set sabund file as new current sabundfile
-        string current = "";
-               itTypes = outputTypes.find("biom");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setBiomFile(current); }
-               }
-
-        
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int MakeBiomCommand::getBiom(vector<SharedRAbundVector*>& lookup){
-       try {
-        
-        string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".biom";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName); outputTypes["biom"].push_back(outputFileName);
-
-        string mothurString = "mothur" + toString(m->getVersion());
-        time_t rawtime;
-        struct tm * timeinfo;
-        time ( &rawtime );
-        timeinfo = localtime ( &rawtime );
-        string dateString = asctime (timeinfo);
-        int pos = dateString.find('\n');
-        if (pos != string::npos) { dateString = dateString.substr(0, pos);}
-        string spaces = "      ";
-        
-        //standard 
-        out << "{\n" + spaces + "\"id\":\"" + sharedfile + "-" + lookup[0]->getLabel() + "\",\n" + spaces + "\"format\": \"Biological Observation Matrix 0.9.1\",\n" + spaces + "\"format_url\": \"http://biom-format.org\",\n";
-        out << spaces + "\"type\": \"OTU table\",\n" + spaces + "\"generated_by\": \"" << mothurString << "\",\n" + spaces + "\"date\": \"" << dateString << "\",\n";
-        
-        vector<string> metadata = getMetaData(lookup);  
-        
-        if (m->control_pressed) {  out.close(); return 0; }
-        
-        //get row info
-        /*"rows":[
-                {"id":"GG_OTU_1", "metadata":null},
-                {"id":"GG_OTU_2", "metadata":null},
-                {"id":"GG_OTU_3", "metadata":null},
-                {"id":"GG_OTU_4", "metadata":null},
-                {"id":"GG_OTU_5", "metadata":null}
-                ],*/
-        out << spaces + "\"rows\":[\n";
-        string rowFront = spaces + spaces + "{\"id\":\"";
-        string rowBack = "\", \"metadata\":";
-        for (int i = 0; i < m->currentBinLabels.size()-1; i++) {
-            if (m->control_pressed) {  out.close(); return 0; }
-            out << rowFront << m->currentBinLabels[i] << rowBack << metadata[i] << "},\n";
-        }
-        out << rowFront << m->currentBinLabels[(m->currentBinLabels.size()-1)] << rowBack << metadata[(m->currentBinLabels.size()-1)] << "}\n" + spaces + "],\n";
-        
-        //get column info
-        /*"columns": [
-                    {"id":"Sample1", "metadata":null},
-                    {"id":"Sample2", "metadata":null},
-                    {"id":"Sample3", "metadata":null},
-                    {"id":"Sample4", "metadata":null},
-                    {"id":"Sample5", "metadata":null},
-                    {"id":"Sample6", "metadata":null}
-                    ],*/
-        
-        string colBack = "\", \"metadata\":null}";
-        out << spaces + "\"columns\":[\n";
-        for (int i = 0; i < lookup.size()-1; i++) {
-            if (m->control_pressed) {  out.close(); return 0; }
-            out << rowFront << lookup[i]->getGroup() << colBack << ",\n";
-        }
-        out << rowFront << lookup[(lookup.size()-1)]->getGroup() << colBack << "\n" + spaces + "],\n";
-        
-        out << spaces + "\"matrix_type\": \"" << format << "\",\n" + spaces + "\"matrix_element_type\": \"int\",\n";
-        out <<  spaces + "\"shape\": [" << m->currentBinLabels.size() << "," << lookup.size() << "],\n";
-        out << spaces + "\"data\":  [";
-        
-        vector<string> dataRows;
-        if (format == "sparse") {
-            /*"data":[[0,2,1],
-             [1,0,5],
-             [1,1,1],
-             [1,3,2],
-             [1,4,3],
-             [1,5,1],
-             [2,2,1],
-             [2,3,4],
-             [2,4,2],
-             [3,0,2],
-             [3,1,1],
-             [3,2,1],
-             [3,5,1],
-             [4,1,1],
-             [4,2,1]
-             ]*/
-            string output = "";
-            for (int i = 0; i < lookup[0]->getNumBins(); i++) {
-                
-                if (m->control_pressed) { out.close(); return 0; }
-                
-                for (int j = 0; j < lookup.size(); j++) {
-                    string binInfo = "[" + toString(i) + "," + toString(j) + "," + toString(lookup[j]->getAbundance(i)) + "]";
-                    //only print non zero values
-                    if (lookup[j]->getAbundance(i) != 0) { dataRows.push_back(binInfo); }
-                }
-            }
-        }else {
-            
-            /* "matrix_type": "dense",
-             "matrix_element_type": "int",
-             "shape": [5,6],
-             "data":  [[0,0,1,0,0,0],
-             [5,1,0,2,3,1],
-             [0,0,1,4,2,0],
-             [2,1,1,0,0,1],
-             [0,1,1,0,0,0]]*/
-            
-            for (int i = 0; i < lookup[0]->getNumBins(); i++) {
-                
-                if (m->control_pressed) { out.close(); return 0; }
-                
-                string binInfo = "[";
-                for (int j = 0; j < lookup.size()-1; j++) {
-                    binInfo += toString(lookup[j]->getAbundance(i)) + ",";
-                }
-                binInfo += toString(lookup[lookup.size()-1]->getAbundance(i)) + "]";
-                dataRows.push_back(binInfo);
-            }
-        }
-        
-        for (int i = 0; i < dataRows.size()-1; i++) {
-            out << dataRows[i] << ",\n" + spaces  + spaces;
-        }
-        out << dataRows[dataRows.size()-1] << "]\n";
-        
-        out << "}\n";
-        out.close();
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "getBiom");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> MakeBiomCommand::getMetaData(vector<SharedRAbundVector*>& lookup){
-       try {
-        vector<string> metadata;
-        
-        if (contaxonomyfile == "") { for (int i = 0; i < lookup[0]->getNumBins(); i++) {  metadata.push_back("null");  } }
-        else {
-            
-            //read constaxonomy file storing in a map, otulabel -> taxonomy
-            //constaxonomy file will most likely contain more labels than the shared file, because sharedfile could have been subsampled.
-            ifstream in;
-            m->openInputFile(contaxonomyfile, in);
-            
-            //grab headers
-            m->getline(in); m->gobble(in);
-            
-            string otuLabel, tax;
-            int size;
-            vector<string> otuLabels;
-            vector<string> taxs;
-            while (!in.eof()) {
-                
-                if (m->control_pressed) { in.close(); return metadata; }
-                
-                in >> otuLabel >> size >> tax; m->gobble(in);
-                
-                otuLabels.push_back(otuLabel);
-                taxs.push_back(tax);
-            }
-            in.close();
-            
-            //should the labels be Otu001 or PhyloType001
-            string firstBin = m->currentBinLabels[0];
-            string binTag = "Otu";
-            if ((firstBin.find("Otu")) == string::npos) { binTag = "PhyloType";  }
-            
-            //convert list file bin labels to shared file bin labels
-            //parse tax strings
-            //save in map
-            map<string, string> labelTaxMap;
-            string snumBins = toString(otuLabels.size());
-            for (int i = 0; i < otuLabels.size(); i++) {  
-                
-                if (m->control_pressed) { return metadata; }
-                
-                //if there is a bin label use it otherwise make one
-                string binLabel = binTag;
-                string sbinNumber = otuLabels[i];
-                if (sbinNumber.length() < snumBins.length()) { 
-                    int diff = snumBins.length() - sbinNumber.length();
-                    for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                }
-                binLabel += sbinNumber;
-                
-                labelTaxMap[binLabel] = taxs[i];
-            }
-            
-            
-            //{"taxonomy":["k__Bacteria", "p__Proteobacteria", "c__Gammaproteobacteria", "o__Enterobacteriales", "f__Enterobacteriaceae", "g__Escherichia", "s__"]}
-            
-            //traverse the binLabels forming the metadata strings and saving them
-            //make sure to sanity check
-            map<string, string>::iterator it;
-            for (int i = 0; i < m->currentBinLabels.size(); i++) {
-                
-                if (m->control_pressed) { return metadata; }
-                
-                it = labelTaxMap.find(m->currentBinLabels[i]);
-                
-                if (it == labelTaxMap.end()) { m->mothurOut("[ERROR]: can't find taxonomy information for " + m->currentBinLabels[i] + ".\n"); m->control_pressed = true; }
-                else {
-                    vector<string> bootstrapValues;
-                    string data = "{\"taxonomy\":[";
-            
-                    vector<string> scores;
-                    vector<string> taxonomies = parseTax(it->second, scores);
-                    
-                    for (int j = 0; j < taxonomies.size()-1; j ++) { data += "\"" + taxonomies[j] + "\", "; }
-                    data += "\"" + taxonomies[taxonomies.size()-1] + "\"]";
-                    
-                    //add bootstrap values if available
-                    if (scores[0] != "null") {
-                        data += ", \"bootstrap\":[";
-                        
-                        for (int j = 0; j < scores.size()-1; j ++) { data += scores[j] + ", "; }
-                        data += scores[scores.size()-1] + "]";
-
-                    }
-                    data += "}";
-                    
-                    metadata.push_back(data);
-                }
-            }
-        }
-        
-        return metadata;
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "getMetadata");
-               exit(1);
-       }
-
-}
-/**************************************************************************************************/
-//returns {Bacteria, Bacteroidetes, ..} and scores is filled with {100, 98, ...} or {null, null, null}
-vector<string> MakeBiomCommand::parseTax(string tax, vector<string>& scores) {
-       try {
-               
-               string taxon;
-        vector<string> taxs;
-               
-               while (tax.find_first_of(';') != -1) {
-                       
-                       if (m->control_pressed) { return taxs; }
-                       
-                       //get taxon
-                       taxon = tax.substr(0,tax.find_first_of(';'));
-            
-                       int pos = taxon.find_last_of('(');
-                       if (pos != -1) {
-                               //is it a number?
-                               int pos2 = taxon.find_last_of(')');
-                               if (pos2 != -1) {
-                                       string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1)));
-                                       if (m->isNumeric1(confidenceScore)) {
-                                               taxon = taxon.substr(0, pos); //rip off confidence 
-                        scores.push_back(confidenceScore);
-                                       }else{ scores.push_back("null"); }
-                               }
-                       }
-                       
-            //strip "" if they are there
-            pos = taxon.find("\"");
-            if (pos != string::npos) {
-                string newTax = "";
-                for (int k = 0; k < taxon.length(); k++) {
-                    if (taxon[k] != '\"') { newTax += taxon[k]; }
-                }
-                taxon = newTax;
-            }
-            
-            //look for bootstrap value
-                       taxs.push_back(taxon);
-            tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-               }
-               
-               return taxs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeBiomCommand", "parseTax");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
diff --git a/makebiomcommand.h b/makebiomcommand.h
deleted file mode 100644 (file)
index 9f80c2e..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef Mothur_makebiomcommand_h
-#define Mothur_makebiomcommand_h
-
-//
-//  makebiomcommand.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/16/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-
-#include "command.hpp"
-#include "sharedrabundvector.h"
-#include "inputdata.h"
-
-
-class MakeBiomCommand : public Command {
-       
-public:
-       MakeBiomCommand(string);
-       MakeBiomCommand();      
-       ~MakeBiomCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "make.biom";   }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://biom-format.org/documentation/biom_format.html, http://www.mothur.org/wiki/Make.biom"; }
-       string getDescription()         { return "creates a biom file"; }
-    
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-    
-       string sharedfile, contaxonomyfile, groups, outputDir, format, label;
-       vector<string> outputNames, Groups;
-       set<string> labels;
-    
-       bool abort, allLines;
-    
-    int getBiom(vector<SharedRAbundVector*>&);
-    vector<string> getMetaData(vector<SharedRAbundVector*>&);
-    vector<string> parseTax(string tax, vector<string>& scores);
-};
-
-
-#endif
diff --git a/makefastqcommand.cpp b/makefastqcommand.cpp
deleted file mode 100644 (file)
index 8e1a7f5..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- *  makefastqcommand.cpp
- *  mothur
- *
- *  Created by westcott on 2/14/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "makefastqcommand.h"
-#include "sequence.hpp"
-#include "qualityscores.h"
-
-//**********************************************************************************************************************
-vector<string> MakeFastQCommand::setParameters(){      
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pqfile);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MakeFastQCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The make.fastq command read a fasta and quality file and creates a fastq file.\n";
-               helpString += "The make.fastq command parameters are fasta and qfile, both are required.\n";
-               helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
-               helpString += "The make.fastq command should be in the following format: make.fastq(qfile=yourQualityFile, fasta=yourFasta).\n";
-               helpString += "Example make.fastq(fasta=amazon.fasta, qfile=amazon.qual).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MakeFastQCommand::MakeFastQCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fastq"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "MakeFastQCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MakeFastQCommand::MakeFastQCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fastq"] = tempOutNames;
-                       
-                                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; fastafile = ""; }
-                       else if (fastafile == "not found") {            
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") {  m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { abort = true; qualfile = ""; }
-                       else if (qualfile == "not found") {                     
-                               qualfile = m->getQualFile(); 
-                               if (qualfile != "") {  m->mothurOut("Using " + qualfile + " as input file for the qfile parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current qualfile and the qfile parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setQualFile(qualfile); }     
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);              }
-
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "MakeFastQCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MakeFastQCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "fastq";
-               outputNames.push_back(outputFile); outputTypes["fastq"].push_back(outputFile);
-               
-               ofstream out;
-               m->openOutputFile(outputFile, out);
-               
-               ifstream qFile;
-               m->openInputFile(qualfile, qFile);
-               
-               ifstream fFile;
-               m->openInputFile(fastafile, fFile);
-               
-               while (!fFile.eof() && !qFile.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence currSeq(fFile); m->gobble(fFile);
-                       QualityScores currQual(qFile);  m->gobble(qFile);
-                       
-                       if (currSeq.getName() != currQual.getName()) { m->mothurOut("[ERROR]: mismatch between fasta and quality files. Found " + currSeq.getName() + " in fasta file and " + currQual.getName() + " in quality file."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       else {
-                               //print sequence
-                               out << '@' << currSeq.getName() << endl << currSeq.getAligned() << endl;
-                               
-                               string qualityString = convertQual(currQual.getQualityScores());
-                               
-                               //print quality info
-                               out << '+' << currQual.getName() << endl << qualityString << endl;
-                       }
-                       
-               }
-               
-               fFile.close();
-               qFile.close();
-               out.close();
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-                                       
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MakeFastQCommand::convertQual(vector<int> qual) {
-       try {
-               string qualScores;
-               
-               int controlChar = int('!');
-               
-               for (int i = 0; i < qual.size(); i++) { 
-                       int temp = qual[i] + controlChar;
-                       char qualChar = (char) temp;
-                       
-                       qualScores += qualChar;
-               }
-               
-               return qualScores;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeFastQCommand", "convertQual");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
-               
diff --git a/makefastqcommand.h b/makefastqcommand.h
deleted file mode 100644 (file)
index 1c209aa..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef MAKEFASTQCOMMAND_H
-#define MAKEFASTQCOMMAND_H
-
-/*
- *  makefastqcommand.h
- *  mothur
- *
- *  Created by westcott on 2/14/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-class MakeFastQCommand : public Command {
-       
-public:
-       
-       MakeFastQCommand(string);       
-       MakeFastQCommand();
-       ~MakeFastQCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "make.fastq";                          }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Make.fastq"; }
-       string getDescription()         { return "creates a fastq file from a fasta and quality file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       
-       string fastafile, qualfile, outputDir;
-       bool abort;
-       vector<string> outputNames;
-       
-       string convertQual(vector<int>);
-       
-};
-
-#endif
-
-
diff --git a/makefile b/makefile
deleted file mode 100644 (file)
index e06c334..0000000
--- a/makefile
+++ /dev/null
@@ -1,123 +0,0 @@
-###################################################
-#
-# Makefile for mothur
-# Created: June 29, 2010
-#
-###################################################
-
-#
-# Macros
-#
-
-USEMPI ?= no
-64BIT_VERSION ?= yes
-USEREADLINE ?= yes
-CYGWIN_BUILD ?= no
-USECOMPRESSION ?= no
-MOTHUR_FILES="\"Enter_your_default_path_here\""
-RELEASE_DATE = "\"4/30/2012\""
-VERSION = "\"1.25.0\""
-FORTAN_COMPILER = gfortran
-FORTRAN_FLAGS = 
-
-# Optimize to level 3:
-CXXFLAGS += -O3 
-
-ifeq  ($(strip $(64BIT_VERSION)),yes)
-       #if you are using centos uncomment the following lines
-       #CXX = g++44
-       
-       #if you are a mac user use the following line
-       TARGET_ARCH += -arch x86_64
-       
-       #if you using cygwin to build Windows the following line
-       #CXX = x86_64-w64-mingw32-g++
-       #CC = x86_64-w64-mingw32-g++
-       #FORTAN_COMPILER = x86_64-w64-mingw32-gfortran
-       #TARGET_ARCH += -m64 -static
-
-       #if you are a linux user use the following line
-       #CXXFLAGS += -mtune=native -march=native -m64
-       
-       CXXFLAGS += -DBIT_VERSION 
-    FORTRAN_FLAGS = -m64
-endif
-
-
-CXXFLAGS += -DRELEASE_DATE=${RELEASE_DATE} -DVERSION=${VERSION}
-
-ifeq  ($(strip $(MOTHUR_FILES)),"\"Enter_your_default_path_here\"")
-else
-       CXXFLAGS += -DMOTHUR_FILES=${MOTHUR_FILES}
-endif
-
-ifeq  ($(strip $(CYGWIN_BUILD)),yes)
-    CXXFLAGS += -mno-cygwin
-    LDFLAGS += -mno-cygwin 
-endif
-
-# if you do not want to use the readline library, set this to no.
-# make sure you have the library installed
-
-
-ifeq  ($(strip $(USEREADLINE)),yes)
-    CXXFLAGS += -DUSE_READLINE
-    LIBS = \
-      -lreadline\
-      -lncurses
-endif
-
-
-ifeq  ($(strip $(USEMPI)),yes)
-    CXX = mpic++
-    CXXFLAGS += -DUSE_MPI
-endif
-
-# if you want to enable reading and writing of compressed files, set to yes.
-# The default is no.  this may only work on unix-like systems, not for windows.
-
-
-ifeq  ($(strip $(USECOMPRESSION)),yes)
-  CXXFLAGS += -DUSE_COMPRESSION
-endif
-
-#
-# INCLUDE directories for mothur
-#
-
-     CXXFLAGS += -I.
-
-#
-# Get the list of all .cpp files, rename to .o files
-#
-
-OBJECTS=$(patsubst %.cpp,%.o,$(wildcard *.cpp))
-OBJECTS+=$(patsubst %.c,%.o,$(wildcard *.c))
-OBJECTS+=$(patsubst %.f,%.o,$(wildcard *.f))
-
-mothur : fortranSource $(OBJECTS) uchime
-       $(CXX) $(LDFLAGS) $(TARGET_ARCH) -o $@ $(OBJECTS) $(LIBS)
-       
-       strip mothur
-uchime:
-       cd uchime_src && ./mk && mv uchime .. && cd ..
-       
-fortranSource:
-       ${FORTAN_COMPILER} -c $(FORTRAN_FLAGS) *.f
-
-install : mothur
-#      cp mothur ../Release/mothur
-       
-%.o : %.c %.h
-       $(COMPILE.c) $(OUTPUT_OPTION) $<
-%.o : %.cpp %.h
-       $(COMPILE.cpp) $(OUTPUT_OPTION) $<
-%.o : %.cpp %.hpp
-       $(COMPILE.cpp) $(OUTPUT_OPTION) $<
-
-
-clean :
-       @rm -f $(OBJECTS)
-       @rm -f uchime
-
diff --git a/makegroupcommand.cpp b/makegroupcommand.cpp
deleted file mode 100644 (file)
index 0add62e..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- *  makegroupcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/7/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "makegroupcommand.h"
-#include "sequence.hpp"
-
-
-//**********************************************************************************************************************
-vector<string> MakeGroupCommand::setParameters(){      
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MakeGroupCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The make.group command reads a fasta file or series of fasta files and creates a groupfile.\n";
-               helpString += "The make.group command parameters are fasta, groups and output. Fasta and group are required.\n";
-               helpString += "The output parameter allows you to specify the name of groupfile created. \n";
-               helpString += "The make.group command should be in the following format: \n";
-               helpString += "make.group(fasta=yourFastaFiles, groups=yourGroups). \n";
-               helpString += "Example make.group(fasta=seqs1.fasta-seq2.fasta-seqs3.fasta, groups=A-B-C)\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFiles).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MakeGroupCommand::MakeGroupCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["group"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "MakeGroupCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-MakeGroupCommand::MakeGroupCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;   
-       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-
-                       fastaFileName = validParameter.validFile(parameters, "fasta", false);
-                       if (fastaFileName == "not found") {                             //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { 
-                               m->splitAtDash(fastaFileName, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  
-                                                       m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); 
-                                                       filename += m->getRootName(m->getSimpleName(fastaFileNames[i]));
-                                               }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               ifstream in;
-                                               int ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else{  filename += m->getRootName(m->getSimpleName(fastaFileNames[i]));  m->setFastaFile(fastaFileNames[i]); }
-                                       }
-                               }
-                               
-                               //prevent giantic file name
-                               if (fastaFileNames.size() > 3) { filename = outputDir + "merge.groups"; }
-                               else {  filename += "groups";  }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       output = validParameter.validFile(parameters, "output", false);                 
-                       if (output == "not found") { output = "";  }
-                       else{ filename = output; }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { m->mothurOut("groups is a required parameter for the make.group command."); m->mothurOutEndLine(); abort = true;  }
-                       else { m->splitAtDash(groups, groupsNames);     }
-
-                       if (groupsNames.size() != fastaFileNames.size()) { m->mothurOut("You do not have the same number of valid fastfile files as groups.  This could be because we could not open a fastafile."); m->mothurOutEndLine(); abort = true;  }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "MakeGroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MakeGroupCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[0]); }
-                       
-               filename = outputDir + filename;
-               
-               ofstream out;
-               m->openOutputFile(filename, out);
-               
-               for (int i = 0; i < fastaFileNames.size(); i++) {
-               
-                       if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(filename); return 0; }
-                       
-                       ifstream in;
-                       m->openInputFile(fastaFileNames[i], in);
-                       
-                       while (!in.eof()) {
-                               
-                               Sequence seq(in, "no align"); m->gobble(in);
-                               
-                               if (m->control_pressed) { outputTypes.clear();  in.close(); out.close(); m->mothurRemove(filename); return 0; }
-                               
-                               if (seq.getName() != "") {      out << seq.getName() << '\t' << groupsNames[i] << endl;         }
-                       }
-                       in.close();
-               }
-               
-               out.close();
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: " + filename); m->mothurOutEndLine(); outputNames.push_back(filename); outputTypes["group"].push_back(filename); 
-               m->mothurOutEndLine();
-               
-               //set group file as new current groupfile
-               string current = "";
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MakeGroupCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/makegroupcommand.h b/makegroupcommand.h
deleted file mode 100644 (file)
index e0c7092..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef MAKEGROUPCOMMAND_H
-#define MAKEGROUPCOMMAND_H
-
-/*
- *  makegroupcommand.h
- *  Mothur
- *
- *  Created by westcott on 5/7/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class MakeGroupCommand : public Command {
-       
-public:
-       MakeGroupCommand(string);
-       MakeGroupCommand();     
-       ~MakeGroupCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "make.group";  }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Make.group"; }
-       string getDescription()         { return "creates a group file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-               
-       string fastaFileName, groups, outputDir, filename, output;
-       vector<string> fastaFileNames;
-       vector<string> groupsNames, outputNames;
-       
-       bool abort;
-};
-
-#endif
-
diff --git a/maligner.cpp b/maligner.cpp
deleted file mode 100644 (file)
index 3d1d1c9..0000000
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
- *  maligner.cpp
- *  Mothur
- *
- *  Created by westcott on 9/23/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "maligner.h"
-
-/***********************************************************************/ //int num, int match, int misMatch, , string mode, Database* dataLeft, Database* dataRight
-Maligner::Maligner(vector<Sequence> temp, int match, int misMatch, float div, int ms, int minCov) : db(temp), matchScore(match), misMatchPenalty(misMatch), minDivR(div), minSimilarity(ms), minCoverage(minCov) { 
-                       //numWanted(num),  , searchMethod(mode), databaseLeft(dataLeft), databaseRight(dataRight)
-                       
-                       m = MothurOut::getInstance(); 
-                       
-}
-/***********************************************************************/
-string Maligner::getResults(Sequence q, DeCalculator decalc) {
-       try {
-               
-               outputResults.clear();
-               
-               //make copy so trimming doesn't destroy query from calling class - remember to deallocate
-               query.setName(q.getName()); query.setAligned(q.getAligned());
-               
-               string chimera;
-               
-               //copy refSeqs so that filter does not effect original
-               for(int i = 0; i < db.size(); i++) {  
-                       Sequence newSeq(db[i].getName(), db[i].getAligned());
-                       refSeqs.push_back(newSeq);
-               }
-               
-               refSeqs = minCoverageFilter(refSeqs);
-               
-               if (refSeqs.size() < 2)  { 
-                       //for (int i = 0; i < refSeqs.size(); i++) {  delete refSeqs[i];        }
-                       percentIdenticalQueryChimera = 0.0;
-                       return "unknown"; 
-               }
-               
-               int chimeraPenalty = computeChimeraPenalty();
-       
-               //fills outputResults
-               chimera = chimeraMaligner(chimeraPenalty, decalc);
-               
-               if (m->control_pressed) { return chimera;  }
-                               
-               //free memory
-               //delete query;
-
-               //for (int i = 0; i < refSeqs.size(); i++) {  delete refSeqs[i];        }
-               
-               return chimera;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "getResults");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string Maligner::chimeraMaligner(int chimeraPenalty, DeCalculator decalc) {
-       try {
-               
-               string chimera;
-               //trims seqs to first non gap char in all seqs and last non gap char in all seqs
-               spotMap = decalc.trimSeqs(query, refSeqs);
-
-               //you trimmed the whole sequence, skip
-               if (query.getAligned() == "") { return "no"; }
-
-               vector<Sequence> temp = refSeqs;
-               temp.push_back(query);
-                       
-               temp = verticalFilter(temp);
-               query = temp[temp.size()-1];
-               for (int i = 0; i < temp.size()-1; i++) {  refSeqs[i] = temp[i]; }
-               
-               //for (int i = 0; i < refSeqs.size(); i++) { cout << refSeqs[i]->getName() << endl ; }//<< refSeqs[i]->getAligned() << endl
-
-               vector< vector<score_struct> > matrix = buildScoreMatrix(query.getAligned().length(), refSeqs.size()); //builds and initializes
-               
-               if (m->control_pressed) { return chimera;  }
-               
-               fillScoreMatrix(matrix, refSeqs, chimeraPenalty);
-               
-               vector<score_struct> path = extractHighestPath(matrix);
-               
-               if (m->control_pressed) { return chimera;  }
-               
-               vector<trace_struct> trace = mapTraceRegionsToAlignment(path);
-                               
-               if (trace.size() > 1) {         chimera = "yes";        }
-               else { chimera = "no";  return chimera; }
-               
-               int traceStart = path[0].col;
-               int traceEnd = path[path.size()-1].col; 
-               string queryInRange = query.getAligned();
-               queryInRange = queryInRange.substr(traceStart, (traceEnd-traceStart+1));
-//             cout << queryInRange << endl;
-               string chimeraSeq = constructChimericSeq(trace, refSeqs);
-//             cout << chimeraSeq << endl;
-               
-//             cout << queryInRange.length() << endl;
-//             cout << chimeraSeq.length() << endl;
-               
-               percentIdenticalQueryChimera = computePercentID(queryInRange, chimeraSeq);
-               
-//             cout << percentIdenticalQueryChimera << endl;
-       /*      
-               vector<trace_struct> trace = extractHighestPath(matrix);
-                               
-               //cout << "traces\n";
-               //for(int i=0;i<trace.size();i++){
-               //      cout << trace[i].col << '\t' << trace[i].oldCol << '\t' << refSeqs[trace[i].row]->getName() << endl;
-               //}
-               
-               if (trace.size() > 1) {         chimera = "yes";        }
-               else { chimera = "no";  return chimera; }
-               
-               int traceStart = trace[0].col;
-               int traceEnd = trace[trace.size()-1].oldCol;    
-               string queryInRange = query->getAligned();
-               queryInRange = queryInRange.substr(traceStart, (traceEnd-traceStart));*/
-               
-               if (m->control_pressed) { return chimera;  }
-               
-               //save output results
-               for (int i = 0; i < trace.size(); i++) {
-                       int regionStart = trace[i].col;
-                       int regionEnd = trace[i].oldCol;
-                       int seqIndex = trace[i].row;
-                       
-//                     cout << regionStart << '\t' << regionEnd << '\t' << seqIndex << endl;
-                       results temp;
-                       
-                       temp.parent = refSeqs[seqIndex].getName();
-                       temp.parentAligned = db[seqIndex].getAligned();
-                       temp.nastRegionStart = spotMap[regionStart];
-                       temp.nastRegionEnd = spotMap[regionEnd];
-                       temp.regionStart = unalignedMap[regionStart];
-                       temp.regionEnd = unalignedMap[regionEnd];
-                       
-                       string parentInRange = refSeqs[seqIndex].getAligned();
-                       parentInRange = parentInRange.substr(traceStart, (traceEnd-traceStart+1));
-                       
-                       temp.queryToParent = computePercentID(queryInRange, parentInRange);
-                       temp.divR = (percentIdenticalQueryChimera / temp.queryToParent);
-
-                       string queryInRegion = query.getAligned();
-                       queryInRegion = queryInRegion.substr(regionStart, (regionEnd-regionStart+1));
-                       
-                       string parentInRegion = refSeqs[seqIndex].getAligned();
-                       parentInRegion = parentInRegion.substr(regionStart, (regionEnd-regionStart+1));
-                       
-                       temp.queryToParentLocal = computePercentID(queryInRegion, parentInRegion);
-                       
-                       //cout << query->getName() << '\t' << temp.parent << '\t' << "NAST:" << temp.nastRegionStart << '-' << temp.nastRegionEnd << " G:" << temp.queryToParent << " L:" << temp.queryToParentLocal << ", " <<  temp.divR << endl;
-
-                       outputResults.push_back(temp);
-               }
-               
-               return chimera;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "chimeraMaligner");
-               exit(1);
-       }
-}
-/***********************************************************************/
-//removes top matches that do not have minimum coverage with query.
-vector<Sequence> Maligner::minCoverageFilter(vector<Sequence> ref){  
-       try {
-               vector<Sequence> newRefs;
-               
-               string queryAligned = query.getAligned();
-               
-               for (int i = 0; i < ref.size(); i++) {
-                       
-                       string refAligned = ref[i].getAligned();
-                       
-                       int numBases = 0;
-                       int numCovered = 0;
-                       
-                       //calculate coverage
-                       for (int j = 0; j < queryAligned.length(); j++) {
-                               
-                               if (isalpha(queryAligned[j])) {
-                                       numBases++;
-                                       
-                                       if (isalpha(refAligned[j])) {
-                                               numCovered++;
-                                       }
-                               }
-                       }
-                       
-                       int coverage = ((numCovered/(float)numBases)*100);
-                       
-                       //if coverage above minimum
-                       if (coverage > minCoverage) {
-                               newRefs.push_back(ref[i]);
-                       }//else {
-                               //delete ref[i];
-                       //}
-               }
-               
-               return newRefs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "minCoverageFilter");
-               exit(1);
-       }
-}
-/***********************************************************************/
-// a breakpoint should yield fewer mismatches than this number with respect to the best parent sequence.
-int Maligner::computeChimeraPenalty() {
-       try {
-               
-               int numAllowable = ((1.0 - (1.0/minDivR)) * query.getNumBases());
-
-//             if(numAllowable < 1){   numAllowable = 1;       }
-               
-               int penalty = int(numAllowable + 1) * misMatchPenalty;
-
-               return penalty;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "computeChimeraPenalty");
-               exit(1);
-       }
-}
-/***********************************************************************/
-//this is a vertical filter
-vector<Sequence> Maligner::verticalFilter(vector<Sequence> seqs) {
-       try {
-               vector<int> gaps;       gaps.resize(query.getAligned().length(), 0);
-               
-               string filterString = (string(query.getAligned().length(), '1'));
-               
-               //for each sequence
-               for (int i = 0; i < seqs.size(); i++) {
-               
-                       string seqAligned = seqs[i].getAligned();
-                       
-                       for (int j = 0; j < seqAligned.length(); j++) {
-                               //if this spot is a gap
-                               if ((seqAligned[j] == '-') || (seqAligned[j] == '.'))   {       gaps[j]++;      }
-                       }
-               }
-               
-               //zero out spot where all sequences have blanks
-               int numColRemoved = 0;
-               for(int i = 0; i < seqs[0].getAligned().length(); i++){
-                       if(gaps[i] == seqs.size())      {       filterString[i] = '0';  numColRemoved++;  }
-               }
-               
-               map<int, int> newMap;
-               //for each sequence
-               for (int i = 0; i < seqs.size(); i++) {
-               
-                       string seqAligned = seqs[i].getAligned();
-                       string newAligned = "";
-                       int count = 0;
-                       
-                       for (int j = 0; j < seqAligned.length(); j++) {
-                               //if this spot is not a gap
-                               if (filterString[j] == '1') { 
-                                       newAligned += seqAligned[j]; 
-                                       newMap[count] = spotMap[j];
-                                       count++;
-                               }
-                       }
-                       
-                       seqs[i].setAligned(newAligned);
-               }
-               
-               string query = seqs[seqs.size()-1].getAligned();
-               int queryLength = query.length();
-               
-               unalignedMap.resize(queryLength, 0);
-               
-               
-               for(int i=1;i<queryLength;i++){
-                       if(query[i] != '.' && query[i] != '-'){
-                               unalignedMap[i] = unalignedMap[i-1] + 1;
-                       }
-                       else{
-                               unalignedMap[i] = unalignedMap[i-1];
-                       }
-               }
-               
-               spotMap = newMap;
-               
-               return seqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "verticalFilter");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector< vector<score_struct> > Maligner::buildScoreMatrix(int cols, int rows) {
-       try{
-               
-               vector< vector<score_struct> > m(rows);
-               
-               for (int i = 0; i < rows; i++) {
-                       for (int j = 0; j < cols; j++) {
-                               
-                               //initialize each cell
-                               score_struct temp;
-                               temp.prev = -1;
-                               temp.score = -9999999;
-                               temp.col = j;
-                               temp.row = i;
-                               
-                               m[i].push_back(temp);
-                       }
-               }
-               
-               return m;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "buildScoreMatrix");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void Maligner::fillScoreMatrix(vector<vector<score_struct> >& ms, vector<Sequence> seqs, int penalty) {
-       try{
-               
-               //get matrix dimensions
-               int numCols = query.getAligned().length();
-               int numRows = seqs.size();
-               
-//             cout << numRows << endl;
-               
-               //initialize first col
-               string queryAligned = query.getAligned();
-               for (int i = 0; i < numRows; i++) {
-                       string subjectAligned = seqs[i].getAligned();
-                       
-                       //are you both gaps?
-                       if ((!isalpha(queryAligned[0])) && (!isalpha(subjectAligned[0]))) {
-                               ms[i][0].score = 0;
-//                             ms[i][0].mismatches = 0;
-                       }else if (queryAligned[0] == subjectAligned[0])  { //|| subjectAligned[0] == 'N')
-                               ms[i][0].score = matchScore;
-//                             ms[i][0].mismatches = 0;
-                       }else{
-                               ms[i][0].score = 0;
-//                             ms[i][0].mismatches = 1;
-                       }
-               }
-               
-               //fill rest of matrix
-               for (int j = 1; j < numCols; j++) {  //iterate through matrix columns
-               
-//                     for (int i = 0; i < 1; i++) {  //iterate through matrix rows
-                       for (int i = 0; i < numRows; i++) {  //iterate through matrix rows
-                               
-                               string subjectAligned = seqs[i].getAligned();
-                               
-                               int matchMisMatchScore = 0;
-                               //are you both gaps?
-                               if ((!isalpha(queryAligned[j])) && (!isalpha(subjectAligned[j]))) {
-                                       //leave the same
-                               }else if ((toupper(queryAligned[j]) == 'N') || (toupper(subjectAligned[j]) == 'N')) {
-                                       //leave the same
-                               }else if (queryAligned[j] == subjectAligned[j]) {
-                                       matchMisMatchScore = matchScore;
-                               }else if (queryAligned[j] != subjectAligned[j]) {
-                                       matchMisMatchScore = misMatchPenalty;
-                               }
-
-                               //compute score based on previous columns scores
-                               for (int prevIndex = 0; prevIndex < numRows; prevIndex++) { //iterate through rows
-                                       
-                                       int sumScore = matchMisMatchScore + ms[prevIndex][j-1].score;
-                                       
-                                       //you are not at yourself
-                                       if (prevIndex != i) {   sumScore += penalty;    }
-                                       if (sumScore < 0)       {       sumScore = 0;                   }
-                                       
-                                       if (sumScore > ms[i][j].score) {
-                                               ms[i][j].score = sumScore;
-                                               ms[i][j].prev = prevIndex;
-                                       }
-                               }
-//                             cout << i << '\t' << j << '\t' << queryAligned[j] << '\t' << subjectAligned[j] << '\t' << matchMisMatchScore << '\t' << ms[i][j].score << endl;
-
-                       }
-                       
-               }
-               
-               
-               
-               
-               
-//             cout << numRows << '\t' << numCols << endl;
-//             for(int i=0;i<numRows;i++){
-//                     cout << seqs[i]->getName();
-//                     for(int j=0;j<numCols;j++){
-//                             cout << '\t' << ms[i][j].score;
-//                     }
-//                     cout << endl;
-//             }
-//             cout << endl;
-//             
-//             for(int i=0;i<numRows;i++){
-//                     cout << seqs[i]->getName();
-//                     for(int j=0;j<numCols;j++){
-//                             cout << '\t' << ms[i][j].prev;
-//                     }
-//                     cout << endl;
-//             }
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "fillScoreMatrix");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<score_struct> Maligner::extractHighestPath(vector<vector<score_struct> > ms) {
-       try {
-               
-               //get matrix dimensions
-               int numCols = query.getAligned().length();
-               int numRows = ms.size();
-               
-               
-               //find highest score scoring matrix
-               score_struct highestStruct;
-               int highestScore = 0;
-               
-               for (int i = 0; i < numRows; i++) {
-                       for (int j = 0; j < numCols; j++) {
-                               if (ms[i][j].score > highestScore) {
-                                       highestScore = ms[i][j].score;
-                                       highestStruct = ms[i][j];
-                               }
-                       }
-               }
-               
-               vector<score_struct> path;
-               
-               int rowIndex = highestStruct.row;
-               int pos = highestStruct.col;
-               int score = highestStruct.score;
-
-//             cout << rowIndex << '\t' << pos << '\t' << score << endl;
-               
-               while (pos >= 0 && score > 0) {
-                       score_struct temp = ms[rowIndex][pos];
-                       score = temp.score;
-                       
-                       if (score > 0) {        path.push_back(temp);   }
-                       
-                       rowIndex = temp.prev;
-                       pos--;
-               }
-               
-               reverse(path.begin(), path.end());
-               
-               return path;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "extractHighestPath");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector<trace_struct> Maligner::mapTraceRegionsToAlignment(vector<score_struct> path) {
-       try {
-               vector<trace_struct> trace;
-               
-               int region_index = path[0].row;
-               int region_start = path[0].col;
-               
-               for (int i = 1; i < path.size(); i++) {
-                       
-                       int next_region_index = path[i].row;
-                       //cout << i << '\t' << next_region_index << endl;
-
-                       if (next_region_index != region_index) {
-                               
-                               // add trace region
-                               int col_index = path[i].col;
-                               trace_struct temp;
-                               temp.col = region_start;
-                               temp.oldCol = col_index-1;
-                               temp.row = region_index;
-                               
-                               trace.push_back(temp);
-                               
-                               region_index = path[i].row;
-                               region_start = col_index;
-                       }
-               }
-               
-               // get last one
-               trace_struct temp;
-               temp.col = region_start;
-               temp.oldCol = path[path.size()-1].col;
-               temp.row = region_index;
-               trace.push_back(temp);
-               
-               return trace;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "mapTraceRegionsToAlignment");
-               exit(1);
-       }
-}
-
-/***************************************************************************************************************
-
-vector<trace_struct> Maligner::extractHighestPath(vector<vector<score_struct> > ms) {
-       try {
-       
-               
-               //get matrix dimensions
-               int numCols = query->getAligned().length();
-               int numRows = ms.size();
-       
-       
-               //find highest score scoring matrix
-               vector<score_struct> highestStruct;
-               int highestScore = 0;
-               
-               for (int i = 0; i < numRows; i++) {
-                       for (int j = 0; j < numCols; j++) {
-                               if (ms[i][j].score > highestScore) {
-                                       highestScore = ms[i][j].score;
-                                       highestStruct.resize(0);
-                                       highestStruct.push_back(ms[i][j]);
-                               }
-                               else if(ms[i][j].score == highestScore){
-                                       highestStruct.push_back(ms[i][j]);
-                               }
-                       }
-               }
-                       
-               //cout << endl << highestScore << '\t' << highestStruct.size() << '\t' << highestStruct[0].row << endl; 
-               
-               vector<trace_struct> maxTrace;
-               double maxPercentIdenticalQueryAntiChimera = 0;
-               
-               for(int i=0;i<highestStruct.size();i++){
-                       
-                       vector<score_struct> path;
-
-                       int rowIndex = highestStruct[i].row;
-                       int pos = highestStruct[i].col;
-                       int score = highestStruct[i].score;
-                                       
-                       while (pos >= 0 && score > 0) {
-                               score_struct temp = ms[rowIndex][pos];
-                               score = temp.score;
-                               
-                               if (score > 0) {        path.push_back(temp);   }
-                               
-                               rowIndex = temp.prev;
-                               pos--;
-                       }
-
-                       reverse(path.begin(), path.end());
-
-                       vector<trace_struct> trace = mapTraceRegionsToAlignment(path, refSeqs);
-               
-                       //cout << "traces\n";
-                       //for(int j=0;j<trace.size();j++){
-                       //      cout << trace[j].col << '\t' << trace[j].oldCol << '\t' << refSeqs[trace[j].row]->getName() << endl;
-                       //}
-                                               
-                       int traceStart = path[0].col;
-                       int traceEnd = path[path.size()-1].col; 
-//                     cout << "traceStart/End\t" << traceStart << '\t' << traceEnd << endl;
-                       
-                       string queryInRange = query->getAligned();
-                       queryInRange = queryInRange.substr(traceStart, (traceEnd-traceStart+1));
-//                     cout << "here" << endl;
-                       string chimeraSeq = constructChimericSeq(trace, refSeqs);
-                       string antiChimeraSeq = constructAntiChimericSeq(trace, refSeqs);
-               
-                       percentIdenticalQueryChimera = computePercentID(queryInRange, chimeraSeq);                      
-                       double percentIdenticalQueryAntiChimera = computePercentID(queryInRange, antiChimeraSeq);
-//                     cout << i << '\t' << percentIdenticalQueryChimera << '\t' << percentIdenticalQueryAntiChimera << endl;
-                       
-                       if(percentIdenticalQueryAntiChimera > maxPercentIdenticalQueryAntiChimera){
-                               maxPercentIdenticalQueryAntiChimera = percentIdenticalQueryAntiChimera;
-                               maxTrace = trace;
-                       }
-               }
-//             cout << maxPercentIdenticalQueryAntiChimera << endl;
-               return maxTrace;
-       
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "extractHighestPath");
-               exit(1);
-       }
-}
-
-***************************************************************************************************************
-
-vector<trace_struct> Maligner::mapTraceRegionsToAlignment(vector<score_struct> path, vector<Sequence*> seqs) {
-       try {
-               vector<trace_struct> trace;
-               
-               int region_index = path[0].row;
-               int region_start = path[0].col;
-       
-               for (int i = 1; i < path.size(); i++) {
-               
-                       int next_region_index = path[i].row;
-                       
-                       if (next_region_index != region_index) {
-                               
-                               // add trace region
-                               int col_index = path[i].col;
-                               trace_struct temp;
-                               temp.col = region_start;
-                               temp.oldCol = col_index-1;
-                               temp.row = region_index;
-                               
-                               trace.push_back(temp);
-                                                       
-                               region_index = path[i].row;
-                               region_start = col_index;
-                       }
-               }
-       
-               // get last one
-               trace_struct temp;
-               temp.col = region_start;
-               temp.oldCol = path[path.size()-1].col;
-               temp.row = region_index;
-               trace.push_back(temp);
-
-//             cout << endl;
-//             cout << trace.size() << endl;
-//             for(int i=0;i<trace.size();i++){
-//                     cout << seqs[trace[i].row]->getName() << endl;
-//             }
-//             cout << endl;
-               
-               return trace;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "mapTraceRegionsToAlignment");
-               exit(1);
-       }
-}
-*/
-//***************************************************************************************************************
-
-string Maligner::constructChimericSeq(vector<trace_struct> trace, vector<Sequence> seqs) {
-       try {
-               string chimera = "";
-               
-               for (int i = 0; i < trace.size(); i++) {
-//                     cout << i << '\t' << trace[i].row << '\t' << trace[i].col << '\t' << trace[i].oldCol << endl;
-                       
-                       string seqAlign = seqs[trace[i].row].getAligned();
-                       seqAlign = seqAlign.substr(trace[i].col, (trace[i].oldCol-trace[i].col+1));
-                       chimera += seqAlign;
-               }
-//             cout << chimera << endl;
-//             if (chimera != "") { chimera = chimera.substr(0, (chimera.length()-1)); }       //this was introducing a fence post error
-//             cout << chimera << endl;
-               return chimera;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "constructChimericSeq");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-string Maligner::constructAntiChimericSeq(vector<trace_struct> trace, vector<Sequence> seqs) {
-       try {
-               string antiChimera = "";
-               
-               for (int i = 0; i < trace.size(); i++) {
-//                     cout << i << '\t' << (trace.size() - i - 1) << '\t' << trace[i].row << '\t' << trace[i].col << '\t' << trace[i].oldCol << endl;
-                       
-                       int oppositeIndex = trace.size() - i - 1;
-                       
-                       string seqAlign = seqs[trace[oppositeIndex].row].getAligned();
-                       seqAlign = seqAlign.substr(trace[i].col, (trace[i].oldCol-trace[i].col+1));
-                       antiChimera += seqAlign;
-               }
-               
-               return antiChimera;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "constructChimericSeq");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-float Maligner::computePercentID(string queryAlign, string chimera) {
-       try {
-       
-               if (queryAlign.length() != chimera.length()) {
-                       m->mothurOut("Error, alignment strings are of different lengths: "); m->mothurOutEndLine();
-                       m->mothurOut(toString(queryAlign.length())); m->mothurOutEndLine(); 
-                       m->mothurOut(toString(chimera.length())); m->mothurOutEndLine();
-                       return -1.0;
-               }
-
-//             cout << queryAlign.length() << endl;
-               int numIdentical = 0;
-               int countA = 0;
-               int countB = 0;
-               for (int i = 0; i < queryAlign.length(); i++) {
-                       if (((queryAlign[i] != 'G') && (queryAlign[i] != 'T') && (queryAlign[i] != 'A') && (queryAlign[i] != 'C')&& (queryAlign[i] != '.') && (queryAlign[i] != '-')) ||
-                               ((chimera[i] != 'G') && (chimera[i] != 'T') && (chimera[i] != 'A') && (chimera[i] != 'C')&& (chimera[i] != '.') && (chimera[i] != '-'))) {}
-                       else {
-
-                               bool charA = false; bool charB = false;
-                               if ((queryAlign[i] == 'G') || (queryAlign[i] == 'T') || (queryAlign[i] == 'A') || (queryAlign[i] == 'C')) { charA = true; }
-                               if ((chimera[i] == 'G') || (chimera[i] == 'T') || (chimera[i] == 'A') || (chimera[i] == 'C')) { charB = true; }
-                                       
-                               
-                               if (charA || charB) {
-                                               
-                                       if (charA) { countA++; }
-                                       if (charB) { countB++; }
-                                               
-                                       if (queryAlign[i] == chimera[i]) {
-                                               numIdentical++;
-                                       }
-                               }
-//                             cout << queryAlign[i] << '\t' << chimera[i] << '\t' << countA << '\t' << countB << endl;
-
-                       }
-               }
-               
-//             cout << "pat\t" << countA << '\t' << countB << '\t' << numIdentical << endl;
-
-               
-               float numBases = (countA + countB) /(float) 2;
-               
-               if (numBases == 0) { return 0; }
-       
-//             cout << numIdentical << '\t' << numBases << endl;
-               
-               float percentIdentical = (numIdentical/(float)numBases) * 100;
-               
-//             cout << percentIdentical << endl;
-               
-               return percentIdentical;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Maligner", "computePercentID");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
diff --git a/maligner.h b/maligner.h
deleted file mode 100644 (file)
index fc00e99..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef MALIGNER_H
-#define MALIGNER_H
-/*
- *  maligner.h
- *  Mothur
- *
- *  Created by westcott on 9/23/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-#include "decalc.h"
-#include "chimera.h"
-#include "database.hpp"
-
-/***********************************************************************/
-//This class was modeled after the chimeraMaligner written by the Broad Institute
-/**********************************************************************/
-class Maligner {
-
-       public:
-               
-               Maligner(vector<Sequence>, int, int, float, int, int); //int, int, int, , string, Database*, Database*
-               ~Maligner() {};
-               
-               string getResults(Sequence, DeCalculator);
-               float getPercentID() {  return percentIdenticalQueryChimera;    }
-               vector<results> getOutput()  {  return outputResults;                   }
-               
-                               
-       private:
-               Sequence query;
-               vector<Sequence> refSeqs;
-               vector<Sequence> db;
-               int minCoverage, minSimilarity, matchScore, misMatchPenalty;
-               float minDivR, percentIdenticalQueryChimera;
-               vector<results> outputResults;
-               map<int, int> spotMap;
-               vector<int> unalignedMap;
-               vector<Sequence> minCoverageFilter(vector<Sequence>);  //removes top matches that do not have minimum coverage with query.
-               int computeChimeraPenalty();
-               vector<Sequence> verticalFilter(vector<Sequence>);
-               
-               vector< vector<score_struct> > buildScoreMatrix(int, int);
-               void fillScoreMatrix(vector<vector<score_struct> >&, vector<Sequence>, int);
-               vector<score_struct> extractHighestPath(vector<vector<score_struct> >);
-               vector<trace_struct> mapTraceRegionsToAlignment(vector<score_struct>);
-               string constructChimericSeq(vector<trace_struct>, vector<Sequence>);
-               string constructAntiChimericSeq(vector<trace_struct>, vector<Sequence>);
-               float computePercentID(string, string);
-               string chimeraMaligner(int, DeCalculator);
-               MothurOut* m;
-               
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/manhattan.cpp b/manhattan.cpp
deleted file mode 100644 (file)
index 134dd91..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *  manhattan.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "manhattan.h"
-
-/***********************************************************************/
-EstOutput Manhattan::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sum = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       sum += abs((Aij - Bij));
-               }
-               
-               data[0] = sum;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Manhattan", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/manhattan.h b/manhattan.h
deleted file mode 100644 (file)
index 91d73a8..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef MANHATTAN_H
-#define MANHATTAN_H
-
-/*
- *  manhattan.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Manhattan : public Calculator  {
-       
-public:
-       Manhattan() :  Calculator("manhattan", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Manhattan"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/mantelcommand.cpp b/mantelcommand.cpp
deleted file mode 100644 (file)
index 409eae4..0000000
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- *  mantelcommand.cpp
- *  mothur
- *
- *  Created by westcott on 2/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mantelcommand.h"
-#include "readphylipvector.h"
-
-
-//**********************************************************************************************************************
-vector<string> MantelCommand::setParameters(){ 
-       try {
-               CommandParameter pphylip1("phylip1", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip1);
-               CommandParameter pphylip2("phylip2", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip2);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MantelCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "Sokal, R. R., & Rohlf, F. J. (1995). Biometry, 3rd edn. New York: Freeman.\n";
-               helpString += "The mantel command reads two distance matrices and calculates the mantel correlation coefficient.\n";
-               helpString += "The mantel command parameters are phylip1, phylip2, iters and method.  The phylip1 and phylip2 parameters are required.  Matrices must be the same size and contain the same names.\n";
-               helpString += "The method parameter allows you to select what method you would like to use. Options are pearson, spearman and kendall. Default=pearson.\n";
-               helpString += "The iters parameter allows you to set number of randomization for the P value.  The default is 1000. \n";
-               helpString += "The mantel command should be in the following format: mantel(phylip1=veg.dist, phylip2=env.dist).\n";
-               helpString += "The mantel command outputs a .mantel file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. phylip1), '=' and parameters (i.e. veg.dist).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MantelCommand::MantelCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["mantel"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "MantelCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MantelCommand::MantelCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["mantel"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip1");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip1"] = inputDir + it->second;          }
-                               }
-                               
-                               it = parameters.find("phylip2");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip2"] = inputDir + it->second;          }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       phylipfile1 = validParameter.validFile(parameters, "phylip1", true);
-                       if (phylipfile1 == "not open") { phylipfile1 = ""; abort = true; }
-                       else if (phylipfile1 == "not found") { phylipfile1 = ""; m->mothurOut("phylip1 is a required parameter for the mantel command."); m->mothurOutEndLine(); abort = true;  }       
-                       
-                       phylipfile2 = validParameter.validFile(parameters, "phylip2", true);
-                       if (phylipfile2 == "not open") { phylipfile2 = ""; abort = true; }
-                       else if (phylipfile2 == "not found") { phylipfile2 = ""; m->mothurOut("phylip2 is a required parameter for the mantel command."); m->mothurOutEndLine(); abort = true;  }       
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(phylipfile1);    }
-                       
-                       method = validParameter.validFile(parameters, "method", false);         if (method == "not found"){     method = "pearson";             }
-                       
-                       string temp = validParameter.validFile(parameters, "iters", false);                     if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters);
-                       
-                       if ((method != "pearson") && (method != "spearman") && (method != "kendall")) { m->mothurOut(method + " is not a valid method. Valid methods are pearson, spearman, and kendall."); m->mothurOutEndLine(); abort = true; }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "MantelCommand");               
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MantelCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               /***************************************************/
-               //    reading distance files                                       //
-               /***************************************************/
-               
-               //read phylip1
-               ReadPhylipVector readMatrix(phylipfile1);
-               vector< vector<double> > matrix1;
-               vector<string> names1 = readMatrix.read(matrix1);
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read phylip2
-               ReadPhylipVector readMatrix2(phylipfile2);
-               vector< vector<double> > matrix2;
-               vector<string> names2 = readMatrix2.read(matrix2);
-               
-               if (m->control_pressed) { return 0; }
-               
-               //make sure matrix2 and matrix1 are in the same order
-               if (names1 == names2) { //then everything is in same order and same size
-               }else if (names1.size() != names2.size()) { //wrong size no need to order, abort
-                       m->mothurOut("[ERROR]: distance matrices are not the same size, aborting."); m->mothurOutEndLine();
-                       m->control_pressed = true;
-               }else { //sizes are the same, but either the names are different or they are in different order
-                       m->mothurOut("[WARNING]: Names do not match between distance files. Comparing based on order in files."); m->mothurOutEndLine();
-               }       
-               
-               if (m->control_pressed) { return 0; }
-               
-               /***************************************************/
-               //    calculating mantel and signifigance                  //
-               /***************************************************/
-               
-               //calc mantel coefficient
-               LinearAlgebra linear;
-               double mantel = 0.0;
-               if (method == "pearson")                {  mantel = linear.calcPearson(matrix1, matrix2);       }
-               else if (method == "spearman")  {  mantel = linear.calcSpearman(matrix1, matrix2);      }
-               else if (method == "kendall")   {  mantel = linear.calcKendall(matrix1, matrix2);       }
-               
-               
-               //calc signifigance
-               int count = 0;
-               for (int i = 0; i < iters; i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //randomize matrix2
-                       vector< vector<double> > matrix2Copy = matrix2;
-                       random_shuffle(matrix2Copy.begin(), matrix2Copy.end());
-               
-                       //calc random mantel
-                       double randomMantel = 0.0;
-                       if (method == "pearson")                {  randomMantel = linear.calcPearson(matrix1, matrix2Copy);     }
-                       else if (method == "spearman")  {  randomMantel = linear.calcSpearman(matrix1, matrix2Copy);    }
-                       else if (method == "kendall")   {  randomMantel = linear.calcKendall(matrix1, matrix2Copy);     }
-                       
-                       if (randomMantel >= mantel) { count++; }
-               }
-               
-               double pValue = count / (float) iters;
-               
-               if (m->control_pressed) { return 0; }
-               
-               string outputFile = outputDir + m->getRootName(m->getSimpleName(phylipfile1)) + "mantel";
-               outputNames.push_back(outputFile); outputTypes["mantel"].push_back(outputFile);
-               ofstream out;
-               
-               m->openOutputFile(outputFile, out);
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               
-               out << "Mantel\tpValue" << endl;
-               out << mantel << '\t' << pValue << endl;
-               
-               out.close();
-       
-               cout << "\nmantel = " << mantel << "\tpValue = " << pValue << endl;
-               m->mothurOutJustToLog("\nmantel = " + toString(mantel) + "\tpValue = " + toString(pValue) + "\n"); 
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();          
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MantelCommand", "execute");     
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/mantelcommand.h b/mantelcommand.h
deleted file mode 100644 (file)
index 0a2c404..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef MANTELCOMMAND_H
-#define MANTELCOMMAND_H
-
-/*
- *  mantelcommand.h
- *  mothur
- *
- *  Created by westcott on 2/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "linearalgebra.h"
-
-class MantelCommand : public Command {
-public:
-       MantelCommand(string);
-       MantelCommand();
-       ~MantelCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "mantel";                                      }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Mantel"; }
-       string getDescription()         { return "Mantel’s test for correlation between matrices"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       
-       string phylipfile1, phylipfile2, outputDir, method;
-       bool abort;
-       int iters;
-       
-       vector<string> outputNames;
-};
-
-
-#endif
-
-
-
diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp
deleted file mode 100644 (file)
index c879d1b..0000000
+++ /dev/null
@@ -1,814 +0,0 @@
-/*
- *  matrixoutputcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "matrixoutputcommand.h"
-#include "subsample.h"
-
-//**********************************************************************************************************************
-vector<string> MatrixOutputCommand::setParameters(){   
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MatrixOutputCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The dist.shared command parameters are shared, groups, calc, output, processors, subsample, iters and label.  shared is a required, unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n";
-               helpString += "The group names are separated by dashes. The label parameter allows you to select what distance levels you would like distance matrices created for, and is also separated by dashes.\n";
-        helpString += "The iters parameter allows you to choose the number of times you would like to run the subsample.\n";
-        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group.\n";
-               helpString += "The dist.shared command should be in the following format: dist.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n";
-               helpString += "The output parameter allows you to specify format of your distance matrix. Options are lt, and square. The default is lt.\n";
-               helpString += "Example dist.shared(groups=A-B-C, calc=jabund-sorabund).\n";
-               helpString += "The default value for groups is all the groups in your groupfile.\n";
-               helpString += "The default value for calc is jclass and thetayc.\n";
-               helpString += validCalculator.printCalc("matrix");
-               helpString += "The dist.shared command outputs a .dist file for each calculator you specify at each distance you choose.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MatrixOutputCommand::MatrixOutputCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["phylip"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-MatrixOutputCommand::MatrixOutputCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters  = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["phylip"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not found") {                        
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else if (sharedfile == "not open") { sharedfile = ""; abort = true; }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(sharedfile); //if user entered a file with a path then preserve it      
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       output = validParameter.validFile(parameters, "output", false);         if(output == "not found"){      output = "lt"; }
-                       if ((output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are lt and square. I will use lt."); m->mothurOutEndLine(); output = "lt"; }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "jclass-thetayc";  }
-                       else { 
-                                if (calc == "default")  {  calc = "jclass-thetayc";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-            
-            temp = validParameter.validFile(parameters, "iters", false);                       if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-            
-            temp = validParameter.validFile(parameters, "subsample", false);           if (temp == "not found") { temp = "F"; }
-                       if (m->isNumeric1(temp)) { m->mothurConvert(temp, subsampleSize); subsample = true; }
-            else {  
-                if (m->isTrue(temp)) { subsample = true; subsampleSize = -1; }  //we will set it to smallest group later 
-                else { subsample = false; }
-            }
-            
-            if (subsample == false) { iters = 1; }
-            
-                       if (abort == false) {
-                       
-                               ValidCalculators validCalculator;
-                               
-                               int i;
-                               for (i=0; i<Estimators.size(); i++) {
-                                       if (validCalculator.isValidCalculator("matrix", Estimators[i]) == true) { 
-                                               if (Estimators[i] == "sharedsobs") { 
-                                                       matrixCalculators.push_back(new SharedSobsCS());
-                                               }else if (Estimators[i] == "sharedchao") { 
-                                                       matrixCalculators.push_back(new SharedChao1());
-                                               }else if (Estimators[i] == "sharedace") { 
-                                                       matrixCalculators.push_back(new SharedAce());
-                                               }else if (Estimators[i] == "jabund") {  
-                                                       matrixCalculators.push_back(new JAbund());
-                                               }else if (Estimators[i] == "sorabund") { 
-                                                       matrixCalculators.push_back(new SorAbund());
-                                               }else if (Estimators[i] == "jclass") { 
-                                                       matrixCalculators.push_back(new Jclass());
-                                               }else if (Estimators[i] == "sorclass") { 
-                                                       matrixCalculators.push_back(new SorClass());
-                                               }else if (Estimators[i] == "jest") { 
-                                                       matrixCalculators.push_back(new Jest());
-                                               }else if (Estimators[i] == "sorest") { 
-                                                       matrixCalculators.push_back(new SorEst());
-                                               }else if (Estimators[i] == "thetayc") { 
-                                                       matrixCalculators.push_back(new ThetaYC());
-                                               }else if (Estimators[i] == "thetan") { 
-                                                       matrixCalculators.push_back(new ThetaN());
-                                               }else if (Estimators[i] == "kstest") { 
-                                                       matrixCalculators.push_back(new KSTest());
-                                               }else if (Estimators[i] == "sharednseqs") { 
-                                                       matrixCalculators.push_back(new SharedNSeqs());
-                                               }else if (Estimators[i] == "ochiai") { 
-                                                       matrixCalculators.push_back(new Ochiai());
-                                               }else if (Estimators[i] == "anderberg") { 
-                                                       matrixCalculators.push_back(new Anderberg());
-                                               }else if (Estimators[i] == "kulczynski") { 
-                                                       matrixCalculators.push_back(new Kulczynski());
-                                               }else if (Estimators[i] == "kulczynskicody") { 
-                                                       matrixCalculators.push_back(new KulczynskiCody());
-                                               }else if (Estimators[i] == "lennon") { 
-                                                       matrixCalculators.push_back(new Lennon());
-                                               }else if (Estimators[i] == "morisitahorn") { 
-                                                       matrixCalculators.push_back(new MorHorn());
-                                               }else if (Estimators[i] == "braycurtis") { 
-                                                       matrixCalculators.push_back(new BrayCurtis());
-                                               }else if (Estimators[i] == "whittaker") { 
-                                                       matrixCalculators.push_back(new Whittaker());
-                                               }else if (Estimators[i] == "odum") { 
-                                                       matrixCalculators.push_back(new Odum());
-                                               }else if (Estimators[i] == "canberra") { 
-                                                       matrixCalculators.push_back(new Canberra());
-                                               }else if (Estimators[i] == "structeuclidean") { 
-                                                       matrixCalculators.push_back(new StructEuclidean());
-                                               }else if (Estimators[i] == "structchord") { 
-                                                       matrixCalculators.push_back(new StructChord());
-                                               }else if (Estimators[i] == "hellinger") { 
-                                                       matrixCalculators.push_back(new Hellinger());
-                                               }else if (Estimators[i] == "manhattan") { 
-                                                       matrixCalculators.push_back(new Manhattan());
-                                               }else if (Estimators[i] == "structpearson") { 
-                                                       matrixCalculators.push_back(new StructPearson());
-                                               }else if (Estimators[i] == "soergel") { 
-                                                       matrixCalculators.push_back(new Soergel());
-                                               }else if (Estimators[i] == "spearman") { 
-                                                       matrixCalculators.push_back(new Spearman());
-                                               }else if (Estimators[i] == "structkulczynski") { 
-                                                       matrixCalculators.push_back(new StructKulczynski());
-                                               }else if (Estimators[i] == "speciesprofile") { 
-                                                       matrixCalculators.push_back(new SpeciesProfile());
-                                               }else if (Estimators[i] == "hamming") { 
-                                                       matrixCalculators.push_back(new Hamming());
-                                               }else if (Estimators[i] == "structchi2") { 
-                                                       matrixCalculators.push_back(new StructChi2());
-                                               }else if (Estimators[i] == "gower") { 
-                                                       matrixCalculators.push_back(new Gower());
-                                               }else if (Estimators[i] == "memchi2") { 
-                                                       matrixCalculators.push_back(new MemChi2());
-                                               }else if (Estimators[i] == "memchord") { 
-                                                       matrixCalculators.push_back(new MemChord());
-                                               }else if (Estimators[i] == "memeuclidean") { 
-                                                       matrixCalculators.push_back(new MemEuclidean());
-                                               }else if (Estimators[i] == "mempearson") { 
-                                                       matrixCalculators.push_back(new MemPearson());
-                                               }
-                                       }
-                               }
-                               
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "MatrixOutputCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-MatrixOutputCommand::~MatrixOutputCommand(){}
-
-//**********************************************************************************************************************
-
-int MatrixOutputCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-                       
-               //if the users entered no valid calculators don't execute command
-               if (matrixCalculators.size() == 0) { m->mothurOut("No valid calculators."); m->mothurOutEndLine();  return 0; }
-                       
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-                                       
-               if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); delete input; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } return 0;}
-        
-        if (subsample) { 
-            if (subsampleSize == -1) { //user has not set size, set size = smallest samples size
-                subsampleSize = lookup[0]->getNumSeqs();
-                for (int i = 1; i < lookup.size(); i++) {
-                    int thisSize = lookup[i]->getNumSeqs();
-                    
-                    if (thisSize < subsampleSize) {    subsampleSize = thisSize;       }
-                }
-            }else {
-                m->clearGroups();
-                Groups.clear();
-                vector<SharedRAbundVector*> temp;
-                for (int i = 0; i < lookup.size(); i++) {
-                    if (lookup[i]->getNumSeqs() < subsampleSize) { 
-                        m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
-                        delete lookup[i];
-                    }else { 
-                        Groups.push_back(lookup[i]->getGroup()); 
-                        temp.push_back(lookup[i]);
-                    }
-                } 
-                lookup = temp;
-                m->setGroups(Groups);
-            }
-            
-            if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); m->control_pressed = true; delete input; return 0; }
-        }
-        
-               numGroups = lookup.size();
-        lines.resize(processors);
-               for (int i = 0; i < processors; i++) {
-                       lines[i].start = int (sqrt(float(i)/float(processors)) * numGroups);
-                       lines[i].end = int (sqrt(float(i+1)/float(processors)) * numGroups);
-               }       
-        
-               if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups(); return 0;  }
-                               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-               
-                       if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0;  }
-               
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       //get next line to process
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0;  }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it);  
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) { outputTypes.clear(); delete input;  for (int i = 0; i < outputNames.size(); i++) {    m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0;  }
-
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {  delete lookup[i]; }  } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       process(lookup);
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               }
-               
-               if (m->control_pressed) { outputTypes.clear();  delete input;  for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0;  }
-               
-               //reset groups parameter
-               m->clearGroups();  
-               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("phylip");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "execute");
-               exit(1);
-       }
-}
-/***********************************************************/
-void MatrixOutputCommand::printSims(ostream& out, vector< vector<double> >& simMatrix) {
-       try {
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               //output num seqs
-               out << simMatrix.size() << endl;
-               
-               if (output == "lt") {
-                       for (int m = 0; m < simMatrix.size(); m++)      {
-                               out << lookup[m]->getGroup() << '\t';
-                               for (int n = 0; n < m; n++)     {
-                                       out << simMatrix[m][n] << '\t'; 
-                               }
-                               out << endl;
-                       }
-               }else{
-                       for (int m = 0; m < simMatrix.size(); m++)      {
-                               out << lookup[m]->getGroup() << '\t';
-                               for (int n = 0; n < simMatrix[m].size(); n++)   {
-                                       out << simMatrix[m][n] << '\t'; 
-                               }
-                               out << endl;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "printSims");
-               exit(1);
-       }
-}
-/***********************************************************/
-int MatrixOutputCommand::process(vector<SharedRAbundVector*> thisLookup){
-       try {
-               vector< vector< vector<seqDist> > > calcDistsTotals;  //each iter, one for each calc, then each groupCombos dists. this will be used to make .dist files
-        vector< vector<seqDist>  > calcDists; calcDists.resize(matrixCalculators.size());              
-
-        for (int thisIter = 0; thisIter < iters; thisIter++) {
-            
-            vector<SharedRAbundVector*> thisItersLookup = thisLookup;
-            
-            if (subsample) {
-                SubSample sample;
-                vector<string> tempLabels; //dont need since we arent printing the sampled sharedRabunds
-                
-                //make copy of lookup so we don't get access violations
-                vector<SharedRAbundVector*> newLookup;
-                for (int k = 0; k < thisItersLookup.size(); k++) {
-                    SharedRAbundVector* temp = new SharedRAbundVector();
-                    temp->setLabel(thisItersLookup[k]->getLabel());
-                    temp->setGroup(thisItersLookup[k]->getGroup());
-                    newLookup.push_back(temp);
-                }
-                
-                //for each bin
-                for (int k = 0; k < thisItersLookup[0]->getNumBins(); k++) {
-                    if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                    for (int j = 0; j < thisItersLookup.size(); j++) { newLookup[j]->push_back(thisItersLookup[j]->getAbundance(k), thisItersLookup[j]->getGroup()); }
-                }
-                
-                tempLabels = sample.getSample(newLookup, subsampleSize);
-                thisItersLookup = newLookup;
-            }
-        
-            if(processors == 1){
-                driver(thisItersLookup, 0, numGroups, calcDists);
-            }else{
-                int process = 1;
-                vector<int> processIDS;
-                
-                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                //loop through and create all the processes you want
-                while (process != processors) {
-                    int pid = fork();
-                    
-                    if (pid > 0) {
-                        processIDS.push_back(pid); 
-                        process++;
-                    }else if (pid == 0){
-                        
-                        driver(thisItersLookup, lines[process].start, lines[process].end, calcDists);   
-                        
-                        string tempdistFileName = m->getRootName(m->getSimpleName(sharedfile)) + toString(getpid()) + ".dist";
-                        ofstream outtemp;
-                        m->openOutputFile(tempdistFileName, outtemp);
-                            
-                        for (int i = 0; i < calcDists.size(); i++) {
-                            outtemp << calcDists[i].size() << endl;
-                                
-                            for (int j = 0; j < calcDists[i].size(); j++) {
-                                outtemp << calcDists[i][j].seq1 << '\t' << calcDists[i][j].seq2 << '\t' << calcDists[i][j].dist << endl;
-                            }
-                        }
-                        outtemp.close();
-                                        
-                        exit(0);
-                    }else { 
-                        m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                        for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                        exit(0);
-                    }
-                }
-                
-                //parent do your part
-                driver(thisItersLookup, lines[0].start, lines[0].end, calcDists);   
-                            
-                //force parent to wait until all the processes are done
-                for (int i = 0; i < processIDS.size(); i++) {
-                    int temp = processIDS[i];
-                    wait(&temp);
-                }
-                
-                for (int i = 0; i < processIDS.size(); i++) {
-                    string tempdistFileName = m->getRootName(m->getSimpleName(sharedfile)) + toString(processIDS[i]) +  ".dist";
-                    ifstream intemp;
-                    m->openInputFile(tempdistFileName, intemp);
-                        
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = 0;
-                        intemp >> size; m->gobble(intemp);
-                            
-                        for (int j = 0; j < size; j++) {
-                            int seq1 = 0;
-                            int seq2 = 0;
-                            float dist = 1.0;
-                                
-                            intemp >> seq1 >> seq2 >> dist;   m->gobble(intemp);
-                                
-                            seqDist tempDist(seq1, seq2, dist);
-                            calcDists[k].push_back(tempDist);
-                        }
-                    }
-                    intemp.close();
-                    m->mothurRemove(tempdistFileName);
-                }
-                #else
-                //////////////////////////////////////////////////////////////////////////////////////////////////////
-                //Windows version shared memory, so be careful when passing variables through the distSharedData struct. 
-                //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-                //Taking advantage of shared memory to pass results vectors.
-                //////////////////////////////////////////////////////////////////////////////////////////////////////
-                
-                vector<distSharedData*> pDataArray; 
-                DWORD   dwThreadIdArray[processors-1];
-                HANDLE  hThreadArray[processors-1]; 
-                
-                //Create processor worker threads.
-                for( int i=1; i<processors; i++ ){
-                    
-                    //make copy of lookup so we don't get access violations
-                    vector<SharedRAbundVector*> newLookup;
-                    for (int k = 0; k < thisItersLookup.size(); k++) {
-                        SharedRAbundVector* temp = new SharedRAbundVector();
-                        temp->setLabel(thisItersLookup[k]->getLabel());
-                        temp->setGroup(thisItersLookup[k]->getGroup());
-                        newLookup.push_back(temp);
-                    }
-                    
-                    //for each bin
-                    for (int k = 0; k < thisItersLookup[0]->getNumBins(); k++) {
-                        if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                        for (int j = 0; j < thisItersLookup.size(); j++) { newLookup[j]->push_back(thisItersLookup[j]->getAbundance(k), thisItersLookup[j]->getGroup()); }
-                    }
-                    
-                    // Allocate memory for thread data.
-                    distSharedData* tempSum = new distSharedData(m, lines[i].start, lines[i].end, Estimators, newLookup);
-                    pDataArray.push_back(tempSum);
-                    processIDS.push_back(i);
-                    
-                    hThreadArray[i-1] = CreateThread(NULL, 0, MyDistSharedThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-                }
-                
-                //parent do your part
-                driver(thisItersLookup, lines[0].start, lines[0].end, calcDists);   
-                           
-                //Wait until all threads have terminated.
-                WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-                
-                //Close all thread handles and free memory allocations.
-                for(int i=0; i < pDataArray.size(); i++){
-                    for (int j = 0; j < pDataArray[i]->thisLookup.size(); j++) {  delete pDataArray[i]->thisLookup[j];  } 
-                    
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = pDataArray[i]->calcDists[k].size();
-                        for (int j = 0; j < size; j++) {    calcDists[k].push_back(pDataArray[i]->calcDists[k][j]);    }
-                    }
-                    
-                    CloseHandle(hThreadArray[i]);
-                    delete pDataArray[i];
-                }
-
-                #endif
-            }
-            
-            calcDistsTotals.push_back(calcDists);
-            
-            if (subsample) {  
-                
-                //clean up memory
-                for (int i = 0; i < thisItersLookup.size(); i++) { delete thisItersLookup[i]; }
-                thisItersLookup.clear();
-                for (int i = 0; i < calcDists.size(); i++) {  calcDists[i].clear(); }
-            }
-               }
-               
-        if (iters != 1) {
-            //we need to find the average distance and standard deviation for each groups distance
-            
-            vector< vector<seqDist>  > calcAverages; calcAverages.resize(matrixCalculators.size()); 
-            for (int i = 0; i < calcAverages.size(); i++) {  //initialize sums to zero.
-                calcAverages[i].resize(calcDistsTotals[0][i].size());
-                
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    calcAverages[i][j].seq1 = calcDists[i][j].seq1;
-                    calcAverages[i][j].seq2 = calcDists[i][j].seq2;
-                    calcAverages[i][j].dist = 0.0;
-                }
-            }
-            
-            for (int thisIter = 0; thisIter < iters; thisIter++) { //sum all groups dists for each calculator
-                for (int i = 0; i < calcAverages.size(); i++) {  //initialize sums to zero.
-                    for (int j = 0; j < calcAverages[i].size(); j++) {
-                        calcAverages[i][j].dist += calcDistsTotals[thisIter][i][j].dist;
-                    }
-                }
-            }
-            
-            for (int i = 0; i < calcAverages.size(); i++) {  //finds average.
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    calcAverages[i][j].dist /= (float) iters;
-                }
-            }
-            
-            //find standard deviation
-            vector< vector<seqDist>  > stdDev; stdDev.resize(matrixCalculators.size());
-            for (int i = 0; i < stdDev.size(); i++) {  //initialize sums to zero.
-                stdDev[i].resize(calcDistsTotals[0][i].size());
-                
-                for (int j = 0; j < stdDev[i].size(); j++) {
-                    stdDev[i][j].seq1 = calcDists[i][j].seq1;
-                    stdDev[i][j].seq2 = calcDists[i][j].seq2;
-                    stdDev[i][j].dist = 0.0;
-                }
-            }
-            
-            for (int thisIter = 0; thisIter < iters; thisIter++) { //compute the difference of each dist from the mean, and square the result of each
-                for (int i = 0; i < stdDev.size(); i++) {  
-                    for (int j = 0; j < stdDev[i].size(); j++) {
-                        stdDev[i][j].dist += ((calcDistsTotals[thisIter][i][j].dist - calcAverages[i][j].dist) * (calcDistsTotals[thisIter][i][j].dist - calcAverages[i][j].dist));
-                    }
-                }
-            }
-
-            for (int i = 0; i < stdDev.size(); i++) {  //finds average.
-                for (int j = 0; j < stdDev[i].size(); j++) {
-                    stdDev[i][j].dist /= (float) iters;
-                    stdDev[i][j].dist = sqrt(stdDev[i][j].dist);
-                }
-            }
-            
-            //print results
-            for (int i = 0; i < calcDists.size(); i++) {
-                vector< vector<double> > matrix; //square matrix to represent the distance
-                matrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                
-                vector< vector<double> > stdmatrix; //square matrix to represent the stdDev
-                stdmatrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  stdmatrix[k].resize(thisLookup.size(), 0.0); }
-
-            
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    int row = calcAverages[i][j].seq1;
-                    int column = calcAverages[i][j].seq2;
-                    float dist = calcAverages[i][j].dist;
-                    float stdDist = stdDev[i][j].dist;
-                    
-                    matrix[row][column] = dist;
-                    matrix[column][row] = dist;
-                    stdmatrix[row][column] = stdDist;
-                    stdmatrix[column][row] = stdDist;
-                }
-            
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".ave.dist";
-                outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
-                ofstream outAve;
-                m->openOutputFile(distFileName, outAve);
-                outAve.setf(ios::fixed, ios::floatfield); outAve.setf(ios::showpoint);
-                
-                printSims(outAve, matrix);
-                
-                outAve.close();
-                
-                distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".std.dist";
-                outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
-                ofstream outSTD;
-                m->openOutputFile(distFileName, outSTD);
-                outSTD.setf(ios::fixed, ios::floatfield); outSTD.setf(ios::showpoint);
-                
-                printSims(outSTD, stdmatrix);
-                
-                outSTD.close();
-
-            }
-        }else {
-        
-            for (int i = 0; i < calcDists.size(); i++) {
-                if (m->control_pressed) { break; }
-                
-                //initialize matrix
-                vector< vector<double> > matrix; //square matrix to represent the distance
-                matrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                
-                for (int j = 0; j < calcDists[i].size(); j++) {
-                    int row = calcDists[i][j].seq1;
-                    int column = calcDists[i][j].seq2;
-                    double dist = calcDists[i][j].dist;
-                    
-                    matrix[row][column] = dist;
-                    matrix[column][row] = dist;
-                }
-                
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + matrixCalculators[i]->getName() + "." + thisLookup[0]->getLabel()  + "." + output + ".dist";
-                outputNames.push_back(distFileName); outputTypes["phylip"].push_back(distFileName);
-                ofstream outDist;
-                m->openOutputFile(distFileName, outDist);
-                outDist.setf(ios::fixed, ios::floatfield); outDist.setf(ios::showpoint);
-                
-                printSims(outDist, matrix);
-                
-                outDist.close();
-            }
-        }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "process");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int MatrixOutputCommand::driver(vector<SharedRAbundVector*> thisLookup, int start, int end, vector< vector<seqDist> >& calcDists) { 
-       try {
-               vector<SharedRAbundVector*> subset;
-               for (int k = start; k < end; k++) { // pass cdd each set of groups to compare
-                       
-                       for (int l = 0; l < k; l++) {
-                               
-                               if (k != l) { //we dont need to similiarity of a groups to itself
-                                       subset.clear(); //clear out old pair of sharedrabunds
-                                       //add new pair of sharedrabunds
-                                       subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]); 
-                                       
-                                       for(int i=0;i<matrixCalculators.size();i++) {
-                                               
-                                               //if this calc needs all groups to calculate the pair load all groups
-                                               if (matrixCalculators[i]->getNeedsAll()) { 
-                                                       //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                       for (int w = 0; w < thisLookup.size(); w++) {
-                                                               if ((w != k) && (w != l)) { subset.push_back(thisLookup[w]); }
-                                                       }
-                                               }
-                                               
-                                               vector<double> tempdata = matrixCalculators[i]->getValues(subset); //saves the calculator outputs
-                                               
-                                               if (m->control_pressed) { return 1; }
-                                               
-                                               seqDist temp(l, k, tempdata[0]);
-                                               calcDists[i].push_back(temp);
-                                       }
-                               }
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MatrixOutputCommand", "driver");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
diff --git a/matrixoutputcommand.h b/matrixoutputcommand.h
deleted file mode 100644 (file)
index 8af539b..0000000
+++ /dev/null
@@ -1,273 +0,0 @@
-#ifndef MATRIXOUTPUTCOMMAND_H
-#define MATRIXOUTPUTCOMMAND_H
-
-/*
- *  matrixoutputcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */ 
-#include "command.hpp"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "validcalculator.h"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "sharednseqs.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedkstest.h"
-#include "whittaker.h"
-#include "sharedochiai.h"
-#include "sharedanderbergs.h"
-#include "sharedkulczynski.h"
-#include "sharedkulczynskicody.h"
-#include "sharedlennon.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-#include "sharedjackknife.h"
-#include "whittaker.h"
-#include "odum.h"
-#include "canberra.h"
-#include "structeuclidean.h"
-#include "structchord.h"
-#include "hellinger.h"
-#include "manhattan.h"
-#include "structpearson.h"
-#include "soergel.h"
-#include "spearman.h"
-#include "structkulczynski.h"
-#include "structchi2.h"
-#include "speciesprofile.h"
-#include "hamming.h"
-#include "gower.h"
-#include "memchi2.h"
-#include "memchord.h"
-#include "memeuclidean.h"
-#include "mempearson.h"
-
-
-// aka. dist.shared()
-
-/* This command create a tree file for each similarity calculator at distance level, using various calculators to find the similiarity between groups. 
-       The user can select the labels they wish to use as well as the groups they would like included.
-       They can also use as many or as few calculators as they wish. */
-       
-
-class MatrixOutputCommand : public Command {
-       
-public:
-       MatrixOutputCommand(string);
-       MatrixOutputCommand();  
-       ~MatrixOutputCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "dist.shared";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Dist.shared"; }
-       string getDescription()         { return "generate a distance matrix that describes the dissimilarity among multiple groups"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       struct linePair {
-               int start;
-               int end;
-       };
-       vector<linePair> lines;
-       
-       void printSims(ostream&, vector< vector<double> >&);
-       int process(vector<SharedRAbundVector*>);
-       
-       vector<Calculator*> matrixCalculators;
-       //vector< vector<float> > simMatrix;
-       InputData* input;
-       vector<SharedRAbundVector*> lookup;
-       string exportFileName, output, sharedfile;
-       int numGroups, processors, iters, subsampleSize;
-       ofstream out;
-
-       bool abort, allLines, subsample;
-       set<string> labels; //holds labels to be used
-       string outputFile, calc, groups, label, outputDir;
-       vector<string>  Estimators, Groups, outputNames; //holds estimators to be used
-       int process(vector<SharedRAbundVector*>, string, string);
-       int driver(vector<SharedRAbundVector*>, int, int, vector< vector<seqDist> >&);
-
-};
-       
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct distSharedData {
-    vector<SharedRAbundVector*> thisLookup;
-    vector< vector<seqDist> > calcDists;
-    vector<string>  Estimators;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       
-       distSharedData(){}
-       distSharedData(MothurOut* mout, unsigned long long st, unsigned long long en, vector<string> est, vector<SharedRAbundVector*> lu) {
-               m = mout;
-               start = st;
-               end = en;
-        Estimators = est;
-        thisLookup = lu;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyDistSharedThreadFunction(LPVOID lpParam){ 
-       distSharedData* pDataArray;
-       pDataArray = (distSharedData*)lpParam;
-       
-       try {
-        
-        vector<Calculator*> matrixCalculators;
-        ValidCalculators validCalculator;
-        for (int i=0; i<pDataArray->Estimators.size(); i++) {
-            if (validCalculator.isValidCalculator("matrix", pDataArray->Estimators[i]) == true) { 
-                if (pDataArray->Estimators[i] == "sharedsobs") { 
-                    matrixCalculators.push_back(new SharedSobsCS());
-                }else if (pDataArray->Estimators[i] == "sharedchao") { 
-                    matrixCalculators.push_back(new SharedChao1());
-                }else if (pDataArray->Estimators[i] == "sharedace") { 
-                    matrixCalculators.push_back(new SharedAce());
-                }else if (pDataArray->Estimators[i] == "jabund") {     
-                    matrixCalculators.push_back(new JAbund());
-                }else if (pDataArray->Estimators[i] == "sorabund") { 
-                    matrixCalculators.push_back(new SorAbund());
-                }else if (pDataArray->Estimators[i] == "jclass") { 
-                    matrixCalculators.push_back(new Jclass());
-                }else if (pDataArray->Estimators[i] == "sorclass") { 
-                    matrixCalculators.push_back(new SorClass());
-                }else if (pDataArray->Estimators[i] == "jest") { 
-                    matrixCalculators.push_back(new Jest());
-                }else if (pDataArray->Estimators[i] == "sorest") { 
-                    matrixCalculators.push_back(new SorEst());
-                }else if (pDataArray->Estimators[i] == "thetayc") { 
-                    matrixCalculators.push_back(new ThetaYC());
-                }else if (pDataArray->Estimators[i] == "thetan") { 
-                    matrixCalculators.push_back(new ThetaN());
-                }else if (pDataArray->Estimators[i] == "kstest") { 
-                    matrixCalculators.push_back(new KSTest());
-                }else if (pDataArray->Estimators[i] == "sharednseqs") { 
-                    matrixCalculators.push_back(new SharedNSeqs());
-                }else if (pDataArray->Estimators[i] == "ochiai") { 
-                    matrixCalculators.push_back(new Ochiai());
-                }else if (pDataArray->Estimators[i] == "anderberg") { 
-                    matrixCalculators.push_back(new Anderberg());
-                }else if (pDataArray->Estimators[i] == "kulczynski") { 
-                    matrixCalculators.push_back(new Kulczynski());
-                }else if (pDataArray->Estimators[i] == "kulczynskicody") { 
-                    matrixCalculators.push_back(new KulczynskiCody());
-                }else if (pDataArray->Estimators[i] == "lennon") { 
-                    matrixCalculators.push_back(new Lennon());
-                }else if (pDataArray->Estimators[i] == "morisitahorn") { 
-                    matrixCalculators.push_back(new MorHorn());
-                }else if (pDataArray->Estimators[i] == "braycurtis") { 
-                    matrixCalculators.push_back(new BrayCurtis());
-                }else if (pDataArray->Estimators[i] == "whittaker") { 
-                    matrixCalculators.push_back(new Whittaker());
-                }else if (pDataArray->Estimators[i] == "odum") { 
-                    matrixCalculators.push_back(new Odum());
-                }else if (pDataArray->Estimators[i] == "canberra") { 
-                    matrixCalculators.push_back(new Canberra());
-                }else if (pDataArray->Estimators[i] == "structeuclidean") { 
-                    matrixCalculators.push_back(new StructEuclidean());
-                }else if (pDataArray->Estimators[i] == "structchord") { 
-                    matrixCalculators.push_back(new StructChord());
-                }else if (pDataArray->Estimators[i] == "hellinger") { 
-                    matrixCalculators.push_back(new Hellinger());
-                }else if (pDataArray->Estimators[i] == "manhattan") { 
-                    matrixCalculators.push_back(new Manhattan());
-                }else if (pDataArray->Estimators[i] == "structpearson") { 
-                    matrixCalculators.push_back(new StructPearson());
-                }else if (pDataArray->Estimators[i] == "soergel") { 
-                    matrixCalculators.push_back(new Soergel());
-                }else if (pDataArray->Estimators[i] == "spearman") { 
-                    matrixCalculators.push_back(new Spearman());
-                }else if (pDataArray->Estimators[i] == "structkulczynski") { 
-                    matrixCalculators.push_back(new StructKulczynski());
-                }else if (pDataArray->Estimators[i] == "speciesprofile") { 
-                    matrixCalculators.push_back(new SpeciesProfile());
-                }else if (pDataArray->Estimators[i] == "hamming") { 
-                    matrixCalculators.push_back(new Hamming());
-                }else if (pDataArray->Estimators[i] == "structchi2") { 
-                    matrixCalculators.push_back(new StructChi2());
-                }else if (pDataArray->Estimators[i] == "gower") { 
-                    matrixCalculators.push_back(new Gower());
-                }else if (pDataArray->Estimators[i] == "memchi2") { 
-                    matrixCalculators.push_back(new MemChi2());
-                }else if (pDataArray->Estimators[i] == "memchord") { 
-                    matrixCalculators.push_back(new MemChord());
-                }else if (pDataArray->Estimators[i] == "memeuclidean") { 
-                    matrixCalculators.push_back(new MemEuclidean());
-                }else if (pDataArray->Estimators[i] == "mempearson") { 
-                    matrixCalculators.push_back(new MemPearson());
-                }
-            }
-        }
-        
-        pDataArray->calcDists.resize(matrixCalculators.size());
-                       
-               vector<SharedRAbundVector*> subset;
-               for (int k = pDataArray->start; k < pDataArray->end; k++) { // pass cdd each set of groups to compare
-                       
-                       for (int l = 0; l < k; l++) {
-                               
-                               if (k != l) { //we dont need to similiarity of a groups to itself
-                                       subset.clear(); //clear out old pair of sharedrabunds
-                                       //add new pair of sharedrabunds
-                                       subset.push_back(pDataArray->thisLookup[k]); subset.push_back(pDataArray->thisLookup[l]); 
-                                       
-                                       for(int i=0;i<matrixCalculators.size();i++) {
-                                               
-                                               //if this calc needs all groups to calculate the pair load all groups
-                                               if (matrixCalculators[i]->getNeedsAll()) { 
-                                                       //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                       for (int w = 0; w < pDataArray->thisLookup.size(); w++) {
-                                                               if ((w != k) && (w != l)) { subset.push_back(pDataArray->thisLookup[w]); }
-                                                       }
-                                               }
-                                               
-                                               vector<double> tempdata = matrixCalculators[i]->getValues(subset); //saves the calculator outputs
-                                               
-                                               if (pDataArray->m->control_pressed) { return 1; }
-                                               
-                                               seqDist temp(l, k, tempdata[0]);
-                                               pDataArray->calcDists[i].push_back(temp);
-                                       }
-                               }
-                       }
-               }
-        
-        for(int i=0;i<matrixCalculators.size();i++){  delete matrixCalculators[i]; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "MatrixOutputCommand", "MyDistSharedThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-       
-#endif
-
diff --git a/memchi2.cpp b/memchi2.cpp
deleted file mode 100644 (file)
index f08b4b8..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  memchi2.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "memchi2.h"
-
-/***********************************************************************/
-EstOutput MemChi2::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               int nonZeroA = 0;
-               int nonZeroB = 0;
-               int totalOtus = shared[0]->getNumBins();
-               //int totalGroups = shared.size();
-               
-               //for each otu
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       if (shared[0]->getAbundance(i) != 0) { nonZeroA++; }
-                       if (shared[1]->getAbundance(i) != 0) { nonZeroB++; }
-               }
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       if (A > 0) { A = 1; }
-                       if (B > 0) { B = 1; }
-                       
-                       double Aterm = A / (float) nonZeroA;
-                       double Bterm = B / (float) nonZeroB;
-
-                       int incidence = 0;
-                       for(int j=0;j<shared.size();j++){
-                               if(shared[j]->getAbundance(i) != 0){    incidence++;    }
-                       }
-                       
-                       if(incidence != 0){
-                               sum += (((Aterm-Bterm)*(Aterm-Bterm))/incidence);
-                       }
-               }
-               
-               data[0] = sqrt(totalOtus * sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MemChi2", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/memchi2.h b/memchi2.h
deleted file mode 100644 (file)
index c230154..0000000
--- a/memchi2.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef MEMCHI2_H
-#define MEMCHI2_H
-
-/*
- *  memchi2.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class MemChi2 : public Calculator  {
-       
-public:
-       MemChi2() :  Calculator("memchi2", 1, false, true) {};  //the true means this calculator needs all groups to calculate the pair value
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Memchi2"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/memchord.cpp b/memchord.cpp
deleted file mode 100644 (file)
index 380ddbe..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *  memchord.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "memchord.h"
-
-/***********************************************************************/
-EstOutput MemChord::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double nonZeroA = 0;
-               double nonZeroB = 0;
-               
-               //for each otu
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       if (shared[0]->getAbundance(i) != 0) { nonZeroA++; }
-                       if (shared[1]->getAbundance(i) != 0) { nonZeroB++; }
-               }
-               
-               nonZeroA = sqrt(nonZeroA);
-               nonZeroB = sqrt(nonZeroB);
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       if (A > 0) { A = 1; }
-                       if (B > 0) { B = 1; }
-                       
-                       double Aterm = A / nonZeroA;
-                       double Bterm = B / nonZeroB;
-                       
-                       sum += ((Aterm-Bterm)*(Aterm-Bterm));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MemChord", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/memchord.h b/memchord.h
deleted file mode 100644 (file)
index 8c4628b..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef MEMCHORD_H
-#define MEMCHORD_H
-
-/*
- *  memchord.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class MemChord : public Calculator  {
-       
-public:
-       MemChord() :  Calculator("memchord", 1, false) {};  
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Memchord"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/memeuclidean.cpp b/memeuclidean.cpp
deleted file mode 100644 (file)
index e613473..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  memeuclidean.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "memeuclidean.h"
-
-/***********************************************************************/
-EstOutput MemEuclidean::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       if (A > 0) { A = 1; }
-                       if (B > 0) { B = 1; }
-                       
-                       sum += ((A-B)*(A-B));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MemEuclidean", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/memeuclidean.h b/memeuclidean.h
deleted file mode 100644 (file)
index aeae07a..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef MEMEUCLIDEAN_H
-#define MEMEUCLIDEAN_H
-
-/*
- *  memeuclidean.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class MemEuclidean : public Calculator  {
-       
-public:
-       MemEuclidean() :  Calculator("memeuclidean", 1, false) {};  
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Memeuclidean"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/mempearson.cpp b/mempearson.cpp
deleted file mode 100644 (file)
index 2503b5d..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *  mempearson.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mempearson.h"
-
-/***********************************************************************/
-EstOutput MemPearson::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               int nonZeroA = 0;
-               int nonZeroB = 0;
-               int numOTUS = shared[0]->getNumBins();
-               
-               //for each otu
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       if (shared[0]->getAbundance(i) != 0) { nonZeroA++; }
-                       if (shared[1]->getAbundance(i) != 0) { nonZeroB++; }
-               }
-               
-               double numTerm = 0.0;
-               double denomTerm1 = 0.0;
-               double denomTerm2 = 0.0;
-               double averageA = nonZeroA / (float) numOTUS;
-               double averageB = nonZeroB / (float) numOTUS;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       int Aij =  shared[0]->getAbundance(i);
-                       int Bij =  shared[1]->getAbundance(i);
-                       
-                       if (Aij > 0) { Aij = 1; }
-                       if (Bij > 0) { Bij = 1; }
-                       
-                       numTerm += ((Aij - averageA) * (Bij - averageB));
-                       denomTerm1 += ((Aij - averageA) * (Aij - averageA));
-                       denomTerm2 += ((Bij - averageB) * (Bij - averageB));
-               }
-               
-               denomTerm1 = sqrt(denomTerm1);
-               denomTerm2 = sqrt(denomTerm2);
-               
-               double denom = denomTerm1 * denomTerm2;
-
-               if (denom != 0) { 
-                       data[0] = (numTerm / denom);
-               }else {
-                       data[0] = 1.0;
-               }
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MemPearson", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/mempearson.h b/mempearson.h
deleted file mode 100644 (file)
index c09dce3..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef MEMPEARSON_H
-#define MEMPEARSON_H
-
-/*
- *  mempearson.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class MemPearson : public Calculator  {
-       
-public:
-       MemPearson() :  Calculator("mempearson", 1, false) {};  
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Mempearson"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/mergefilecommand.cpp b/mergefilecommand.cpp
deleted file mode 100644 (file)
index 04c92fa..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- *  mergefilecommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 6/14/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mergefilecommand.h"
-
-//**********************************************************************************************************************
-vector<string> MergeFileCommand::setParameters(){      
-       try {
-               CommandParameter pinput("input", "String", "", "", "", "", "",false,true); parameters.push_back(pinput);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,true); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeFileCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MergeFileCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The merge.file command takes a list of files separated by dashes and merges them into one file."; 
-               helpString += "The merge.file command parameters are input and output."; 
-               helpString += "Example merge.file(input=small.fasta-large.fasta, output=all.fasta).";
-               helpString += "Note: No spaces between parameter labels (i.e. output), '=' and parameters (i.e.yourOutputFileName).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeFileCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-MergeFileCommand::MergeFileCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["merge"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeFileCommand", "MergeFileCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-MergeFileCommand::MergeFileCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               if(option == "help") {
-                       help();
-                       abort = true; calledHelp = true;
-               }else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["merge"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       
-                       string fileList = validParameter.validFile(parameters, "input", false);                 
-                       if(fileList == "not found") { m->mothurOut("you must enter two or more file names"); m->mothurOutEndLine();  abort=true;  }
-                       else{   m->splitAtDash(fileList, fileNames);    }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found")   {       outputDir = "";         }
-                       
-                       
-                       numInputFiles = fileNames.size();
-                       ifstream testFile;
-                       if(numInputFiles == 0){
-                               m->mothurOut("you must enter two or more file names and you entered " + toString(fileNames.size()) +  " file names"); m->mothurOutEndLine();
-                               abort=true;  
-                       }
-                       else{
-                               for(int i=0;i<numInputFiles;i++){
-                                       if (inputDir != "") {
-                                               string path = m->hasPath(fileNames[i]);
-                                               //if the user has not given a path then, add inputdir. else leave path alone.
-                                               if (path == "") {       fileNames[i] = inputDir + fileNames[i];         }
-                                       }
-                                       
-                                       if(m->openInputFile(fileNames[i], testFile)){   abort = true;   }
-                                       testFile.close();
-                               }
-                       }   
-                       
-                       outputFileName = validParameter.validFile(parameters, "output", false);                 
-                       if (outputFileName == "not found") { m->mothurOut("you must enter an output file name"); m->mothurOutEndLine();  abort=true;  }
-                       else if (outputDir != "") { outputFileName = outputDir + m->getSimpleName(outputFileName);  }
-               }
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeFileCommand", "MergeFileCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MergeFileCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               ofstream outputFile;
-               m->openOutputFile(outputFileName, outputFile);
-               
-               char c;
-               for(int i=0;i<numInputFiles;i++){
-                       ifstream inputFile; //declaration must be inside for loop of windows throws an error
-                       
-                       m->openInputFile(fileNames[i], inputFile);
-                       
-                       while(!inputFile.eof()){        
-                               if (m->control_pressed) { outputTypes.clear(); inputFile.close(); outputFile.close(); m->mothurRemove(outputFileName); return 0;  }
-                       
-                               c = inputFile.get(); 
-                               //-1 is eof char
-                               if (int(c) != -1) { outputFile << c; }   
-                       }
-                       
-                       inputFile.close();
-               }
-               
-               outputFile.close();
-               
-               if (m->control_pressed) { outputTypes.clear();  m->mothurRemove(outputFileName); return 0;  }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["merge"].push_back(outputFileName);
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeFileCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/mergefilecommand.h b/mergefilecommand.h
deleted file mode 100644 (file)
index 1c3c4d5..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef MERGEFILECOMMAND_H
-#define MERGEFILECOMMAND_H
-
-/*
- *  mergefilecommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 6/14/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-
-class MergeFileCommand : public Command {
-public:
-       MergeFileCommand(string);
-       MergeFileCommand();
-       ~MergeFileCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "merge.files"; }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Merge.files"; }
-       string getDescription()         { return "appends files creating one file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       vector<string> fileNames, outputNames;
-       string outputFileName;
-       int numInputFiles;
-       bool abort;
-};
-
-#endif
diff --git a/mergegroupscommand.cpp b/mergegroupscommand.cpp
deleted file mode 100644 (file)
index e30558c..0000000
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- *  mergegroupscommand.cpp
- *  mothur
- *
- *  Created by westcott on 1/24/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mergegroupscommand.h"
-#include "sharedutilities.h"
-
-//**********************************************************************************************************************
-vector<string> MergeGroupsCommand::setParameters(){    
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MergeGroupsCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The merge.groups command reads a shared or group file and a design file and merges the groups that are in the same grouping in the design file.\n";
-               helpString += "The merge.groups command outputs a .shared file. \n";
-               helpString += "The merge.groups command parameters are shared, group, groups, label and design.  The design parameter is required.\n";
-               helpString += "The design parameter allows you to assign your groups to sets. It is required. \n";
-               helpString += "The design file looks like the group file.  It is a 2 column tab delimited file, where the first column is the group name and the second column is the set the group belongs to.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your shared or group file you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The merge.groups command should be in the following format: merge.groups(design=yourDesignFile, shared=yourSharedFile).\n";
-               helpString += "Example merge.groups(design=temp.design, groups=A-B-C, shared=temp.shared).\n";
-               helpString += "The default value for groups is all the groups in your sharedfile, and all labels in your inputfile will be used.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MergeGroupsCommand::MergeGroupsCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "MetaStatsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-MergeGroupsCommand::MergeGroupsCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                       }
-                       
-                       //check for required parameters
-                       designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { abort = true; }
-                       else if (designfile == "not found") {                           
-                               //if there is a current shared file, use it
-                               designfile = m->getDesignFile(); 
-                               if (designfile != "") { m->mothurOut("Using " + designfile + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current designfile and the design parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setDesignFile(designfile); } 
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; sharedfile = ""; }
-                       else if (sharedfile == "not found") {  sharedfile = ""; }
-                       else { m->setSharedFile(sharedfile); }  
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; groupfile = ""; }
-                       else if (groupfile == "not found") {  groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }    
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "all";  }
-                       m->splitAtDash(groups, Groups);
-                       m->setGroups(Groups);
-                       
-                       if ((sharedfile == "") && (groupfile == "")) { 
-                               //give priority to group, then shared
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") {  m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       sharedfile = m->getSharedFile(); 
-                                       if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
-                                       }
-                               }
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "MergeGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MergeGroupsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-       
-               designMap = new GroupMap(designfile);
-               designMap->readDesignMap();
-               
-               if (groupfile != "") { processGroupFile(designMap); }
-               if (sharedfile != "") { processSharedFile(designMap); }
-
-               //reset groups parameter
-               m->clearGroups();  
-               delete designMap;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0;}
-               
-               
-               //set shared file as new current sharedfile
-               string current = "";
-               itTypes = outputTypes.find("shared");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MergeGroupsCommand::process(vector<SharedRAbundVector*>& thisLookUp, ofstream& out){
-       try {
-               
-               map<string, SharedRAbundVector> merged;
-               map<string, SharedRAbundVector>::iterator it;
-               
-               for (int i = 0; i < thisLookUp.size(); i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //what grouping does this group belong to
-                       string grouping = designMap->getGroup(thisLookUp[i]->getGroup());
-                       if (grouping == "not found") { m->mothurOut("[ERROR]: " + thisLookUp[i]->getGroup() + " is not in your design file. Ignoring!"); m->mothurOutEndLine(); grouping = "NOTFOUND"; }
-                       
-                       else {
-                               //do we already have a member of this grouping?
-                               it = merged.find(grouping);
-                               
-                               if (it == merged.end()) { //nope, so create it
-                                       merged[grouping] = *thisLookUp[i];
-                                       merged[grouping].setGroup(grouping);
-                               }else { //yes, merge it
-                                       
-                                       for (int j = 0; j < thisLookUp[i]->getNumBins(); j++) {
-                                               int abund = (it->second).getAbundance(j);
-                                               abund += thisLookUp[i]->getAbundance(j);
-                                               
-                                               (it->second).set(j, abund, grouping);
-                                       }
-                               }
-                       }
-               }
-               
-               //print new file
-               for (it = merged.begin(); it != merged.end(); it++) {
-                       out << (it->second).getLabel() << '\t' << it->first << '\t';
-                       (it->second).print(out);
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "process");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MergeGroupsCommand::processSharedFile(GroupMap*& designMap){
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "merge" +  m->getExtension(sharedfile);
-               outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               InputData input(sharedfile, "sharedfile");
-               lookup = input.getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  out.close(); for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups();  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {    m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               process(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               lookup = input.getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               process(lookup, out);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       
-                       if (m->control_pressed) {  out.close(); m->clearGroups();   delete designMap;  for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       //get next line to process
-                       lookup = input.getSharedRAbundVectors();                                
-               }
-               
-               if (m->control_pressed) { out.close(); m->clearGroups();  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); }  return 0; }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input.getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       
-                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                       process(lookup, out);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-               
-               out.close();
-               
-                               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "processSharedFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MergeGroupsCommand::processGroupFile(GroupMap*& designMap){
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "merge" +  m->getExtension(groupfile);
-               outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               //read groupfile
-               GroupMap groupMap(groupfile);
-               groupMap.readMap();
-               
-               //fill Groups - checks for "all" and for any typo groups
-               SharedUtil* util = new SharedUtil();
-               vector<string> nameGroups = groupMap.getNamesOfGroups();
-               util->setGroups(Groups, nameGroups);
-               delete util;
-               
-               vector<string> namesOfSeqs = groupMap.getNamesSeqs();
-               bool error = false;
-               
-               for (int i = 0; i < namesOfSeqs.size(); i++) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       string thisGroup = groupMap.getGroup(namesOfSeqs[i]);
-                       
-                       //are you in a group the user wants
-                       if (m->inUsersGroups(thisGroup, Groups)) {
-                               string thisGrouping = designMap->getGroup(thisGroup);
-                               
-                               if (thisGrouping == "not found") { m->mothurOut("[ERROR]: " + namesOfSeqs[i] + " is from group " + thisGroup + " which is not in your design file, please correct."); m->mothurOutEndLine();  error = true; }
-                               else {
-                                       out << namesOfSeqs[i] << '\t' << thisGrouping << endl;
-                               }
-                       }
-               }
-               
-               if (error) { m->control_pressed = true; }
-
-               out.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MergeGroupsCommand", "processGroupFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/mergegroupscommand.h b/mergegroupscommand.h
deleted file mode 100644 (file)
index 7f216eb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef MERGEGROUPSCOMMAND_H
-#define MERGEGROUPSCOMMAND_H
-
-/*
- *  mergegroupscommand.h
- *  mothur
- *
- *  Created by westcott on 1/24/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedrabundvector.h"
-
-class MergeGroupsCommand : public Command {
-       
-public:
-       MergeGroupsCommand(string);
-       MergeGroupsCommand();
-       ~MergeGroupsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "merge.groups";        }
-       string getCommandCategory()             { return "General";                     }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Merge.groups"; }
-       string getDescription()         { return "reads shared file and a design file and merges the groups in the shared file that are in the same grouping in the design file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       GroupMap* designMap;
-       vector<SharedRAbundVector*> lookup;
-       
-       bool abort, allLines, pickedGroups;
-       set<string> labels; //holds labels to be used
-       string groups, label, outputDir, inputDir, designfile, sharedfile, groupfile;
-       vector<string> Groups, outputNames;
-               
-       int process(vector<SharedRAbundVector*>&, ofstream&);
-       int processSharedFile(GroupMap*&);
-       int processGroupFile(GroupMap*&);
-};
-
-#endif
-
diff --git a/metastatscommand.cpp b/metastatscommand.cpp
deleted file mode 100644 (file)
index c5d349b..0000000
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- *  metastatscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/16/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "metastatscommand.h"
-#include "sharedutilities.h"
-
-
-//**********************************************************************************************************************
-vector<string> MetaStatsCommand::setParameters(){      
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pdesign);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pthreshold("threshold", "Number", "", "0.05", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter psets("sets", "String", "", "", "", "", "",false,false); parameters.push_back(psets);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MetaStatsCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "This command is based on the Metastats program, White, J.R., Nagarajan, N. & Pop, M. Statistical methods for detecting differentially abundant features in clinical metagenomic samples. PLoS Comput Biol 5, e1000352 (2009).\n";
-               helpString += "The metastats command outputs a .metastats file. \n";
-               helpString += "The metastats command parameters are shared, iters, threshold, groups, label, design, sets and processors.  The shared and design parameters are required, unless you have valid current files.\n";
-               helpString += "The design parameter allows you to assign your groups to sets when you are running metastat. mothur will run all pairwise comparisons of the sets. It is required. \n";
-               helpString += "The design file looks like the group file.  It is a 2 column tab delimited file, where the first column is the group name and the second column is the set the group belongs to.\n";
-               helpString += "The sets parameter allows you to specify which of the sets in your designfile you would like to analyze. The set names are separated by dashes. THe default is all sets in the designfile.\n";
-               helpString += "The iters parameter allows you to set number of bootstrap permutations for estimating null distribution of t statistic.  The default is 1000. \n";
-               helpString += "The threshold parameter allows you to set the significance level to reject null hypotheses (default 0.05).\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-               helpString += "The metastats command should be in the following format: metastats(design=yourDesignFile).\n";
-               helpString += "Example metastats(design=temp.design, groups=A-B-C).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MetaStatsCommand::MetaStatsCommand(){  
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["metastats"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "MetaStatsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-MetaStatsCommand::MetaStatsCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["metastats"] = tempOutNames;
-                       
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                       }
-                       
-                       //check for required parameters
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; }
-                       else if (sharedfile == "not found") {                           //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       //check for required parameters
-                       designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { abort = true; }
-                       else if (designfile == "not found") {                           
-                               //if there is a current design file, use it
-                               designfile = m->getDesignFile(); 
-                               if (designfile != "") { m->mothurOut("Using " + designfile + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current designfile and the design parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setDesignFile(designfile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(sharedfile); //if user entered a file with a path then preserve it      
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; pickedGroups = false; }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       sets = validParameter.validFile(parameters, "sets", false);                     
-                       if (sets == "not found") { sets = ""; }
-                       else { 
-                               m->splitAtDash(sets, Sets);
-                       }
-
-                       
-                       string temp = validParameter.validFile(parameters, "iters", false);                     if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "threshold", false);                        if (temp == "not found") { temp = "0.05"; }
-                       m->mothurConvert(temp, threshold); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "MetaStatsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MetaStatsCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               designMap = new GroupMap(designfile);
-               designMap->readDesignMap();
-       
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //setup the pairwise comparions of sets for metastats
-               //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
-               //make sure sets are all in designMap
-               SharedUtil* util = new SharedUtil(); 
-               vector<string> dGroups = designMap->getNamesOfGroups();
-               util->setGroups(Sets, dGroups);  
-               delete util;
-               
-               int numGroups = Sets.size();
-               for (int a=0; a<numGroups; a++) { 
-                       for (int l = 0; l < a; l++) {   
-                               vector<string> groups; groups.push_back(Sets[a]); groups.push_back(Sets[l]);
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-       
-               
-               //only 1 combo
-               if (numGroups == 2) { processors = 1; }
-               else if (numGroups < 2) { m->mothurOut("Not enough sets, I need at least 2 valid sets. Unable to complete command."); m->mothurOutEndLine(); m->control_pressed = true; }
-
-        if(processors != 1){
-            int numPairs = namesOfGroupCombos.size();
-            int numPairsPerProcessor = numPairs / processors;
-                       
-            for (int i = 0; i < processors; i++) {
-                int startPos = i * numPairsPerProcessor;
-                if(i == processors - 1){
-                    numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                }
-                lines.push_back(linePair(startPos, numPairsPerProcessor));
-            }
-        }
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                       
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               process(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       
-                       if (m->control_pressed) {  outputTypes.clear(); m->clearGroups(); delete input;  delete designMap;  for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]); } return 0; }
-
-                       //get next line to process
-                       lookup = input->getSharedRAbundVectors();                               
-               }
-               
-               if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; delete designMap;  for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); }  return 0; }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-       
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       
-                       process(lookup);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-       
-               //reset groups parameter
-               m->clearGroups();  
-               delete input; 
-               delete designMap;
-               
-               if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]); } return 0;}
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int MetaStatsCommand::process(vector<SharedRAbundVector*>& thisLookUp){
-       try {
-               
-               
-                               if(processors == 1){
-                                       driver(0, namesOfGroupCombos.size(), thisLookUp);
-                               }else{
-                                       int process = 1;
-                                       vector<int> processIDS;
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                                       //loop through and create all the processes you want
-                                       while (process != processors) {
-                                               int pid = fork();
-                       
-                                               if (pid > 0) {
-                                                       processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                                                       process++;
-                                               }else if (pid == 0){
-                                                       driver(lines[process].start, lines[process].num, thisLookUp);
-                                                       exit(0);
-                                               }else { 
-                                                       m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                                                       for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                                                       exit(0);
-                                               }
-                                       }
-                                       
-                                       //do my part
-                                       driver(lines[0].start, lines[0].num, thisLookUp);
-               
-                                       //force parent to wait until all the processes are done
-                                       for (int i=0;i<(processors-1);i++) { 
-                                               int temp = processIDS[i];
-                                               wait(&temp);
-                                       }
-        #else
-                    
-                    //////////////////////////////////////////////////////////////////////////////////////////////////////
-                    //Windows version shared memory, so be careful when passing variables through the summarySharedData struct. 
-                    //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-                    //Taking advantage of shared memory to pass results vectors.
-                    //////////////////////////////////////////////////////////////////////////////////////////////////////
-                    
-                    vector<metastatsData*> pDataArray; 
-                    DWORD   dwThreadIdArray[processors-1];
-                    HANDLE  hThreadArray[processors-1]; 
-                    
-                    //Create processor worker threads.
-                    for( int i=1; i<processors; i++ ){
-                        
-                        //make copy of lookup so we don't get access violations
-                        vector<SharedRAbundVector*> newLookup;
-                        vector<string> designMapGroups;
-                        for (int k = 0; k < thisLookUp.size(); k++) {
-                            SharedRAbundVector* temp = new SharedRAbundVector();
-                            temp->setLabel(thisLookUp[k]->getLabel());
-                            temp->setGroup(thisLookUp[k]->getGroup());
-                            newLookup.push_back(temp);
-                            designMapGroups.push_back(designMap->getGroup(thisLookUp[k]->getGroup()));
-                        }
-                        
-                        //for each bin
-                        for (int k = 0; k < thisLookUp[0]->getNumBins(); k++) {
-                            if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                            for (int j = 0; j < thisLookUp.size(); j++) { newLookup[j]->push_back(thisLookUp[j]->getAbundance(k), thisLookUp[j]->getGroup()); }
-                        }
-                        
-                        // Allocate memory for thread data.
-                        metastatsData* tempSum = new metastatsData(sharedfile, outputDir, m, lines[i].start, lines[i].num, namesOfGroupCombos, newLookup, designMapGroups, iters, threshold);
-                        pDataArray.push_back(tempSum);
-                        processIDS.push_back(i);
-                        
-                        hThreadArray[i-1] = CreateThread(NULL, 0, MyMetastatsThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-                    }
-                    
-                    //do my part
-                                       driver(lines[0].start, lines[0].num, thisLookUp);
-                    
-                    //Wait until all threads have terminated.
-                    WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-                    
-                    //Close all thread handles and free memory allocations.
-                    for(int i=0; i < pDataArray.size(); i++){
-                        for (int j = 0; j < pDataArray[i]->thisLookUp.size(); j++) {  delete pDataArray[i]->thisLookUp[j];  } 
-                        for (int j = 0; j < pDataArray[i]->outputNames.size(); j++) {  
-                            outputNames.push_back(pDataArray[i]->outputNames[j]);
-                            outputTypes["metastats"].push_back(pDataArray[i]->outputNames[j]);
-                        }
-                                                
-                        CloseHandle(hThreadArray[i]);
-                        delete pDataArray[i];
-                    }
-        #endif
-
-                               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "process");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int MetaStatsCommand::driver(int start, int num, vector<SharedRAbundVector*>& thisLookUp) { 
-       try {
-       
-               //for each combo
-               for (int c = start; c < (start+num); c++) {
-                       
-                       //get set names
-                       string setA = namesOfGroupCombos[c][0]; 
-                       string setB = namesOfGroupCombos[c][1];
-               
-                       //get filename
-                       string outputFileName = outputDir +  m->getRootName(m->getSimpleName(sharedfile)) + thisLookUp[0]->getLabel() + "." + setA + "-" + setB + ".metastats";
-                       outputNames.push_back(outputFileName); outputTypes["metastats"].push_back(outputFileName);
-                       //int nameLength = outputFileName.length();
-                       //char * output = new char[nameLength];
-                       //strcpy(output, outputFileName.c_str());
-       
-                       //build matrix from shared rabunds
-                       //double** data;
-                       //data = new double*[thisLookUp[0]->getNumBins()];
-                       
-                       vector< vector<double> > data2; data2.resize(thisLookUp[0]->getNumBins());
-                       
-                       vector<SharedRAbundVector*> subset;
-                       int setACount = 0;
-                       int setBCount = 0;
-                       for (int i = 0; i < thisLookUp.size(); i++) {
-                               string thisGroup = thisLookUp[i]->getGroup();
-                               
-                               //is this group for a set we want to compare??
-                               //sorting the sets by putting setB at the back and setA in the front
-                               if ((designMap->getGroup(thisGroup) == setB)) {  
-                                       subset.push_back(thisLookUp[i]);
-                                       setBCount++;
-                               }else if ((designMap->getGroup(thisGroup) == setA)) {
-                                       subset.insert(subset.begin()+setACount, thisLookUp[i]);
-                                       setACount++;
-                               }
-                       }
-                                               
-                       if ((setACount == 0) || (setBCount == 0))  { 
-                               m->mothurOut("Missing shared info for " + setA + " or " + setB + ". Skipping comparison."); m->mothurOutEndLine(); 
-                               outputNames.pop_back();
-                       }else {
-                
-                               //fill data
-                               for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                                       //data[j] = new double[subset.size()];
-                                       data2[j].resize(subset.size(), 0.0);
-                   
-                                       for (int i = 0; i < subset.size(); i++) {
-                                               data2[j][i] = (subset[i]->getAbundance(j));
-                                       }
-                               }
-                               
-                               m->mothurOut("Comparing " + setA + " and " + setB + "..."); m->mothurOutEndLine(); 
-                               //metastat_main(output, thisLookUp[0]->getNumBins(), subset.size(), threshold, iters, data, setACount);
-                               
-                               m->mothurOutEndLine();
-                               MothurMetastats mothurMeta(threshold, iters);
-                               mothurMeta.runMetastats(outputFileName , data2, setACount);
-                               m->mothurOutEndLine();
-                               m->mothurOutEndLine(); 
-                       }
-                       
-                       //free memory
-                       //delete output;
-                       //for(int i = 0; i < thisLookUp[0]->getNumBins(); i++)  {  delete[] data[i];  }
-                       //delete[] data; 
-               }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MetaStatsCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/metastatscommand.h b/metastatscommand.h
deleted file mode 100644 (file)
index b4800b7..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-#ifndef METASTATSCOMMAND_H
-#define METASTATSCOMMAND_H
-
-/*
- *  metastatscommand.h
- *  Mothur
- *
- *  Created by westcott on 9/16/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedrabundvector.h"
-#include "mothurmetastats.h"
-
-class MetaStatsCommand : public Command {
-
-public:
-       MetaStatsCommand(string);
-       MetaStatsCommand();
-       ~MetaStatsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "metastats";                           }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "White JR, Nagarajan N, Pop M (2009). Statistical methods for detecting differentially abundant features in clinical metagenomic samples. PLoS Comput Biol 5: e1000352. \nhttp://www.mothur.org/wiki/Metastats"; }
-       string getDescription()         { return "detects differentially abundant features in clinical metagenomic samples"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       struct linePair {
-               int start;
-               int num;
-               linePair(int i, int j) : start(i), num(j) {}
-       };
-       vector<linePair> lines;
-       
-       GroupMap* designMap;
-       InputData* input;
-       vector<SharedRAbundVector*> lookup;
-               
-       bool abort, allLines, pickedGroups;
-       set<string> labels; //holds labels to be used
-       string groups, label, outputDir, inputDir, designfile, sets, sharedfile;
-       vector<string> Groups, outputNames, Sets;
-       vector< vector<string> > namesOfGroupCombos;
-       int iters, processors;
-       float threshold;
-       
-       int process(vector<SharedRAbundVector*>&);
-       int driver(int, int, vector<SharedRAbundVector*>&);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct metastatsData {
-    vector<SharedRAbundVector*> thisLookUp;
-    vector< vector<string> > namesOfGroupCombos;
-    vector<string> designMapGroups;
-    vector<string> outputNames;
-       int start;
-       int num, iters;
-       float threshold;
-       MothurOut* m;
-       string sharedfile;
-    string outputDir;
-       
-       metastatsData(){}
-       metastatsData(string sf, string oDir, MothurOut* mout, int st, int en, vector< vector<string> > ns, vector<SharedRAbundVector*> lu, vector<string> dg, int i, float thr) {
-               sharedfile = sf;
-        outputDir = oDir;
-               m = mout;
-               start = st;
-               num = en;
-        namesOfGroupCombos = ns;
-        thisLookUp = lu;
-        designMapGroups = dg;
-        iters = i;
-        threshold = thr;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyMetastatsThreadFunction(LPVOID lpParam){ 
-       metastatsData* pDataArray;
-       pDataArray = (metastatsData*)lpParam;
-       
-       try {
-               
-        //for each combo
-               for (int c = pDataArray->start; c < (pDataArray->start+pDataArray->num); c++) {
-                       
-                       //get set names
-                       string setA = pDataArray->namesOfGroupCombos[c][0]; 
-                       string setB = pDataArray->namesOfGroupCombos[c][1];
-            
-                       //get filename
-                       string outputFileName = pDataArray->outputDir +  pDataArray->m->getRootName(pDataArray->m->getSimpleName(pDataArray->sharedfile)) + pDataArray->thisLookUp[0]->getLabel() + "." + setA + "-" + setB + ".metastats";
-                       pDataArray->outputNames.push_back(outputFileName); 
-                       
-                       vector< vector<double> > data2; data2.resize(pDataArray->thisLookUp[0]->getNumBins());
-                       
-                       vector<SharedRAbundVector*> subset;
-                       int setACount = 0;
-                       int setBCount = 0;
-                       for (int i = 0; i < pDataArray->thisLookUp.size(); i++) {
-                               //is this group for a set we want to compare??
-                               //sorting the sets by putting setB at the back and setA in the front
-                               if (pDataArray->designMapGroups[i] == setB) {  
-                                       subset.push_back(pDataArray->thisLookUp[i]);
-                                       setBCount++;
-                               }else if (pDataArray->designMapGroups[i] == setA) {
-                                       subset.insert(subset.begin()+setACount, pDataArray->thisLookUp[i]);
-                                       setACount++;
-                               }
-                       }
-            
-                       if ((setACount == 0) || (setBCount == 0))  { 
-                               pDataArray->m->mothurOut("Missing shared info for " + setA + " or " + setB + ". Skipping comparison."); pDataArray->m->mothurOutEndLine(); 
-                               pDataArray->outputNames.pop_back();
-                       }else {
-                               //fill data
-                               for (int j = 0; j < pDataArray->thisLookUp[0]->getNumBins(); j++) {
-                                       data2[j].resize(subset.size(), 0.0);
-                                       for (int i = 0; i < subset.size(); i++) {
-                                               data2[j][i] = (subset[i]->getAbundance(j));
-                                       }
-                               }
-                               
-                               pDataArray->m->mothurOut("Comparing " + setA + " and " + setB + "..."); pDataArray->m->mothurOutEndLine(); 
-                               
-                               pDataArray->m->mothurOutEndLine();
-                               MothurMetastats mothurMeta(pDataArray->threshold, pDataArray->iters);
-                               mothurMeta.runMetastats(outputFileName, data2, setACount);
-                               pDataArray->m->mothurOutEndLine();
-                               pDataArray->m->mothurOutEndLine(); 
-                       }
-        }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "MetaStatsCommand", "MyMetastatsThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-
-#endif
-
diff --git a/mgclustercommand.cpp b/mgclustercommand.cpp
deleted file mode 100644 (file)
index 9c45afe..0000000
+++ /dev/null
@@ -1,680 +0,0 @@
-/*
- *  mgclustercommand.cpp
- *  Mothur
- *
- *  Created by westcott on 12/11/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mgclustercommand.h"
-
-//**********************************************************************************************************************
-vector<string> MGClusterCommand::setParameters(){      
-       try {
-               CommandParameter pblast("blast", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pblast);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter plength("length", "Number", "", "5", "", "", "",false,false); parameters.push_back(plength);
-               CommandParameter ppenalty("penalty", "Number", "", "0.10", "", "", "",false,false); parameters.push_back(ppenalty);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter pmethod("method", "Multiple", "furthest-nearest-average", "average", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter phard("hard", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pmin("min", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmin);
-               CommandParameter pmerge("merge", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmerge);
-               CommandParameter phcluster("hcluster", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phcluster);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string MGClusterCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The mgcluster command parameter options are blast, name, cutoff, precision, hard,  method, merge, min, length, penalty and hcluster. The blast parameter is required.\n";
-               helpString += "The mgcluster command reads a blast and name file and clusters the sequences into OPF units similiar to the OTUs.\n";
-               helpString += "This command outputs a .list, .rabund and .sabund file that can be used with mothur other commands to estimate richness.\n";
-               helpString += "The cutoff parameter is used to specify the maximum distance you would like to cluster to. The default is 0.70.\n";
-               helpString += "The precision parameter's default value is 100. \n";
-               helpString += "The acceptable mgcluster methods are furthest, nearest and average.  If no method is provided then average is assumed.\n";       
-               helpString += "The min parameter allows you to specify is you want the minimum or maximum blast score ratio used in calculating the distance. The default is true, meaning you want the minimum.\n";
-               helpString += "The length parameter is used to specify the minimum overlap required.  The default is 5.\n";
-               helpString += "The penalty parameter is used to adjust the error rate.  The default is 0.10.\n";
-               helpString += "The merge parameter allows you to shut off merging based on overlaps and just cluster.  By default merge is true, meaning you want to merge.\n";
-               helpString += "The hcluster parameter allows you to use the hcluster algorithm when clustering.  This may be neccessary if your file is too large to fit into RAM. The default is false.\n";
-               helpString += "The mgcluster command should be in the following format: \n";
-               helpString += "mgcluster(blast=yourBlastfile, name=yourNameFile, cutoff=yourCutOff).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. balst), '=' and parameters (i.e.yourBlastfile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MGClusterCommand::MGClusterCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "MGClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-MGClusterCommand::MGClusterCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("blast");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["blast"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       blastfile = validParameter.validFile(parameters, "blast", true);
-                       if (blastfile == "not open") { blastfile = ""; abort = true; }  
-                       else if (blastfile == "not found") { blastfile = ""; }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(blastfile); //if user entered a file with a path then preserve it       
-                       }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       if ((blastfile == "")) { m->mothurOut("When executing a mgcluster command you must provide a blastfile."); m->mothurOutEndLine(); abort = true; }
-                       
-                       //check for optional parameter and set defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);                if (temp == "not found") { temp = "100"; }
-                       precisionLength = temp.length();
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "0.70"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));
-                       
-                       method = validParameter.validFile(parameters, "method", false);
-                       if (method == "not found") { method = "average"; }
-                       
-                       if ((method == "furthest") || (method == "nearest") || (method == "average")) { }
-                       else { m->mothurOut("Not a valid clustering method.  Valid clustering algorithms are furthest, nearest or average."); m->mothurOutEndLine(); abort = true; }
-
-                       temp = validParameter.validFile(parameters, "length", false);                   if (temp == "not found") { temp = "5"; }
-                       m->mothurConvert(temp, length); 
-                       
-                       temp = validParameter.validFile(parameters, "penalty", false);                  if (temp == "not found") { temp = "0.10"; }
-                       m->mothurConvert(temp, penalty); 
-                       
-                       temp = validParameter.validFile(parameters, "min", false);                              if (temp == "not found") { temp = "true"; }
-                       minWanted = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "merge", false);                    if (temp == "not found") { temp = "true"; }
-                       merge = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "hcluster", false);                 if (temp == "not found") { temp = "false"; }
-                       hclusterWanted = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "hard", false);                     if (temp == "not found") { temp = "T"; }
-                       hard = m->isTrue(temp);
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "MGClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int MGClusterCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read names file
-               if (namefile != "") {
-                       nameMap = new NameAssignment(namefile);
-                       nameMap->readMap();
-               }else{ nameMap= new NameAssignment(); }
-               
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(blastfile));
-               string tag = "";
-               time_t start;
-               float previousDist = 0.00000;
-               float rndPreviousDist = 0.00000;
-               
-               //read blastfile - creates sparsematrices for the distances and overlaps as well as a listvector
-               //must remember to delete those objects here since readBlast does not
-               read = new ReadBlast(blastfile, cutoff, penalty, length, minWanted, hclusterWanted);
-               read->read(nameMap);
-               
-               list = new ListVector(nameMap->getListVector());
-               RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
-               
-               if (m->control_pressed) { outputTypes.clear(); delete nameMap; delete read; delete list; delete rabund; return 0; }
-               
-               start = time(NULL);
-               oldList = *list;
-               map<string, int> Seq2Bin;
-               map<string, int> oldSeq2Bin;
-               
-               if (method == "furthest")               { tag = "fn";  }
-               else if (method == "nearest")   { tag = "nn";  }
-               else                                                    { tag = "an";  }
-               
-               //open output files
-               m->openOutputFile(fileroot+ tag + ".list",  listFile);
-               m->openOutputFile(fileroot+ tag + ".rabund",  rabundFile);
-               m->openOutputFile(fileroot+ tag + ".sabund",  sabundFile);
-               
-               if (m->control_pressed) { 
-                       delete nameMap; delete read; delete list; delete rabund; 
-                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                       outputTypes.clear();
-                       return 0; 
-               }
-               
-               double saveCutoff = cutoff;
-               
-               if (!hclusterWanted) {
-                       //get distmatrix and overlap
-                       SparseMatrix* distMatrix = read->getDistMatrix();
-                       overlapMatrix = read->getOverlapMatrix(); //already sorted by read 
-                       delete read;
-               
-                       //create cluster
-                       if (method == "furthest")       {       cluster = new CompleteLinkage(rabund, list, distMatrix, cutoff, method); }
-                       else if(method == "nearest"){   cluster = new SingleLinkage(rabund, list, distMatrix, cutoff, method); }
-                       else if(method == "average"){   cluster = new AverageLinkage(rabund, list, distMatrix, cutoff, method); }
-                       cluster->setMapWanted(true);
-                       Seq2Bin = cluster->getSeqtoBin();
-                       oldSeq2Bin = Seq2Bin;
-                       
-                       if (m->control_pressed) { 
-                               delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
-                               listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                               outputTypes.clear();
-                               return 0; 
-                       }
-               
-                       //cluster using cluster classes
-                       while (distMatrix->getSmallDist() < cutoff && distMatrix->getNNodes() > 0){
-                               
-                               cluster->update(cutoff);
-                               
-                               if (m->control_pressed) { 
-                                       delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster;
-                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                       outputTypes.clear();
-                                       return 0; 
-                               }
-                               
-                               float dist = distMatrix->getSmallDist();
-                               float rndDist;
-                               if (hard) {
-                                       rndDist = m->ceilDist(dist, precision); 
-                               }else{
-                                       rndDist = m->roundDist(dist, precision); 
-                               }
-                               
-                               if(previousDist <= 0.0000 && dist != previousDist){
-                                       oldList.setLabel("unique");
-                                       printData(&oldList);
-                               }
-                               else if(rndDist != rndPreviousDist){
-                                       if (merge) {
-                                               ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
-                                               
-                                               if (m->control_pressed) { 
-                                                       delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
-                                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                                       outputTypes.clear();
-                                                       return 0; 
-                                               }
-                                               
-                                               temp->setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                               printData(temp);
-                                               delete temp;
-                                       }else{
-                                               oldList.setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                               printData(&oldList);
-                                       }
-                               }
-       
-                               previousDist = dist;
-                               rndPreviousDist = rndDist;
-                               oldList = *list;
-                               Seq2Bin = cluster->getSeqtoBin();
-                               oldSeq2Bin = Seq2Bin;
-                       }
-                       
-                       if(previousDist <= 0.0000){
-                               oldList.setLabel("unique");
-                               printData(&oldList);
-                       }
-                       else if(rndPreviousDist<cutoff){
-                               if (merge) {
-                                       ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
-                                       
-                                       if (m->control_pressed) { 
-                                                       delete nameMap; delete distMatrix; delete list; delete rabund; delete cluster; delete temp;
-                                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                                       outputTypes.clear();
-                                                       return 0; 
-                                       }
-                                       
-                                       temp->setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                       printData(temp);
-                                       delete temp;
-                               }else{
-                                       oldList.setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                       printData(&oldList);
-                               }
-                       }
-                       
-                       //free memory
-                       overlapMatrix.clear();
-                       delete distMatrix;
-                       delete cluster;
-                       
-               }else { //use hcluster to cluster
-                       //get distmatrix and overlap
-                       overlapFile = read->getOverlapFile();
-                       distFile = read->getDistFile(); 
-                       delete read;
-               
-                       //sort the distance and overlap files
-                       sortHclusterFiles(distFile, overlapFile);
-                       
-                       if (m->control_pressed) { 
-                               delete nameMap;  delete list; delete rabund; 
-                               listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                               outputTypes.clear();
-                               return 0; 
-                       }
-               
-                       //create cluster
-                       hcluster = new HCluster(rabund, list, method, distFile, nameMap, cutoff);
-                       hcluster->setMapWanted(true);
-                       Seq2Bin = cluster->getSeqtoBin();
-                       oldSeq2Bin = Seq2Bin;
-                       
-                       vector<seqDist> seqs; seqs.resize(1); // to start loop
-                       //ifstream inHcluster;
-                       //m->openInputFile(distFile, inHcluster);
-                       
-                       if (m->control_pressed) { 
-                               delete nameMap;  delete list; delete rabund; delete hcluster;
-                               listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                               outputTypes.clear();
-                               return 0; 
-                       }
-
-                       while (seqs.size() != 0){
-               
-                               seqs = hcluster->getSeqs();
-                               
-                               //to account for cutoff change in average neighbor
-                               if (seqs.size() != 0) {
-                                       if (seqs[0].dist > cutoff) { break; }
-                               }
-                               
-                               if (m->control_pressed) { 
-                                       delete nameMap;  delete list; delete rabund; delete hcluster;
-                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                       m->mothurRemove(distFile);
-                                       m->mothurRemove(overlapFile);
-                                       outputTypes.clear();
-                                       return 0; 
-                               }
-                               
-                               for (int i = 0; i < seqs.size(); i++) {  //-1 means skip me
-                                       
-                                       if (seqs[i].seq1 != seqs[i].seq2) {
-               
-                                               cutoff = hcluster->update(seqs[i].seq1, seqs[i].seq2, seqs[i].dist);
-                                               
-                                               if (m->control_pressed) { 
-                                                       delete nameMap;  delete list; delete rabund; delete hcluster;
-                                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                                       m->mothurRemove(distFile);
-                                                       m->mothurRemove(overlapFile);
-                                                       outputTypes.clear();
-                                                       return 0; 
-                                               }
-       
-                                               float rndDist;
-                                               if (hard) {
-                                                       rndDist = m->ceilDist(seqs[i].dist, precision); 
-                                               }else{
-                                                       rndDist = m->roundDist(seqs[i].dist, precision); 
-                                               }
-                                                                                               
-                                               if((previousDist <= 0.0000) && (seqs[i].dist != previousDist)){
-                                                       oldList.setLabel("unique");
-                                                       printData(&oldList);
-                                               }
-                                               else if((rndDist != rndPreviousDist)){
-                                                       if (merge) {
-                                                               ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
-                                                               
-                                                               if (m->control_pressed) { 
-                                                                       delete nameMap;  delete list; delete rabund; delete hcluster; delete temp;
-                                                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                                                       m->mothurRemove(distFile);
-                                                                       m->mothurRemove(overlapFile);
-                                                                       outputTypes.clear();
-                                                                       return 0; 
-                                                               }
-
-                                                               temp->setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                                               printData(temp);
-                                                               delete temp;
-                                                       }else{
-                                                               oldList.setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                                               printData(&oldList);
-                                                       }
-                                               }
-                                               
-                                               previousDist = seqs[i].dist;
-                                               rndPreviousDist = rndDist;
-                                               oldList = *list;
-                                               Seq2Bin = cluster->getSeqtoBin();
-                                               oldSeq2Bin = Seq2Bin;
-                                       }
-                               }
-                       }
-                       //inHcluster.close();
-                       
-                       if(previousDist <= 0.0000){
-                               oldList.setLabel("unique");
-                               printData(&oldList);
-                       }
-                       else if(rndPreviousDist<cutoff){
-                               if (merge) {
-                                       ListVector* temp = mergeOPFs(oldSeq2Bin, rndPreviousDist);
-                                       
-                                       if (m->control_pressed) { 
-                                                       delete nameMap; delete list; delete rabund; delete hcluster; delete temp;
-                                                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                                                       m->mothurRemove(distFile);
-                                                       m->mothurRemove(overlapFile);
-                                                       outputTypes.clear();
-                                                       return 0; 
-                                       }
-                                       
-                                       temp->setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                       printData(temp);
-                                       delete temp;
-                               }else{
-                                       oldList.setLabel(toString(rndPreviousDist,  precisionLength-1));
-                                       printData(&oldList);
-                               }
-                       }
-                       
-                       delete hcluster;
-                       m->mothurRemove(distFile);
-                       m->mothurRemove(overlapFile);
-               }
-               
-               delete list; 
-               delete rabund;
-               listFile.close();
-               sabundFile.close();
-               rabundFile.close();
-       
-               if (m->control_pressed) { 
-                       delete nameMap; 
-                       listFile.close(); rabundFile.close(); sabundFile.close(); m->mothurRemove((fileroot+ tag + ".list")); m->mothurRemove((fileroot+ tag + ".rabund")); m->mothurRemove((fileroot+ tag + ".sabund"));
-                       outputTypes.clear();
-                       return 0; 
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(fileroot+ tag + ".list"); m->mothurOutEndLine();   outputNames.push_back(fileroot+ tag + ".list"); outputTypes["list"].push_back(fileroot+ tag + ".list");
-               m->mothurOut(fileroot+ tag + ".rabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".rabund"); outputTypes["rabund"].push_back(fileroot+ tag + ".rabund");
-               m->mothurOut(fileroot+ tag + ".sabund"); m->mothurOutEndLine(); outputNames.push_back(fileroot+ tag + ".sabund"); outputTypes["sabund"].push_back(fileroot+ tag + ".sabund");
-               m->mothurOutEndLine();
-               
-               if (saveCutoff != cutoff) { 
-                       if (hard)       {  saveCutoff = m->ceilDist(saveCutoff, precision);     }
-                       else            {       saveCutoff = m->roundDist(saveCutoff, precision);  }
-                       
-                       m->mothurOut("changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); 
-               }
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " seconds to cluster."); m->mothurOutEndLine();
-                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void MGClusterCommand::printData(ListVector* mergedList){
-       try {
-               mergedList->print(listFile);
-               mergedList->getRAbundVector().print(rabundFile);
-               
-               SAbundVector sabund = mergedList->getSAbundVector();
-
-               sabund.print(cout);
-               sabund.print(sabundFile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "printData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//this merging is just at the reporting level, after this info is printed to the file it is gone and does not effect the datastructures
-//that are used to cluster by distance.  this is done so that the overlapping data does not have more influenece than the distance data.
-ListVector* MGClusterCommand::mergeOPFs(map<string, int> binInfo, float dist){
-       try {
-               //create new listvector so you don't overwrite the clustering
-               ListVector* newList = new ListVector(oldList);
-
-               bool done = false;
-               ifstream inOverlap;
-               int count = 0;
-               
-               if (hclusterWanted) {  
-                       m->openInputFile(overlapFile, inOverlap);  
-                       if (inOverlap.eof()) {  done = true;  }
-               }else { if (overlapMatrix.size() == 0)  {  done = true;  } } 
-               
-               while (!done) {
-                       if (m->control_pressed) { 
-                               if (hclusterWanted) {   inOverlap.close();  }           
-                               return newList;
-                       }
-                       
-                       //get next overlap
-                       seqDist overlapNode;
-                       if (!hclusterWanted) {  
-                               if (count < overlapMatrix.size()) { //do we have another node in the matrix
-                                       overlapNode = overlapMatrix[count];
-                                       count++;
-                               }else { break; }
-                       }else { 
-                               if (!inOverlap.eof()) {
-                                       string firstName, secondName;
-                                       float overlapDistance;
-                                       inOverlap >> firstName >> secondName >> overlapDistance; m->gobble(inOverlap);
-                                       
-                                       //commented out because we check this in readblast already
-                                       //map<string,int>::iterator itA = nameMap->find(firstName);
-                                       //map<string,int>::iterator itB = nameMap->find(secondName);
-                                       //if(itA == nameMap->end()){  cerr << "AAError: Sequence '" << firstName << "' was not found in the names file, please correct\n"; exit(1);  }
-                                       //if(itB == nameMap->end()){  cerr << "ABError: Sequence '" << secondName << "' was not found in the names file, please correct\n"; exit(1);  }
-                                       
-                                       //overlapNode.seq1 = itA->second;
-                                       //overlapNode.seq2 = itB->second;
-                                       overlapNode.seq1 = nameMap->get(firstName);
-                                       overlapNode.seq2 = nameMap->get(secondName);
-                                       overlapNode.dist = overlapDistance;
-                               }else { inOverlap.close(); break; }
-                       } 
-               
-                       if (overlapNode.dist < dist) {
-                               //get names of seqs that overlap
-                               string name1 = nameMap->get(overlapNode.seq1);
-                               string name2 = nameMap->get(overlapNode.seq2);
-                       
-                               //use binInfo to find out if they are already in the same bin
-                               //map<string, int>::iterator itBin1 = binInfo.find(name1);
-                               //map<string, int>::iterator itBin2 = binInfo.find(name2);
-                               
-                               //if(itBin1 == binInfo.end()){  cerr << "AAError: Sequence '" << name1 << "' does not have any bin info.\n"; exit(1);  }
-                               //if(itBin2 == binInfo.end()){  cerr << "ABError: Sequence '" << name2 << "' does not have any bin info.\n"; exit(1);  }
-
-                               //int binKeep = itBin1->second;
-                               //int binRemove = itBin2->second;
-                               
-                               int binKeep = binInfo[name1];
-                               int binRemove = binInfo[name2];
-                       
-                               //if not merge bins and update binInfo
-                               if(binKeep != binRemove) {
-               
-                                       //save names in old bin
-                                       string names = newList->get(binRemove);
-               
-                                       //merge bins into name1s bin
-                                       newList->set(binKeep, newList->get(binRemove)+','+newList->get(binKeep));
-                                       newList->set(binRemove, "");    
-                                       
-                                       //update binInfo
-                                       while (names.find_first_of(',') != -1) { 
-                                               //get name from bin
-                                               string name = names.substr(0,names.find_first_of(','));
-                                               //save name and bin number
-                                               binInfo[name] = binKeep;
-                                               names = names.substr(names.find_first_of(',')+1, names.length());
-                                       }
-                                       
-                                       //get last name
-                                       binInfo[names] = binKeep;
-                               }
-                               
-                       }else { done = true; }
-               }
-               
-               //return listvector
-               return newList;
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "mergeOPFs");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void MGClusterCommand::sortHclusterFiles(string unsortedDist, string unsortedOverlap) {
-       try {
-               //sort distFile
-               string sortedDistFile = m->sortFile(unsortedDist, outputDir);
-               m->mothurRemove(unsortedDist);  //delete unsorted file
-               distFile = sortedDistFile;
-               
-               //sort overlap file
-               string sortedOverlapFile = m->sortFile(unsortedOverlap, outputDir);
-               m->mothurRemove(unsortedOverlap);  //delete unsorted file
-               overlapFile = sortedOverlapFile;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MGClusterCommand", "sortHclusterFiles");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
-
-
diff --git a/mgclustercommand.h b/mgclustercommand.h
deleted file mode 100644 (file)
index df0c526..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef MGCLUSTERCOMMAND_H
-#define MGCLUSTERCOMMAND_H
-
-/*
- *  mgclustercommand.h
- *  Mothur
- *
- *  Created by westcott on 12/11/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readblast.h"
-#include "sparsematrix.hpp"
-#include "nameassignment.hpp"
-#include "cluster.hpp"
-#include "hcluster.h"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-
-/**********************************************************************/
-
-class MGClusterCommand : public Command {
-
-public:
-       MGClusterCommand(string);
-       MGClusterCommand();
-       ~MGClusterCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "mgcluster";   }
-       string getCommandCategory()             { return "Clustering";  }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Handelsman J (2008). A statistical toolbox for metagenomics. BMC Bioinformatics 9: 34. \nhttp://www.mothur.org/wiki/Mgcluster"; }
-       string getDescription()         { return "cluster your sequences into OTUs using a blast file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       ReadBlast* read;
-       NameAssignment* nameMap;
-       Cluster* cluster;
-       HCluster* hcluster;
-       ListVector* list;
-       ListVector oldList;
-       vector<seqDist> overlapMatrix;
-       vector<string> outputNames;
-       
-       string blastfile, method, namefile, overlapFile, distFile, outputDir;
-       ofstream sabundFile, rabundFile, listFile;
-       double cutoff;
-       float penalty;
-       int precision, length, precisionLength;
-       bool abort, minWanted, hclusterWanted, merge, hard;
-       
-       void printData(ListVector*);
-       ListVector* mergeOPFs(map<string, int>, float);
-       void sortHclusterFiles(string, string);
-       vector<seqDist> getSeqs(ifstream&);
-
-};
-
-/**********************************************************************/
-
-#endif
-
-
-
diff --git a/mothur.cpp b/mothur.cpp
deleted file mode 100644 (file)
index accdb29..0000000
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- *  interface.cpp
- *  
- *
- *  Created by Pat Schloss on 8/14/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-#include "mothur.h"
-#include "engine.hpp"
-#include "mothurout.h"
-#include "referencedb.h"
-
-/**************************************************************************************************/
-
-CommandFactory* CommandFactory::_uniqueInstance = 0;
-MothurOut* MothurOut::_uniqueInstance = 0;
-ReferenceDB* ReferenceDB::myInstance = 0;
-/***********************************************************************/
-volatile int ctrlc_pressed = 0;
-void ctrlc_handler ( int sig ) {
-       MothurOut* m = MothurOut::getInstance();
-    ctrlc_pressed = 1;
-       m->control_pressed = ctrlc_pressed;
-       
-       if (m->executing) { //if mid command quit execution, else quit mothur
-               m->mothurOutEndLine(); m->mothurOut("quitting command...");  m->mothurOutEndLine();
-       }else{
-               m->mothurOut("quitting mothur");  m->mothurOutEndLine();
-               exit(1);
-       }
-}
-/***********************************************************************/
-int main(int argc, char *argv[]){
-       MothurOut* m = MothurOut::getInstance();
-       try {   
-               signal(SIGINT, ctrlc_handler );
-                               
-               time_t ltime = time(NULL); /* calendar time */  
-               string logFileName = "mothur." + toString(ltime) + ".logfile";
-               
-               #ifdef USE_MPI
-                       MPI_Init(&argc, &argv); 
-               #endif
-
-               m->setFileName(logFileName);
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       system("clear");
-               #else
-                       system("CLS");
-               #endif
-               
-               #ifdef MOTHUR_FILES
-                       string temp = MOTHUR_FILES; 
-               
-                       //add / to name if needed
-                       string lastChar = temp.substr(temp.length()-1);
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               if (lastChar != "/") { temp += "/"; }
-                       #else
-                               if (lastChar != "\\") { temp += "\\"; } 
-                       #endif
-               
-                       temp = m->getFullPathName(temp);
-                       m->setDefaultPath(temp);
-               #endif
-               
-               #ifdef USE_MPI
-                       int version, subversion;
-                       MPI_Get_version(&version, &subversion);
-               #endif
-               
-               //get releaseDate from Make
-               string releaseDate = RELEASE_DATE; 
-               string mothurVersion = VERSION; 
-               m->setReleaseDate(releaseDate);
-               m->setVersion(mothurVersion);
-               
-               //will make the gui output "pretty"
-               bool outputHeader = true;
-               if (argc>1) {
-                       string guiInput = argv[1];
-                       if (guiInput[0] == '+') { outputHeader = false; }
-                       if (guiInput[0] == '-') { outputHeader = false; }
-               }
-               
-               if (outputHeader)  {
-                       //version
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               #if defined (__APPLE__) || (__MACH__)
-                                       m->mothurOutJustToLog("Mac version");
-                                       m->mothurOutEndLine(); m->mothurOutEndLine();
-                               #else
-                                       m->mothurOutJustToLog("Linux version");
-                                       m->mothurOutEndLine(); m->mothurOutEndLine();
-                               #endif
-
-                       #else
-                               m->mothurOutJustToLog("Windows version");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                       #endif          
-                       
-                       #ifdef USE_READLINE
-                               m->mothurOutJustToLog("Using ReadLine");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                       #endif
-                       
-                       #ifdef MOTHUR_FILES
-                               m->mothurOutJustToLog("Using default file location " + temp);
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                       #endif
-                       
-                       #ifdef BIT_VERSION
-                               m->mothurOutJustToLog("Running 64Bit Version");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                       #else
-                               m->mothurOutJustToLog("Running 32Bit Version");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                       #endif
-                       
-                       //header
-                       m->mothurOut("mothur v." + mothurVersion);
-                       m->mothurOutEndLine();          
-                       m->mothurOut("Last updated: " + releaseDate);
-                       m->mothurOutEndLine();  
-                       m->mothurOutEndLine();          
-                       m->mothurOut("by");
-                       m->mothurOutEndLine();          
-                       m->mothurOut("Patrick D. Schloss");
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine();                  
-                       m->mothurOut("Department of Microbiology & Immunology");
-                       m->mothurOutEndLine();  
-                       m->mothurOut("University of Michigan");
-                       m->mothurOutEndLine();                  
-                       m->mothurOut("pschloss@umich.edu");
-                       m->mothurOutEndLine();          
-                       m->mothurOut("http://www.mothur.org");
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine();
-                       m->mothurOut("When using, please cite:");
-                       m->mothurOutEndLine();
-                       m->mothurOut("Schloss, P.D., et al., Introducing mothur: Open-source, platform-independent, community-supported software for describing and comparing microbial communities. Appl Environ Microbiol, 2009. 75(23):7537-41.");
-                       m->mothurOutEndLine();  
-                       m->mothurOutEndLine();          
-                       m->mothurOut("Distributed under the GNU General Public License");
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine();                  
-                       m->mothurOut("Type 'help()' for information on the commands that are available");
-                       m->mothurOutEndLine();
-                       m->mothurOutEndLine();                  
-                       m->mothurOut("Type 'quit()' to exit program");
-                       m->mothurOutEndLine();  
-                       
-                       #ifdef USE_MPI
-                               m->mothurOutJustToLog("Using MPI\tversion ");
-                               m->mothurOutJustToLog(toString(version) + "." + toString(subversion) + "\n");
-                       #endif
-               }
-               
-               //srand(54321);
-               srand( (unsigned)time( NULL ) );
-               
-               Engine* mothur = NULL;
-               bool bail = 0;
-               string input;
-               if(argc>1){
-                       input = argv[1];
-                       //m->mothurOut("input = " + input); m->mothurOutEndLine();
-
-                       if (input[0] == '#') {
-                               m->mothurOutJustToLog("Script Mode");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-
-                               mothur = new ScriptEngine(argv[0], argv[1]);
-                       }else if (input[0] == '+') {
-                                       mothur = new ScriptEngine(argv[0], argv[1]);
-                                       m->gui = true;
-                       }else if (input == "-version") {
-                               m->mothurOut("Mothur version=" + mothurVersion + "\nRelease Date=" + releaseDate); m->mothurOutEndLine(); m->mothurOutEndLine(); m->closeLog();
-                               #ifdef USE_MPI
-                                       MPI_Finalize();
-                               #endif
-                               return 0;
-                       }else{
-                               m->mothurOutJustToLog("Batch Mode");
-                               m->mothurOutEndLine(); m->mothurOutEndLine();
-                               
-                               mothur = new BatchEngine(argv[0], argv[1]);
-                       }
-               }
-               else{
-                       m->mothurOutJustToLog("Interactive Mode");
-                       m->mothurOutEndLine(); m->mothurOutEndLine();
-                       
-                       mothur = new InteractEngine(argv[0]);   
-               }
-               
-               while(bail == 0)        {       bail = mothur->getInput();      }
-               
-               //closes logfile so we can rename
-               m->closeLog();
-               
-               string outputDir = mothur->getOutputDir();
-               string tempLog = mothur->getLogFileName();
-               bool append = mothur->getAppend();
-               
-               string newlogFileName;
-               if (tempLog != "") {
-                       newlogFileName = outputDir + tempLog;
-                       
-                       if (!append) {  
-                               //need this because m->mothurOut makes the logfile, but doesn't know where to put it
-                               rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
-
-                       }else {
-                               ofstream outNewLog;
-                               m->openOutputFileAppend(newlogFileName, outNewLog);
-                               
-                               if (!m->gui) {
-                                       outNewLog << endl << endl << "*********************************************************************************" << endl << endl;
-                               }else {
-                                       outNewLog << endl;
-                               }
-                               outNewLog.close();
-                               
-                               m->appendFiles(logFileName, newlogFileName);
-                               m->mothurRemove(logFileName);
-                       }
-               }else{  
-                       newlogFileName = outputDir + logFileName;
-                       //need this because m->mothurOut makes the logfile, but doesn't know where to put it
-                       rename(logFileName.c_str(), newlogFileName.c_str()); //logfile with timestamp
-               }
-               
-                               
-               if (mothur != NULL) { delete mothur; }
-               
-               #ifdef USE_MPI
-                       MPI_Finalize();
-               #endif
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "mothur", "main");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
diff --git a/mothur.h b/mothur.h
deleted file mode 100644 (file)
index 2c143e8..0000000
--- a/mothur.h
+++ /dev/null
@@ -1,285 +0,0 @@
-#ifndef MOTHUR_H
-#define MOTHUR_H
-
-
-
-/*
- *  mothur.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/19/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This file contains all the standard incudes we use in the project as well as some common utilities. */
-
-//#include <cstddef>
-
-//io libraries
-#include <iostream>
-#include <iomanip>
-#include <fstream>
-#include <sstream>
-#include <signal.h>
-
-
-//exception
-#include <stdexcept>
-#include <exception>
-#include <cstdlib> 
-
-
-//containers
-#include <vector>
-#include <set>
-#include <map>
-#include <string>
-#include <list>
-#include <string.h>
-
-//math
-#include <cmath>
-#include <math.h>
-#include <algorithm>
-#include <numeric>
-
-//misc
-#include <cerrno>
-#include <ctime>
-#include <limits>
-
-#ifdef USE_MPI
-       #include "mpi.h"
-#endif
-/***********************************************************************/
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-       #include <sys/wait.h>
-       #include <sys/time.h>
-       #include <sys/resource.h>
-       #include <sys/types.h>
-       #include <sys/stat.h>
-       #include <unistd.h>
-       
-       #ifdef USE_READLINE
-               #include <readline/readline.h>
-               #include <readline/history.h>
-       #endif
-
-#else
-       #include <conio.h> //allows unbuffered screen capture from stdin
-       #include <direct.h> //get cwd
-       #include <windows.h>
-       #include <psapi.h>
-       #include <direct.h>
-       #include <tchar.h>
-
-#endif
-
-using namespace std;
-
-#define exp(x) (exp((double) x))
-#define sqrt(x) (sqrt((double) x))
-#define log10(x) (log10((double) x))
-#define log2(x) (log10(x)/log10(2))
-#define isnan(x) ((x) != (x))
-#define isinf(x) (fabs(x) == std::numeric_limits<double>::infinity())
-
-
-typedef unsigned long ull;
-
-struct IntNode {
-       int lvalue;
-       int rvalue;
-       int lcoef;
-       int rcoef;
-       IntNode* left;
-       IntNode* right;
-       
-       IntNode(int lv, int rv, IntNode* l, IntNode* r) : lvalue(lv), rvalue(rv), left(l), right(r) {};
-       IntNode() {};
-};
-
-struct ThreadNode {
-       int* pid;
-       IntNode* left;
-       IntNode* right;
-};
-
-struct diffPair {
-       float   prob;
-       float   reverseProb;
-       
-       diffPair() {
-               prob = 0; reverseProb = 0;
-       }
-       diffPair(float p, float rp) {
-               prob = p;
-               reverseProb = rp;
-       }
-};
-
-/************************************************************/
-struct clusterNode {
-       int numSeq;
-       int parent;
-       int smallChild; //used to make linkTable work with list and rabund. represents bin number of this cluster node
-       clusterNode(int num, int par, int kid) : numSeq(num), parent(par), smallChild(kid) {};
-};
-/************************************************************/
-struct seqDist {
-       int seq1;
-       int seq2;
-       double dist;
-       seqDist() {}
-       seqDist(int s1, int s2, double d) : seq1(s1), seq2(s2), dist(d) {}
-       ~seqDist() {}
-};
-/************************************************************/
-struct distlinePair {
-       int start;
-       int end;
-       
-};
-/************************************************************/
-struct seqPriorityNode {
-       int numIdentical;
-       string seq;
-       string name;
-       seqPriorityNode() {}
-       seqPriorityNode(int n, string s, string nm) : numIdentical(n), seq(s), name(nm) {}
-       ~seqPriorityNode() {}
-};
-/***************************************************************/
-struct spearmanRank {
-       string name;
-       float score;
-       
-       spearmanRank(string n, float s) : name(n), score(s) {}
-};
-//********************************************************************************************************************
-//sorts highest to lowest
-inline bool compareSpearman(spearmanRank left, spearmanRank right){
-       return (left.score > right.score);      
-} 
-//********************************************************************************************************************
-//sorts highest to lowest
-inline bool compareSeqPriorityNodes(seqPriorityNode left, seqPriorityNode right){
-       return (left.numIdentical > right.numIdentical);        
-} 
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSpearmanReverse(spearmanRank left, spearmanRank right){
-       return (left.score < right.score);      
-} 
-/************************************************************/
-//sorts lowest to highest
-inline bool compareDistLinePairs(distlinePair left, distlinePair right){
-       return (left.end < right.end);  
-} 
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSequenceDistance(seqDist left, seqDist right){
-       return (left.dist < right.dist);        
-} 
-/***********************************************************************/
-
-// snagged from http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.2
-// works for now, but there should be a way to do it without killing the whole program
-
-class BadConversion : public runtime_error {
-public:
-       BadConversion(const string& s) : runtime_error(s){ }
-};
-
-//**********************************************************************************************************************
-template<typename T>
-void convert(const string& s, T& x, bool failIfLeftoverChars = true){
-       
-               istringstream i(s);
-               char c;
-               if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
-                       throw BadConversion(s);
-       
-}
-//**********************************************************************************************************************
-template <typename T> int sgn(T val){ return (val > T(0)) - (val < T(0)); }
-//**********************************************************************************************************************
-
-template<typename T>
-bool convertTestFloat(const string& s, T& x, bool failIfLeftoverChars = true){
-       
-               istringstream i(s);
-               char c;
-               if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
-               {
-                       return false;
-               } 
-               return true;
-       
-}
-
-//**********************************************************************************************************************
-
-template<typename T>
-bool convertTest(const string& s, T& x, bool failIfLeftoverChars = true){
-       
-               istringstream i(s);
-               char c;
-               if (!(i >> x) || (failIfLeftoverChars && i.get(c)))
-               {
-                       return false;
-               } 
-               return true;
-       
-}
-//**********************************************************************************************************************
-template<typename T>
-string toString(const T&x){
-       
-               stringstream output;
-               output << x;
-               return output.str();
-       
-}
-
-//**********************************************************************************************************************
-
-template<typename T>
-string toHex(const T&x){
-       
-               stringstream output;
-               
-               output << hex << x;
-
-               return output.str();
-       
-}
-//**********************************************************************************************************************
-
-template<typename T>
-string toString(const T&x, int i){
-       
-               stringstream output;
-               
-               output.precision(i);
-               output << fixed << x;
-               
-               return output.str();
-       
-}
-//**********************************************************************************************************************
-
-template<class T>
-T fromString(const string& s){
-       istringstream stream (s);
-       T t;
-       stream >> t;
-       return t;
-}
-
-//**********************************************************************************************************************
-
-#endif
-
diff --git a/mothurfisher.cpp b/mothurfisher.cpp
deleted file mode 100644 (file)
index 7acefb2..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *  mothurfisher.cpp
- *  Mothur
- *
- *  Created by westcott on 7/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-//translated to c++ using source code http://www.langsrud.com/stat/fisher.htm as a reference
-
-#include "mothurfisher.h"
-/***********************************************************/
-double MothurFisher::fexact(double n11_, double n12_, double n21_, double n22_) {
-       try {
-               sleft = 0.0; sright = 0.0; sless = 0.0; slarg = 0.0;
-               
-               if(n11_<0) n11_ *= -1;
-               if(n12_<0) n12_ *= -1;
-               if(n21_<0) n21_ *= -1;
-               if(n22_<0) n22_ *= -1; 
-               
-               double n1_ = n11_+n12_;
-               double n_1 = n11_+n21_;
-               double n   = n11_ +n12_ +n21_ +n22_;
-               exact(n11_,n1_,n_1,n);
-               double twotail = sleft+sright;
-               
-               if(twotail>1) twotail=1;
-               double result = twotail;
-               return result; 
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "fexact");
-               exit(1);
-       }       
-}
-/***********************************************************/
-double MothurFisher::lngamm(double z) {
-       // Reference: "Lanczos, C. 'A precision approximation 
-       // of the gamma function', J. SIAM Numer. Anal., B, 1, 86-96, 1964."
-       // Translation of  Alan Miller's FORTRAN-implementation
-       // See http://lib.stat.cmu.edu/apstat/245
-       try {
-               double x = 0;
-               x += 0.1659470187408462e-06/(z+7);
-               x += 0.9934937113930748e-05/(z+6);
-               x -= 0.1385710331296526    /(z+5);
-               x += 12.50734324009056     /(z+4);
-               x -= 176.6150291498386     /(z+3);
-               x += 771.3234287757674     /(z+2);
-               x -= 1259.139216722289     /(z+1);
-               x += 676.5203681218835     /(z);
-               x += 0.9999999999995183;
-               
-               return(log(x)-5.58106146679532777-z+(z-0.5)*log(z+6.5));
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "lngamm");
-               exit(1);
-       }       
-}
-
-/***********************************************************/
-double MothurFisher::lnfact(double n){
-       try {
-               if(n <= 1) return(0);
-               return(lngamm(n+1));
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "lnfact");
-               exit(1);
-       }       
-}
-/***********************************************************/
-double MothurFisher::lnbico(double n, double k){
-       try {
-               return(lnfact(n)-lnfact(k)-lnfact(n-k));
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "lnbico");
-               exit(1);
-       }
-}
-/***********************************************************/
-double MothurFisher::hyper_323(double n11, double n1_, double n_1, double n){
-       try {
-               return(exp(lnbico(n1_,n11)+lnbico(n-n1_,n_1-n11)-lnbico(n,n_1)));
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "hyper_323");
-               exit(1);
-       }
-}
-/***********************************************************/
-double MothurFisher::myhyper(double n11){
-       try {
-               double hyper0Result = hyper0(n11,0,0,0);
-               return hyper0Result;
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "myhyper");
-               exit(1);
-       }
-}
-/***********************************************************/
-double MothurFisher::hyper0(double n11i, double n1_i, double n_1i, double ni) {
-       try {
-               if (!((n1_i != 0)&&(n_1i != 0)&&(ni != 0))) {
-                       if(!(((int)n11i % 10) == 0)){
-                               if(n11i==sn11+1)  
-                               {
-                                       sprob *= ((sn1_-sn11)/(n11i))*((sn_1-sn11)/(n11i+sn-sn1_-sn_1));
-                                       sn11 = n11i;
-                                       return sprob;
-                               }
-                               if(n11i==sn11-1)
-                               {
-                                       sprob *= ((sn11)/(sn1_-n11i))*((sn11+sn-sn1_-sn_1)/(sn_1-n11i));
-                                       sn11 = n11i;
-                                       return sprob;
-                               }
-                       }
-                       sn11 = n11i;
-               }else{
-                       sn11 = n11i;
-                       sn1_=n1_i;
-                       sn_1=n_1i;
-                       sn=ni;
-               }
-               
-               sprob = hyper_323(sn11,sn1_,sn_1,sn);
-               return sprob;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "hyper0");
-               exit(1);
-       }
-}
-/***********************************************************/
-double MothurFisher::exact(double n11, double n1_, double n_1, double n){
-       try {
-               double p,i,j,prob;
-               double max=n1_;
-               if(n_1<max) max=n_1;
-               double min = n1_+n_1-n;
-               if(min<0) min=0;
-               if(min==max)
-               {
-                       sless = 1;
-                       sright= 1;
-                       sleft = 1;
-                       slarg = 1;
-                       return 1;
-               }
-               prob=hyper0(n11,n1_,n_1,n);
-               sleft=0;
-               p=myhyper(min);
-               for(i=min+1; p<0.99999999*prob; i++)
-               {
-                       sleft += p;
-                       p=myhyper(i);
-               }
-               i--;
-               if(p<1.00000001*prob) sleft += p;
-               else i--;
-               sright=0;
-               p=myhyper(max);
-               for(j=max-1; p<0.99999999*prob; j--)
-               {
-                       sright += p;
-                       p=myhyper(j);
-               }
-               j++;
-               if(p<1.00000001*prob) sright += p;
-               else j++;
-               if(abs(i-n11)<abs(j-n11)) 
-               {
-                       sless = sleft;
-                       slarg = 1 - sleft + prob;
-               } 
-               else 
-               {
-                       sless = 1 - sright + prob;
-                       slarg = sright;
-               }
-               return prob;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurFisher", "exact");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
diff --git a/mothurfisher.h b/mothurfisher.h
deleted file mode 100644 (file)
index 2742f97..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef MOTHUR_FISHER
-#define MOTHUR_FISHER
-
-/*
- *  mothurfisher.h
- *  Mothur
- *
- *  Created by westcott on 7/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothurout.h"
-
-class MothurFisher {
-       
-public:
-       MothurFisher(){}
-       ~MothurFisher(){}
-       
-       double fexact(double, double, double, double);
-       
-private:
-       MothurOut* m;
-       double sleft, sright, sless, slarg;
-       double sn11,sn1_,sn_1,sn,sprob;
-       double lngamm(double);
-       double lnfact(double);
-       double lnbico(double, double);
-       double hyper_323(double, double, double, double);
-       double myhyper(double);
-       double hyper0(double, double, double, double);
-       double exact(double, double, double, double);
-};
-
-
-#endif
-
diff --git a/mothurmetastats.cpp b/mothurmetastats.cpp
deleted file mode 100644 (file)
index 5678973..0000000
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- *  mothurmetastats.cpp
- *  Mothur
- *
- *  Created by westcott on 7/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurmetastats.h"
-#include "mothurfisher.h"
-#include "spline.h"
-
-/***********************************************************/
-MothurMetastats::MothurMetastats(double t, int n) {
-       try {
-               m = MothurOut::getInstance(); 
-               threshold = t;
-               numPermutations = n;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "MothurMetastats");
-               exit(1);
-       }       
-}
-/***********************************************************/
-MothurMetastats::~MothurMetastats() {}
-/***********************************************************/
- //main metastats function
-int MothurMetastats::runMetastats(string outputFileName, vector< vector<double> >& data, int secGroupingStart) {
-    try {
-        row = data.size();              //numBins
-               column = data[0].size(); //numGroups in subset
-        secondGroupingStart = secGroupingStart; //g
-         
-        vector< vector<double> > Pmatrix; Pmatrix.resize(row);
-        for (int i = 0; i < row; i++) { Pmatrix[i].resize(column, 0.0);  } // the relative proportion matrix
-        vector< vector<double> > C1; C1.resize(row);
-        for (int i = 0; i < row; i++) { C1[i].resize(3, 0.0);  } // statistic profiles for class1 and class 2
-        vector< vector<double> > C2; C2.resize(row);            // mean[1], variance[2], standard error[3] 
-        for (int i = 0; i < row; i++) { C2[i].resize(3, 0.0);  } 
-        vector<double> T_statistics; T_statistics.resize(row, 1); // a place to store the true t-statistics 
-        vector<double> pvalues; pvalues.resize(row, 1); // place to store pvalues
-        vector<double> qvalues; qvalues.resize(row, 1); // stores qvalues
-       
-        //*************************************
-        //      convert to proportions
-        //      generate Pmatrix
-        //*************************************
-        vector<double> totals; totals.resize(column, 0); // sum of columns
-        //total[i] = total abundance for group[i]
-               for (int i = 0; i < column; i++) {
-                       for (int j = 0; j < row; j++) {
-                               totals[i] += data[j][i];
-                       }
-        }
-        
-        for (int i = 0; i < column; i++) {
-                       for (int j = 0; j < row; j++) {
-                               Pmatrix[j][i] = data[j][i]/totals[i];
-               
-                       }
-        }
-        
-        //#********************************************************************************
-        //# ************************** STATISTICAL TESTING ********************************
-        //#********************************************************************************
-        
-        if (column == 2){  //# then we have a two sample comparison
-            //#************************************************************
-            //#  generate p values fisher's exact test
-            //#************************************************************
-            double total1, total2;
-                       //total for first grouping
-            for (int i = 0; i < secondGroupingStart; i++) { total1 += totals[i]; }
-            
-            //total for second grouping
-            for (int i = secondGroupingStart; i < column; i++) { total2 += totals[i]; }
-            
-            vector<double> fish;       fish.resize(row, 0.0);
-                       vector<double> fish2;   fish2.resize(row, 0.0);
-            
-                       for(int i = 0; i < row; i++){
-                               
-                               for(int j = 0; j < secondGroupingStart; j++)            { fish[i] += data[i][j];        }
-                               for(int j = secondGroupingStart; j < column; j++)       { fish2[i] += data[i][j];       }
-                               
-                               double f11, f12, f21, f22;
-                               f11 = fish[i];
-                               f12 = fish2[i];
-                               f21 = total1 - fish[i];
-                               f22 = total2 - fish2[i];
-                               
-                               MothurFisher fisher;
-                               double pre = fisher.fexact(f11, f12, f21, f22);
-                               if (pre > 0.999999999)  { pre = 1.0; }
-                
-                               if (m->control_pressed) { return 1; }
-                               
-                               pvalues[i] = pre;
-                       }
-            
-            //#*************************************
-            //#  calculate q values from p values
-            //#*************************************
-            qvalues = calc_qvalues(pvalues);
-            
-        }else { //we have multiple subjects per population
-            
-            //#*************************************
-            //#  generate statistics mean, var, stderr    
-            //#*************************************
-            for(int i = 0; i < row; i++){ // for each taxa
-                //# find the mean of each group
-                double g1Total = 0.0; double g2Total = 0.0;
-                for (int j = 0; j < secondGroupingStart; j++)       {     g1Total += Pmatrix[i][j]; }
-                C1[i][0] = g1Total/(double)(secondGroupingStart);
-                for (int j = secondGroupingStart; j < column; j++)  {     g2Total += Pmatrix[i][j]; }
-                C2[i][0] = g2Total/(double)(column-secondGroupingStart);
-                
-                 //# find the variance of each group
-                double g1Var = 0.0; double g2Var = 0.0;
-                for (int j = 0; j < secondGroupingStart; j++)       {     g1Var += pow((Pmatrix[i][j]-C1[i][0]), 2);  }
-                C1[i][1] = g1Var/(double)(secondGroupingStart-1);
-                for (int j = secondGroupingStart; j < column; j++)  {     g2Var += pow((Pmatrix[i][j]-C2[i][0]), 2);  }
-                C2[i][1] = g2Var/(double)(column-secondGroupingStart-1);
-                
-                //# find the std error of each group -std err^2 (will change to std err at end)
-                C1[i][2] = C1[i][1]/(double)(secondGroupingStart);    
-                C2[i][2] = C2[i][1]/(double)(column-secondGroupingStart);
-            }
-            
-            //#*************************************
-            //#  two sample t-statistics
-            //#*************************************
-            for(int i = 0; i < row; i++){                  // # for each taxa
-                double xbar_diff = C1[i][0] - C2[i][0]; 
-                double denom = sqrt(C1[i][2] + C2[i][2]);
-                T_statistics[i] = xbar_diff/denom;  // calculate two sample t-statistic
-            }
-            
-            /*for (int i = 0; i < row; i++) {  
-                for (int j = 0; j < 3; j++) {
-                    cout << "C1[" << i+1 << "," << j+1 << "]=" << C1[i][j] << ";" << endl;
-                    cout << "C2[" << i+1 << "," << j+1 << "]=" << C2[i][j] << ";" << endl;
-                }
-                cout << "T_statistics[" << i+1 << "]=" << T_statistics[i] << ";" << endl;
-            }*/
-            //#*************************************
-            //# generate initial permuted p-values
-            //#*************************************
-            pvalues = permuted_pvalues(Pmatrix, T_statistics, data);
-            
-            //#*************************************
-            //#  generate p values for sparse data 
-            //#  using fisher's exact test
-            //#*************************************
-            double total1, total2;
-                       //total for first grouping
-            for (int i = 0; i < secondGroupingStart; i++) { total1 += totals[i]; }
-            
-            //total for second grouping
-            for (int i = secondGroupingStart; i < column; i++) { total2 += totals[i]; }
-            
-            vector<double> fish;       fish.resize(row, 0.0);
-                       vector<double> fish2;   fish2.resize(row, 0.0);
-            
-                       for(int i = 0; i < row; i++){
-                               
-                               for(int j = 0; j < secondGroupingStart; j++)            { fish[i] += data[i][j];        }
-                               for(int j = secondGroupingStart; j < column; j++)       { fish2[i] += data[i][j];       }
-                               
-                if ((fish[1] < secondGroupingStart) && (fish2[i] < (column-secondGroupingStart))) {
-                    double f11, f12, f21, f22;
-                    f11 = fish[i];
-                    f12 = fish2[i];
-                    f21 = total1 - fish[i];
-                    f22 = total2 - fish2[i];
-                               
-                    MothurFisher fisher;
-                    double pre = fisher.fexact(f11, f12, f21, f22);
-                    if (pre > 0.999999999)     { pre = 1.0; }
-                
-                    if (m->control_pressed) { return 1; }
-                               
-                    pvalues[i] = pre;
-                }
-                       }
-
-            //#*************************************
-            //#  calculate q values from p values
-            //#*************************************
-            qvalues = calc_qvalues(pvalues);
-            
-            //#*************************************
-            //#  convert stderr^2 to std error
-            //#*************************************
-            for(int i = 0; i < row; i++){
-                C1[i][2] = sqrt(C1[i][2]);
-                C2[i][2] = sqrt(C2[i][2]);
-            }
-        }
-        
-        // And now we write the files to a text file.
-               struct tm *local;
-               time_t t; t = time(NULL);
-               local = localtime(&t);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-        
-               out << "Local time and date of test: " << asctime(local) << endl;
-               out << "# rows = " << row << ", # col = " << column << ", g = " << secondGroupingStart << endl << endl;
-               out << numPermutations << " permutations" << endl << endl;      
-               
-               //output column headings - not really sure... documentation labels 9 columns, there are 10 in the output file
-               //storage 0 = meanGroup1 - line 529, 1 = varGroup1 - line 532, 2 = err rate1 - line 534, 3 = mean of counts group1?? - line 291, 4 = meanGroup2 - line 536, 5 = varGroup2 - line 539, 6 = err rate2 - line 541, 7 = mean of counts group2?? - line 292, 8 = pvalues - line 293
-               out << "OTU\tmean(group1)\tvariance(group1)\tstderr(group1)\tmean(group2)\tvariance(group2)\tstderr(group2)\tp-value\tq-value\n";
-               
-               for(int i = 0; i < row; i++){
-                       if (m->control_pressed) { out.close(); return 0; }
-                       
-            //if there are binlabels use them otherwise count.
-                       if (m->binLabelsInFile.size() == row) { out << m->binLabelsInFile[i] << '\t'; }
-            else { out << (i+1) << '\t'; }
-            
-            out << C1[i][0] << '\t' << C1[i][1] << '\t' << C1[i][2] << '\t' << C2[i][0] << '\t' << C2[i][1] << '\t' << C2[i][2] << '\t' << pvalues[i] << '\t' << qvalues[i] << endl;
-               }  
-               
-               out << endl << endl;
-               out.close();
-               
-
-
-        return 0;
-        
-    }catch(exception& e) {
-        m->errorOut(e, "MothurMetastats", "runMetastats");
-        exit(1);
-    }  
-}
-/***********************************************************/
-vector<double> MothurMetastats::permuted_pvalues(vector< vector<double> >& Imatrix, vector<double>& tstats, vector< vector<double> >& Fmatrix) {
-       try {
-        //# matrix stores tstats for each taxa(row) for each permuted trial(column)
-        vector<double> ps;  ps.resize(row, 0.0); //# to store the pvalues
-        vector< vector<double> > permuted_ttests; permuted_ttests.resize(numPermutations);            
-        for (int i = 0; i < numPermutations; i++) { permuted_ttests[i].resize(row, 0.0);  } 
-        //# calculate null version of tstats using B permutations.
-        for (int i = 0; i < numPermutations; i++) {   
-            permuted_ttests[i] = permute_and_calc_ts(Imatrix);
-        }
-        
-        //# calculate each pvalue using the null ts
-        if ((secondGroupingStart) < 8 || (column-secondGroupingStart) < 8){
-            vector< vector<double> > cleanedpermuted_ttests; cleanedpermuted_ttests.resize(numPermutations);  //# the array pooling just the frequently observed ts
-            //# then pool the t's together!
-            //# count how many high freq taxa there are
-            int hfc = 1;
-            for (int i = 0; i < row; i++) {                 // # for each taxa
-                double group1Total = 0.0; double group2Total = 0.0;
-                for(int j = 0; j < secondGroupingStart; j++)           { group1Total += Fmatrix[i][j]; }
-                               for(int j = secondGroupingStart; j < column; j++)       { group2Total += Fmatrix[i][j]; }
-                
-                if (group1Total >= secondGroupingStart || group2Total >= (column-secondGroupingStart)){ 
-                    hfc++;
-                    for (int j = 0; j < numPermutations; j++) {   cleanedpermuted_ttests[j].push_back(permuted_ttests[j][i]); }
-                }
-            }
-              
-            //#now for each taxa
-            for (int i = 0; i < row; i++) { 
-                //number of cleanedpermuted_ttests greater than tstat[i]
-                int numGreater = 0;
-                for (int j = 0; j < numPermutations; j++) {
-                    for (int k = 0; k < hfc; k++) {
-                        if (cleanedpermuted_ttests[j][k] > abs(tstats[i])) { numGreater++; }
-                    }
-                }
-                
-                ps[i] = (1/(double)(numPermutations*hfc))*numGreater;
-            }
-        }else{
-            for (int i = 0; i < row; i++) { 
-                //number of permuted_ttests[i] greater than tstat[i] //(sum(permuted_ttests[i,] > abs(tstats[i]))+1)
-                int numGreater = 1;
-                for (int j = 0; j < numPermutations; j++) { if (permuted_ttests[j][i] > abs(tstats[i])) { numGreater++; }   }
-                ps[i] = (1/(double)(numPermutations+1))*numGreater;
-            }
-        }
-        
-        return ps;
-        
-    }catch(exception& e) {
-        m->errorOut(e, "MothurMetastats", "permuted_pvalues");
-        exit(1);
-    }  
-}
-/***********************************************************/
-vector<double> MothurMetastats::permute_and_calc_ts(vector< vector<double> >& Imatrix) {
-       try {
-        vector< vector<double> > permutedMatrix = Imatrix;
-        
-        //randomize columns, ie group abundances.
-        for (int i = 0; i < permutedMatrix.size(); i++) {   random_shuffle(permutedMatrix[i].begin(), permutedMatrix[i].end());     }
-        
-        //calc ts
-        vector< vector<double> > C1; C1.resize(row);
-        for (int i = 0; i < row; i++) { C1[i].resize(3, 0.0);  } // statistic profiles for class1 and class 2
-        vector< vector<double> > C2; C2.resize(row);            // mean[1], variance[2], standard error[3] 
-        for (int i = 0; i < row; i++) { C2[i].resize(3, 0.0);  } 
-        vector<double> Ts; Ts.resize(row, 0.0); // a place to store the true t-statistics 
-
-        //#*************************************
-        //#  generate statistics mean, var, stderr    
-        //#*************************************
-        for(int i = 0; i < row; i++){ // for each taxa
-            //# find the mean of each group
-            double g1Total = 0.0; double g2Total = 0.0;
-            for (int j = 0; j < secondGroupingStart; j++)       {     g1Total += permutedMatrix[i][j]; }
-            C1[i][0] = g1Total/(double)(secondGroupingStart);
-            for (int j = secondGroupingStart; j < column; j++)  {     g2Total += permutedMatrix[i][j]; }
-            C2[i][0] = g2Total/(double)(column-secondGroupingStart);
-            
-            //# find the variance of each group
-            double g1Var = 0.0; double g2Var = 0.0;
-            for (int j = 0; j < secondGroupingStart; j++)       {     g1Var += pow((permutedMatrix[i][j]-C1[i][0]), 2);  }
-            C1[i][1] = g1Var/(double)(secondGroupingStart-1);
-            for (int j = secondGroupingStart; j < column; j++)  {     g2Var += pow((permutedMatrix[i][j]-C2[i][0]), 2);  }
-            C2[i][1] = g2Var/(double)(column-secondGroupingStart-1);
-            
-            //# find the std error of each group -std err^2 (will change to std err at end)
-            C1[i][2] = C1[i][1]/(double)(secondGroupingStart);    
-            C2[i][2] = C2[i][1]/(double)(column-secondGroupingStart);
-        }
-        
-        //#*************************************
-        //#  two sample t-statistics
-        //#*************************************
-        for(int i = 0; i < row; i++){                  // # for each taxa
-            double xbar_diff = C1[i][0] - C2[i][0]; 
-            double denom = sqrt(C1[i][2] + C2[i][2]);
-            Ts[i] = abs(xbar_diff/denom);  // calculate two sample t-statistic
-        }
-
-        return Ts;
-
-        
-    }catch(exception& e) {
-        m->errorOut(e, "MothurMetastats", "permuted_ttests");
-        exit(1);
-    }  
-}
-/***********************************************************/
-vector<double> MothurMetastats::calc_qvalues(vector<double>& pValues) {
-       try {
-               
-       /* cout << "x <- c(" << pValues[0];
-        for (int l = 1; l < pValues.size(); l++){
-            cout << ", " << pValues[l];
-        }
-        cout << ")\n";*/
-        
-               int numRows = pValues.size();
-               vector<double> qvalues(numRows, 0.0);
-
-               //fill lambdas with 0.00, 0.01, 0.02... 0.95
-               vector<double> lambdas(96, 0);
-               for (int i = 1; i < lambdas.size(); i++) { lambdas[i] = lambdas[i-1] + 0.01; }
-               
-               vector<double> pi0_hat(lambdas.size(), 0);
-               
-               //calculate pi0_hat
-               for (int l = 0; l < lambdas.size(); l++){ // for each lambda value
-                       int count = 0;
-                       for (int i = 0; i < numRows; i++){ // for each p-value in order
-                               if (pValues[i] > lambdas[l]){ count++; }
-                       }
-                       pi0_hat[l] = count/(double)(numRows*(1-lambdas[l]));
-               }
-               
-               double pi0 = smoothSpline(lambdas, pi0_hat, 3);
-               
-               //order p-values
-               vector<double> ordered_qs = qvalues;
-               vector<int> ordered_ps(pValues.size(), 0);
-               for (int i = 1; i < ordered_ps.size(); i++) {  ordered_ps[i] = ordered_ps[i-1] + 1; }
-               vector<double> tempPvalues = pValues;
-               OrderPValues(0, numRows-1, tempPvalues, ordered_ps);
-               
-               ordered_qs[numRows-1] = min((pValues[ordered_ps[numRows-1]]*pi0), 1.0);
-               for (int i = (numRows-2); i >= 0; i--){
-                       double p = pValues[ordered_ps[i]];
-                       double temp = p*numRows*pi0/(double)(i+1);
-
-                       ordered_qs[i] = min(temp, ordered_qs[i+1]);
-               }
-               
-               //re-distribute calculated qvalues to appropriate rows
-               for (int i = 0; i < numRows; i++){
-                       qvalues[ordered_ps[i]] = ordered_qs[i];
-               }
-               
-               return qvalues;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "calc_qvalues");
-               exit(1);
-       }
-}
-/***********************************************************/
-int MothurMetastats::OrderPValues(int low, int high, vector<double>& p, vector<int>& order) {
-       try {
-               
-               if (low < high) {
-                       int i = low+1;
-                       int j = high;
-                       int pivot = (low+high) / 2;
-                       
-                       swapElements(low, pivot, p, order);  //puts pivot in final spot
-                       
-                       /* compare value */
-                       double key = p[low];
-                       
-                       /* partition */
-                       while(i <= j) {
-                               /* find member above ... */
-                               while((i <= high) && (p[i] <= key))     {  i++;  }  
-                               
-                               /* find element below ... */
-                               while((j >= low) && (p[j] > key))       {  j--;  } 
-                               
-                               if(i < j) {
-                                       swapElements(i, j, p, order);
-                               }
-                       } 
-                       
-                       swapElements(low, j, p, order);
-                       
-                       /* recurse */
-                       OrderPValues(low, j-1, p, order);
-                       OrderPValues(j+1, high, p, order); 
-               }               
-               
-               return 0;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "OrderPValues");
-               exit(1);
-       }
-}
-/***********************************************************/
-int MothurMetastats::swapElements(int i, int j, vector<double>& p, vector<int>& order) {
-       try {
-               
-               double z = p[i];
-               p[i] = p[j];
-               p[j] = z;
-               
-               int temp = order[i];
-               order[i] = order[j];
-               order[j] = temp;
-               
-               return 0;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "swapElements");
-               exit(1);
-       }
-}
-/***********************************************************/
-double MothurMetastats::smoothSpline(vector<double>& x, vector<double>& y, int df) {
-       try {
-                               
-               double result = 0.0;
-               int n = x.size();
-               vector<double> w(n, 1);
-               double* xb = new double[n];
-               double* yb = new double[n];
-               double* wb = new double[n];
-               double yssw = 0.0;
-               for (int i = 0; i < n; i++) {
-                       wb[i] = w[i];
-                       yb[i] = w[i]*y[i];
-                       yssw += (w[i] * y[i] * y[i]) - wb[i] * (yb[i] * yb[i]);
-                       xb[i] = (x[i] - x[0]) / (x[n-1] - x[0]);
-               }
-               
-               vector<double> knot = sknot1(xb, n);
-               int nk = knot.size() - 4;
-
-               double low = -1.5; double high = 1.5; double tol = 1e-04; double eps = 2e-08; int maxit = 500;
-               int ispar = 0; int icrit = 3; double dofoff = 3.0;
-               double penalty = 1.0; 
-               int ld4 = 4; int isetup = 0; int ldnk = 1; int ier; double spar = 1.0; double crit;
-               
-               double* knotb = new double[knot.size()];
-               double* coef1 = new double[nk];
-               double* lev1 = new double[n];
-               double* sz1 = new double[n];
-               for (int i = 0; i < knot.size(); i++) { knotb[i] = knot[i];     }
-               
-               Spline spline;
-               spline.sbart(&penalty, &dofoff, &xb[0], &yb[0], &wb[0], &yssw, &n, &knotb[0], &nk, &coef1[0], &sz1[0], &lev1[0], &crit,
-                               &icrit, &spar, &ispar, &maxit, &low, &high, &tol, &eps, &isetup, &ld4, &ldnk, &ier);
-               
-               result = coef1[nk-1];
-               
-               //free memory
-               delete [] xb;
-               delete [] yb;
-               delete [] wb;
-               delete [] knotb;
-               delete [] coef1;
-               delete [] lev1;
-               delete [] sz1;
-                                                       
-               return result;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "smoothSpline");
-               exit(1);
-       }
-}
-/***********************************************************/
-vector<double> MothurMetastats::sknot1(double* x, int n) {
-       try {
-               vector<double> knots;
-               int nk = nkn(n);
-               
-               //R equivalent - rep(x[1L], 3L)
-               knots.push_back(x[0]); knots.push_back(x[0]); knots.push_back(x[0]);
-               
-               //generate a sequence of nk equally spaced values from 1 to n. R equivalent = seq.int(1, n, length.out = nk)
-               vector<int> indexes = getSequence(0, n-1, nk);
-               for (int i = 0; i < indexes.size(); i++) { knots.push_back(x[indexes[i]]);  } 
-               
-               //R equivalent - rep(x[n], 3L)
-               knots.push_back(x[n-1]); knots.push_back(x[n-1]); knots.push_back(x[n-1]);
-                               
-               return knots;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "sknot1");
-               exit(1);
-       }
-}
-/***********************************************************/
-vector<int> MothurMetastats::getSequence(int start, int end, int length) {
-       try {
-               vector<int> sequence;
-               double increment = (end-start) / (double) (length-1);
-               
-               sequence.push_back(start);
-               for (int i = 1; i < length-1; i++) {
-                       sequence.push_back(int(i*increment));
-               }
-               sequence.push_back(end);
-               
-               return sequence;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "getSequence");
-               exit(1);
-       }
-}      
-/***********************************************************/
-//not right, havent fully figured out the variable types yet...
-int MothurMetastats::nkn(int n) {
-       try {
-               
-               if (n < 50) { return n; }
-               else {
-                       double a1 = log2(50);
-                       double a2 = log2(100);
-                       double a3 = log2(140);
-                       double a4 = log2(200);
-                       
-                       if (n < 200) {
-                               return (int)pow(2.0, (a1 + (a2 - a1) * (n - 50)/(float)150));
-                       }else if (n < 800) {
-                               return (int)pow(2.0, (a2 + (a3 - a2) * (n - 200)/(float)600));
-                       }else if (n < 3200) {
-                               return (int)pow(2.0, (a3 + (a4 - a3) * (n - 800)/(float)2400));
-                       }else {
-                               return (int)pow((double)(200 + (n - 3200)), 0.2);
-                       }
-               }
-       
-               return 0;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "MothurMetastats", "nkn");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
-
-
diff --git a/mothurmetastats.h b/mothurmetastats.h
deleted file mode 100644 (file)
index 4d6cf91..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef MOTHUR_METASTATS
-#define MOTHUR_METASTATS
-
-/*
- *  mothurmetastats.h
- *  Mothur
- *
- *  Created by westcott on 7/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothurout.h"
-
-class MothurMetastats {
-       
-       public:
-               MothurMetastats(double, int); //threshold, numPermutations
-               ~MothurMetastats();
-       
-               int runMetastats(string, vector< vector<double> >&, int); //outputFileName, data, secondGroupingStart
-       
-       private:
-               MothurOut* m;
-               int row, column, numPermutations, secondGroupingStart;
-               double threshold;
-        
-    vector<double> permuted_pvalues(vector< vector<double> >&, vector<double>&, vector< vector<double> >&);
-    vector<double> permute_and_calc_ts(vector< vector<double> >&);
-    
-               int start(vector<double>&, int, vector<double>&, vector< vector<double> >&); //Find the initial values for the matrix
-               int meanvar(vector<double>&, int, vector<double>&);
-               int testp(vector<double>&, vector<double>&, vector<double>&, int, vector<double>&, vector<double>&);
-               int permute_matrix(vector<double>&, vector<double>&, int, vector<double>&, vector<double>&, vector<double>&);
-               int permute_array(vector<int>&);
-               int calc_twosample_ts(vector<double>&, int, vector<double>&, vector<double>&, vector<double>&);
-               double smoothSpline(vector<double>&, vector<double>&, int);
-               vector<double> calc_qvalues(vector<double>&);
-               vector<double> sknot1(double*, int);
-               int nkn(int);
-               int OrderPValues(int, int, vector<double>&, vector<int>&);
-               int swapElements(int, int, vector<double>&, vector<int>&);
-               vector<int> getSequence(int, int, int);
-               
-};
-       
-#endif
-
diff --git a/mothurout.cpp b/mothurout.cpp
deleted file mode 100644 (file)
index 0431d36..0000000
+++ /dev/null
@@ -1,2248 +0,0 @@
-/*
- *  mothurOut.cpp
- *  Mothur
- *
- *  Created by westcott on 2/25/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-
-
-/******************************************************/
-MothurOut* MothurOut::getInstance() {
-       if( _uniqueInstance == 0) {
-               _uniqueInstance = new MothurOut();
-       }
-       return _uniqueInstance;
-}
-/*********************************************************************************************/
-void MothurOut::printCurrentFiles()  {
-       try {
-               if (accnosfile != "")           {  mothurOut("accnos=" + accnosfile); mothurOutEndLine();                       }
-               if (columnfile != "")           {  mothurOut("column=" + columnfile); mothurOutEndLine();                       }
-               if (designfile != "")           {  mothurOut("design=" + designfile); mothurOutEndLine();                       }
-               if (fastafile != "")            {  mothurOut("fasta=" + fastafile); mothurOutEndLine();                         }
-               if (groupfile != "")            {  mothurOut("group=" + groupfile); mothurOutEndLine();                         }
-               if (listfile != "")                     {  mothurOut("list=" + listfile); mothurOutEndLine();                           }
-               if (namefile != "")                     {  mothurOut("name=" + namefile); mothurOutEndLine();                           }
-               if (oligosfile != "")           {  mothurOut("oligos=" + oligosfile); mothurOutEndLine();                       }
-               if (orderfile != "")            {  mothurOut("order=" + orderfile); mothurOutEndLine();                         }
-               if (ordergroupfile != "")       {  mothurOut("ordergroup=" + ordergroupfile); mothurOutEndLine();       }
-               if (phylipfile != "")           {  mothurOut("phylip=" + phylipfile); mothurOutEndLine();                       }
-               if (qualfile != "")                     {  mothurOut("qfile=" + qualfile); mothurOutEndLine();                          }
-               if (rabundfile != "")           {  mothurOut("rabund=" + rabundfile); mothurOutEndLine();                       }
-               if (relabundfile != "")         {  mothurOut("relabund=" + relabundfile); mothurOutEndLine();           }
-               if (sabundfile != "")           {  mothurOut("sabund=" + sabundfile); mothurOutEndLine();                       }
-               if (sfffile != "")                      {  mothurOut("sff=" + sfffile); mothurOutEndLine();                                     }
-               if (sharedfile != "")           {  mothurOut("shared=" + sharedfile); mothurOutEndLine();                       }
-               if (taxonomyfile != "")         {  mothurOut("taxonomy=" + taxonomyfile); mothurOutEndLine();           }
-               if (treefile != "")                     {  mothurOut("tree=" + treefile); mothurOutEndLine();                           }
-               if (flowfile != "")                     {  mothurOut("flow=" + flowfile); mothurOutEndLine();                           }
-        if (biomfile != "")                    {  mothurOut("biom=" + biomfile); mothurOutEndLine();                           }
-               if (processors != "1")          {  mothurOut("processors=" + processors); mothurOutEndLine();           }
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "printCurrentFiles");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-bool MothurOut::hasCurrentFiles()  {
-       try {
-               bool hasCurrent = false;
-               
-               if (accnosfile != "")           {  return true;                 }
-               if (columnfile != "")           {  return true;                 }
-               if (designfile != "")           {  return true;                 }
-               if (fastafile != "")            {  return true;                 }
-               if (groupfile != "")            {  return true;                 }
-               if (listfile != "")                     {  return true;                 }
-               if (namefile != "")                     {  return true;                 }
-               if (oligosfile != "")           {  return true;                 }
-               if (orderfile != "")            {  return true;                 }
-               if (ordergroupfile != "")       {  return true;                 }
-               if (phylipfile != "")           {  return true;                 }
-               if (qualfile != "")                     {  return true;                 }
-               if (rabundfile != "")           {  return true;                 }
-               if (relabundfile != "")         {  return true;                 }
-               if (sabundfile != "")           {  return true;                 }
-               if (sfffile != "")                      {  return true;                 }
-               if (sharedfile != "")           {  return true;                 }
-               if (taxonomyfile != "")         {  return true;                 }
-               if (treefile != "")                     {  return true;                 }
-               if (flowfile != "")                     {  return true;                 }
-        if (biomfile != "")                    {  return true;                 }
-               if (processors != "1")          {  return true;                 }
-               
-               return hasCurrent;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "hasCurrentFiles");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************/
-void MothurOut::clearCurrentFiles()  {
-       try {
-               phylipfile = "";
-               columnfile = "";
-               listfile = "";
-               rabundfile = "";
-               sabundfile = "";
-               namefile = "";
-               groupfile = "";
-               designfile = "";
-               orderfile = "";
-               treefile = "";
-               sharedfile = "";
-               ordergroupfile = "";
-               relabundfile = "";
-               fastafile = "";
-               qualfile = "";
-               sfffile = "";
-               oligosfile = "";
-               accnosfile = "";
-               taxonomyfile = "";      
-               flowfile = "";
-        biomfile = "";
-               processors = "1";
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "clearCurrentFiles");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::setFileName(string filename)  {
-       try {
-               logFileName = filename;
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               openOutputFile(filename, out);
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setFileName");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::setDefaultPath(string pathname)  {
-       try {
-       
-               //add / to name if needed
-               string lastChar = pathname.substr(pathname.length()-1);
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if (lastChar != "/") { pathname += "/"; }
-               #else
-                       if (lastChar != "\\") { pathname += "\\"; }     
-               #endif
-               
-               defaultPath = pathname;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setDefaultPath");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::setOutputDir(string pathname)  {
-       try {
-               outputDir = pathname;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setOutputDir");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::closeLog()  {
-       try {
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out.close();
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "closeLog");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************/
-MothurOut::~MothurOut() {
-       try {
-               _uniqueInstance = 0;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOut");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOut(string output) {
-       try {
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out << output;
-        logger() << output;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOut");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOutEndLine() {
-       try {
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out << endl;
-        logger() << endl;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOutEndLine");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOut(string output, ofstream& outputFile) {
-       try {
-               
-#ifdef USE_MPI
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-               
-               if (pid == 0) { //only one process should output to screen
-#endif
-                       
-                       
-                       out << output;
-                       outputFile << output;
-            logger() << output;
-                       
-#ifdef USE_MPI
-               }
-#endif
-        
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOut");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOutEndLine(ofstream& outputFile) {
-       try {
-#ifdef USE_MPI
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-               
-               if (pid == 0) { //only one process should output to screen
-#endif
-                       
-                       out << endl;
-                       outputFile << endl;
-            logger() << endl;
-                       
-#ifdef USE_MPI
-               }
-#endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOutEndLine");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::mothurOutJustToLog(string output) {
-       try {
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should output to screen
-               #endif
-               
-               out << output;
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "MothurOutJustToLog");
-               exit(1);
-       }
-}
-/*********************************************************************************************/
-void MothurOut::errorOut(exception& e, string object, string function) {
-       //double vm, rss;
-       //mem_usage(vm, rss);
-       
-       mothurOut("[ERROR]: ");
-       mothurOut(toString(e.what()));
-       mothurOut(" has occurred in the " + object + " class function " + function + ". Please contact Pat Schloss at mothur.bugs@gmail.com, and be sure to include the mothur.logFile with your inquiry.");
-       mothurOutEndLine();
-}
-/*********************************************************************************************/
-//The following was originally from http://stackoverflow.com/questions/669438/how-to-get-memory-usage-at-run-time-in-c 
-// process_mem_usage(double &, double &) - takes two doubles by reference,
-// attempts to read the system-dependent data for a process' virtual memory
-// size and resident set size, and return the results in KB.
-//
-// On failure, returns 0.0, 0.0
-int MothurOut::mem_usage(double& vm_usage, double& resident_set) {
-  #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-  
-          vm_usage     = 0.0;
-          resident_set = 0.0;
-
-          // 'file' stat seems to give the most reliable results
-          //
-          ifstream stat_stream("/proc/self/stat",ios_base::in);
-
-          // dummy vars for leading entries in stat that we don't care about
-          //
-          string pid, comm, state, ppid, pgrp, session, tty_nr;
-          string tpgid, flags, minflt, cminflt, majflt, cmajflt;
-          string utime, stime, cutime, cstime, priority, nice;
-          string O, itrealvalue, starttime;
-
-          // the two fields we want
-          //
-          unsigned long vsize;
-          long rss;
-
-          stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
-                                  >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
-                                  >> utime >> stime >> cutime >> cstime >> priority >> nice
-                                  >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest
-
-          long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages
-          vm_usage     = vsize / 1024.0;
-          resident_set = rss * page_size_kb;
-          
-          mothurOut("Memory Usage: vm = " + toString(vm_usage) + " rss = " + toString(resident_set) + "\n");
-               return 0;
-
-       #else
-/*             //windows memory usage
-               // Get the list of process identifiers.
-               DWORD aProcesses[1024], cbNeeded, cProcesses;
-               
-               if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) ){ return 1; }
-
-               // Calculate how many process identifiers were returned.
-               cProcesses = cbNeeded / sizeof(DWORD);
-
-               // Print the memory usage for each process
-               for (int i = 0; i < cProcesses; i++ ) {
-                       DWORD processID = aProcesses[i];
-                       
-                       PROCESS_MEMORY_COUNTERS pmc;
-
-                       HANDLE hProcess = OpenProcess((PROCESS_QUERY_INFORMATION | PROCESS_VM_READ), FALSE, processID);
-
-                       // Print the process identifier.
-                       printf( "\nProcess ID: %u\n", processID);
-                       
-                       if (NULL != hProcess) {
-
-                               if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) ) {
-                                       printf( "\tPageFaultCount: 0x%08X\n", pmc.PageFaultCount );
-                                       printf( "\tPeakWorkingSetSize: 0x%08X\n", pmc.PeakWorkingSetSize );
-                                       printf( "\tWorkingSetSize: 0x%08X\n", pmc.WorkingSetSize );
-                                       printf( "\tQuotaPeakPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakPagedPoolUsage );
-                                       printf( "\tQuotaPagedPoolUsage: 0x%08X\n", pmc.QuotaPagedPoolUsage );
-                                       printf( "\tQuotaPeakNonPagedPoolUsage: 0x%08X\n", pmc.QuotaPeakNonPagedPoolUsage );
-                                       printf( "\tQuotaNonPagedPoolUsage: 0x%08X\n", pmc.QuotaNonPagedPoolUsage );
-                                       printf( "\tPagefileUsage: 0x%08X\n", pmc.PagefileUsage ); 
-                                       printf( "\tPeakPagefileUsage: 0x%08X\n", pmc.PeakPagefileUsage );
-                               }
-                               CloseHandle(hProcess);
-                       }
-               }
-*/
-                       return 0;
-
-       #endif
-}
-
-
-/***********************************************************************/
-int MothurOut::openOutputFileAppend(string fileName, ofstream& fileHandle){
-       try {
-               fileName = getFullPathName(fileName);
-               
-               fileHandle.open(fileName.c_str(), ios::app);
-               if(!fileHandle) {
-                       mothurOut("[ERROR]: Could not open " + fileName); mothurOutEndLine();
-                       return 1;
-               }
-               else {
-                       return 0;
-               }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "openOutputFileAppend");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void MothurOut::gobble(istream& f){
-       try {
-               
-               char d;
-               while(isspace(d=f.get()))               { ;}
-               if(!f.eof()) { f.putback(d); }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "gobble");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void MothurOut::gobble(istringstream& f){
-       try {
-               char d;
-               while(isspace(d=f.get()))               {;}
-               if(!f.eof()) { f.putback(d); }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "gobble");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-string MothurOut::getline(istringstream& fileHandle) {
-       try {
-       
-               string line = "";
-               
-               while (!fileHandle.eof())       {
-                       //get next character
-                       char c = fileHandle.get(); 
-                       
-                       //are you at the end of the line
-                       if ((c == '\n') || (c == '\r') || (c == '\f')){  break; }       
-                       else {          line += c;              }
-               }
-               
-               return line;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getline");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-string MothurOut::getline(ifstream& fileHandle) {
-       try {
-       
-               string line = "";
-               
-               while (fileHandle)      {
-                       //get next character
-                       char c = fileHandle.get(); 
-                       
-                       //are you at the end of the line
-                       if ((c == '\n') || (c == '\r') || (c == '\f') || (c == EOF)){  break;   }       
-                       else {          line += c;              }
-               }
-               
-               return line;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getline");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#ifdef USE_COMPRESSION
-inline bool endsWith(string s, const char * suffix){
-  size_t suffixLength = strlen(suffix);
-  return s.size() >= suffixLength && s.substr(s.size() - suffixLength, suffixLength).compare(suffix) == 0;
-}
-#endif
-#endif
-
-string MothurOut::getRootName(string longName){
-       try {
-       
-               string rootName = longName;
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#ifdef USE_COMPRESSION
-    if (endsWith(rootName, ".gz") || endsWith(rootName, ".bz2")) {
-      int pos = rootName.find_last_of('.');
-      rootName = rootName.substr(0, pos);
-      cerr << "shortening " << longName << " to " << rootName << "\n";
-    }
-#endif
-#endif
-               if(rootName.find_last_of(".") != rootName.npos){
-                       int pos = rootName.find_last_of('.')+1;
-                       rootName = rootName.substr(0, pos);
-               }
-
-               return rootName;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getRootName");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-string MothurOut::getSimpleName(string longName){
-       try {
-               string simpleName = longName;
-               
-               size_t found;
-               found=longName.find_last_of("/\\");
-
-               if(found != longName.npos){
-                       simpleName = longName.substr(found+1);
-               }
-               
-               return simpleName;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getSimpleName");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-int MothurOut::getRandomIndex(int highest){
-       try {
-               
-               int random = (int) ((float)(highest+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
-               
-               return random;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getRandomIndex");
-               exit(1);
-       }       
-       
-}
-/**********************************************************************/
-
-string MothurOut::getPathName(string longName){
-       try {
-               string rootPathName = longName;
-               
-               if(longName.find_last_of("/\\") != longName.npos){
-                       int pos = longName.find_last_of("/\\")+1;
-                       rootPathName = longName.substr(0, pos);
-               }
-               
-               return rootPathName;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getPathName");
-               exit(1);
-       }       
-
-}
-/***********************************************************************/
-
-bool MothurOut::dirCheck(string& dirName){
-       try {
-        
-        string tag = "";
-        #ifdef USE_MPI
-            int pid; 
-            MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               
-            tag = toString(pid);
-        #endif
-
-        //add / to name if needed
-        string lastChar = dirName.substr(dirName.length()-1);
-        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-        if (lastChar != "/") { dirName += "/"; }
-        #else
-        if (lastChar != "\\") { dirName += "\\"; }     
-        #endif
-
-        //test to make sure directory exists
-        dirName = getFullPathName(dirName);
-        string outTemp = dirName + tag + "temp";
-        ofstream out;
-        out.open(outTemp.c_str(), ios::trunc);
-        if(!out) {
-            mothurOut(dirName + " directory does not exist or is not writable."); mothurOutEndLine(); 
-        }else{
-            out.close();
-            mothurRemove(outTemp);
-            return true;
-        }
-        
-        return false;
-    }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "dirCheck");
-               exit(1);
-       }       
-    
-}
-/***********************************************************************/
-
-string MothurOut::hasPath(string longName){
-       try {
-               string path = "";
-               
-               size_t found;
-               found=longName.find_last_of("~/\\");
-
-               if(found != longName.npos){
-                       path = longName.substr(0, found+1);
-               }
-               
-               return path;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "hasPath");
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-
-string MothurOut::getExtension(string longName){
-       try {
-               string extension = "";
-               
-               if(longName.find_last_of('.') != longName.npos){
-                       int pos = longName.find_last_of('.');
-                       extension = longName.substr(pos, longName.length());
-               }
-               
-               return extension;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getExtension");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-bool MothurOut::isBlank(string fileName){
-       try {
-               
-               fileName = getFullPathName(fileName);
-               
-               ifstream fileHandle;
-               fileHandle.open(fileName.c_str());
-               if(!fileHandle) {
-                       mothurOut("[ERROR]: Could not open " + fileName); mothurOutEndLine();
-                       return false;
-               }else {
-                       //check for blank file
-                       gobble(fileHandle);
-                       if (fileHandle.eof()) { fileHandle.close(); return true;  }
-                       fileHandle.close();
-               }
-               return false;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "isBlank");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-
-string MothurOut::getFullPathName(string fileName){
-       try{
-       
-       string path = hasPath(fileName);
-       string newFileName;
-       int pos;
-       
-       if (path == "") { return fileName; } //its a simple name
-       else { //we need to complete the pathname
-               // ex. ../../../filename 
-               // cwd = /user/work/desktop
-                               
-               string cwd;
-               //get current working directory 
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)  
-                       
-                       if (path.find("~") != -1) { //go to home directory
-                               string homeDir;
-                       
-                               char *homepath = NULL;
-                               homepath = getenv ("HOME");
-                               if ( homepath != NULL) { homeDir = homepath; }
-                               else { homeDir = "";  }
-
-                               newFileName = homeDir + fileName.substr(fileName.find("~")+1);
-                               return newFileName;
-                       }else { //find path
-                               if (path.rfind("./") == string::npos) { return fileName; } //already complete name
-                               else { newFileName = fileName.substr(fileName.rfind("./")+2); } //save the complete part of the name
-                               
-                               //char* cwdpath = new char[1024];
-                               //size_t size;
-                               //cwdpath=getcwd(cwdpath,size);
-                               //cwd = cwdpath;
-                               
-                               char *cwdpath = NULL;
-                               cwdpath = getcwd(NULL, 0); // or _getcwd
-                               if ( cwdpath != NULL) { cwd = cwdpath; }
-                               else { cwd = "";  }
-
-                               
-                               //rip off first '/'
-                               string simpleCWD;
-                               if (cwd.length() > 0) { simpleCWD = cwd.substr(1); }
-                               
-                               //break apart the current working directory
-                               vector<string> dirs;
-                               while (simpleCWD.find_first_of('/') != string::npos) {
-                                       string dir = simpleCWD.substr(0,simpleCWD.find_first_of('/'));
-                                       simpleCWD = simpleCWD.substr(simpleCWD.find_first_of('/')+1, simpleCWD.length());
-                                       dirs.push_back(dir);
-                               }
-                               //get last one              // ex. ../../../filename = /user/work/desktop/filename
-                               dirs.push_back(simpleCWD);  //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
-                               
-                       
-                               int index = dirs.size()-1;
-               
-                               while((pos = path.rfind("./")) != string::npos) { //while you don't have a complete path
-                                       if (pos == 0) { break;  //you are at the end
-                                       }else if (path[(pos-1)] == '.') { //you want your parent directory ../
-                                               path = path.substr(0, pos-1);
-                                               index--;
-                                               if (index == 0) {  break; }
-                                       }else if (path[(pos-1)] == '/') { //you want the current working dir ./
-                                               path = path.substr(0, pos);
-                                       }else if (pos == 1) { break;  //you are at the end
-                                       }else { mothurOut("cannot resolve path for " +  fileName + "\n"); return fileName; }
-                               }
-                       
-                               for (int i = index; i >= 0; i--) {
-                                       newFileName = dirs[i] +  "/" + newFileName;             
-                               }
-                               
-                               newFileName =  "/" +  newFileName;
-                               return newFileName;
-                       }       
-               #else
-                       if (path.find("~") != string::npos) { //go to home directory
-                               string homeDir = getenv ("HOMEPATH");
-                               newFileName = homeDir + fileName.substr(fileName.find("~")+1);
-                               return newFileName;
-                       }else { //find path
-                               if (path.rfind(".\\") == string::npos) { return fileName; } //already complete name
-                               else { newFileName = fileName.substr(fileName.rfind(".\\")+2); } //save the complete part of the name
-                                                       
-                               char *cwdpath = NULL;
-                               cwdpath = getcwd(NULL, 0); // or _getcwd
-                               if ( cwdpath != NULL) { cwd = cwdpath; }
-                               else { cwd = "";  }
-                               
-                               //break apart the current working directory
-                               vector<string> dirs;
-                               while (cwd.find_first_of('\\') != -1) {
-                                       string dir = cwd.substr(0,cwd.find_first_of('\\'));
-                                       cwd = cwd.substr(cwd.find_first_of('\\')+1, cwd.length());
-                                       dirs.push_back(dir);
-               
-                               }
-                               //get last one
-                               dirs.push_back(cwd);  //ex. dirs[0] = user, dirs[1] = work, dirs[2] = desktop
-                                       
-                               int index = dirs.size()-1;
-                                       
-                               while((pos = path.rfind(".\\")) != string::npos) { //while you don't have a complete path
-                                       if (pos == 0) { break;  //you are at the end
-                                       }else if (path[(pos-1)] == '.') { //you want your parent directory ../
-                                               path = path.substr(0, pos-1);
-                                               index--;
-                                               if (index == 0) {  break; }
-                                       }else if (path[(pos-1)] == '\\') { //you want the current working dir ./
-                                               path = path.substr(0, pos);
-                                       }else if (pos == 1) { break;  //you are at the end
-                                       }else { mothurOut("cannot resolve path for " +  fileName + "\n"); return fileName; }
-                               }
-                       
-                               for (int i = index; i >= 0; i--) {
-                                       newFileName = dirs[i] +  "\\" + newFileName;            
-                               }
-                               
-                               return newFileName;
-                       }
-                       
-               #endif
-       }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getFullPathName");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-
-int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){
-       try {
-                       //get full path name
-                       string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#ifdef USE_COMPRESSION
-      // check for gzipped or bzipped file
-      if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
-        string tempName = string(tmpnam(0));
-        mkfifo(tempName.c_str(), 0666);
-        int fork_result = fork();
-        if (fork_result < 0) {
-          cerr << "Error forking.\n";
-          exit(1);
-        } else if (fork_result == 0) {
-          string command = (endsWith(completeFileName, ".gz") ? "zcat " : "bzcat ") + completeFileName + string(" > ") + tempName;
-          cerr << "Decompressing " << completeFileName << " via temporary named pipe " << tempName << "\n";
-          system(command.c_str());
-          cerr << "Done decompressing " << completeFileName << "\n";
-          mothurRemove(tempName);
-          exit(EXIT_SUCCESS);
-        } else {
-          cerr << "waiting on child process " << fork_result << "\n";
-          completeFileName = tempName;
-        }
-      }
-#endif
-#endif
-                       fileHandle.open(completeFileName.c_str());
-                       if(!fileHandle) {
-                               //mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
-                               return 1;
-                       }else {
-                               //check for blank file
-                               gobble(fileHandle);
-                               return 0;
-                       }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "openInputFile - no Error");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int MothurOut::openInputFile(string fileName, ifstream& fileHandle){
-       try {
-
-               //get full path name
-               string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#ifdef USE_COMPRESSION
-  // check for gzipped or bzipped file
-  if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
-    string tempName = string(tmpnam(0));
-    mkfifo(tempName.c_str(), 0666);
-    int fork_result = fork();
-    if (fork_result < 0) {
-      cerr << "Error forking.\n";
-      exit(1);
-    } else if (fork_result == 0) {
-      string command = (endsWith(completeFileName, ".gz") ? "zcat " : "bzcat ") + completeFileName + string(" > ") + tempName;
-      cerr << "Decompressing " << completeFileName << " via temporary named pipe " << tempName << "\n";
-      system(command.c_str());
-      cerr << "Done decompressing " << completeFileName << "\n";
-      mothurRemove(tempName);
-      exit(EXIT_SUCCESS);
-    } else {
-      cerr << "waiting on child process " << fork_result << "\n";
-      completeFileName = tempName;
-    }
-  }
-#endif
-#endif
-
-               fileHandle.open(completeFileName.c_str());
-               if(!fileHandle) {
-                       mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
-                       return 1;
-               }
-               else {
-                       //check for blank file
-                       gobble(fileHandle);
-                       if (fileHandle.eof()) { mothurOut("[ERROR]: " + completeFileName + " is blank. Please correct."); mothurOutEndLine();  }
-                       
-                       return 0;
-               }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "openInputFile");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-
-int MothurOut::renameFile(string oldName, string newName){
-       try {
-               ifstream inTest;
-               int exist = openInputFile(newName, inTest, "");
-               inTest.close();
-               
-       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)          
-               if (exist == 0) { //you could open it so you want to delete it
-                       string command = "rm " + newName;
-                       system(command.c_str());
-               }
-                               
-               string command = "mv " + oldName + " " + newName;
-               system(command.c_str());
-       #else
-               mothurRemove(newName);
-               int renameOk = rename(oldName.c_str(), newName.c_str());
-       #endif
-               return 0;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "renameFile");
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-
-int MothurOut::openOutputFile(string fileName, ofstream& fileHandle){
-       try { 
-       
-               string completeFileName = getFullPathName(fileName);
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#ifdef USE_COMPRESSION
-    // check for gzipped file
-    if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) {
-      string tempName = string(tmpnam(0));
-      mkfifo(tempName.c_str(), 0666);
-      cerr << "Compressing " << completeFileName << " via temporary named pipe " << tempName << "\n";
-      int fork_result = fork();
-      if (fork_result < 0) {
-        cerr << "Error forking.\n";
-        exit(1);
-      } else if (fork_result == 0) {
-        string command = string(endsWith(completeFileName, ".gz") ?  "gzip" : "bzip2") + " -v > " + completeFileName + string(" < ") + tempName;
-        system(command.c_str());
-        exit(0);
-      } else {
-        completeFileName = tempName;
-      }
-    }
-#endif
-#endif
-               fileHandle.open(completeFileName.c_str(), ios::trunc);
-               if(!fileHandle) {
-                       mothurOut("[ERROR]: Could not open " + completeFileName); mothurOutEndLine();
-                       return 1;
-               }
-               else {
-                       return 0;
-               }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "openOutputFile");
-               exit(1);
-       }       
-
-}
-
-/**************************************************************************************************/
-int MothurOut::appendFiles(string temp, string filename) {
-       try{
-               ofstream output;
-               ifstream input;
-       
-               //open output file in append mode
-               openOutputFileAppend(filename, output);
-               int ableToOpen = openInputFile(temp, input, "no error");
-               //int ableToOpen = openInputFile(temp, input);
-               
-               int numLines = 0;
-               if (ableToOpen == 0) { //you opened it
-                       while(!input.eof()){
-                char c = input.get();
-                               if(input.eof())         {       break;                  }
-                               else                            {       output << c;    if (c == '\n') {numLines++;} }
-                       }
-                       input.close();
-               }
-               
-               output.close();
-               
-               return numLines;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "appendFiles");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-string MothurOut::sortFile(string distFile, string outputDir){
-       try {   
-       
-               //if (outputDir == "") {  outputDir += hasPath(distFile);  }
-               string outfile = getRootName(distFile) + "sorted.dist";
-
-               
-               //if you can, use the unix sort since its been optimized for years
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       string command = "sort -n -k +3 " + distFile + " -o " + outfile;
-                       system(command.c_str());
-               #else //you are stuck with my best attempt...
-                       //windows sort does not have a way to specify a column, only a character in the line
-                       //since we cannot assume that the distance will always be at the the same character location on each line
-                       //due to variable sequence name lengths, I chose to force the distance into first position, then sort and then put it back.
-               
-                       //read in file line by file and put distance first
-                       string tempDistFile = distFile + ".temp";
-                       ifstream input;
-                       ofstream output;
-                       openInputFile(distFile, input);
-                       openOutputFile(tempDistFile, output);
-
-                       string firstName, secondName;
-                       float dist;
-                       while (input) {
-                               input >> firstName >> secondName >> dist;
-                               output << dist << '\t' << firstName << '\t' << secondName << endl;
-                               gobble(input);
-                       }
-                       input.close();
-                       output.close();
-               
-       
-                       //sort using windows sort
-                       string tempOutfile = outfile + ".temp";
-                       string command = "sort " + tempDistFile + " /O " + tempOutfile;
-                       system(command.c_str());
-               
-                       //read in sorted file and put distance at end again
-                       ifstream input2;
-                       openInputFile(tempOutfile, input2);
-                       openOutputFile(outfile, output);
-               
-                       while (input2) {
-                               input2 >> dist >> firstName >> secondName;
-                               output << firstName << '\t' << secondName << '\t' << dist << endl;
-                               gobble(input2);
-                       }
-                       input2.close();
-                       output.close();
-               
-                       //remove temp files
-                       mothurRemove(tempDistFile);
-                       mothurRemove(tempOutfile);
-               #endif
-               
-               return outfile;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "sortFile");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-vector<unsigned long long> MothurOut::setFilePosFasta(string filename, int& num) {
-       try {
-                       vector<unsigned long long> positions;
-                       ifstream inFASTA;
-                       //openInputFile(filename, inFASTA);
-                       inFASTA.open(filename.c_str(), ios::binary);
-                                               
-                       string input;
-                       unsigned long long count = 0;
-                       while(!inFASTA.eof()){
-                               //input = getline(inFASTA); 
-                               //cout << input << '\t' << inFASTA.tellg() << endl;
-                               //if (input.length() != 0) {
-                               //      if(input[0] == '>'){    unsigned long int pos = inFASTA.tellg(); positions.push_back(pos - input.length() - 1);  cout << (pos - input.length() - 1) << endl; }
-                               //}
-                               //gobble(inFASTA); //has to be here since windows line endings are 2 characters and mess up the positions
-                               char c = inFASTA.get(); count++;
-                               if (c == '>') {
-                                       positions.push_back(count-1);
-                                       //cout << count << endl;
-                               }
-                       }
-                       inFASTA.close();
-               
-                       num = positions.size();
-               
-                       /*FILE * pFile;
-                       long size;
-               
-                       //get num bytes in file
-                       pFile = fopen (filename.c_str(),"rb");
-                       if (pFile==NULL) perror ("Error opening file");
-                       else{
-                               fseek (pFile, 0, SEEK_END);
-                               size=ftell (pFile);
-                               fclose (pFile);
-                       }*/
-                       
-                       unsigned long long size = positions[(positions.size()-1)];
-                       ifstream in;
-                       openInputFile(filename, in);
-                       
-                       in.seekg(size);
-               
-                       while(in.get()){
-                               if(in.eof())            {       break;  }
-                               else                            {       size++; }
-                       }
-                       in.close();
-               
-                       positions.push_back(size);
-                       positions[0] = 0;
-               
-                       return positions;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setFilePosFasta");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<unsigned long long> MothurOut::setFilePosEachLine(string filename, int& num) {
-       try {
-                       filename = getFullPathName(filename);
-                       
-                       vector<unsigned long long> positions;
-                       ifstream in;
-                       //openInputFile(filename, in);
-                       in.open(filename.c_str(), ios::binary);
-               
-                       string input;
-                       unsigned long long count = 0;
-                       positions.push_back(0);
-               
-                       while(!in.eof()){
-                               //unsigned long long lastpos = in.tellg();
-                               //input = getline(in); 
-                               //if (input.length() != 0) {
-                                       //unsigned long long pos = in.tellg(); 
-                                       //if (pos != -1) { positions.push_back(pos - input.length() - 1);       }
-                                       //else {  positions.push_back(lastpos);  }
-                               //}
-                               //gobble(in); //has to be here since windows line endings are 2 characters and mess up the positions
-                               
-                               
-                               //getline counting reads
-                               char d = in.get(); count++;
-                               while ((d != '\n') && (d != '\r') && (d != '\f') && (d != in.eof()))    {
-                                       //get next character
-                                       d = in.get(); 
-                                       count++;
-                               }
-                               
-                               if (!in.eof()) {
-                                       d=in.get(); count++;
-                                       while(isspace(d) && (d != in.eof()))            { d=in.get(); count++;}
-                               }
-                               positions.push_back(count-1);
-                               //cout << count-1 << endl;
-                       }
-                       in.close();
-               
-                       num = positions.size()-1;
-               
-                       FILE * pFile;
-                       unsigned long long size;
-                       
-                       //get num bytes in file
-                       pFile = fopen (filename.c_str(),"rb");
-                       if (pFile==NULL) perror ("Error opening file");
-                       else{
-                               fseek (pFile, 0, SEEK_END);
-                               size=ftell (pFile);
-                               fclose (pFile);
-                       }
-               
-                       positions[(positions.size()-1)] = size;
-               
-                       return positions;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "setFilePosEachLine");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-vector<unsigned long long> MothurOut::divideFile(string filename, int& proc) {
-       try{
-               vector<unsigned long long> filePos;
-               filePos.push_back(0);
-               
-               FILE * pFile;
-               unsigned long long size;
-               
-               filename = getFullPathName(filename);
-       
-               //get num bytes in file
-               pFile = fopen (filename.c_str(),"rb");
-               if (pFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (pFile, 0, SEEK_END);
-                       size=ftell (pFile);
-                       fclose (pFile);
-               }
-               
-       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               
-               //estimate file breaks
-               unsigned long long chunkSize = 0;
-               chunkSize = size / proc;
-
-               //file to small to divide by processors
-               if (chunkSize == 0)  {  proc = 1;       filePos.push_back(size); return filePos;        }
-       
-               //for each process seekg to closest file break and search for next '>' char. make that the filebreak
-               for (int i = 0; i < proc; i++) {
-                       unsigned long long spot = (i+1) * chunkSize;
-                       
-                       ifstream in;
-                       openInputFile(filename, in);
-                       in.seekg(spot);
-                       
-                       //look for next '>'
-                       unsigned long long newSpot = spot;
-                       while (!in.eof()) {
-                          char c = in.get();
-                               
-                          if (c == '>') {   in.putback(c); newSpot = in.tellg(); break;  }
-                          else if (int(c) == -1) { break; }
-                               
-                       }
-               
-                       //there was not another sequence before the end of the file
-                       unsigned long long sanityPos = in.tellg();
-
-                       if (sanityPos == -1) {  break;  }
-                       else {  filePos.push_back(newSpot);  }
-                       
-                       in.close();
-               }
-               
-               //save end pos
-               filePos.push_back(size);
-               
-               //sanity check filePos
-               for (int i = 0; i < (filePos.size()-1); i++) {
-                       if (filePos[(i+1)] <= filePos[i]) {  filePos.erase(filePos.begin()+(i+1)); i--; }
-               }
-
-               proc = (filePos.size() - 1);
-#else
-               mothurOut("[ERROR]: Windows version should not be calling the divideFile function."); mothurOutEndLine();
-               proc=1;
-               filePos.push_back(size);
-#endif
-               return filePos;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "divideFile");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int MothurOut::divideFile(string filename, int& proc, vector<string>& files) {
-       try{
-               
-               vector<unsigned long long> filePos = divideFile(filename, proc);
-               
-               for (int i = 0; i < (filePos.size()-1); i++) {
-                       
-                       //read file chunk
-                       ifstream in;
-                       openInputFile(filename, in);
-                       in.seekg(filePos[i]);
-                       unsigned long long size = filePos[(i+1)] - filePos[i];
-                       char* chunk = new char[size];
-                       in.read(chunk, size);
-                       in.close();
-                       
-                       //open new file
-                       string fileChunkName = filename + "." + toString(i) + ".tmp";
-                       ofstream out; 
-                       openOutputFile(fileChunkName, out);
-                       
-                       out << chunk << endl;
-                       out.close();
-                       delete[] chunk;
-                       
-                       //save name
-                       files.push_back(fileChunkName);
-               }
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "divideFile");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-bool MothurOut::isTrue(string f){
-       try {
-               
-               for (int i = 0; i < f.length(); i++) { f[i] = toupper(f[i]); }
-               
-               if ((f == "TRUE") || (f == "T")) {      return true;    }
-               else {  return false;  }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "isTrue");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-float MothurOut::roundDist(float dist, int precision){
-       try {
-               return int(dist * precision + 0.5)/float(precision);
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "roundDist");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-float MothurOut::ceilDist(float dist, int precision){
-       try {
-               return int(ceil(dist * precision))/float(precision);
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "ceilDist");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int MothurOut::readNames(string namefile, map<string, string>& nameMap) { 
-       try {
-               
-               //open input file
-               ifstream in;
-               openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; gobble(in);
-                       
-                       nameMap[firstCol] = secondCol;
-               }
-               in.close();
-               
-               return nameMap.size();
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "readNames");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int MothurOut::readNames(string namefile, map<string, vector<string> >& nameMap) { 
-       try {
-               
-               //open input file
-               ifstream in;
-               openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; gobble(in);
-                       
-                       vector<string> temp;
-                       splitAtComma(secondCol, temp);
-                       
-                       nameMap[firstCol] = temp;
-               }
-               in.close();
-               
-               return nameMap.size();
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "readNames");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-map<string, int> MothurOut::readNames(string namefile) { 
-       try {
-               
-               map<string, int> nameMap;
-               
-               //open input file
-               ifstream in;
-               openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol;  gobble(in);
-            in >> secondCol; gobble(in);
-                       
-                       int num = getNumNames(secondCol);
-                       
-                       nameMap[firstCol] = num;
-               }
-               in.close();
-               
-               return nameMap;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "readNames");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int MothurOut::readNames(string namefile, vector<seqPriorityNode>& nameVector, map<string, string>& fastamap) { 
-       try {
-               int error = 0;
-               
-               //open input file
-               ifstream in;
-               openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; gobble(in);
-                       
-                       int num = getNumNames(secondCol);
-                       
-                       map<string, string>::iterator it = fastamap.find(firstCol);
-                       if (it == fastamap.end()) {
-                               error = 1;
-                               mothurOut("[ERROR]: " + firstCol + " is not in your fastafile, but is in your namesfile, please correct."); mothurOutEndLine();
-                       }else {
-                               seqPriorityNode temp(num, it->second, firstCol);
-                               nameVector.push_back(temp);
-                       }
-               }
-               in.close();
-               
-               return error;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "readNames");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-int MothurOut::getNumNames(string names){
-       try {
-               int count = 0;
-               
-               if(names != ""){
-                       count = 1;
-                       for(int i=0;i<names.size();i++){
-                               if(names[i] == ','){
-                                       count++;
-                               }
-                       }
-               }
-               
-               return count;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getNumNames");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int MothurOut::getNumChar(string line, char c){
-       try {
-               int count = 0;
-               
-               if(line != ""){
-                       for(int i=0;i<line.size();i++){
-                               if(line[i] == c){
-                                       count++;
-                               }
-                       }
-               }
-               
-               return count;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getNumChar");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int MothurOut::mothurRemove(string filename){
-       try {
-               filename = getFullPathName(filename);
-               int error = remove(filename.c_str());
-               //if (error != 0) { 
-               //      if (errno != ENOENT) { //ENOENT == file does not exist
-               //              string message = "Error deleting file " + filename;
-               //              perror(message.c_str()); 
-               //      }
-               //}
-               return error;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "mothurRemove");
-               exit(1);
-       }
-}
-/***********************************************************************/
-bool MothurOut::mothurConvert(string item, int& num){
-       try {
-               bool error = false;
-               
-               if (isNumeric1(item)) {
-                       convert(item, num);
-               }else {
-                       num = 0;
-                       error = true;
-                       mothurOut("[ERROR]: cannot convert " + item + " to an integer."); mothurOutEndLine();
-                       commandInputsConvertError = true;
-               }
-               
-               return error;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "mothurConvert");
-               exit(1);
-       }
-}
-/***********************************************************************/
-bool MothurOut::isNumeric1(string stringToCheck){
-       try {
-               bool numeric = false;
-               
-               if(stringToCheck.find_first_not_of("0123456789.-") == string::npos) { numeric = true; }
-                       
-               return numeric;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "isNumeric1");
-               exit(1);
-       }
-       
-}
-/***********************************************************************/
-bool MothurOut::mothurConvert(string item, float& num){
-       try {
-               bool error = false;
-               
-               if (isNumeric1(item)) {
-                       convert(item, num);
-               }else {
-                       num = 0;
-                       error = true;
-                       mothurOut("[ERROR]: cannot convert " + item + " to a float."); mothurOutEndLine();
-                       commandInputsConvertError = true;
-               }
-               
-               return error;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "mothurConvert");
-               exit(1);
-       }
-}
-/***********************************************************************/
-bool MothurOut::mothurConvert(string item, double& num){
-       try {
-               bool error = false;
-               
-               if (isNumeric1(item)) {
-                       convert(item, num);
-               }else {
-                       num = 0;
-                       error = true;
-                       mothurOut("[ERROR]: cannot convert " + item + " to a double."); mothurOutEndLine();
-                       commandInputsConvertError = true;
-               }
-               
-               return error;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "mothurConvert");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-vector<vector<double> > MothurOut::binomial(int maxOrder){
-       try {
-       vector<vector<double> > binomial(maxOrder+1);
-       
-    for(int i=0;i<=maxOrder;i++){
-               binomial[i].resize(maxOrder+1);
-               binomial[i][0]=1;
-               binomial[0][i]=0;
-    }
-    binomial[0][0]=1;
-       
-    binomial[1][0]=1;
-    binomial[1][1]=1;
-       
-    for(int i=2;i<=maxOrder;i++){
-               binomial[1][i]=0;
-    }
-       
-    for(int i=2;i<=maxOrder;i++){
-               for(int j=1;j<=maxOrder;j++){
-                       if(i==j){       binomial[i][j]=1;                                                                       }
-                       if(j>i) {       binomial[i][j]=0;                                                                       }
-                       else    {       binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j];     }
-               }
-    }
-       
-       return binomial;
-       
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "binomial");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-unsigned int MothurOut::fromBase36(string base36){
-       try {
-               unsigned int num = 0;
-               
-               map<char, int> converts;
-               converts['A'] = 0;
-               converts['a'] = 0;
-               converts['B'] = 1;
-               converts['b'] = 1;
-               converts['C'] = 2;
-               converts['c'] = 2;
-               converts['D'] = 3;
-               converts['d'] = 3;
-               converts['E'] = 4;
-               converts['e'] = 4;
-               converts['F'] = 5;
-               converts['f'] = 5;
-               converts['G'] = 6;
-               converts['g'] = 6;
-               converts['H'] = 7;
-               converts['h'] = 7;
-               converts['I'] = 8;
-               converts['i'] = 8;
-               converts['J'] = 9;
-               converts['j'] = 9;
-               converts['K'] = 10;
-               converts['k'] = 10;
-               converts['L'] = 11;
-               converts['l'] = 11;
-               converts['M'] = 12;
-               converts['m'] = 12;
-               converts['N'] = 13;
-               converts['n'] = 13;
-               converts['O'] = 14;
-               converts['o'] = 14;
-               converts['P'] = 15;
-               converts['p'] = 15;
-               converts['Q'] = 16;
-               converts['q'] = 16;
-               converts['R'] = 17;
-               converts['r'] = 17;
-               converts['S'] = 18;
-               converts['s'] = 18;
-               converts['T'] = 19;
-               converts['t'] = 19;
-               converts['U'] = 20;
-               converts['u'] = 20;
-               converts['V'] = 21;
-               converts['v'] = 21;
-               converts['W'] = 22;
-               converts['w'] = 22;
-               converts['X'] = 23;
-               converts['x'] = 23;
-               converts['Y'] = 24;
-               converts['y'] = 24;
-               converts['Z'] = 25;
-               converts['z'] = 25;
-               converts['0'] = 26;
-               converts['1'] = 27;
-               converts['2'] = 28;
-               converts['3'] = 29;
-               converts['4'] = 30;
-               converts['5'] = 31;
-               converts['6'] = 32;
-               converts['7'] = 33;
-               converts['8'] = 34;
-               converts['9'] = 35;             
-               
-               int i = 0;
-               while (i < base36.length()) {
-                       char c = base36[i];
-                       num = 36 * num + converts[c];
-                       i++;
-               }
-               
-               return num;
-               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "fromBase36");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int MothurOut::factorial(int num){
-       try {
-               int total = 1;
-               
-               for (int i = 1; i <= num; i++) {
-                       total *= i;
-               }
-               
-               return total;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "factorial");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int MothurOut::getNumSeqs(ifstream& file){
-       try {
-               int numSeqs = count(istreambuf_iterator<char>(file),istreambuf_iterator<char>(), '>');
-               file.seekg(0);
-               return numSeqs;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getNumSeqs");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-void MothurOut::getNumSeqs(ifstream& file, int& numSeqs){
-       try {
-               string input;
-               numSeqs = 0;
-               while(!file.eof()){
-                       input = getline(file);
-                       if (input.length() != 0) {
-                               if(input[0] == '>'){ numSeqs++; }
-                       }
-               }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "getNumSeqs");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-
-//This function parses the estimator options and puts them in a vector
-void MothurOut::splitAtChar(string& estim, vector<string>& container, char symbol) {
-       try {
-               string individual = "";
-               int estimLength = estim.size();
-               for(int i=0;i<estimLength;i++){
-                       if(estim[i] == symbol){
-                               container.push_back(individual);
-                               individual = "";                                
-                       }
-                       else{
-                               individual += estim[i];
-                       }
-               }
-               container.push_back(individual);
-
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtChar");
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-
-//This function parses the estimator options and puts them in a vector
-void MothurOut::splitAtDash(string& estim, vector<string>& container) {
-       try {
-               string individual = "";
-               int estimLength = estim.size();
-               for(int i=0;i<estimLength;i++){
-                       if(estim[i] == '-'){
-                               container.push_back(individual);
-                               individual = "";                                
-                       }
-                       else{
-                               individual += estim[i];
-                       }
-               }
-               container.push_back(individual);
-
-       
-       /*      string individual;
-               
-               while (estim.find_first_of('-') != -1) {
-                       individual = estim.substr(0,estim.find_first_of('-'));
-                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-                               container.push_back(individual);
-                       }
-               }
-               //get last one
-               container.push_back(estim); */
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtDash");
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-//This function parses the label options and puts them in a set
-void MothurOut::splitAtDash(string& estim, set<string>& container) {
-       try {
-               string individual = "";
-               int estimLength = estim.size();
-               for(int i=0;i<estimLength;i++){
-                       if(estim[i] == '-'){
-                               container.insert(individual);
-                               individual = "";                                
-                       }
-                       else{
-                               individual += estim[i];
-                       }
-               }
-               container.insert(individual);
-
-       //      string individual;
-               
-       //      while (estim.find_first_of('-') != -1) {
-       //              individual = estim.substr(0,estim.find_first_of('-'));
-       //              if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-       //                      estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-       //                      container.insert(individual);
-       //              }
-       //      }
-               //get last one
-       //      container.insert(estim);
-       
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtDash");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-//This function parses the line options and puts them in a set
-void MothurOut::splitAtDash(string& estim, set<int>& container) {
-       try {
-               string individual;
-               int lineNum;
-               
-               while (estim.find_first_of('-') != -1) {
-                       individual = estim.substr(0,estim.find_first_of('-'));
-                       if ((estim.find_first_of('-')+1) <= estim.length()) { //checks to make sure you don't have dash at end of string
-                               estim = estim.substr(estim.find_first_of('-')+1, estim.length());
-                               convert(individual, lineNum); //convert the string to int
-                               container.insert(lineNum);
-                       }
-               }
-               //get last one
-               convert(estim, lineNum); //convert the string to int
-               container.insert(lineNum);
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtDash");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-//This function parses the a string and puts peices in a vector
-void MothurOut::splitAtComma(string& estim, vector<string>& container) {
-       try {
-               string individual = "";
-               int estimLength = estim.size();
-               for(int i=0;i<estimLength;i++){
-                       if(estim[i] == ','){
-                               container.push_back(individual);
-                               individual = "";                                
-                       }
-                       else{
-                               individual += estim[i];
-                       }
-               }
-               container.push_back(individual);
-               
-               
-               
-               
-//             string individual;
-//             
-//             while (estim.find_first_of(',') != -1) {
-//                     individual = estim.substr(0,estim.find_first_of(','));
-//                     if ((estim.find_first_of(',')+1) <= estim.length()) { //checks to make sure you don't have comma at end of string
-//                             estim = estim.substr(estim.find_first_of(',')+1, estim.length());
-//                             container.push_back(individual);
-//                     }
-//             }
-//             //get last one
-//             container.push_back(estim);
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtComma");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-//This function splits up the various option parameters
-void MothurOut::splitAtChar(string& prefix, string& suffix, char c){
-       try {
-               prefix = suffix.substr(0,suffix.find_first_of(c));
-               if ((suffix.find_first_of(c)+2) <= suffix.length()) {  //checks to make sure you don't have comma at end of string
-                       suffix = suffix.substr(suffix.find_first_of(c)+1, suffix.length());
-                       string space = " ";
-                       while(suffix.at(0) == ' ')
-                               suffix = suffix.substr(1, suffix.length());
-               }
-        
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtComma");
-               exit(1);
-       }       
-}
-
-/***********************************************************************/
-
-//This function splits up the various option parameters
-void MothurOut::splitAtComma(string& prefix, string& suffix){
-       try {
-               prefix = suffix.substr(0,suffix.find_first_of(','));
-               if ((suffix.find_first_of(',')+2) <= suffix.length()) {  //checks to make sure you don't have comma at end of string
-                       suffix = suffix.substr(suffix.find_first_of(',')+1, suffix.length());
-                       string space = " ";
-                       while(suffix.at(0) == ' ')
-                               suffix = suffix.substr(1, suffix.length());
-               }
-
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtComma");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-
-//This function separates the key value from the option value i.e. dist=96_...
-void MothurOut::splitAtEquals(string& key, string& value){             
-       try {
-               if(value.find_first_of('=') != -1){
-                       key = value.substr(0,value.find_first_of('='));
-                       if ((value.find_first_of('=')+1) <= value.length()) {
-                               value = value.substr(value.find_first_of('=')+1, value.length());
-                       }
-               }else{
-                       key = value;
-                       value = 1;
-               }
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "splitAtEquals");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-bool MothurOut::inUsersGroups(string groupname, vector<string> Groups) {
-       try {
-               for (int i = 0; i < Groups.size(); i++) {
-                       if (groupname == Groups[i]) { return true; }
-               }
-               return false;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "inUsersGroups");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-//returns true if any of the strings in first vector are in second vector
-bool MothurOut::inUsersGroups(vector<string> groupnames, vector<string> Groups) {
-       try {
-               
-               for (int i = 0; i < groupnames.size(); i++) {
-                       if (inUsersGroups(groupnames[i], Groups)) { return true; }
-               }
-               return false;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "inUsersGroups");
-               exit(1);
-       }       
-}
-/***********************************************************************/
-//this function determines if the user has given us labels that are smaller than the given label.
-//if so then it returns true so that the calling function can run the previous valid distance.
-//it's a "smart" distance function.  It also checks for invalid labels.
-bool MothurOut::anyLabelsToProcess(string label, set<string>& userLabels, string errorOff) {
-       try {
-               
-               set<string>::iterator it;
-               vector<float> orderFloat;
-               map<string, float> userMap;  //the conversion process removes trailing 0's which we need to put back
-               map<string, float>::iterator it2;
-               float labelFloat;
-               bool smaller = false;
-               
-               //unique is the smallest line
-               if (label == "unique") {  return false;  }
-               else { 
-                       if (convertTestFloat(label, labelFloat)) {
-                               convert(label, labelFloat); 
-                       }else { //cant convert 
-                               return false;
-                       }
-               }
-               
-               //go through users set and make them floats
-               for(it = userLabels.begin(); it != userLabels.end();) {
-                       
-                       float temp;
-                       if ((*it != "unique") && (convertTestFloat(*it, temp) == true)){
-                               convert(*it, temp);
-                               orderFloat.push_back(temp);
-                               userMap[*it] = temp;
-                               it++;
-                       }else if (*it == "unique") { 
-                               orderFloat.push_back(-1.0);
-                               userMap["unique"] = -1.0;
-                               it++;
-                       }else {
-                               if (errorOff == "") {  mothurOut(*it + " is not a valid label."); mothurOutEndLine();  }
-                               userLabels.erase(it++); 
-                       }
-               }
-               
-               //sort order
-               sort(orderFloat.begin(), orderFloat.end());
-               
-               /*************************************************/
-               //is this label bigger than any of the users labels
-               /*************************************************/
-                               
-               //loop through order until you find a label greater than label
-               for (int i = 0; i < orderFloat.size(); i++) {
-                       if (orderFloat[i] < labelFloat) {
-                               smaller = true;
-                               if (orderFloat[i] == -1) { 
-                                       if (errorOff == "") { mothurOut("Your file does not include the label unique."); mothurOutEndLine(); }
-                                       userLabels.erase("unique");
-                               }
-                               else {  
-                                       if (errorOff == "") { mothurOut("Your file does not include the label "); mothurOutEndLine(); }
-                                       string s = "";
-                                       for (it2 = userMap.begin(); it2!= userMap.end(); it2++) {  
-                                               if (it2->second == orderFloat[i]) {  
-                                                       s = it2->first;  
-                                                       //remove small labels
-                                                       userLabels.erase(s);
-                                                       break;
-                                               }
-                                       }
-                                       if (errorOff == "") {mothurOut( s +  ". I will use the next smallest distance. "); mothurOutEndLine(); }
-                               }
-                       //since they are sorted once you find a bigger one stop looking
-                       }else { break; }
-               }
-               
-               return smaller;
-                                               
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "anyLabelsToProcess");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-bool MothurOut::checkReleaseVersion(ifstream& file, string version) {
-       try {
-               
-               bool good = true;
-               
-               string line = getline(file);  
-
-               //before we added this check
-               if (line[0] != '#') {  good = false;  }
-               else {
-                       //rip off #
-                       line = line.substr(1);
-                       
-                       vector<string> versionVector;
-                       splitAtChar(version, versionVector, '.');
-                       
-                       //check file version
-                       vector<string> linesVector;
-                       splitAtChar(line, linesVector, '.');
-                       
-                       if (versionVector.size() != linesVector.size()) { good = false; }
-                       else {
-                               for (int j = 0; j < versionVector.size(); j++) {
-                                       int num1, num2;
-                                       convert(versionVector[j], num1);
-                                       convert(linesVector[j], num2);
-                                       
-                                       //if mothurs version is newer than this files version, then we want to remake it
-                                       if (num1 > num2) {  good = false; break;  }
-                               }
-                       }
-                       
-               }
-               
-               if (!good) {  file.close();  }
-               else { file.seekg(0);  }
-               
-               return good;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "checkReleaseVersion");                
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-bool MothurOut::isContainingOnlyDigits(string input) {
-       try{
-               
-               //are you a digit in ascii code
-               for (int i = 0;i < input.length(); i++){
-                       if( input[i]>47 && input[i]<58){}
-                       else { return false; }
-               }
-               
-               return true;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "isContainingOnlyDigits");             
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int MothurOut::removeConfidences(string& tax) {
-       try {
-               
-               string taxon;
-               string newTax = "";
-               
-               while (tax.find_first_of(';') != -1) {
-                       
-                       if (control_pressed) { return 0; }
-                       
-                       //get taxon
-                       taxon = tax.substr(0,tax.find_first_of(';'));
-       
-                       int pos = taxon.find_last_of('(');
-                       if (pos != -1) {
-                               //is it a number?
-                               int pos2 = taxon.find_last_of(')');
-                               if (pos2 != -1) {
-                                       string confidenceScore = taxon.substr(pos+1, (pos2-(pos+1)));
-                                       if (isNumeric1(confidenceScore)) {
-                                               taxon = taxon.substr(0, pos); //rip off confidence 
-                                       }
-                               }
-                       }
-                       taxon += ";";
-                       
-                       tax = tax.substr(tax.find_first_of(';')+1, tax.length());
-                       newTax += taxon;
-               }
-               
-               tax = newTax;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               errorOut(e, "MothurOut", "removeConfidences");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
-
-
-
diff --git a/mothurout.h b/mothurout.h
deleted file mode 100644 (file)
index 9ce698b..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-#ifndef MOTHUROUT_H
-#define MOTHUROUT_H
-
-/*
- *  mothurOut.h
- *  Mothur
- *
- *  Created by westcott on 2/25/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-/***********************************************/
-struct logger {
-    
-    logger() {}
-    ~logger() {}
-    
-    template< class T >
-    logger& operator <<( const T& o ) {
-        cout << o; return *this;
-    }
-    
-    logger& operator<<(ostream& (*m)(ostream&) ) {
-        cout << m; return *this;
-    }
-    
-}; 
-/***********************************************/
-
-class MothurOut {
-       
-       public:
-               static MothurOut* getInstance();
-               void setFileName(string);
-               
-               void mothurOut(string); //writes to cout and the logfile
-               void mothurOutEndLine(); //writes to cout and the logfile
-               void mothurOut(string, ofstream&); //writes to the ofstream, cout and the logfile
-               void mothurOutEndLine(ofstream&); //writes to the ofstream, cout and the logfile
-               void mothurOutJustToLog(string);
-               void errorOut(exception&, string, string);
-               void closeLog();
-               string getDefaultPath() { return defaultPath; }
-               void setDefaultPath(string);
-               string getOutputDir() { return outputDir; }
-               void setOutputDir(string);
-               
-               string getReleaseDate() { return releaseDate; }
-               void setReleaseDate(string r) { releaseDate = r; }
-               string getVersion() { return version; }
-               void setVersion(string r) { version = r; }
-       
-               void addGroup(string g) { Groups.push_back(g); }
-               void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
-               void clearGroups() { Groups.clear(); }
-           int getNumGroups() { return Groups.size(); }
-               vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
-               void addAllGroup(string g) { namesOfGroups.push_back(g); }
-               void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
-               void clearAllGroups() { namesOfGroups.clear(); }
-               int getNumAllGroups() { return namesOfGroups.size(); }
-       
-               vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
-               vector<string> Treenames;
-               //map<string, string> names;
-               vector<string> binLabelsInFile;
-               vector<string> currentBinLabels;
-               string saveNextLabel, argv, sharedHeaderMode;
-               bool printedHeaders, commandInputsConvertError;
-               
-               //functions from mothur.h
-               //file operations
-        bool dirCheck(string&); //completes path, appends appropriate / or \, makes sure dir is writable.
-               vector<unsigned long long> divideFile(string, int&);
-               int divideFile(string, int&, vector<string>&);
-               vector<unsigned long long> setFilePosEachLine(string, int&);
-               vector<unsigned long long> setFilePosFasta(string, int&);
-               string sortFile(string, string);
-               int appendFiles(string, string);
-               int renameFile(string, string); //oldname, newname
-               string getFullPathName(string);
-               string hasPath(string);
-               string getExtension(string);
-               string getPathName(string);
-               string getSimpleName(string);
-               string getRootName(string);
-               bool isBlank(string);
-               int openOutputFile(string, ofstream&);
-               int openOutputFileAppend(string, ofstream&);
-               int openInputFile(string, ifstream&);
-               int openInputFile(string, ifstream&, string); //no error given 
-               string getline(ifstream&);
-               string getline(istringstream&);
-               void gobble(istream&);
-               void gobble(istringstream&);
-               map<string, int> readNames(string);
-               int readNames(string, map<string, string>&);
-               int readNames(string, map<string, vector<string> >&);
-               int readNames(string, vector<seqPriorityNode>&, map<string, string>&);
-               int mothurRemove(string);
-               bool mothurConvert(string, int&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
-               bool mothurConvert(string, float&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
-               bool mothurConvert(string, double&); //use for converting user inputs. Sets commandInputsConvertError to true if error occurs. Engines check this.
-       
-               
-               //searchs and checks
-               bool checkReleaseVersion(ifstream&, string);
-               bool anyLabelsToProcess(string, set<string>&, string);
-               bool inUsersGroups(vector<string>, vector<string>);
-               bool inUsersGroups(string, vector<string>);
-               void getNumSeqs(ifstream&, int&);
-               int getNumSeqs(ifstream&);
-               int getNumNames(string);
-               int getNumChar(string, char);
-               bool isTrue(string);
-               bool isContainingOnlyDigits(string);
-               bool isNumeric1(string);
-       
-               
-               //string manipulation
-               void splitAtEquals(string&, string&);
-               void splitAtComma(string&, string&);    
-               void splitAtComma(string&, vector<string>&);
-               void splitAtDash(string&, set<int>&);
-               void splitAtDash(string&, set<string>&);
-               void splitAtDash(string&, vector<string>&);
-               void splitAtChar(string&, vector<string>&, char);
-        void splitAtChar(string&, string&, char);
-               int removeConfidences(string&);
-               
-               //math operation
-               int factorial(int num);
-               vector<vector<double> > binomial(int);
-               float ceilDist(float, int);
-               float roundDist(float, int);
-               unsigned int fromBase36(string);
-               int getRandomIndex(int); //highest
-
-               int control_pressed;
-               bool executing, runParse, jumble, gui, mothurCalling;
-               
-               //current files - if you add a new type you must edit optionParser->getParameters, get.current command and mothurOut->printCurrentFiles/clearCurrentFiles.
-               string getPhylipFile()          { return phylipfile;            }
-               string getColumnFile()          { return columnfile;            }
-               string getListFile()            { return listfile;                      }
-               string getRabundFile()          { return rabundfile;            }
-               string getSabundFile()          { return sabundfile;            }
-               string getNameFile()            { return namefile;                      }       
-               string getGroupFile()           { return groupfile;                     }       
-               string getOrderFile()           { return orderfile;                     }
-               string getOrderGroupFile()      { return ordergroupfile;        }
-               string getTreeFile()            { return treefile;                      }
-               string getSharedFile()          { return sharedfile;            }
-               string getRelAbundFile()        { return relabundfile;          }
-               string getDesignFile()          { return designfile;            }
-               string getFastaFile()           { return fastafile;                     }
-               string getSFFFile()                     { return sfffile;                       }
-               string getQualFile()            { return qualfile;                      }
-               string getOligosFile()          { return oligosfile;            }
-               string getAccnosFile()          { return accnosfile;            }
-               string getTaxonomyFile()        { return taxonomyfile;          }
-               string getFlowFile()            { return flowfile;                      }
-        string getBiomFile()           { return biomfile;                      }
-               string getProcessors()          { return processors;            }
-               
-               void setListFile(string f)                      { listfile = getFullPathName(f);                        }
-               void setTreeFile(string f)                      { treefile = getFullPathName(f);                        }
-               void setGroupFile(string f)                     { groupfile = getFullPathName(f);                       }               
-               void setPhylipFile(string f)            { phylipfile = getFullPathName(f);                      }
-               void setColumnFile(string f)            { columnfile = getFullPathName(f);                      }
-               void setNameFile(string f)                      { namefile = getFullPathName(f);                        }       
-               void setRabundFile(string f)            { rabundfile = getFullPathName(f);                      }
-               void setSabundFile(string f)            { sabundfile = getFullPathName(f);                      }
-               void setSharedFile(string f)            { sharedfile = getFullPathName(f);                      }
-               void setRelAbundFile(string f)          { relabundfile = getFullPathName(f);            }
-               void setOrderFile(string f)                     { orderfile = getFullPathName(f);                       }
-               void setOrderGroupFile(string f)        { ordergroupfile = getFullPathName(f);          }
-               void setDesignFile(string f)            { designfile = getFullPathName(f);                      }
-               void setFastaFile(string f)                     { fastafile = getFullPathName(f);                       }
-               void setSFFFile(string f)                       { sfffile = getFullPathName(f);                         }
-               void setQualFile(string f)                      { qualfile = getFullPathName(f);                        }
-               void setOligosFile(string f)            { oligosfile = getFullPathName(f);                      }
-               void setAccnosFile(string f)            { accnosfile = getFullPathName(f);                      }
-               void setTaxonomyFile(string f)          { taxonomyfile = getFullPathName(f);            }
-               void setFlowFile(string f)                      { flowfile = getFullPathName(f);                        }
-        void setBiomFile(string f)                     { biomfile = getFullPathName(f);                        }
-               void setProcessors(string p)            { processors = p;                                                       }
-               
-               void printCurrentFiles();
-               bool hasCurrentFiles();
-               void clearCurrentFiles();
-               
-       private:
-               static MothurOut* _uniqueInstance;
-               MothurOut( const MothurOut& ); // Disable copy constructor
-               void operator=( const MothurOut& ); // Disable assignment operator
-               MothurOut() { 
-                       control_pressed = false; defaultPath=""; 
-                       phylipfile = "";
-                       columnfile = "";
-                       listfile = "";
-                       rabundfile = "";
-                       sabundfile = "";
-                       namefile = "";
-                       groupfile = "";
-                       designfile = "";
-                       orderfile = "";
-                       treefile = "";
-                       sharedfile = "";
-                       ordergroupfile = "";
-                       relabundfile = "";
-                       fastafile = "";
-                       qualfile = "";
-                       sfffile = "";
-                       oligosfile = "";
-                       accnosfile = "";
-                       taxonomyfile = "";
-                       processors = "1";
-                       flowfile = "";
-            biomfile = "";
-                       gui = false;
-                       printedHeaders = false;
-                       commandInputsConvertError = false;
-            mothurCalling = false;
-                       sharedHeaderMode = "";
-               }
-               ~MothurOut();
-
-               string logFileName;
-               string defaultPath, outputDir;
-               string releaseDate, version;
-       
-               string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
-               string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
-
-               vector<string> Groups;
-               vector<string> namesOfGroups;
-               ofstream out;
-               
-               int mem_usage(double&, double&);
-
-};
-/***********************************************/
-
-#endif
-
diff --git a/myPerseus.cpp b/myPerseus.cpp
deleted file mode 100644 (file)
index f7cb65e..0000000
+++ /dev/null
@@ -1,1073 +0,0 @@
-/*
- *  myPerseus.cpp
- *  
- *
- *  Created by Pat Schloss on 9/5/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "myPerseus.h"
-
-/**************************************************************************************************/
-int PERSEUSMAXINT = numeric_limits<int>::max();
-/**************************************************************************************************/
-
-vector<vector<double> > Perseus::binomial(int maxOrder){
-       try {
-               vector<vector<double> > binomial(maxOrder+1);
-               
-               for(int i=0;i<=maxOrder;i++){
-                       binomial[i].resize(maxOrder+1);
-                       binomial[i][0]=1;
-                       binomial[0][i]=0;
-               }
-               binomial[0][0]=1;
-               
-               binomial[1][0]=1;
-               binomial[1][1]=1;
-               
-               for(int i=2;i<=maxOrder;i++){
-                       binomial[1][i]=0;
-               }
-               
-               for(int i=2;i<=maxOrder;i++){
-                       for(int j=1;j<=maxOrder;j++){
-                               if(i==j){       binomial[i][j]=1;                                                                       }
-                               if(j>i) {       binomial[i][j]=0;                                                                       }
-                               else    {       binomial[i][j]=binomial[i-1][j-1]+binomial[i-1][j];     }
-                       }
-               }
-               
-               return binomial;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "binomial");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-double Perseus::basicPairwiseAlignSeqs(string query, string reference, string& qAlign, string& rAlign, pwModel model){
-       try {
-               double GAP = model.GAP_OPEN;
-               double MATCH = model.MATCH;
-               double MISMATCH = model.MISMATCH;
-               
-               int queryLength = query.size();
-               int refLength = reference.size();
-               
-               vector<vector<double> > alignMatrix(queryLength + 1);
-               vector<vector<char> > alignMoves(queryLength + 1);
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i].resize(refLength + 1, 0);
-                       alignMoves[i].resize(refLength + 1, 'x');
-               }
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i][0] = GAP * i;
-                       alignMoves[i][0] = 'u';
-               }
-               
-               for(int i=0;i<=refLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[0][i] = GAP * i;
-                       alignMoves[0][i] = 'l';
-               }
-               
-               for(int i=1;i<=queryLength;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       for(int j=1;j<=refLength;j++){
-                               
-                               double nogapScore;              
-                               if(query[i-1] == reference[j-1]){       nogapScore = alignMatrix[i-1][j-1] + MATCH;             }
-                               else                                                    {       nogapScore = alignMatrix[i-1][j-1] + MISMATCH;  }
-                               
-                               double leftScore;
-                               if(i == queryLength)                    {       leftScore = alignMatrix[i][j-1];                                }
-                               else                                                    {       leftScore = alignMatrix[i][j-1] + GAP;                  }
-                               
-                               
-                               double upScore;
-                               if(j == refLength)                              {       upScore = alignMatrix[i-1][j];                                  }
-                               else                                                    {       upScore = alignMatrix[i-1][j] + GAP;                    }
-                               
-                               if(nogapScore > leftScore){
-                                       if(nogapScore > upScore){
-                                               alignMoves[i][j] = 'd';
-                                               alignMatrix[i][j] = nogapScore;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = upScore;
-                                       }
-                               }
-                               else{
-                                       if(leftScore > upScore){
-                                               alignMoves[i][j] = 'l';
-                                               alignMatrix[i][j] = leftScore;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = upScore;
-                                       }
-                               }
-                       }
-               }
-               
-               int i = queryLength;
-               int j = refLength;
-               
-               qAlign = "";
-               rAlign = "";
-                       
-               int diffs = 0;
-               int length = 0;
-               
-               while(i > 0 && j > 0){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(alignMoves[i][j] == 'd'){
-                               qAlign = query[i-1] + qAlign;
-                               rAlign = reference[j-1] + rAlign;
-
-                               if(query[i-1] != reference[j-1]){       diffs++;        }
-                               length++;
-                               
-                               i--;
-                               j--;
-                       }
-                       else if(alignMoves[i][j] == 'u'){
-                               qAlign = query[i-1] + qAlign;
-                               
-                               if(j != refLength)      {       rAlign = '-' + rAlign;  diffs++;        length++;       }
-                               else                            {       rAlign = '.' + rAlign;  }
-                               i--;
-                       }
-                       else if(alignMoves[i][j] == 'l'){
-                               rAlign = reference[j-1] + rAlign;
-                               
-                               if(i != queryLength){   qAlign = '-' + qAlign;  diffs++;        length++;       }
-                               else                            {       qAlign = '.' + qAlign;  }
-                               j--;
-                       }
-               }
-               
-               while(i>0){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       rAlign = '.' + rAlign;
-                       qAlign = query[i-1] + qAlign;
-                       i--;
-               }
-               
-               while(j>0){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       rAlign = reference[j-1] + rAlign;
-                       qAlign = '.' + qAlign;
-                       j--;
-               }
-               
-               
-
-               return double(diffs)/double(length);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "basicPairwiseAlignSeqs");
-               exit(1);
-       }
-       
-}
-/**************************************************************************************************/
-int Perseus::getDiffs(string qAlign, string rAlign, vector<int>& leftDiffs, vector<int>& leftMap, vector<int>& rightDiffs, vector<int>& rightMap){
-       try {
-               int alignLength = qAlign.length();
-               
-               int lDiffs = 0;
-               int lCount = 0;
-               for(int l=0;l<alignLength;l++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(qAlign[l] == '-'){
-                               lDiffs++;               
-                       }
-                       else if(qAlign[l] != '.'){
-                               
-                               if(rAlign[l] == '-'){
-                                       lDiffs++;
-                               }
-                               else if(qAlign[l] != rAlign[l] && rAlign[l] != '.'){
-                                       lDiffs++;
-                               }
-                               leftDiffs[lCount] = lDiffs;
-                               leftMap[lCount] = l;
-                               
-                               lCount++;
-                       }                       
-               }
-               
-               int rDiffs = 0;
-               int rCount = 0;
-               for(int l=alignLength-1;l>=0;l--){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(qAlign[l] == '-'){
-                               rDiffs++;               
-                       }
-                       else if(qAlign[l] != '.'){
-                               
-                               if(rAlign[l] == '-'){
-                                       rDiffs++;
-                               }
-                               else if(qAlign[l] != rAlign[l] && rAlign[l] != '.'){
-                                       rDiffs++;
-                               }
-                               
-                               rightDiffs[rCount] = rDiffs;
-                               rightMap[rCount] = l;
-                               rCount++;
-                               
-                       }
-                       
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "getDiffs");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Perseus::getLastMatch(char direction, vector<vector<char> >& alignMoves, int i, int j, string& seqA, string& seqB){
-       try {
-               char nullReturn = -1;
-               
-               while(i>=1 && j>=1){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(direction == 'd'){
-                               if(seqA[i-1] == seqB[j-1])      {       return seqA[i-1];       }
-                               else                                            {       return nullReturn;      }
-                       }
-                       
-                       else if(direction == 'l')               {       j--;                            }
-                       else                                                    {       i--;                            }
-                       
-                       direction = alignMoves[i][j];
-               }
-               
-               return nullReturn;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "getLastMatch");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int Perseus::toInt(char b){
-       try {
-               if(b == 'A')            {       return 0;       }
-               else if(b == 'C')       {       return 1;       }
-               else if(b == 'T')       {       return 2;       }
-               else if(b == 'G')       {       return 3;       }
-               else { m->mothurOut("[ERROR]: " + toString(b) + " is not ATGC."); m->mothurOutEndLine(); return -1; }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "toInt");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double Perseus::modeledPairwiseAlignSeqs(string query, string reference, string& qAlign, string& rAlign, vector<vector<double> >& correctMatrix){
-       try {
-               int queryLength = query.size();
-               int refLength = reference.size();
-               
-               vector<vector<double> > alignMatrix(queryLength + 1);
-               vector<vector<char> > alignMoves(queryLength + 1);
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i].resize(refLength + 1, 0);
-                       alignMoves[i].resize(refLength + 1, 'x');
-               }
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i][0] = 15.0 * i;
-                       alignMoves[i][0] = 'u';
-               }
-               
-               for(int i=0;i<=refLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[0][i] = 15.0 * i;
-                       alignMoves[0][i] = 'l';
-               }
-               
-               for(int i=1;i<=queryLength;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       for(int j=1;j<=refLength;j++){
-                               
-                               double nogap;           
-                               nogap = alignMatrix[i-1][j-1] + correctMatrix[toInt(query[i-1])][toInt(reference[j-1])];                        
-                               
-                               double gap;
-                               
-                               double left;
-                               if(i == queryLength){ //terminal gap
-                                       left = alignMatrix[i][j-1];
-                               }
-                               else{
-                                       if(reference[j-1] == getLastMatch('l', alignMoves, i, j, query, reference)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       left = alignMatrix[i][j-1] + gap;
-                               }
-                               
-                               double up;
-                               if(j == refLength){ //terminal gap
-                                       up = alignMatrix[i-1][j];
-                               }
-                               else{
-                                       
-                                       if(query[i-1] == getLastMatch('u', alignMoves, i, j, query, reference)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       up = alignMatrix[i-1][j] + gap;
-                               }
-                               
-                               
-                               if(nogap < left){
-                                       if(nogap < up){
-                                               alignMoves[i][j] = 'd';
-                                               alignMatrix[i][j] = nogap;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                               else{
-                                       if(left < up){
-                                               alignMoves[i][j] = 'l';
-                                               alignMatrix[i][j] = left;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                       }
-               }
-
-               int i = queryLength;
-               int j = refLength;
-               
-               int alignLength = 0;
-               
-               while(i > 0 && j > 0){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(alignMoves[i][j] == 'd'){
-                               qAlign = query[i-1] + qAlign;
-                               rAlign = reference[j-1] + rAlign;
-                               alignLength++;
-                               i--;
-                               j--;
-                       }
-                       else if(alignMoves[i][j] == 'u'){
-                               if(j != refLength){
-                                       qAlign = query[i-1] + qAlign;
-                                       rAlign = '-' + rAlign;
-                                       alignLength++;
-                               }
-                               
-                               i--;
-                       }
-                       else if(alignMoves[i][j] == 'l'){
-                               if(i != queryLength){
-                                       qAlign = '-' + qAlign;
-                                       rAlign = reference[j-1] + rAlign;
-                                       alignLength++;                          
-                               }
-                               
-                               j--;
-                       }
-               }
-
-               return alignMatrix[queryLength][refLength] / (double)alignLength;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "modeledPairwiseAlignSeqs");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int Perseus::getAlignments(int curSequenceIndex, vector<seqData> sequences, vector<pwAlign>& alignments, vector<vector<int> >& leftDiffs, vector<vector<int> >& leftMaps, vector<vector<int> >& rightDiffs, vector<vector<int> >& rightMaps, int& bestRefSeq, int& bestRefDiff, vector<bool>& restricted){
-       try {
-               int numSeqs = sequences.size();
-               //int bestSequenceMismatch = PERSEUSMAXINT;
-
-               string curSequence = sequences[curSequenceIndex].sequence;
-               int curFrequency = sequences[curSequenceIndex].frequency; 
-
-               bestRefSeq = -1;
-               
-               int bestIndex = -1;
-               int bestDiffs = PERSEUSMAXINT;
-               int comparisons = 0;
-                       
-               pwModel model(0, -1, -1.5);
-               
-               for(int i=0;i<numSeqs;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(i != curSequenceIndex && restricted[i] != 1 && sequences[i].frequency >= 2 * curFrequency){
-                               string refSequence = sequences[i].sequence;
-                               
-                               leftDiffs[i].assign(curSequence.length(), 0);
-                               leftMaps[i].assign(curSequence.length(), 0);
-                               rightDiffs[i].assign(curSequence.length(), 0);
-                               rightMaps[i].assign(curSequence.length(), 0);
-                               
-                               basicPairwiseAlignSeqs(curSequence, refSequence, alignments[i].query, alignments[i].reference, model);
-                               
-
-                               getDiffs(alignments[i].query, alignments[i].reference, leftDiffs[i], leftMaps[i], rightDiffs[i], rightMaps[i]);
-                               
-                               int diffs = rightDiffs[i][curSequence.length()-1];                                                      
-
-                               if(diffs < bestDiffs){
-                                       bestDiffs = diffs;
-                                       bestIndex = i;
-                               }
-                               comparisons++;
-                               restricted[i] = 0;
-                       }
-                       else{
-                               restricted[i] = 1;
-                       }
-               }
-
-               bestRefSeq = bestIndex;
-               bestRefDiff = bestDiffs;
-               
-               return comparisons;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "getAlignments");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Perseus::getChimera(vector<seqData> sequences,
-                          vector<vector<int> >& leftDiffs, 
-                          vector<vector<int> >& rightDiffs,
-                          int& leftParent, 
-                          int& rightParent, 
-                          int& breakPoint,
-                          vector<int>& singleLeft, 
-                          vector<int>& bestLeft, 
-                          vector<int>& singleRight, 
-                          vector<int>& bestRight, 
-                          vector<bool> restricted){
-       try {
-               int numRefSeqs = restricted.size();
-               int seqLength = leftDiffs[0].size();
-               
-               singleLeft.resize(seqLength, PERSEUSMAXINT);
-               bestLeft.resize(seqLength, -1);
-
-               for(int l=0;l<seqLength;l++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       for(int i=0;i<numRefSeqs;i++){
-                               
-                               if(restricted[i] == 0){
-                                       if(((leftDiffs[i][l] < singleLeft[l]) && sequences[i].frequency) || ((leftDiffs[i][l] == singleLeft[l]) && (sequences[i].frequency > sequences[bestLeft[l]].frequency))){
-                                               singleLeft[l] = leftDiffs[i][l];
-                                               bestLeft[l] = i;
-                                       }
-                               }
-                       }
-               }
-               
-               singleRight.resize(seqLength, PERSEUSMAXINT);
-               bestRight.resize(seqLength, -1);
-               
-               for(int l=0;l<seqLength;l++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       for(int i=0;i<numRefSeqs;i++){
-                               
-                               if(restricted[i] == 0){
-                                       if((rightDiffs[i][l] < singleRight[l] && sequences[i].frequency) || ((rightDiffs[i][l] == singleRight[l] && sequences[i].frequency > sequences[bestRight[l]].frequency))){
-                                               singleRight[l] = rightDiffs[i][l];
-                                               bestRight[l] = i;
-                                       }
-                               }
-                       }
-               }
-
-               
-               
-               int bestChimeraMismatches = PERSEUSMAXINT;
-               leftParent = -1;
-               rightParent = -1;
-               breakPoint = -1;
-               
-               for(int l=0;l<seqLength-1;l++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       int chimera = singleLeft[l] + singleRight[seqLength - l - 2];
-                       if(chimera < bestChimeraMismatches){
-                               bestChimeraMismatches = chimera;
-                               breakPoint = l;
-                               leftParent = bestLeft[l];
-                               rightParent = bestRight[seqLength - l - 2];
-                       }
-               }
-               
-               return bestChimeraMismatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "getChimera");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string Perseus::stitchBimera(vector<pwAlign>& alignments, int leftParent, int rightParent, int breakPoint, vector<vector<int> >& leftMaps, vector<vector<int> >& rightMaps){
-       try {
-               int breakLeft = leftMaps[leftParent][breakPoint];
-               int breakRight = rightMaps[rightParent][rightMaps[rightParent].size() - breakPoint - 2];
-               
-               string left = alignments[leftParent].reference;
-               string right = alignments[rightParent].reference;
-               string chimera = "";
-               
-               for(int i=0;i<=breakLeft;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(left[i] != '-' && left[i] != '.'){
-                               chimera += left[i];
-                       }
-               }
-               
-
-               for(int i=breakRight;i<right.length();i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(right[i] != '-' && right[i] != '.'){
-                               chimera += right[i];
-                       }
-               }
-               
-               return chimera;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "stitchBimera");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Perseus::getTrimera(vector<seqData>& sequences,
-                          vector<vector<int> >& leftDiffs,
-                          int& leftParent,
-                          int& middleParent,
-                          int& rightParent,
-                          int& breakPointA,
-                          int& breakPointB,
-                          vector<int>& singleLeft,
-                          vector<int>& bestLeft, 
-                          vector<int>& singleRight,
-                          vector<int>& bestRight,
-                          vector<bool> restricted){
-       try {
-               int numRefSeqs = leftDiffs.size();
-               int alignLength = leftDiffs[0].size();
-               int bestTrimeraMismatches = PERSEUSMAXINT;
-               
-               leftParent = -1;
-               middleParent = -1;
-               rightParent = -1;
-               
-               breakPointA = -1;
-               breakPointB = -1;
-               
-               vector<vector<int> > minDelta(alignLength);
-               vector<vector<int> > minDeltaSeq(alignLength);
-               
-               for(int i=0;i<alignLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       minDelta[i].assign(alignLength, PERSEUSMAXINT);
-                       minDeltaSeq[i].assign(alignLength, -1);
-               }
-               
-               for(int x=0;x<alignLength;x++){
-                       for(int y=x;y<alignLength-1;y++){
-                               for(int i=0;i<numRefSeqs;i++){
-                                       
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       if(restricted[i] == 0){
-                                               int delta = leftDiffs[i][y] - leftDiffs[i][x];
-
-                                               if(delta < minDelta[x][y] || (delta == minDelta[x][y] && sequences[i].frequency > sequences[minDeltaSeq[x][y]].frequency)){
-                                                       minDelta[x][y] = delta;
-                                                       minDeltaSeq[x][y] = i;                                  
-                                               }                               
-                                       }
-                               }
-                               minDelta[x][y] += singleLeft[x] + singleRight[alignLength - y - 2];
-                               
-                               if(minDelta[x][y] < bestTrimeraMismatches){
-                                       bestTrimeraMismatches = minDelta[x][y];
-                                       
-                                       breakPointA = x;
-                                       breakPointB = y;
-                                       
-                                       leftParent = bestLeft[x];
-                                       middleParent = minDeltaSeq[x][y];
-                                       rightParent = bestRight[alignLength - y - 2];                           
-                               }
-                       }               
-               }
-               
-               return bestTrimeraMismatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "getTrimera");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string Perseus::stitchTrimera(vector<pwAlign> alignments, int leftParent, int middleParent, int rightParent, int breakPointA, int breakPointB, vector<vector<int> >& leftMaps, vector<vector<int> >& rightMaps){
-       try {
-               int p1SplitPoint = leftMaps[leftParent][breakPointA];
-               int p2SplitPoint = leftMaps[middleParent][breakPointB];
-               int p3SplitPoint = rightMaps[rightParent][rightMaps[rightParent].size() - breakPointB - 2];
-               
-               string chimeraRefSeq;
-               for(int i=0;i<=p1SplitPoint;i++){
-                       if (m->control_pressed) { return chimeraRefSeq; }
-                       if(alignments[leftParent].reference[i] != '-' && alignments[leftParent].reference[i] != '.'){
-                               chimeraRefSeq += alignments[leftParent].reference[i];
-                       }
-               }
-               
-               for(int i=p1SplitPoint+1;i<=p2SplitPoint;i++){
-                       if (m->control_pressed) { return chimeraRefSeq; }
-                       if(alignments[middleParent].reference[i] != '-' && alignments[middleParent].reference[i] != '.'){
-                               chimeraRefSeq += alignments[middleParent].reference[i];
-                       }
-               }
-               
-               for(int i=p3SplitPoint;i<alignments[rightParent].reference.length();i++){
-                       if (m->control_pressed) { return chimeraRefSeq; }
-                       if(alignments[rightParent].reference[i] != '-' && alignments[rightParent].reference[i] != '.'){
-                               chimeraRefSeq += alignments[rightParent].reference[i];
-                       }
-               }
-
-               return chimeraRefSeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "stitchTrimera");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int Perseus::threeWayAlign(string query, string parent1, string parent2, string& qAlign, string& aAlign, string& bAlign){
-       try {
-               pwModel model(1.0, -1.0, -5.0);
-               
-               string qL, rL;
-               string qR, rR;
-
-               basicPairwiseAlignSeqs(query, parent1, qL, rL, model);  
-               basicPairwiseAlignSeqs(query, parent2, qR, rR, model);
-
-               int lLength = qL.length();
-               int rLength = qR.length();
-               
-               string qLNew, rLNew;
-               string qRNew, rRNew;
-               
-               int lIndex = 0;
-               int rIndex = 0;
-               
-               while(lIndex<lLength || rIndex<rLength){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(qL[lIndex] == qR[rIndex]){
-                               qLNew += qL[lIndex];
-                               rLNew += rL[lIndex];
-                               lIndex++;
-
-                               qRNew += qR[rIndex];
-                               rRNew += rR[rIndex];
-                               rIndex++;
-                       }
-                       else if(qL[lIndex] == '-' || qL[lIndex] == '.'){
-                               //insert a gap into the right sequences
-                               qLNew += qL[lIndex];
-                               rLNew += rL[lIndex];
-                               lIndex++;
-                               
-                               if(rIndex != rLength){
-                                       qRNew += '-';
-                                       rRNew += '-';
-                               }
-                               else{
-                                       qRNew += '.';
-                                       rRNew += '.';
-                               }
-                       }
-                       else if(qR[rIndex] == '-' || qR[rIndex] == '.'){
-                               //insert a gap into the left sequences
-                               qRNew += qR[rIndex];
-                               rRNew += rR[rIndex];
-                               rIndex++;
-                               
-
-                               if(lIndex != lLength){
-                                       qLNew += '-';
-                                       rLNew += '-';
-                               }
-                               else{
-                                       qLNew += '.';
-                                       rLNew += '.';
-                               }
-                               
-                       }
-               }
-               
-               qAlign = qLNew;
-               aAlign = rLNew;
-               bAlign = rRNew;
-               
-               bool qStart = 0;
-               bool aStart = 0;
-               bool bStart = 0;
-               
-               for(int i=0;i<qAlign.length();i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(qStart == 0){
-                               if(qAlign[i] == '-')    {       qAlign[i] = '.';        }
-                               else                                    {       qStart = 1;                     }
-                       }
-                       if(aStart == 0){
-                               if(aAlign[i] == '-')    {       aAlign[i] = '.';        }
-                               else                                    {       aStart = 1;                     }
-                       }
-                       if(bStart == 0){
-                               if(bAlign[i] == '-')    {       bAlign[i] = '.';        }
-                               else                                    {       bStart = 1;                     }
-                       }
-                       if(aStart == 1 && bStart == 1 && qStart == 1){
-                               break;
-                       }
-               }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "threeWayAlign");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double Perseus::calcLoonIndex(string query, string parent1, string parent2, int breakPoint, vector<vector<double> >& binMatrix){
-       try {
-               string queryAln, leftParentAln, rightParentAln;
-               threeWayAlign(query, parent1, parent2, queryAln, leftParentAln, rightParentAln);
-               
-               int alignLength = queryAln.length();
-
-               int endPos = alignLength;
-               for(int i=alignLength-1;i>=0; i--){
-                       if(queryAln[i] != '.' && leftParentAln[i] != '.' && rightParentAln[i] != '.'){
-                               endPos = i + 1;
-                               break;
-                       }
-               }
-               
-               int diffToLeftCount = 0;
-               vector<int> diffToLeftMap(alignLength, 0);
-               
-               int diffToRightCount = 0;
-               vector<int> diffToRightMap(alignLength, 0);
-               
-               for(int i=0;i<endPos;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(queryAln[i] != leftParentAln[i]){
-                               diffToLeftMap[diffToLeftCount] = i;
-                               diffToLeftCount++;
-                       }
-                       
-                       if(queryAln[i] != rightParentAln[i]){
-                               diffToRightMap[diffToRightCount] = i;
-                               diffToRightCount++;
-                       }
-               }
-               
-               
-               
-               diffToLeftMap[diffToLeftCount] = endPos;
-               diffToRightMap[diffToRightCount] = endPos;
-               
-               int indexL = 0;
-               int indexR = 0;
-               int indexS = 0;
-               
-               vector<int> diffs;
-               vector<int> splits;
-               
-               splits.push_back(-1);
-               diffs.push_back(diffToRightCount);
-               indexS++;
-                       
-               while(indexL < diffToLeftCount || indexR < diffToRightCount){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(diffToLeftMap[indexL] <= diffToRightMap[indexR]){
-                               diffs.push_back(diffs[indexS - 1] + 1);
-                               splits.push_back(diffToLeftMap[indexL]);
-                               
-                               indexL++;
-                               indexS++;                       
-                       }
-                       else if(diffToLeftMap[indexL] > diffToRightMap[indexR]) {
-                               diffs.push_back(diffs[indexS - 1] - 1);
-                               splits.push_back(diffToRightMap[indexR]);
-                               
-                               indexR++;
-                               indexS++;                       
-                       }
-               }
-               
-               int minDiff = PERSEUSMAXINT;
-               int minIndex = -1;
-               for(int i=0;i<indexS;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(diffs[i] < minDiff){
-                               minDiff = diffs[i];
-                               minIndex = i;
-                       }
-               }
-               
-               int splitPos = endPos;
-               if(minIndex < indexS - 1){
-                       splitPos = (splits[minIndex]+splits[minIndex+1]) / 2;
-               }
-               
-               int diffToChimera = 0;
-               int leftDiffToP1 = 0;
-               int rightDiffToP1 = 0;
-               int leftDiffToP2 = 0;
-               int rightDiffToP2 = 0;
-               
-               for(int i=0;i<endPos;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       char bQuery = queryAln[i];
-                       char bP1 = leftParentAln[i];
-                       char bP2 = rightParentAln[i];
-                       
-                       char bConsensus = bQuery;
-                       if(bP1 == bP2){ bConsensus = bP1;       }
-                       
-                       if(bConsensus != bQuery){
-                               diffToChimera++;
-                       }
-                       
-                       if(bConsensus != bP1){
-                               if(i <= splitPos){
-                                       leftDiffToP1++;
-                               }
-                               else{
-                                       rightDiffToP1++;                                
-                               }
-                       }
-                       if(bConsensus != bP2){
-                               if(i <= splitPos){
-                                       leftDiffToP2++;
-                               }
-                               else{
-                                       rightDiffToP2++;                                
-                               }
-                       }
-               }               
-               
-
-               int diffToClosestParent, diffToFurtherParent;
-               int xA, xB, yA, yB;
-               double aFraction, bFraction;
-               
-               if(diffToLeftCount <= diffToRightCount){        //if parent 1 is closer
-
-                       diffToClosestParent = leftDiffToP1 + rightDiffToP1;
-                       xA = leftDiffToP1;
-                       xB = rightDiffToP1;
-                       
-                       diffToFurtherParent = leftDiffToP2 + rightDiffToP2;
-                       yA = leftDiffToP2;
-                       yB = rightDiffToP2;
-                       
-                       aFraction = double(splitPos + 1)/(double) endPos;
-                       bFraction = 1 - aFraction;
-                       
-               }
-               else{                                                                                           //if parent 2 is closer
-
-                       diffToClosestParent = leftDiffToP2 + rightDiffToP2;
-                       xA = rightDiffToP2;
-                       xB = leftDiffToP2;
-                       
-                       diffToFurtherParent = leftDiffToP1 + rightDiffToP1;
-                       yA = rightDiffToP1;
-                       yB = leftDiffToP1;
-                       
-                       bFraction = double(splitPos + 1)/(double) endPos;
-                       aFraction = 1 - bFraction;
-
-               }
-               
-               double loonIndex = 0;
-               
-               int totalDifference = diffToClosestParent + diffToChimera;
-               
-               if(totalDifference > 0){
-                       double prob = 0;
-                       
-                       for(int i=diffToClosestParent;i<=totalDifference;i++){
-                               prob += binMatrix[totalDifference][i] * pow(0.50, i) * pow(0.50, totalDifference - i);
-                       }
-                       loonIndex += -log(prob);
-               }
-               
-               if(diffToFurtherParent > 0){
-                       double prob = 0;
-                       
-                       for(int i=yA;i<=diffToFurtherParent;i++){
-                               prob += binMatrix[diffToFurtherParent][i] * pow(aFraction, i) * pow(1-aFraction, diffToFurtherParent - i);
-                       }
-                       loonIndex += -log(prob);
-               }
-               
-               if(diffToClosestParent > 0){
-                       double prob = 0;
-                       
-                       for(int i=xB;i<=diffToClosestParent;i++){
-                               prob += binMatrix[diffToClosestParent][i] * pow(bFraction, i) * pow(1-bFraction, diffToClosestParent - i);
-                       }
-                       loonIndex += -log(prob);
-               }
-               
-               return loonIndex;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "calcLoonIndex");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double Perseus::calcBestDistance(string query, string reference){
-       try {
-               int alignLength = query.length();
-               int mismatch = 0;
-               int counter = 0;
-               
-               for(int i=0;i<alignLength;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if((query[i] != '.' || reference[i] != '.') && (query[i] != '-' && reference[i] != '-')){
-                               if(query[i] != reference[i]){   mismatch++;     }
-                               counter++;                      
-                       }
-               }
-               
-               return (double)mismatch / (double)counter;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "calcBestDistance");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double Perseus::classifyChimera(double singleDist, double cIndex, double loonIndex, double alpha, double beta){
-       try {
-               double difference = cIndex - singleDist;        //y
-               double probability;
-               
-               if(cIndex >= 0.15 || difference > 0.00){
-                       probability = 0.0000;
-               }
-               else{
-                       probability = 1.0 / (1.0 + exp(-(alpha + beta * loonIndex)));
-               }
-               
-               return probability;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Perseus", "classifyChimera");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
diff --git a/myPerseus.h b/myPerseus.h
deleted file mode 100644 (file)
index 93ef8ae..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef MOTHURPERSEUS
-#define MOTHURPERSEUS
-
-/*
- *  myPerseus.h
- *  
- *
- *  Created by Pat Schloss on 9/5/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "mothurout.h"
-
-/**************************************************************************************************/
-struct seqData {
-       
-       seqData(string name, string seq, int freq) : seqName(name), sequence(seq), frequency(freq) {    }
-       
-       bool operator<( seqData const& rhs ) const {
-               
-               bool verdict = 0;
-               
-               if(frequency < rhs.frequency){
-                       verdict = 1;
-               }
-               else if(frequency == rhs.frequency){
-                       verdict = (seqName > rhs.seqName);
-               }
-               
-               return verdict; 
-       }
-       
-       string seqName;
-       string sequence;
-       int frequency;
-};
-/**************************************************************************************************/
-struct pwModel {
-       pwModel(double m, double mm, double g): MATCH(m), MISMATCH(mm), GAP_OPEN(g) {;}
-       double MATCH;
-       double MISMATCH;
-       double GAP_OPEN;        
-};
-/**************************************************************************************************/
-struct pwAlign {
-       pwAlign(): query(""), reference(""){}
-       pwAlign(string q, string r): query(q), reference(r){}
-       string query;
-       string reference;
-       
-};
-/**************************************************************************************************/
-class Perseus {
-       
-public:
-       Perseus() { m = MothurOut::getInstance(); }
-       ~Perseus() {}
-       
-       vector<vector<double> > binomial(int);
-       double modeledPairwiseAlignSeqs(string, string, string&, string&, vector<vector<double> >&);
-       int getAlignments(int, vector<seqData>, vector<pwAlign>&, vector<vector<int> >& , vector<vector<int> >&, vector<vector<int> >&, vector<vector<int> >&, int&, int&, vector<bool>&);
-       int getChimera(vector<seqData>,vector<vector<int> >&, vector<vector<int> >&,int&, int&, int&,vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<bool>);
-       string stitchBimera(vector<pwAlign>&, int, int, int, vector<vector<int> >&, vector<vector<int> >&);
-       int getTrimera(vector<seqData>&, vector<vector<int> >&, int&, int&, int&, int&, int&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<bool>);
-       string stitchTrimera(vector<pwAlign>, int, int, int, int, int, vector<vector<int> >&, vector<vector<int> >&);
-       double calcLoonIndex(string, string, string, int, vector<vector<double> >&);
-       double classifyChimera(double, double, double, double, double);
-       
-private:
-       MothurOut* m;
-       int toInt(char);
-       double basicPairwiseAlignSeqs(string, string, string&, string&, pwModel);
-       int getDiffs(string, string, vector<int>&, vector<int>&, vector<int>&, vector<int>&);
-       int getLastMatch(char, vector<vector<char> >&, int, int, string&, string&);
-       int threeWayAlign(string, string, string, string&, string&, string&);
-       double calcBestDistance(string, string);
-
-       
-};
-/**************************************************************************************************/
-#endif
-
-
diff --git a/myseqdist.cpp b/myseqdist.cpp
deleted file mode 100644 (file)
index 78255d8..0000000
+++ /dev/null
@@ -1,416 +0,0 @@
-/*
- *  pds.seqdist.cpp
- *  
- *
- *  Created by Pat Schloss on 8/12/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "myseqdist.h"
-#include "sequence.hpp"
-
-/**************************************************************************************************/
-correctDist::correctDist(int p) : processors(p) {
-       try {
-               m = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "correctDist");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-correctDist::correctDist(string sequenceFileName, int p) : processors(p) {
-       try {
-               m = MothurOut::getInstance();
-               getSequences(sequenceFileName);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "correctDist");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int correctDist::addSeq(string seqName, string seqSeq){
-       try {
-               names.push_back(seqName);
-               sequences.push_back(fixSequence(seqSeq));
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "addSeq");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int correctDist::execute(string distanceFileName){
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-               processors = 1;
-#endif
-               correctMatrix.resize(4);
-               for(int i=0;i<4;i++){   correctMatrix[i].resize(4);     }
-               
-               correctMatrix[0][0] = 0.000000;         //AA
-               correctMatrix[1][0] = 11.619259;        //CA
-               correctMatrix[2][0] = 11.694004;        //TA
-               correctMatrix[3][0] = 7.748623;         //GA
-               
-               correctMatrix[1][1] = 0.000000;         //CC
-               correctMatrix[2][1] = 7.619657;         //TC
-               correctMatrix[3][1] = 12.852562;        //GC
-               
-               correctMatrix[2][2] = 0.000000;         //TT
-               correctMatrix[3][2] = 10.964048;        //TG
-               
-               correctMatrix[3][3] = 0.000000;         //GG
-               
-               for(int i=0;i<4;i++){
-                       for(int j=0;j<i;j++){
-                               correctMatrix[j][i] = correctMatrix[i][j];
-                       }
-               }
-               
-               numSeqs = names.size();
-                               
-               if(processors == 1){ driver(0, numSeqs, distanceFileName); }
-               else{
-                       
-                       for(int i=0;i<processors;i++){
-                               start.push_back(int (sqrt(float(i)/float(processors)) * numSeqs));
-                               end.push_back(int (sqrt(float(i+1)/float(processors)) * numSeqs));
-                       }
-                       
-                       createProcess(distanceFileName);
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int correctDist::getSequences(string sequenceFileName){
-       try {
-               ifstream sequenceFile;
-               m->openInputFile(sequenceFileName, sequenceFile);
-               string seqName, seqSeq;
-               
-               while(!sequenceFile.eof()){
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence temp(sequenceFile); m->gobble(sequenceFile);
-                       
-                       if (temp.getName() != "") {
-                               names.push_back(temp.getName());
-                               sequences.push_back(fixSequence(temp.getAligned()));
-                       }
-               }
-               sequenceFile.close();
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "getSequences");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-vector<int> correctDist::fixSequence(string sequence){
-       try {
-               int alignLength = sequence.length();
-               
-               vector<int> seqVector;
-               
-               for(int i=0;i<alignLength;i++){
-                       if(sequence[i] == 'A')          {       seqVector.push_back(0);         }
-                       else if(sequence[i] == 'C')     {       seqVector.push_back(1);         }
-                       else if(sequence[i] == 'T')     {       seqVector.push_back(2);         }
-                       else if(sequence[i] == 'G')     {       seqVector.push_back(3);         }
-                       else if(sequence[i] == 'N')     {       seqVector.push_back(0);         }//hmmmm....
-               }
-               
-               return seqVector;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "fixSequence");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-int correctDist::createProcess(string distanceFileName){
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDs;
-               
-               while(process != processors){
-                       
-                       int pid = fork();
-                       
-                       if(pid > 0){
-                               processIDs.push_back(pid);
-                               process++;
-                       }
-                       else if(pid == 0){
-                               driver(start[process], end[process], distanceFileName + toString(getpid()) + ".temp");
-                               exit(0);
-                       }
-                       else{
-                               cout << "Doh!" << endl;
-                               for (int i=0;i<processIDs.size();i++) {  int temp = processIDs[i]; kill(temp, SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               driver(start[0], end[0], distanceFileName);
-               
-               for (int i=0;i<processIDs.size();i++) { 
-                       int temp = processIDs[i];
-                       wait(&temp);
-               }
-               
-               for(int i=0;i<processIDs.size();i++){
-                       m->appendFiles((distanceFileName + toString(processIDs[i]) + ".temp"), distanceFileName);
-                       remove((distanceFileName + toString(processIDs[i]) + ".temp").c_str());
-               }
-#endif
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "createProcess");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-int correctDist::driver(int start, int end, string distFileName){
-       try {
-               ofstream distFile;
-               m->openOutputFile(distFileName, distFile);
-               distFile << setprecision(9);
-               
-               if(start == 0){
-                       distFile << numSeqs << endl;
-               }
-               
-               int startTime = time(NULL);
-               
-               m->mothurOut("\nCalculating distances...\n");
-               
-               for(int i=start;i<end;i++){
-                       
-                       distFile << i;
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { distFile.close(); return 0; }
-                               
-                               double dist = getDist(sequences[i], sequences[j]);
-                               
-                               distFile << ' ' << dist;
-                       }
-                       distFile << endl;
-                       
-                       if(i % 100 == 0){ m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine(); }
-               }
-               distFile.close();
-               
-               if((end-1) % 100 != 0){ m->mothurOut(toString(end-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine(); }
-               m->mothurOut("Done.\n");
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "driver");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-double correctDist::getDist(vector<int>& seqA, vector<int>& seqB){
-       try {
-               
-               int lengthA = seqA.size();
-               int lengthB = seqB.size();
-               
-               vector<vector<double> > alignMatrix(lengthA+1);
-               vector<vector<char> > alignMoves(lengthA+1);
-               
-               for(int i=0;i<=lengthA;i++){
-                       alignMatrix[i].resize(lengthB+1, 0);
-                       alignMoves[i].resize(lengthB+1, 'x');
-               }
-               
-               for(int i=0;i<=lengthA;i++){
-                       alignMatrix[i][0] = 15.0 * i;
-                       alignMoves[i][0] = 'u';
-               }
-               for(int i=0;i<=lengthB;i++){
-                       alignMatrix[0][i] = 15.0 * i;
-                       alignMoves[0][i] = 'l';
-               }
-               
-               for(int i=1;i<=lengthA;i++){
-                       for(int j=1;j<=lengthB;j++){
-                               
-                               if (m->control_pressed) {  return 0;  }
-                               
-                               double nogap;           
-                               nogap = alignMatrix[i-1][j-1] + correctMatrix[seqA[i-1]][seqB[j-1]];
-                               
-                               
-                               double gap;
-                               double left;
-                               if(i == lengthA){ //terminal gap
-                                       left = alignMatrix[i][j-1];
-                               }
-                               else{
-                                       if(seqB[j-1] == getLastMatch('l', alignMoves, i, j, seqA, seqB)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       left = alignMatrix[i][j-1] + gap;
-                               }
-                               
-                               
-                               double up;
-                               if(j == lengthB){ //terminal gap
-                                       up = alignMatrix[i-1][j];
-                               }
-                               else{
-                                       
-                                       if(seqA[i-1] == getLastMatch('u', alignMoves, i, j, seqA, seqB)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       up = alignMatrix[i-1][j] + gap;
-                               }
-                               
-                               
-                               
-                               if(nogap < left){
-                                       if(nogap < up){
-                                               alignMoves[i][j] = 'd';
-                                               alignMatrix[i][j] = nogap;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                               else{
-                                       if(left < up){
-                                               alignMoves[i][j] = 'l';
-                                               alignMatrix[i][j] = left;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                       }
-               }
-               
-               int i = lengthA;
-               int j = lengthB;
-               int count = 0;
-               
-               
-               //      string alignA = "";
-               //      string alignB = "";
-               //      string bases = "ACTG";
-               //      
-               //      for(int i=0;i<lengthA;i++){
-               //              cout << bases[seqA[i]];
-               //      }cout << endl;
-               //
-               //      for(int i=0;i<lengthB;i++){
-               //              cout << bases[seqB[i]];
-               //      }cout << endl;
-               
-               while(i > 0 && j > 0){
-                       
-                       if (m->control_pressed) {  return 0;  }
-                       
-                       if(alignMoves[i][j] == 'd'){
-                               //                      alignA = bases[seqA[i-1]] + alignA;
-                               //                      alignB = bases[seqB[j-1]] + alignB;
-                               
-                               count++;
-                               i--;
-                               j--;
-                       }
-                       else if(alignMoves[i][j] == 'u'){
-                               if(j != lengthB){
-                                       //                              alignA = bases[seqA[i-1]] + alignA;
-                                       //                              alignB = '-' + alignB;
-                                       count++;
-                               }
-                               
-                               i--;
-                       }
-                       else if(alignMoves[i][j] == 'l'){
-                               if(i != lengthA){
-                                       //                              alignA = '-' + alignA;
-                                       //                              alignB = bases[seqB[j-1]] + alignB;
-                                       count++;
-                               }
-                               
-                               j--;
-                       }
-               }
-               
-               //      cout << alignA << endl << alignB << endl;
-               
-               return alignMatrix[lengthA][lengthB] / (double)count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "getDist");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-int correctDist::getLastMatch(char direction, vector<vector<char> >& alignMoves, int i, int j, vector<int>& seqA, vector<int>& seqB){
-       try {
-               
-               char nullReturn = -1;
-               
-               while(i>=1 && j>=1){
-                       
-                       if (m->control_pressed) { return nullReturn; }
-                       
-                       if(direction == 'd'){
-                               if(seqA[i-1] == seqB[j-1])      {       return seqA[i-1];       }
-                               else                                            {       return nullReturn;      }
-                       }
-                       
-                       else if(direction == 'l')               {       j--;                            }
-                       else                                                    {       i--;                            }
-                       
-                       direction = alignMoves[i][j];
-               }
-               
-               return nullReturn;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "correctDist", "getLastMatch");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-
-
-
diff --git a/myseqdist.h b/myseqdist.h
deleted file mode 100644 (file)
index 74c9ea7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef CORRECTDIST_H
-#define CORRECTDIST_H
-
-
-/*
- *  pds.seqdist.h
- *  
- *
- *  Created by Pat Schloss on 8/12/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-
-/**************************************************************************************************/
-
-class correctDist {
-public:
-       correctDist(string, int);
-       correctDist(int);
-       ~correctDist(){}
-       
-       int addSeq(string, string);
-       int execute(string);
-       
-private:
-       MothurOut* m;
-       int getSequences(string);
-       vector<int> fixSequence(string);
-       
-       int driver(int, int, string);
-       int createProcess(string);
-       
-       double getDist(vector<int>&, vector<int>&);
-       int getLastMatch(char, vector<vector<char> >&, int, int, vector<int>&, vector<int>&);
-       
-       vector<vector<double> > correctMatrix;
-       
-       vector<vector<int> > sequences;
-       
-       vector<string> names;   
-       int numSeqs;
-       int processors;
-       vector<int> start;
-       vector<int> end;
-};
-
-/**************************************************************************************************/
-
-#endif
-
-
diff --git a/nameassignment.cpp b/nameassignment.cpp
deleted file mode 100644 (file)
index 3d99551..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-
-
-#include "nameassignment.hpp"
-
-//**********************************************************************************************************************
-
-NameAssignment::NameAssignment(string nameMapFile){
-       m = MothurOut::getInstance();
-       m->openInputFile(nameMapFile, fileHandle);
-       
-}
-
-//**********************************************************************************************************************
-
-void NameAssignment::readMap(){
-       try{
-               string firstCol, secondCol, skip;
-       //      int index = 0;
-       
-               
-               map<string, int>::iterator itData;
-               int rowIndex = 0;
-               
-               while(fileHandle){
-                       fileHandle >> firstCol;                         //read from first column
-                       fileHandle >> secondCol;                        //read from second column
-                                               
-                       itData = (*this).find(firstCol);
-                       if (itData == (*this).end()) {
-                       
-                               (*this)[firstCol] = rowIndex++;
-                               list.push_back(secondCol);              //adds data's value to list
-                               reverse[rowIndex] = firstCol;
-                               
-                       }else{  m->mothurOut(firstCol + " is already in namesfile. I will use first definition."); m->mothurOutEndLine();  }
-                       
-                       m->gobble(fileHandle);
-               }
-               fileHandle.close();
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NameAssignment", "readMap");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void NameAssignment::push_back(string name) {
-       try{
-       
-               int num = (*this).size();
-               (*this)[name] = num;
-               reverse[num] = name;
-               
-               list.push_back(name);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NameAssignment", "push_back");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-ListVector NameAssignment::getListVector(void){
-
-       return list;
-       
-}
-
-//**********************************************************************************************************************
-
-void NameAssignment::print(ostream& out){
-       try {
-               map<string,int>::iterator it;
-//cout << (*this).size() << endl;
-               for(it = (*this).begin(); it!=(*this).end(); it++){
-                       out << it->first << '\t' <<  it->second << endl;  //prints out keys and values of the map this.
-                       //out << it->first << '\t' <<  it->first << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NameAssignment", "print");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int NameAssignment::get(string key){
-       try {
-               map<string, int>::iterator itGet = (*this).find(key);
-               
-               //if you can't find it
-               if (itGet == (*this).end()) { return -1; }
-               
-               return  (*this)[key];   
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NameAssignment", "get");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-string NameAssignment::get(int key){
-       try {
-       
-               map<int, string>::iterator itGet = reverse.find(key);
-       
-               if (itGet == reverse.end()) { return "not found"; }
-       
-               return  reverse[key];   
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NameAssignment", "get");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/nameassignment.hpp b/nameassignment.hpp
deleted file mode 100644 (file)
index 758a080..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef NAMEASSIGNMENT_HPP
-#define NAMEASSIGNMENT_HPP
-
-#include "mothur.h"
-#include "listvector.hpp"
-
-class NameAssignment : public map<string,int> {
-public:
-       NameAssignment(string);
-       NameAssignment(){};
-       void readMap();
-       ListVector getListVector();
-       int get(string);
-       string get(int);
-       void print(ostream&);
-       void push_back(string);
-private:
-       ifstream fileHandle;
-       ListVector list;
-       map<int, string> reverse;
-       MothurOut* m;
-};
-
-
-
-
-#endif
diff --git a/nast.cpp b/nast.cpp
deleted file mode 100644 (file)
index 647e0e4..0000000
--- a/nast.cpp
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- *  nast.cpp
- *  
- *
- *  Created by Pat Schloss on 12/17/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is my implementation of the NAST (nearest alignment space termination) algorithm as described in:
- *
- *     DeSantis TZ, Hugenholtz P, Keller K, Brodie EL, Larsen N, Piceno YM, Phan R, & Anderson GL.  2006.  NAST: a multiple
- *             sequence alignment server for comparative analysis of 16S rRNA genes.  Nucleic Acids Research.  34:W394-9.
- *
- *     To construct an object one needs to provide a method of getting a pairwise alignment (alignment) and the template
- *     and candidate sequence that are to be aligned to each other.
- *
- */
-
-#include "sequence.hpp"
-#include "alignment.hpp"
-#include "nast.hpp"
-
-/**************************************************************************************************/
-
-Nast::Nast(Alignment* method, Sequence* cand, Sequence* temp) : alignment(method), candidateSeq(cand), templateSeq(temp) {
-       try {
-               m = MothurOut::getInstance();
-               maxInsertLength = 0;
-       
-               pairwiseAlignSeqs();    //      This is part A in Fig. 2 of DeSantis et al.
-               regapSequences();               //      This is parts B-F in Fig. 2 of DeSantis et al.
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Nast", "Nast");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void Nast::pairwiseAlignSeqs(){        //      Here we call one of the pairwise alignment methods to align our unaligned candidate
-                                                               //      and template sequences
-       try {   
-               alignment->align(candidateSeq->getUnaligned(), templateSeq->getUnaligned());
-
-               string candAln = alignment->getSeqAAln();
-               string tempAln = alignment->getSeqBAln();
-       
-               if(candAln == ""){
-
-                       candidateSeq->setPairwise("");
-                       templateSeq->setPairwise(templateSeq->getUnaligned());
-
-               }
-               else{
-                       if(tempAln[0] == '-'){
-                               int pairwiseAlignmentLength = tempAln.length(); //      we need to make sure that the candidate sequence alignment
-                               for(int i=0;i<pairwiseAlignmentLength;i++){             //      starts where the template sequence alignment starts, if it
-                                       if(isalpha(tempAln[i])){                                        //      starts early, we nuke the beginning of the candidate
-                                               candAln = candAln.substr(i);                    //      sequence
-                                               tempAln = tempAln.substr(i);
-                                               break;
-                                       }
-                               }
-                       }
-                       int pairwiseAlignmentLength = tempAln.length();
-                       if(tempAln[pairwiseAlignmentLength-1] == '-'){          //      we need to make sure that the candidate sequence alignment
-                               for(int i=pairwiseAlignmentLength-1; i>=0; i--){//      ends where the template sequence alignment ends, if it runs
-                                       if(isalpha(tempAln[i])){                                        //      long, we nuke the end of the candidate sequence
-                                               candAln = candAln.substr(0,i+1);
-                                               tempAln = tempAln.substr(0,i+1);
-                                               break;
-                                       }               
-                               }
-                       }
-
-               }
-
-               candidateSeq->setPairwise(candAln);                                     //      set the pairwise sequences in the Sequence objects for
-               templateSeq->setPairwise(tempAln);                                      //      the candidate and template sequences
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Nast", "pairwiseAlignSeqs");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-void Nast::removeExtraGaps(string& candAln, string tempAln, string newTemplateAlign){
-
-//     here we do steps C-F of Fig. 2 from DeSantis et al.
-       try {
-               
-               int longAlignmentLength = newTemplateAlign.length();    
-       
-               for(int i=0; i<longAlignmentLength; i++){                               //      use the long alignment as the standard
-                       int rightIndex, rightRoom, leftIndex, leftRoom;
-       
-                       //      Part C of Fig. 2 from DeSantis et al.
-                       if((isalpha(newTemplateAlign[i]) != isalpha(tempAln[i]))){      //if there is a discrepancy between the regapped
-                               
-                               rightRoom = 0; leftRoom = 0;
-                               
-                               //      Part D of Fig. 2 from DeSantis et al.           //      template sequence and the official template sequence
-                               for(leftIndex=i-1;leftIndex>0;leftIndex--){             //      then we've got problems...
-                                       if(!isalpha(candAln[leftIndex])){
-                                               leftRoom = 1;   //count how far it is to the nearest gap on the LEFT side of the anomaly
-                                               while(leftIndex-leftRoom>=0 && !isalpha(candAln[leftIndex-leftRoom]))   {       leftRoom++;             }
-                                               break;
-                                       }
-                               }
-
-                               for(rightIndex=i+1;rightIndex<longAlignmentLength-1;rightIndex++){
-                                       if(!isalpha(candAln[rightIndex])){
-                                               rightRoom = 1;  //count how far it is to the nearest gap on the RIGHT side of the anomaly
-                                               while(rightIndex+rightRoom<longAlignmentLength && !isalpha(candAln[rightIndex+rightRoom]))      {       rightRoom++;    }
-                                               break;
-                                       }
-                               }
-                                                               
-                               int insertLength = 0;                                                   //      figure out how long the anomaly is
-                               while(!isalpha(newTemplateAlign[i + insertLength]))     {       insertLength++; }
-                               if(insertLength > maxInsertLength){     maxInsertLength = insertLength; }
-               
-                               if((leftRoom + rightRoom) >= insertLength){
-       
-                                       //      Parts D & E from Fig. 2 of DeSantis et al.
-                                       if((i-leftIndex) <= (rightIndex-i)){            //      the left gap is closer - > move stuff left there's
-       
-                                               if(leftRoom >= insertLength){                   //      enough room to the left to move
-                       //cout << "lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << insertLength << endl;
-                                                       string leftTemplateString = newTemplateAlign.substr(0,i);
-                                                       string rightTemplateString = newTemplateAlign.substr((i+insertLength));
-                                                       newTemplateAlign = leftTemplateString + rightTemplateString;
-                                                       longAlignmentLength = newTemplateAlign.length();
-                       //cout << "lr candAln = " << candAln.length() << '\t' << leftIndex << '\t'  << endl;                            
-                                                       string leftCandidateString = candAln.substr(0,(leftIndex-insertLength+1));
-                                                       string rightCandidateString = candAln.substr((leftIndex+1));
-                                                       candAln = leftCandidateString + rightCandidateString;
-                                                       
-                                               }else{                                                                  //      not enough room to the left, have to steal some space to the right
-                                               
-                       //cout << "in else lr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << insertLength << endl;
-                                                       string leftTemplateString = newTemplateAlign.substr(0,i);       
-                                                       string rightTemplateString = newTemplateAlign.substr((i+insertLength));
-                                                       newTemplateAlign = leftTemplateString + rightTemplateString;
-                                                       longAlignmentLength = newTemplateAlign.length();
-                       //cout << " in else lr candAln = " << candAln.length() << '\t' << " leftIndex = " << leftIndex << " leftroom = " << leftRoom << " rightIndex = " << rightIndex << '\t' << " rightroom = " << rightRoom << '\t' << endl;                                 
-                                                       string leftCandidateString = candAln.substr(0,(leftIndex-leftRoom+1));
-                                                       string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
-                                                       string rightCandidateString = candAln.substr((rightIndex+(insertLength-leftRoom)));
-                                                       candAln = leftCandidateString + insertString + rightCandidateString;
-                               
-                                               }
-                                       }else{                                                                          //      the right gap is closer - > move stuff right there's
-                                               if(rightRoom >= insertLength){                  //      enough room to the right to move
-                       //cout << "rr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << i+insertLength << endl;
-                                                       string leftTemplateString = newTemplateAlign.substr(0,i);
-                                                       string rightTemplateString = newTemplateAlign.substr((i+insertLength));
-                                                       newTemplateAlign = leftTemplateString + rightTemplateString;
-                                                       longAlignmentLength = newTemplateAlign.length();
-                       //cout << "rr candAln = " << candAln.length() << '\t' << i << '\t' << rightIndex << '\t' << rightIndex+insertLength << endl;                            
-                                                       string leftCandidateString = candAln.substr(0,rightIndex);
-                                                       string rightCandidateString = candAln.substr((rightIndex+insertLength));
-                                                       candAln = leftCandidateString + rightCandidateString;   
-                                                                       
-                                               }
-                                               else{                                                                   //      not enough room to the right, have to steal some        
-                                                       //      space to the left lets move left and then right...
-                                       //cout << "in else rr newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << i+insertLength << endl;
-                                                       string leftTemplateString = newTemplateAlign.substr(0,i);
-                                                       string rightTemplateString = newTemplateAlign.substr((i+insertLength));
-                                                       newTemplateAlign = leftTemplateString + rightTemplateString;
-                                                       longAlignmentLength = newTemplateAlign.length();
-                                       //cout << "in else rr candAln = " << candAln.length() << '\t' << '\t' << (leftIndex-(insertLength-rightRoom)+1) << '\t' <<  (leftIndex+1,rightIndex-leftIndex-1) << '\t' << (rightIndex+rightRoom) << endl;                             
-                                                       string leftCandidateString = candAln.substr(0,(leftIndex-(insertLength-rightRoom)+1));
-                                                       string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
-                                                       string rightCandidateString = candAln.substr((rightIndex+rightRoom));
-                                                       candAln = leftCandidateString + insertString + rightCandidateString;    
-                                                                       
-                                               }
-                                       }
-                                       
-                                       if ((i - insertLength) < 0) {  i = 0; }
-                                       else { i -= insertLength; }
-
-                               }
-                               else{
-                       //      there could be a case where there isn't enough room in either direction to move stuff
-//cout << "in else else newTemplateAlign = " << newTemplateAlign.length() << '\t' << i << '\t' << (i+leftRoom+rightRoom) << endl;
-                                       string leftTemplateString = newTemplateAlign.substr(0,i);       
-                                       string rightTemplateString = newTemplateAlign.substr((i+leftRoom+rightRoom));
-                                       newTemplateAlign = leftTemplateString + rightTemplateString;
-                                       longAlignmentLength = newTemplateAlign.length();
-                                                       
-               //cout << "in else else newTemplateAlign = " << candAln.length() << '\t' << (leftIndex-leftRoom+1) << '\t' << (leftIndex+1) << '\t' << (rightIndex-leftIndex-1) << '\t' << (rightIndex+rightRoom) << endl;      
-                                       string leftCandidateString = candAln.substr(0,(leftIndex-leftRoom+1));
-                                       string insertString = candAln.substr((leftIndex+1),(rightIndex-leftIndex-1));
-                                       string rightCandidateString = candAln.substr((rightIndex+rightRoom));
-                                       candAln = leftCandidateString + insertString + rightCandidateString;
-                                       
-                                       i -= (leftRoom + rightRoom);
-                               }
-                       
-//                             i -= insertLength;
-                               
-                               //if i is negative, we want to remove the extra gaps to the right
-                               if (i < 0) { m->mothurOut("i is negative"); m->mothurOutEndLine(); } 
-                       } 
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Nast", "removeExtraGaps");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-void Nast::regapSequences(){   //This is essentially part B in Fig 2. of DeSantis et al.
-       try { 
-       //cout << candidateSeq->getName() << endl;
-               string candPair = candidateSeq->getPairwise();
-               string candAln = "";
-               
-               string tempPair = templateSeq->getPairwise();
-               string tempAln = templateSeq->getAligned();             //      we use the template aligned sequence as our guide
-               
-               int pairwiseLength = candPair.length();
-               int fullAlignLength = tempAln.length();
-               
-               if(candPair == ""){
-                       for(int i=0;i<fullAlignLength;i++)      {       candAln += '.';         }
-                       candidateSeq->setAligned(candAln);
-                       return;
-               }
-       
-               int fullAlignIndex = 0;
-               int pairwiseAlignIndex = 0;
-               string newTemplateAlign = "";                                   //      this is going to be messy so we want a temporary template
-               //      alignment string
-               while(tempAln[fullAlignIndex] == '.' || tempAln[fullAlignIndex]  == '-'){
-                       candAln += '.';                                                         //      add the initial '-' and '.' to the candidate and template
-                       newTemplateAlign += tempAln[fullAlignIndex];//  pairwise sequences
-                       fullAlignIndex++;
-               }
-
-               string lastLoop = "";
-               
-               while(pairwiseAlignIndex<pairwiseLength){
-       //cout << pairwiseAlignIndex << '\t' << fullAlignIndex << '\t' << pairwiseLength << endl;
-                       if(isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
-                          && isalpha(candPair[pairwiseAlignIndex])){
-                               //  the template and candidate pairwise and template aligned have characters
-                               //      need to add character onto the candidatSeq.aligned sequence
-                               
-                               candAln += candPair[pairwiseAlignIndex];
-                               newTemplateAlign += tempPair[pairwiseAlignIndex];//
-                               
-                               pairwiseAlignIndex++;
-                               fullAlignIndex++;
-                       }
-                       else if(isalpha(tempPair[pairwiseAlignIndex]) && !isalpha(tempAln[fullAlignIndex])
-                                       && isalpha(candPair[pairwiseAlignIndex])){
-                               //      the template pairwise and candidate pairwise are characters and the template aligned is a gap
-                               //      need to insert gaps into the candidateSeq.aligned sequence
-                               
-                               candAln += '-';
-                               newTemplateAlign += '-';//
-                               fullAlignIndex++;
-                       }
-                       else if(!isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
-                                       && isalpha(candPair[pairwiseAlignIndex])){
-                               //  the template pairwise is a gap and the template aligned and pairwise sequences have characters
-                               //      this is the alpha scenario.  add character to the candidateSeq.aligned sequence without progressing
-                               //      further through the tempAln sequence.
-                               
-                               candAln += candPair[pairwiseAlignIndex];
-                               newTemplateAlign += '-';//
-                               pairwiseAlignIndex++;
-                       }
-                       else if(isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
-                                       && !isalpha(candPair[pairwiseAlignIndex])){
-                               //  the template pairwise and full alignment are characters and the candidate sequence has a gap
-                               //      should not be a big deal, just add the gap position to the candidateSeq.aligned sequence;
-                               
-                               candAln += candPair[pairwiseAlignIndex];
-                               newTemplateAlign += tempAln[fullAlignIndex];//
-                               fullAlignIndex++;                       
-                               pairwiseAlignIndex++;
-                       }
-                       else if(!isalpha(tempPair[pairwiseAlignIndex]) && !isalpha(tempAln[fullAlignIndex])
-                                       && isalpha(candPair[pairwiseAlignIndex])){
-                               //      the template pairwise and aligned are gaps while the candidate pairwise has a character
-                               //      this would be an insertion, go ahead and add the character->seems to be the opposite of the alpha scenario
-                               
-                               candAln += candPair[pairwiseAlignIndex];
-                               newTemplateAlign += tempAln[fullAlignIndex];//
-                               pairwiseAlignIndex++;
-                               fullAlignIndex++;                       
-                       }
-                       else if(isalpha(tempPair[pairwiseAlignIndex]) && !isalpha(tempAln[fullAlignIndex])
-                                       && !isalpha(candPair[pairwiseAlignIndex])){
-                               //      template pairwise has a character, but its full aligned sequence and candidate sequence have gaps
-                               //      this would happen like we need to add a gap.  basically the opposite of the alpha situation
-                               
-                               newTemplateAlign += tempAln[fullAlignIndex];//
-                               candAln += "-";
-                               fullAlignIndex++;                       
-                       }
-                       else if(!isalpha(tempPair[pairwiseAlignIndex]) && isalpha(tempAln[fullAlignIndex])
-                                       && !isalpha(candPair[pairwiseAlignIndex])){
-                               //      template and candidate pairwise are gaps and the template aligned is not a gap this should not be possible
-                               //      would skip the gaps and not progress through full alignment sequence
-                               //      not tested yet
-                               
-                               m->mothurOut("We're into D " + toString(fullAlignIndex) + " " +  toString(pairwiseAlignIndex)); m->mothurOutEndLine();
-                               pairwiseAlignIndex++;
-                       }
-                       else{
-                               //      everything has a gap - not possible
-                               //      not tested yet
-                               
-                               m->mothurOut("We're into F " +  toString(fullAlignIndex) + " " +  toString(pairwiseAlignIndex)); m->mothurOutEndLine();
-                               pairwiseAlignIndex++;
-                               fullAlignIndex++;                       
-                       }               
-               }
-               
-               for(int i=fullAlignIndex;i<fullAlignLength;i++){
-                       candAln += '.';
-                       newTemplateAlign += tempAln[i];//
-               }
-               
-               int start = 0;
-               int end = candAln.length()-1;
-
-               for(int i=0;i<candAln.length();i++){
-                       if(candAln[i] == 'Z' || !isalnum(candAln[i]))   {       candAln[i] = '.';       }       //      if we padded the alignemnt from
-                       else{                   start = i;                      break;          }                                                       //      blast with Z's, change them to
-               }                                                                                                                                                               //      '.' characters
-               
-               for(int i=candAln.length()-1;i>=0;i--){                                                                                 //      ditto.
-                       if(candAln[i] == 'Z' || !isalnum(candAln[i]))   {       candAln[i] = '.';       }
-                       else{                   end = i;                        break;          }
-               }
-               
-               for(int i=start;i<=end;i++){                                    //      go through the candidate alignment sequence and make sure that
-                       candAln[i] = toupper(candAln[i]);                       //      everything is upper case
-               }
-               
-
-               if(candAln.length() != tempAln.length()){               //      if the regapped candidate sequence is longer than the official
-                       removeExtraGaps(candAln, tempAln, newTemplateAlign);//  template alignment then we need to do steps C-F in Fig.
-               }                                                                                               //      2 of Desantis et al.
-
-               candidateSeq->setAligned(candAln);
-       //cout << "here" << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Nast", "regapSequences");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-float Nast::getSimilarityScore(){
-       try {
-       
-               string cand = candidateSeq->getAligned();
-               string temp = templateSeq->getAligned();
-               int alignmentLength = temp.length();
-               int mismatch = 0;
-               int denominator = 0;
-               
-               for(int i=0;i<alignmentLength;i++){
-                       if(cand[i] == '-' && temp[i] == '-'){
-                               
-                       }
-                       else if(cand[i] != '.' && temp[i] != '.'){
-                               denominator++;
-                               
-                               if(cand[i] != temp[i]){
-                                       mismatch++;
-                               }
-                       }
-               }
-               float similarity = 100 * (1. - mismatch / (float)denominator);
-               if(denominator == 0){   similarity = 0.0000;    }
-               
-               return similarity;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Nast", "getSimilarityScore");
-               exit(1);
-       }       
-}
-
-/**************************************************************************************************/
-
-int Nast::getMaxInsertLength(){
-       
-       return maxInsertLength;
-       
-}
-       
-/**************************************************************************************************/
diff --git a/nast.hpp b/nast.hpp
deleted file mode 100644 (file)
index 9428aed..0000000
--- a/nast.hpp
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef NAST_HPP
-#define NAST_HPP
-
-/*
- *  nast.hpp
- *  
- *
- *  Created by Pat Schloss on 12/17/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is my implementation of the NAST (nearest alignment space termination) algorithm as described in:
- *
- *     DeSantis TZ, Hugenholtz P, Keller K, Brodie EL, Larsen N, Piceno YM, Phan R, & Anderson GL.  2006.  NAST: a multiple
- *             sequence alignment server for comparative analysis of 16S rRNA genes.  Nucleic Acids Research.  34:W394-9.
- *
- *     To construct an object one needs to provide a method of getting a pairwise alignment (alignment) and the template
- *     and candidate sequence that are to be aligned to each other.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-class Alignment;
-class Sequence;
-
-/**************************************************************************************************/
-
-class Nast {
-       
-public:
-       Nast(Alignment*, Sequence*, Sequence*);
-       ~Nast(){};
-       float getSimilarityScore();
-       int getMaxInsertLength();
-       
-private:
-       void pairwiseAlignSeqs();
-       void regapSequences();
-       void removeExtraGaps(string&, string, string);
-       
-       Alignment* alignment;
-       Sequence* candidateSeq;
-       Sequence* templateSeq;
-       
-       int maxInsertLength;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/nastreport.cpp b/nastreport.cpp
deleted file mode 100644 (file)
index 95901a3..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- *  nastreport.cpp
- *  
- *
- *  Created by Pat Schloss on 12/19/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "sequence.hpp"
-#include "nast.hpp"
-#include "alignment.hpp"
-#include "nastreport.hpp"
-
-
-/******************************************************************************************************************/
-
-NastReport::NastReport() {
-       try {
-               m = MothurOut::getInstance();
-               output = "";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "NastReport");
-               exit(1);
-       }
-}
-/******************************************************************************************************************/
-string NastReport::getHeaders() {
-       try {
-               output = "";
-               
-               output += "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
-               output += "SearchMethod\tSearchScore\t";
-               output += "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
-               output += "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
-               output += "LongestInsert\t";
-               output += "SimBtwnQuery&Template\n";
-               
-               return output;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "getHeaders");
-               exit(1);
-       }
-}
-/******************************************************************************************************************/
-
-NastReport::NastReport(string candidateReportFName) {
-       try {
-               m = MothurOut::getInstance();
-               m->openOutputFile(candidateReportFName, candidateReportFile);
-               
-               candidateReportFile << "QueryName\tQueryLength\tTemplateName\tTemplateLength\t";
-               candidateReportFile << "SearchMethod\tSearchScore\t";
-               candidateReportFile << "AlignmentMethod\tQueryStart\tQueryEnd\tTemplateStart\tTemplateEnd\t";
-               candidateReportFile << "PairwiseAlignmentLength\tGapsInQuery\tGapsInTemplate\t";
-               candidateReportFile << "LongestInsert\t";
-               candidateReportFile << "SimBtwnQuery&Template" << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "NastReport");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-NastReport::~NastReport() {
-       try {
-               candidateReportFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "~NastReport");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::print(){
-       try {
-               candidateReportFile << queryName << '\t' << queryLength << '\t' << templateName << '\t' << templateLength << '\t';
-               candidateReportFile << searchMethod << '\t' << setprecision(2) << fixed << searchScore << '\t';
-
-               candidateReportFile << alignmentMethod << '\t' << candidateStartPosition << "\t" << candidateEndPosition << '\t';
-               candidateReportFile << templateStartPosition << "\t" << templateEndPosition << '\t';
-               candidateReportFile << pairwiseAlignmentLength << '\t' << totalGapsInQuery << '\t' << totalGapsInTemplate << '\t';
-               candidateReportFile << longestInsert << '\t';
-               candidateReportFile << setprecision(2) << similarityToTemplate;
-               
-               candidateReportFile << endl;
-               candidateReportFile.flush();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "print");
-               exit(1);
-       }
-}
-/******************************************************************************************************************/
-
-string NastReport::getReport(){
-       try {
-               output = "";
-               
-               output += queryName + '\t' + toString(queryLength) + '\t' + templateName + '\t' + toString(templateLength) + '\t';
-               
-               string temp = toString(searchScore);
-               int pos = temp.find_last_of('.');  //find deicmal point if their is one
-               
-               //if there is a decimal
-               if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
-               else{   temp += ".00";  }
-               
-               output += searchMethod + '\t' + temp + '\t';
-               output += alignmentMethod + '\t' + toString(candidateStartPosition) + "\t" + toString(candidateEndPosition) + '\t';
-               output += toString(templateStartPosition) + "\t" + toString(templateEndPosition) + '\t';
-               output += toString(pairwiseAlignmentLength) + '\t' + toString(totalGapsInQuery) + '\t' + toString(totalGapsInTemplate) + '\t';
-               output += toString(longestInsert) + '\t';
-               
-               temp = toString(similarityToTemplate);
-               pos = temp.find_last_of('.');  //find deicmal point if their is one
-               
-               //if there is a decimal
-               if (pos != -1) { temp = temp.substr(0, pos+3); } //set precision to 2 places
-               else{   temp += ".00";  }
-               
-               output += temp + '\n';
-               
-               return output;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "getReport");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::setCandidate(Sequence* candSeq){ 
-       try {
-               queryName = candSeq->getName();
-               queryLength = candSeq->getNumBases();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "setCandidate");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::setTemplate(Sequence* tempSeq){ 
-       try {
-               templateName = tempSeq->getName();
-               templateLength = tempSeq->getNumBases();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "setTemplate");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::setSearchParameters(string method, float score){
-       try {
-               searchMethod = method;
-               searchScore = score;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "setSearchParameters");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::setAlignmentParameters(string method, Alignment* align){
-       try {
-               alignmentMethod = method;
-               
-               candidateStartPosition = align->getCandidateStartPos();
-               candidateEndPosition = align->getCandidateEndPos();
-               templateStartPosition = align->getTemplateStartPos();
-               templateEndPosition = align->getTemplateEndPos();
-               pairwiseAlignmentLength = align->getPairwiseLength();
-
-               totalGapsInQuery = pairwiseAlignmentLength - (candidateEndPosition - candidateStartPosition + 1);
-               totalGapsInTemplate = pairwiseAlignmentLength - (templateEndPosition - templateStartPosition + 1);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "setAlignmentParameters");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
-
-void NastReport::setNastParameters(Nast nast){
-       try {
-
-               longestInsert = nast.getMaxInsertLength();
-               similarityToTemplate = nast.getSimilarityScore();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NastReport", "setNastParameters");
-               exit(1);
-       }
-}
-
-/******************************************************************************************************************/
diff --git a/nastreport.hpp b/nastreport.hpp
deleted file mode 100644 (file)
index c25575a..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef NASTREPORT_HPP
-#define NASTREPORT_HPP
-
-
-/*
- *  nastreport.hpp
- *  
- *
- *  Created by Pat Schloss on 12/19/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-/******************************************************************************************************************/
-
-class NastReport {
-
-public:
-       NastReport(string);
-       NastReport();
-       ~NastReport();
-       void setCandidate(Sequence*);
-       void setTemplate(Sequence*);
-       void setSearchParameters(string, float);
-       void setAlignmentParameters(string, Alignment*);
-       void setNastParameters(Nast);
-       void print();
-       string getReport();
-       string getHeaders();
-       
-private:
-       string queryName;
-       string output;
-       int queryLength;
-       string templateName;
-       int templateLength;
-       string searchMethod;
-       float searchScore;
-       string alignmentMethod;
-       int candidateStartPosition, candidateEndPosition;
-       int templateStartPosition, templateEndPosition;
-
-       int pairwiseAlignmentLength;
-       int longestInsert;
-       int totalGapsInQuery, totalGapsInTemplate;
-       float similarityToTemplate;
-       ofstream candidateReportFile;
-       MothurOut* m;
-};
-
-/******************************************************************************************************************/
-
-#endif
diff --git a/needlemanoverlap.cpp b/needlemanoverlap.cpp
deleted file mode 100644 (file)
index 1239beb..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  needleman.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is an Alignment child class that implements the Gotoh pairwise alignment algorithm as described in:
- *             
- *             Gotoh O. 1982.  An improved algorithm for matching biological sequences.  J. Mol. Biol.  162:705-8.
- *             Myers, EW & Miller, W.  1988.  Optimal alignments in linear space.  Comput Appl Biosci. 4:11-7.
- *
- *     This method is nice because it allows for an affine gap penalty to be assessed, which is analogous to what is used
- *     in blast and is an alternative to Needleman-Wunsch, which only charges the same penalty for each gap position.
- *     Because this method typically has problems at the ends when two sequences do not full overlap, we employ a separate
- *     method to fix the ends (see Overlap class documentation)
- *
- */
-
-#include "alignmentcell.hpp"
-#include "alignment.hpp"
-#include "overlap.hpp"
-#include "needlemanoverlap.hpp"
-
-/**************************************************************************************************/
-
-NeedlemanOverlap::NeedlemanOverlap(float gO, float f, float mm, int r) ://     note that we don't have a gap extend
-gap(gO), match(f), mismatch(mm), Alignment(r) {                                                        //      the gap openning penalty is assessed for
-       try {                                                                                                                                   //      every gapped position
-               for(int i=1;i<nCols;i++){
-                       alignment[0][i].prevCell = 'l';                                 //      initialize first row by pointing all poiters to the left
-                       alignment[0][i].cValue = 0;                                             //      and the score to zero
-               }
-               
-               for(int i=1;i<nRows;i++){
-                       alignment[i][0].prevCell = 'u';                                 //      initialize first column by pointing all poiters upwards
-                       alignment[i][0].cValue = 0;                                             //      and the score to zero
-               }
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NeedlemanOverlap", "NeedlemanOverlap");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-NeedlemanOverlap::~NeedlemanOverlap(){ /*      do nothing      */      }
-
-/**************************************************************************************************/
-
-void NeedlemanOverlap::align(string A, string B){
-       try {
-       
-               seqA = ' ' + A; lA = seqA.length();             //      algorithm requires a dummy space at the beginning of each string
-               seqB = ' ' + B; lB = seqB.length();             //      algorithm requires a dummy space at the beginning of each string
-
-               if (lA > nRows) { m->mothurOut("One of your candidate sequences is longer than you longest template sequence. Your longest template sequence is " + toString(nRows) + ". Your candidate is " + toString(lA) + "."); m->mothurOutEndLine();  }
-               
-               for(int i=1;i<lB;i++){                                  //      This code was largely translated from Perl code provided in Ex 3.1 
-               
-                       for(int j=1;j<lA;j++){                          //      of the O'Reilly BLAST book.  I found that the example output had a
-       
-                               //      number of errors
-                               float diagonal;
-                               if(seqB[i] == seqA[j])  {       diagonal = alignment[i-1][j-1].cValue + match;          }
-                               else                                    {       diagonal = alignment[i-1][j-1].cValue + mismatch;       }
-                       
-                               float up        = alignment[i-1][j].cValue + gap;
-                               float left      = alignment[i][j-1].cValue + gap;
-                               
-                               if(diagonal >= up){
-                                       if(diagonal >= left){
-                                               alignment[i][j].cValue = diagonal;
-                                               alignment[i][j].prevCell = 'd';
-                                       }
-                                       else{
-                                               alignment[i][j].cValue = left;
-                                               alignment[i][j].prevCell = 'l';
-                                       }
-                               }
-                               else{
-                                       if(up >= left){
-                                               alignment[i][j].cValue = up;
-                                               alignment[i][j].prevCell = 'u';
-                                       }
-                                       else{
-                                               alignment[i][j].cValue = left;
-                                               alignment[i][j].prevCell = 'l';
-                                       }
-                               }
-                       }
-               }
-
-               Overlap over;                                           
-               over.setOverlap(alignment, lA, lB, 0);          //      Fix gaps at the beginning and end of the sequences
-               traceBack();                                                            //      Traceback the alignment to populate seqAaln and seqBaln
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NeedlemanOverlap", "align");
-               exit(1);
-       }
-
-}
-
-/**************************************************************************************************/
-
diff --git a/needlemanoverlap.hpp b/needlemanoverlap.hpp
deleted file mode 100644 (file)
index ea7bee5..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef NEEDLEMAN_H
-#define NEEDLEMAN_H
-
-/*
- *  needleman.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class is an Alignment child class that implements the Needleman-Wunsch pairwise alignment algorithm as
- *     described in:
- *             
- *     Needleman SB & Wunsch CD.  1970.  A general method applicable to the search for similarities in the amino acid
- *             sequence of two proteins.  J Mol Biol.  48:443-53.
- *     Korf I, Yandell M, & Bedell J.  2003.  BLAST.  O'Reilly & Associates.  Sebastopol, CA.
- *
- *     This method is simple as it assesses a consistent penalty for each gap position.  Because this method typically has
- *     problems at the ends when two sequences do not full overlap, we employ a separate method to fix the ends (see
- *     Overlap class documentation)
- *
- */
-
-#include "mothur.h"
-#include "alignment.hpp"
-
-/**************************************************************************************************/
-
-class NeedlemanOverlap : public Alignment {
-       
-public:
-       NeedlemanOverlap(float, float, float, int);
-       ~NeedlemanOverlap();
-       void align(string, string);
-
-       
-private:       
-       float gap;
-       float match;
-       float mismatch;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/nmdscommand.cpp b/nmdscommand.cpp
deleted file mode 100644 (file)
index e2a3712..0000000
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- *  nmdscommand.cpp
- *  mothur
- *
- *  Created by westcott on 1/11/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "nmdscommand.h"
-#include "readphylipvector.h"
-
-//**********************************************************************************************************************
-vector<string> NMDSCommand::setParameters(){   
-       try {
-               CommandParameter paxes("axes", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paxes);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pmaxdim("maxdim", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmaxdim);
-               CommandParameter pmindim("mindim", "Number", "", "2", "", "", "",false,false); parameters.push_back(pmindim);
-               CommandParameter piters("iters", "Number", "", "10", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pmaxiters("maxiters", "Number", "", "500", "", "", "",false,false); parameters.push_back(pmaxiters);
-               CommandParameter pepsilon("epsilon", "Number", "", "0.000000000001", "", "", "",false,false); parameters.push_back(pepsilon);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string NMDSCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The nmds command is modelled after the nmds code written in R by Sarah Goslee, using Non-metric multidimensional scaling function using the majorization algorithm from Borg & Groenen 1997, Modern Multidimensional Scaling.\n";
-               helpString += "The nmds command parameters are phylip, axes, mindim, maxdim, maxiters, iters and epsilon.\n"; 
-               helpString += "The phylip parameter allows you to enter your distance file.\n"; 
-               helpString += "The axes parameter allows you to enter a file containing a starting configuration.\n";
-               helpString += "The maxdim parameter allows you to select the maximum dimensions to use. Default=2\n"; 
-               helpString += "The mindim parameter allows you to select the minimum dimensions to use. Default=2\n";
-               helpString += "The maxiters parameter allows you to select the maximum number of iters to try with each random configuration. Default=500\n"; 
-               helpString += "The iters parameter allows you to select the number of random configuration to try. Default=10\n"; 
-               helpString += "The epsilon parameter allows you to select set an acceptable stopping point. Default=1e-12.\n"; 
-               helpString += "Example nmds(phylip=yourDistanceFile).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. phylip), '=' and parameters (i.e.yourDistanceFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-NMDSCommand::NMDSCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["nmds"] = tempOutNames;
-               outputTypes["stress"] = tempOutNames;
-               outputTypes["iters"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "NMDSCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-NMDSCommand::NMDSCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser. getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("axes");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["axes"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["nmds"] = tempOutNames;
-                       outputTypes["iters"] = tempOutNames;
-                       outputTypes["stress"] = tempOutNames;
-                       
-                       //required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { phylipfile = ""; abort = true; }
-                       else if (phylipfile == "not found") {                           
-                               //if there is a current phylip file, use it
-                               phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") { m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setPhylipFile(phylipfile); } 
-                       
-                       axesfile = validParameter.validFile(parameters, "axes", true);
-                       if (axesfile == "not open") { axesfile = ""; abort = true; }
-                       else if (axesfile == "not found") { axesfile = "";  }                           
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(phylipfile); //if user entered a file with a path then preserve it      
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "mindim", false);    if (temp == "not found") {      temp = "2";     }
-                       m->mothurConvert(temp, mindim);
-                       
-                       temp = validParameter.validFile(parameters, "maxiters", false); if (temp == "not found") {      temp = "500";   }
-                       m->mothurConvert(temp, maxIters);
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);    if (temp == "not found") {      temp = "10";    }
-                       m->mothurConvert(temp, iters);
-                       
-                       temp = validParameter.validFile(parameters, "maxdim", false);   if (temp == "not found") {      temp = "2";     }
-                       m->mothurConvert(temp, maxdim);
-                       
-                       temp = validParameter.validFile(parameters, "epsilon", false);  if (temp == "not found") {      temp = "0.000000000001";        }
-                       m->mothurConvert(temp, epsilon); 
-                       
-                       if (mindim < 1) { m->mothurOut("mindim must be at least 1."); m->mothurOutEndLine(); abort = true; }
-                       if (maxdim < mindim) { maxdim = mindim; }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "NMDSCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int NMDSCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               cout.setf(ios::fixed, ios::floatfield);
-               cout.setf(ios::showpoint);
-               
-               vector<string> names;
-               vector< vector< double> > matrix; 
-               
-               //read in phylip file
-               ReadPhylipVector readFile(phylipfile);
-               names = readFile.read(matrix);
-               if (m->control_pressed) { return 0; }
-               
-               //read axes
-               vector< vector<double> > axes;
-               if (axesfile != "") {  axes = readAxes(names);          }
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.iters";
-               string stressFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.stress";
-               outputNames.push_back(outputFileName); outputTypes["iters"].push_back(outputFileName);
-               outputNames.push_back(stressFileName); outputTypes["stress"].push_back(stressFileName);
-               
-               ofstream out, out2;
-               m->openOutputFile(outputFileName, out);
-               m->openOutputFile(stressFileName, out2);
-               
-               out2.setf(ios::fixed, ios::floatfield);
-               out2.setf(ios::showpoint);
-               out.setf(ios::fixed, ios::floatfield);
-               out.setf(ios::showpoint);
-               
-               out2 << "Dimension\tIter\tStress\tRsq" << endl;
-               
-               double bestStress = 10000000;
-               double bestR2 = 10000000;
-               vector< vector<double> > bestConfig;
-               int bestDim = 0;
-               
-               for (int i = mindim; i <= maxdim; i++) {
-                       m->mothurOut("Processing Dimension: " + toString(i)); m->mothurOutEndLine();
-                       
-                       for (int j = 0; j < iters; j++) {
-                               m->mothurOut(toString(j+1)); m->mothurOutEndLine(); 
-                               
-                               //get configuration - either randomly generate or resize to this dimension
-                               vector< vector<double> > thisConfig;
-                               if (axesfile == "") {   thisConfig = generateStartingConfiguration(names.size(), i);            }
-                               else                            {       thisConfig = getConfiguration(axes, i);                                                         }
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
-                               
-                               //calc nmds for this dimension
-                               double stress;
-                               vector< vector<double> > endConfig = nmdsCalc(matrix, thisConfig, stress);
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
-                               
-                               //calc euclid distances for new config
-                               vector< vector<double> > newEuclid = linearCalc.calculateEuclidianDistance(endConfig);
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
-                               
-                               //calc correlation between original distances and euclidean distances from this config
-                               double rsquared = linearCalc.calcPearson(newEuclid, matrix);
-                               rsquared *= rsquared;
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
-                               
-                               //output results
-                               out << "Config" << (j+1) << '\t';
-                               for (int k = 0; k < i; k++) { out << "axis" << (k+1) << '\t'; }
-                               out << endl;
-                               out2 << i << '\t' << (j+1) << '\t' << stress << '\t' << rsquared << endl;
-                               
-                               output(endConfig, names, out);
-                               
-                               //save best
-                               if (stress < bestStress) {
-                                       bestDim = i;
-                                       bestStress = stress;
-                                       bestR2 = rsquared;
-                                       bestConfig = endConfig;
-                               }
-                               
-                               if (m->control_pressed) { out.close(); out2.close(); for (int k = 0; k < outputNames.size(); k++) {     m->mothurRemove(outputNames[k]);        } return 0; }
-                       }
-               }
-               
-               out.close(); out2.close();
-               
-               //output best config
-               string BestFileName = outputDir + m->getRootName(m->getSimpleName(phylipfile)) + "nmds.axes";
-               outputNames.push_back(BestFileName); outputTypes["nmds"].push_back(BestFileName);
-               
-               m->mothurOut("\nNumber of dimensions:\t" + toString(bestDim) + "\n");
-               m->mothurOut("Lowest stress :\t" + toString(bestStress) + "\n");
-               m->mothurOut("R-squared for configuration:\t" + toString(bestR2) + "\n");
-               
-               ofstream outBest;
-               m->openOutputFile(BestFileName, outBest);
-               outBest.setf(ios::fixed, ios::floatfield);
-               outBest.setf(ios::showpoint);
-               
-               outBest << '\t';
-               for (int k = 0; k < bestConfig.size(); k++) { outBest << "axis" << (k+1) << '\t'; }
-               outBest << endl;
-               
-               output(bestConfig, names, outBest);
-               
-               outBest.close();
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector< vector<double> > NMDSCommand::nmdsCalc(vector< vector<double> >& matrix, vector< vector<double> >& config, double& stress1) {
-       try {
-               
-               vector< vector<double> > newConfig = config;
-               
-               //calc euclid distances
-               vector< vector<double> > euclid = linearCalc.calculateEuclidianDistance(newConfig);
-               if (m->control_pressed) { return newConfig; }           
-               
-               double stress2 = calculateStress(matrix, euclid);
-               stress1 = stress2 + 1.0 + epsilon;
-               
-               int count = 0;
-               while ((count < maxIters) && (abs(stress1 - stress2) > epsilon)) {
-                       count++;
-                       
-                       stress1 = stress2;
-                       
-                       if (m->control_pressed) { return newConfig; }
-                       
-                       vector< vector<double> > b; b.resize(euclid.size());
-                       for (int i = 0; i < b.size(); i++) { b[i].resize(euclid[i].size(), 0.0); }
-                       
-                       vector<double> columnSums; columnSums.resize(euclid.size(), 0.0);
-                       for (int i = 0; i < euclid.size(); i++) {
-                               for (int j = 0; j < euclid[i].size(); j++) {
-                                       //eliminate divide by zero error
-                                       if (euclid[i][j] != 0) { 
-                                               b[i][j] = matrix[i][j] / euclid[i][j];
-                                               columnSums[j] += b[i][j];
-                                               b[i][j] *= -1.0;
-                                       }
-                               }
-                       }
-                       
-                       //put in diagonal sums
-                       for (int i = 0; i < euclid.size(); i++) {  b[i][i] = columnSums[i]; }
-                       
-                       int numInLowerTriangle = matrix.size() * (matrix.size()-1) / 2.0;
-                       double n = (1.0 + sqrt(1.0 + 8.0 * numInLowerTriangle)) / 2.0;
-                       
-                       //matrix mult
-                       newConfig = linearCalc.matrix_mult(newConfig, b);
-                       for (int i = 0; i < newConfig.size(); i++) {
-                               for (int j = 0; j < newConfig[i].size(); j++) {
-                                       newConfig[i][j] *= (1.0 / n);
-                               }
-                       }
-                       
-                       euclid = linearCalc.calculateEuclidianDistance(newConfig);
-                       
-                       stress2 = calculateStress(matrix, euclid);
-               }
-               
-               return newConfig;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "generateStartingConfiguration");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-//generate random config
-vector< vector<double> > NMDSCommand::generateStartingConfiguration(int numNames, int dimension) {
-       try {
-               vector< vector<double> > axes;  axes.resize(dimension);
-               for (int i = 0; i < axes.size(); i++) {  axes[i].resize(numNames); }
-               
-               //generate random number between -1 and 1, precision 6
-               for (int i = 0; i < axes.size(); i++) {
-                       for (int j = 0; j < axes[i].size(); j++) {
-                               
-                               if (m->control_pressed) { return axes; }
-                               
-                               //generate random int between 0 and 99999
-                               int myrand = (int)((float)(rand()) / ((RAND_MAX / 99998) + 1));
-                               
-                               //generate random sign
-                               int mysign = (int)((float)(rand()) / ((RAND_MAX / 99998) + 1));
-                               
-                               //if mysign is even then sign = positive, else sign = negative
-                               if ((mysign % 2) == 0) { mysign = 1.0; }
-                               else { mysign = -1.0; }
-                               
-                               axes[i][j] = mysign * myrand / (float) 100000;
-                       }
-               }
-
-               return axes;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "generateStartingConfiguration");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//normalize configuration
-int NMDSCommand::normalizeConfiguration(vector< vector<double> >& axes, int numNames, int dimension) {
-       try {
-               vector<double> averageAxes; averageAxes.resize(dimension, 0.0);
-               
-               //find average
-               for (int i = 0; i < axes.size(); i++) {
-                       for (int j = 0; j < axes[i].size(); j++) {      averageAxes[i] += axes[i][j];   }
-                       
-                       averageAxes[i] /= (float) numNames;
-               }
-               
-               //normalize axes
-               double sumDenom = 0.0;
-               for (int i = 0; i < axes.size(); i++) {
-                       for (int j = 0; j < axes[i].size(); j++) {
-                               sumDenom += ((axes[i][j] - averageAxes[i]) * (axes[i][j] - averageAxes[i]));
-                       }
-               }
-               
-               double denom = sqrt((sumDenom / (float) (axes.size() * numNames)));
-               
-               for (int i = 0; i < axes.size(); i++) {
-                       for (int j = 0; j < axes[i].size(); j++) {
-                               axes[i][j] = (axes[i][j] - averageAxes[i]) / denom;
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "normalizeConfiguration");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//get configuration
-vector< vector<double> > NMDSCommand::getConfiguration(vector< vector<double> >& axes, int dimension) {
-       try {
-               vector< vector<double> > newAxes; newAxes.resize(dimension);
-               
-               for (int i = 0; i < dimension; i++) {
-                       newAxes[i] = axes[i];
-               }
-                               
-               return newAxes;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "getConfiguration");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//find raw stress, and normalize using
-double NMDSCommand::calculateStress(vector< vector<double> >& matrix, vector< vector<double> >& config) {
-       try {
-               double normStress = 0.0;
-               double denom = 0.0;
-               double rawStress = 0.0;
-               
-               //find raw stress
-               for (int i = 0; i < matrix.size(); i++) {
-                       for (int j = 0; j < matrix[i].size(); j++) {
-                               if (m->control_pressed) { return normStress; }
-                               
-                               rawStress += ((matrix[i][j] - config[i][j]) * (matrix[i][j] - config[i][j]));
-                               denom += (config[i][j] * config[i][j]);
-                       }
-               }
-               
-               //normalize stress
-               if ((rawStress != 0.0) && (denom != 0.0)) {
-                       normStress = sqrt((rawStress / denom));
-               }
-
-               return normStress;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "calculateStress");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int NMDSCommand::output(vector< vector<double> >& config, vector<string>& names, ofstream& out) {
-       try {
-               
-               for (int i = 0; i < names.size(); i++) {
-                       
-                       out << names[i] << '\t';
-                       
-                       for (int j = 0; j < config.size(); j++) {
-                               out << config[j][i] << '\t';
-                       }
-                       
-                       out << endl;
-               }
-               
-               out << endl << endl;
-                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "output");
-               exit(1);
-       }
-}
-/*****************************************************************/
-vector< vector<double> > NMDSCommand::readAxes(vector<string> names){
-       try {
-               ifstream in;
-               m->openInputFile(axesfile, in);
-               
-               string headerLine = m->getline(in); m->gobble(in);
-               
-               //count the number of axis you are reading
-               bool done = false;
-               int count = 0;
-               while (!done) {
-                       int pos = headerLine.find("axis");
-                       if (pos != string::npos) {
-                               count++;
-                               headerLine = headerLine.substr(pos+4);
-                       }else { done = true; }
-               }
-               
-               if (maxdim > count) { 
-                       m->mothurOut("You requested maxdim = " + toString(maxdim) + ", but your file only includes " + toString(count) + ". Using " + toString(count) + "."); m->mothurOutEndLine(); 
-                       maxdim = count; 
-                       if (maxdim < mindim) { m->mothurOut("Also adjusting mindim to " + toString(maxdim-1) + "."); m->mothurOutEndLine(); }
-               }
-               
-               vector< vector<double> > axes;  axes.resize(maxdim);
-               for (int i = 0; i < axes.size(); i++) { axes[i].resize(names.size(), 0.0); }
-               
-               map <string, vector<double> > orderedAxes;
-               map     <string, vector<double> >::iterator it;
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return axes; }
-                       
-                       string group = "";
-                       in >> group; m->gobble(in);
-                       
-                       bool ignore = false;
-                       if (!m->inUsersGroups(group, names)) { ignore = true; m->mothurOut(group + " is in your axes file and not in your distance file, ignoring."); m->mothurOutEndLine(); }
-                       
-                       vector<double> thisGroupsAxes;
-                       for (int i = 0; i < count; i++) {
-                               float temp = 0.0;
-                               in >> temp; 
-                               
-                               //only save the axis we want
-                               if (i < maxdim) {  thisGroupsAxes.push_back(temp); }
-                       }
-                       
-                       if (!ignore) {  orderedAxes[group] = thisGroupsAxes; }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-                               
-               //sanity check
-               if (names.size() != orderedAxes.size()) { m->mothurOut("[ERROR]: your axes file does not match your distance file, aborting."); m->mothurOutEndLine(); m->control_pressed = true; return axes; }
-               
-               //put axes info in same order as distance file, just in case
-               for (int i = 0; i < names.size(); i++) {
-                       it = orderedAxes.find(names[i]);
-                       
-                       if (it != orderedAxes.end()) {
-                               vector<double> thisGroupsAxes = it->second;
-                               
-                               for (int j = 0; j < thisGroupsAxes.size(); j++) {
-                                       axes[j][i] = thisGroupsAxes[j];
-                               }
-                               
-                       }else { m->mothurOut("[ERROR]: your axes file does not match your distance file, aborting."); m->mothurOutEndLine(); m->control_pressed = true; return axes; }
-               }
-               
-               return axes;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NMDSCommand", "readAxes");      
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-
-
-
diff --git a/nmdscommand.h b/nmdscommand.h
deleted file mode 100644 (file)
index c05c9fe..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef NMDSCOMMAND_H
-#define NMDSCOMMAND_H
-
-/*
- *  nmdscommand.h
- *  mothur
- *
- *  Created by westcott on 1/11/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "linearalgebra.h"
-
-
-/*  
- Translated from the nmds.R code written by Sarah Goslee using,
- # Non-metric multidimensional scaling function
- # using the majorization algorithm from
- # Borg & Groenen 1997, Modern Multidimensional Scaling.
- #
- # also referenced (Kruskal 1964)
- */
-
-/*****************************************************************/
-class NMDSCommand : public Command {
-       
-public:
-       NMDSCommand(string);    
-       NMDSCommand();
-       ~NMDSCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "nmds";                                        }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Borg, Groenen (1997). Non-metric multidimensional scaling function using the majorization algorithm, in Modern Multidimensional Scaling. Ed. T.F. Cox and M.A.A. Cox. Chapman and Hall. \nhttp://www.mothur.org/wiki/Nmds"; }
-       string getDescription()         { return "nmds"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       
-       bool abort;
-       string phylipfile, outputDir, axesfile;
-       int maxdim, mindim, maxIters, iters;
-       double epsilon;
-       vector<string> outputNames;
-       LinearAlgebra linearCalc;
-       
-       vector< vector<double> > nmdsCalc(vector< vector<double> >&, vector< vector<double> >&, double&);
-       vector< vector<double> > getConfiguration(vector< vector<double> >&, int);
-       vector< vector<double> > generateStartingConfiguration(int, int); //pass in numNames, return axes
-       int normalizeConfiguration(vector< vector<double> >&, int, int);
-       double calculateStress(vector< vector<double> >&, vector< vector<double> >&);
-       vector< vector<double> > readAxes(vector<string>);
-       int output(vector< vector<double> >&, vector<string>&, ofstream&);      
-};
-
-/*****************************************************************/
-
-#endif
-
-
diff --git a/noalign.cpp b/noalign.cpp
deleted file mode 100644 (file)
index e87b757..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *  noalign.cpp
- *  
- *
- *  Created by Pat Schloss on 2/19/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "alignment.hpp"
-#include "noalign.hpp"
-
-/**************************************************************************************************/
-
-NoAlign::NoAlign(){    /*      do nothing      */      }
-
-/**************************************************************************************************/
-
-NoAlign::~NoAlign(){   /*      do nothing      */      }
-
-/**************************************************************************************************/
-
-void NoAlign::align(string A, string B){       }
-
-/**************************************************************************************************/
diff --git a/noalign.hpp b/noalign.hpp
deleted file mode 100644 (file)
index 2e520b3..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef NOALIGN_HPP
-#define NOALIGN_HPP
-
-/*
- *  noalign.hpp
- *  
- *
- *  Created by Pat Schloss on 2/19/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-
-/**************************************************************************************************/
-
-class NoAlign : public Alignment {
-       
-public:
-       NoAlign();
-       ~NoAlign();
-       void align(string, string);
-       
-private:       
-};
-
-/**************************************************************************************************/
-
-
-#endif
diff --git a/nocommands.cpp b/nocommands.cpp
deleted file mode 100644 (file)
index 7df8edc..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  nocommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "nocommands.h"
-
-//**********************************************************************************************************************
-
-NoCommand::NoCommand(string option)  {}
-
-//**********************************************************************************************************************
-
-int NoCommand::execute(){
-       //Could choose to give more help here?fdsah
-       cout << "Invalid command.\n";
-   
-       CommandFactory* valid =  CommandFactory::getInstance();
-       valid->printCommands(cout);
-       
-       return 0;
-}
-
-//**********************************************************************************************************************
diff --git a/nocommands.h b/nocommands.h
deleted file mode 100644 (file)
index 5ed7e12..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef NOCOMMAND_H
-#define NOCOMMAND_H
-/*
- *  nocommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This command is run if the user enters an invalid command. */
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-class NoCommand : public Command {
-
-public:
-       NoCommand(string);
-       NoCommand() {}
-       ~NoCommand(){}
-       
-       vector<string> setParameters()  { return outputNames;   } //dummy, doesn't really do anything   
-       string getCommandName()                 { return "NoCommand";   }
-       string getCommandCategory()             { return "Hidden";              }
-       string getHelpString() { return "No Command"; } 
-       string getCitation() { return "no citation"; }
-       string getDescription()         { return "no description"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       vector<string> outputNames;
-               
-};
-
-#endif
diff --git a/normalizesharedcommand.cpp b/normalizesharedcommand.cpp
deleted file mode 100644 (file)
index bbf9a83..0000000
+++ /dev/null
@@ -1,734 +0,0 @@
-/*
- *  normalizesharedcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "normalizesharedcommand.h"
-
-//**********************************************************************************************************************
-vector<string> NormalizeSharedCommand::setParameters(){        
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "totalgroup-zscore", "totalgroup", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pnorm("norm", "Number", "", "0", "", "", "",false,false); parameters.push_back(pnorm);
-               CommandParameter pmakerelabund("makerelabund", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pmakerelabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string NormalizeSharedCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The normalize.shared command parameters are shared, relabund, groups, method, norm, makerelabund and label.  shared or relabund is required, unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The method parameter allows you to select what method you would like to use to normalize. The options are totalgroup and zscore. We hope to add more ways to normalize in the future, suggestions are welcome!\n";
-               helpString += "The makerelabund parameter allows you to convert a shared file to a relabund file before you normalize. default=f.\n";
-               helpString += "The norm parameter allows you to number you would like to normalize to. By default this is set to the number of sequences in your smallest group.\n";
-               helpString += "The normalize.shared command should be in the following format: normalize.shared(groups=yourGroups, label=yourLabels).\n";
-               helpString += "Example normalize.shared(groups=A-B-C, scale=totalgroup).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "The normalize.shared command outputs a .norm.shared file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-NormalizeSharedCommand::NormalizeSharedCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "NormalizeSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-NormalizeSharedCommand::NormalizeSharedCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { relabundfile = ""; abort = true; }    
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else {  format = "relabund"; inputfile = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       
-                       if ((sharedfile == "") && (relabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       relabundfile = m->getRelAbundFile(); 
-                                       if (relabundfile != "") { inputfile = relabundfile; format = "relabund"; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a list, sabund, rabund, relabund or shared file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-                       
-                       
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; pickedGroups = false; }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       method = validParameter.validFile(parameters, "method", false);                         if (method == "not found") { method = "totalgroup"; }
-                       if ((method != "totalgroup") && (method != "zscore")) {  m->mothurOut(method + " is not a valid scaling option for the normalize.shared command. The options are totalgroup and zscore. We hope to add more ways to normalize in the future, suggestions are welcome!"); m->mothurOutEndLine(); abort = true; }
-               
-                       string temp = validParameter.validFile(parameters, "norm", false);                              
-                       if (temp == "not found") {  
-                               norm = 0;  //once you have read, set norm to smallest group number
-                       }else { 
-                               m->mothurConvert(temp, norm);
-                               if (norm < 0) { m->mothurOut("norm must be positive."); m->mothurOutEndLine(); abort=true; }
-                       }
-                       
-                       temp = validParameter.validFile(parameters, "makerelabund", false);     if (temp == "") { temp = "f"; }
-                       makeRelabund = m->isTrue(temp);
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "NormalizeSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int NormalizeSharedCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               input = new InputData(inputfile, format);
-               
-               //you are reading a sharedfile and you do not want to make relabund
-               if ((format == "sharedfile") && (!makeRelabund)) {
-                       lookup = input->getSharedRAbundVectors();
-                       string lastLabel = lookup[0]->getLabel();
-                       
-                       //look for groups whose numseqs is below norm and remove them, warning the user
-                       if (norm != 0) { 
-                               m->clearGroups();
-                               vector<string> mGroups;
-                               vector<SharedRAbundVector*> temp;
-                               for (int i = 0; i < lookup.size(); i++) {
-                                       if (lookup[i]->getNumSeqs() < norm) { 
-                                               m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
-                                               delete lookup[i];
-                                       }else { 
-                                               mGroups.push_back(lookup[i]->getGroup()); 
-                                               temp.push_back(lookup[i]);
-                                       }
-                               } 
-                               lookup = temp;
-                               m->setGroups(mGroups);
-                       }
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       if (method == "totalgroup") {
-                               //set norm to smallest group number
-                               if (norm == 0) { 
-                                       norm = lookup[0]->getNumSeqs();
-                                       for (int i = 1; i < lookup.size(); i++) {
-                                               if (lookup[i]->getNumSeqs() < norm) { norm = lookup[i]->getNumSeqs();  }
-                                       }  
-                               }
-                               
-                               m->mothurOut("Normalizing to " + toString(norm) + "."); m->mothurOutEndLine();
-                       }
-                       
-                       
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear();  for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } m->clearGroups();   return 0; }
-                               
-                               if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                                       
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       normalize(lookup);
-                                       
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookup[0]->getLabel();
-                                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       
-                                       normalize(lookup);
-                                       
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookup[0]->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = lookup[0]->getLabel();
-                               //prevent memory leak
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                               
-                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } outputTypes.clear(); m->clearGroups();  return 0; }
-                               
-                               //get next line to process
-                               lookup = input->getSharedRAbundVectors();                               
-                       }
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear(); m->clearGroups();   return 0; }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               normalize(lookup);
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                       }
-                       
-               }else{ //relabund values
-                       lookupFloat = input->getSharedRAbundFloatVectors();
-                       string lastLabel = lookupFloat[0]->getLabel();
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       //look for groups whose numseqs is below norm and remove them, warning the user
-                       if (norm != 0) { 
-                               m->clearGroups();
-                               vector<string> mGroups;
-                               vector<SharedRAbundFloatVector*> temp;
-                               for (int i = 0; i < lookupFloat.size(); i++) {
-                                       if (lookupFloat[i]->getNumSeqs() < norm) { 
-                                               m->mothurOut(lookupFloat[i]->getGroup() + " contains " + toString(lookupFloat[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
-                                               delete lookupFloat[i];
-                                       }else { 
-                                               mGroups.push_back(lookupFloat[i]->getGroup()); 
-                                               temp.push_back(lookupFloat[i]);
-                                       }
-                               } 
-                               lookupFloat = temp;
-                               m->setGroups(mGroups);
-                       }
-                       
-                       //set norm to smallest group number
-                       if (method == "totalgroup") {
-                               if (norm == 0) { 
-                                       norm = lookupFloat[0]->getNumSeqs();
-                                       for (int i = 1; i < lookupFloat.size(); i++) {
-                                               if (lookupFloat[i]->getNumSeqs() < norm) { norm = lookupFloat[i]->getNumSeqs();  }
-                                       }  
-                               }
-                               
-                               m->mothurOut("Normalizing to " + toString(norm) + "."); m->mothurOutEndLine();
-                       }
-                       
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear();  for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } m->clearGroups();  return 0; }
-                               
-                               if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){                     
-                                       
-                                       m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                                       
-                                       normalize(lookupFloat);
-                                       
-                                       processedLabels.insert(lookupFloat[0]->getLabel());
-                                       userLabels.erase(lookupFloat[0]->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookupFloat[0]->getLabel();
-                                       
-                                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  
-                                       lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                                       
-                                       m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-               
-                                       normalize(lookupFloat);
-                                       
-                                       processedLabels.insert(lookupFloat[0]->getLabel());
-                                       userLabels.erase(lookupFloat[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookupFloat[0]->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = lookupFloat[0]->getLabel();
-                               //prevent memory leak
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i]; lookupFloat[i] = NULL; }
-                               
-                               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } outputTypes.clear(); m->clearGroups();   return 0; }
-                               
-                               //get next line to process
-                               lookupFloat = input->getSharedRAbundFloatVectors();                             
-                       }
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear(); m->clearGroups();   return 0; }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               for (int i = 0; i < lookupFloat.size(); i++) { if (lookupFloat[i] != NULL) { delete lookupFloat[i]; } }  
-                               lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               m->mothurOut(lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               normalize(lookupFloat);
-                               
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }
-                       }
-                       
-               }
-               //reset groups parameter
-               m->clearGroups();  
-               delete input;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } outputTypes.clear(); return 0;}
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               //m->mothurOut(outputFileName); m->mothurOutEndLine(); outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               //set shared file as new current sharedfile
-               string current = "";
-               itTypes = outputTypes.find("shared");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int NormalizeSharedCommand::normalize(vector<SharedRAbundVector*>& thisLookUp){
-       try {
-               //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
-               
-               if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + ".norm.shared";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
-                               
-               if (method == "totalgroup") { 
-                       
-                       //save numSeqs since they will change as the data is normalized
-                       vector<int> sizes;
-                       for (int i = 0; i < thisLookUp.size(); i++) {  sizes.push_back(thisLookUp[i]->getNumSeqs()); }
-                                       
-                       for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                                               
-                                       for (int i = 0; i < thisLookUp.size(); i++) {
-                                                       
-                                               if (m->control_pressed) { out.close(); return 0; }
-                                                       
-                                               int abund = thisLookUp[i]->getAbundance(j);
-                                                       
-                                               float relabund = abund / (float) sizes[i];
-                                               float newNorm = relabund * norm;
-                                               
-                                               //round to nearest int
-                                               int finalNorm = (int) floor((newNorm + 0.5));
-                                               
-                                               thisLookUp[i]->set(j, finalNorm, thisLookUp[i]->getGroup());
-                                       }
-                               }
-                                       
-               }else if (method == "zscore") {
-                       
-                       for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                               
-                               if (m->control_pressed) { out.close(); return 0; }
-                               
-                               //calc mean
-                               float mean = 0.0;
-                               for (int i = 0; i < thisLookUp.size(); i++) {  mean += thisLookUp[i]->getAbundance(j); }
-                               mean /= (float) thisLookUp.size();
-                                       
-                               //calc standard deviation
-                               float sumSquared = 0.0;
-                               for (int i = 0; i < thisLookUp.size(); i++) { sumSquared += (((float)thisLookUp[i]->getAbundance(j) - mean) * ((float)thisLookUp[i]->getAbundance(j) - mean)); }
-                               sumSquared /= (float) thisLookUp.size();
-                               
-                               float standardDev = sqrt(sumSquared);
-                                       
-                               for (int i = 0; i < thisLookUp.size(); i++) {
-                                       int finalNorm = 0;
-                                       if (standardDev != 0) { // stop divide by zero
-                                               float newNorm = ((float)thisLookUp[i]->getAbundance(j) - mean) / standardDev;
-                                               //round to nearest int
-                                               finalNorm = (int) floor((newNorm + 0.5));
-                                       }
-                                       
-                                       thisLookUp[i]->set(j, finalNorm, thisLookUp[i]->getGroup());
-                               }
-                       }
-                                               
-               }else{ m->mothurOut(method + " is not a valid scaling option."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-                               
-                               
-                                               
-               eliminateZeroOTUS(thisLookUp);
-               
-               thisLookUp[0]->printHeaders(out); 
-                
-               for (int i = 0; i < thisLookUp.size(); i++) {
-                       out << thisLookUp[i]->getLabel() << '\t' << thisLookUp[i]->getGroup() << '\t';
-                       thisLookUp[i]->print(out);
-               }
-               
-               out.close();
-               
-               m->currentBinLabels = saveBinLabels;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "normalize");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int NormalizeSharedCommand::normalize(vector<SharedRAbundFloatVector*>& thisLookUp){
-       try {
-               
-               //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputfile)) + thisLookUp[0]->getLabel() + ".norm.shared";
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
-               
-               
-               if (pickedGroups) { eliminateZeroOTUS(thisLookUp); }
-               
-               if (method == "totalgroup") { 
-                       
-                       //save numSeqs since they will change as the data is normalized
-                       vector<float> sizes;
-                       for (int i = 0; i < thisLookUp.size(); i++) {  sizes.push_back(thisLookUp[i]->getNumSeqs()); }
-                       
-                       for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                               
-                               for (int i = 0; i < thisLookUp.size(); i++) {
-                                       
-                                       if (m->control_pressed) { out.close(); return 0; }
-                                       
-                                       float abund = thisLookUp[i]->getAbundance(j);
-                                       
-                                       float relabund = abund / (float) sizes[i];
-                                       float newNorm = relabund * norm;
-                                       
-                                       thisLookUp[i]->set(j, newNorm, thisLookUp[i]->getGroup());
-                               }
-                       }
-                       
-               }else if (method == "zscore") {
-                       for (int j = 0; j < thisLookUp[0]->getNumBins(); j++) {
-                               
-                               if (m->control_pressed) { out.close(); return 0; }
-                               
-                               //calc mean
-                               float mean = 0.0;
-                               for (int i = 0; i < thisLookUp.size(); i++) {  mean += thisLookUp[i]->getAbundance(j); }
-                               mean /= (float) thisLookUp.size();
-                               
-                               //calc standard deviation
-                               float sumSquared = 0.0;
-                               for (int i = 0; i < thisLookUp.size(); i++) { sumSquared += ((thisLookUp[i]->getAbundance(j) - mean) * (thisLookUp[i]->getAbundance(j) - mean)); }
-                               sumSquared /= (float) thisLookUp.size();
-                               
-                               float standardDev = sqrt(sumSquared);
-                               
-                               for (int i = 0; i < thisLookUp.size(); i++) {
-                                       float newNorm = 0.0;
-                                       if (standardDev != 0) { // stop divide by zero
-                                               newNorm = (thisLookUp[i]->getAbundance(j) - mean) / standardDev;
-                                       }
-                                       thisLookUp[i]->set(j, newNorm, thisLookUp[i]->getGroup());
-                               }
-                       }                       
-                       
-               }else{ m->mothurOut(method + " is not a valid scaling option."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-               
-               
-               eliminateZeroOTUS(thisLookUp);
-               
-               thisLookUp[0]->printHeaders(out); 
-               
-               for (int i = 0; i < thisLookUp.size(); i++) {
-                       out << thisLookUp[i]->getLabel() << '\t' << thisLookUp[i]->getGroup() << '\t';
-                       thisLookUp[i]->print(out);
-               }
-               
-               out.close();
-               
-               m->currentBinLabels = saveBinLabels;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "normalize");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
-       try {
-               
-               vector<SharedRAbundVector*> newLookup;
-               for (int i = 0; i < thislookup.size(); i++) {
-                       SharedRAbundVector* temp = new SharedRAbundVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookup.push_back(temp);
-               }
-               
-               //for each bin
-               vector<string> newBinLabels;
-               string snumBins = toString(thislookup[0]->getNumBins());
-               for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                       if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-               
-                       //look at each sharedRabund and make sure they are not all zero
-                       bool allZero = true;
-                       for (int j = 0; j < thislookup.size(); j++) {
-                               if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                       }
-                       
-                       //if they are not all zero add this bin
-                       if (!allZero) {
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                               }
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               newBinLabels.push_back(binLabel);
-                       }
-               }
-
-               for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-
-               thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "eliminateZeroOTUS");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int NormalizeSharedCommand::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>& thislookup) {
-       try {
-               
-               vector<SharedRAbundFloatVector*> newLookup;
-               for (int i = 0; i < thislookup.size(); i++) {
-                       SharedRAbundFloatVector* temp = new SharedRAbundFloatVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookup.push_back(temp);
-               }
-               
-               //for each bin
-               vector<string> newBinLabels;
-               string snumBins = toString(thislookup[0]->getNumBins());
-               for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                       if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                       
-                       //look at each sharedRabund and make sure they are not all zero
-                       bool allZero = true;
-                       for (int j = 0; j < thislookup.size(); j++) {
-                               if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                       }
-                       
-                       //if they are not all zero add this bin
-                       if (!allZero) {
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                               }
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               newBinLabels.push_back(binLabel);
-                       }
-               }
-               
-               for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-               
-               thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NormalizeSharedCommand", "eliminateZeroOTUS");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/normalizesharedcommand.h b/normalizesharedcommand.h
deleted file mode 100644 (file)
index 4b6f7fd..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef NORMALIZESHAREDCOMMAND_H
-#define NORMALIZESHAREDCOMMAND_H
-
-/*
- *  normalizesharedcommand.h
- *  Mothur
- *
- *  Created by westcott on 9/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedrabundvector.h"
-
-class NormalizeSharedCommand : public Command {
-
-public:
-       NormalizeSharedCommand(string);
-       NormalizeSharedCommand();
-       ~NormalizeSharedCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "normalize.shared";            }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Normalize.shared"; }
-       string getDescription()         { return "normalize samples in a shared or relabund file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       InputData* input;
-       vector<SharedRAbundVector*> lookup;
-       vector<SharedRAbundFloatVector*> lookupFloat;
-       
-       bool abort, allLines, pickedGroups, makeRelabund;
-       set<string> labels; //holds labels to be used
-       string groups, label, outputDir, method, sharedfile, relabundfile, format, inputfile;
-       int norm;
-       vector<string> Groups, outputNames;
-               
-       int normalize(vector<SharedRAbundVector*>&);
-       int normalize(vector<SharedRAbundFloatVector*>&);
-       int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
-       int eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&);
-
-};
-
-#endif
-
diff --git a/npshannon.cpp b/npshannon.cpp
deleted file mode 100644 (file)
index a855b31..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  npshannon.cpp
- *  Dotur
- *
- *  Created by John Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "npshannon.h"
-
-/***********************************************************************/
-
-
-EstOutput NPShannon::getValues(SAbundVector* rank){
-       try {
-               data.resize(1,0);
-               float npShannon = 0.0000;
-       
-               double maxRank = (double)rank->getMaxRank();
-               double sampled = rank->getNumSeqs();
-       
-               double Chat = 1.0000 - (double)rank->get(1)/(double)sampled;
-       
-               if(Chat>0)      {       
-                       for(int i=1;i<=maxRank;i++){
-                               double pi = ((double) i)/((double)sampled);
-                               double ChatPi = Chat*pi;
-                               if(ChatPi>0){
-                                       npShannon += rank->get(i) * ChatPi*log(ChatPi)/(1-pow(1-ChatPi,(double)sampled));
-                               }
-                       }
-                       npShannon = -npShannon;
-               }
-               else{
-                       npShannon = 0.000;
-               }
-       
-               data[0] = npShannon;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "NPShannon", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/npshannon.h b/npshannon.h
deleted file mode 100644 (file)
index ea870d3..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef NPSHANNON_H
-#define NPSHANNON_H
-
-/*
- *  npshannon.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the NPShannon estimator on single group. 
-It is a child of the calculator class. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class NPShannon : public Calculator  {
-       
-public:
-       NPShannon() : Calculator("npshannon", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Npshannon"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/nseqs.h b/nseqs.h
deleted file mode 100644 (file)
index c0f9549..0000000
--- a/nseqs.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef NSEQS_H
-#define NSEQS_H
-
-/*
- *  nseqs.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/16/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class NSeqs : public Calculator {
-
-public:
-       NSeqs() : Calculator("nseqs", 1, false) {};
-       EstOutput getValues(SAbundVector* rank){
-               data.resize(1,0);
-               data[0] = (double)rank->getNumSeqs();
-               return data;
-       }
-       
-       EstOutput getValues(vector<SharedRAbundVector*> shared) { //return number of sequences in the sharedotus
-               
-               int numGroups = shared.size();
-               data.clear(); data.resize(numGroups,0);
-
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //get bin values and set sharedByAll 
-                       bool sharedByAll = true;
-                       for (int j = 0; j < numGroups; j++) {
-                               if (shared[j]->getAbundance(i) == 0) { sharedByAll = false; }
-                       }
-                       
-                       //they are shared
-                       if (sharedByAll == true) {  for (int j = 0; j < numGroups; j++) {  data[j] += shared[j]->getAbundance(i);  } }
-               }
-
-               return data;
-       }
-       string getCitation() { return "http://www.mothur.org/wiki/Nseqs"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/observable.h b/observable.h
deleted file mode 100644 (file)
index 05e537a..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef OBSERVABLE_H
-#define OBSERVABLE_H
-
-
-#include "collectdisplay.h"
-
-
-/***********************************************************************/
-
-class Observable {
-       
-public:
-       virtual void registerDisplay(Display*) = 0;
-       virtual void removeDisplay(Display*) = 0;
-       virtual void notifyDisplays() = 0;      
-       virtual ~Observable() {}
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/odum.cpp b/odum.cpp
deleted file mode 100644 (file)
index ec432e0..0000000
--- a/odum.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  odum.cpp
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "odum.h"
-
-/***********************************************************************/
-
-EstOutput Odum::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumNum = 0.0;
-               double sumDenom = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       sumNum += abs(Aij - Bij);
-                       sumDenom += (Aij + Bij);
-               }
-               
-               data[0] = sumNum / sumDenom;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Odum", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/odum.h b/odum.h
deleted file mode 100644 (file)
index ff2a3a7..0000000
--- a/odum.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef ODUM_H
-#define ODUM_H
-
-/*
- *  odum.h
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Odum : public Calculator  {
-       
-public:
-       Odum() :  Calculator("odum", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Odum"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/onegapdist.h b/onegapdist.h
deleted file mode 100644 (file)
index 3e5b6c7..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef ONEGAPDIST_H
-#define ONEGAPDIST_H
-/*
- *  onegapdist.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "dist.h"
-
-
-/**************************************************************************************************/
-
-class oneGapDist : public Dist {
-       
-public:
-       
-       oneGapDist() {}
-       
-       void calcDist(Sequence A, Sequence B){
-               
-               int difference = 0;
-               int minLength = 0;
-               int openGapA = 0;
-               int openGapB = 0;
-               int start = 0;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-               int alignLength = seqA.length();
-               
-               for(int i=0;i<alignLength;i++){
-                       if((seqA[i] != '.' || seqB[i] != '.')){
-                               start = i;
-                               break;
-                       }
-               }
-
-               for(int i=start;i<alignLength;i++){
-                       if((seqA[i] == '-' && seqB[i] == '-') || (seqA[i] == '.' && seqB[i] == '-') || (seqA[i] == '-' && seqB[i] == '.')){     ;       }
-                       else if(seqA[i] == '.' && seqB[i] == '.'){
-                               break;
-                       }
-                       else if(seqB[i] != '-' && (seqA[i] == '-' || seqA[i] == '.')){
-                               if(openGapA == 0){
-                                       difference++;
-                                       minLength++;
-                                       openGapA = 1;
-                                       openGapB = 0;
-                               }
-                       }
-                       else if(seqA[i] != '-' && (seqB[i] == '-' || seqB[i] == '.')){
-                               if(openGapB == 0){
-                                       difference++;
-                                       minLength++;
-                                       openGapA = 0;
-                                       openGapB = 1;
-                               }
-                       }
-                       else if(seqA[i] != '-' && seqB[i] != '-'){
-                               if(seqA[i] != seqB[i]){
-                                       difference++;
-                                       minLength++;
-                                       openGapA = 0;
-                                       openGapB = 0;
-                               }
-                               else{
-                                       minLength++;
-                                       openGapA = 0;
-                                       openGapB = 0;
-                               }
-                       }
-               }
-       
-               if(minLength == 0)      {       dist = 1.0000;                                                  }
-               else                            {       dist = (double)difference / minLength;  }
-       }
-       
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/onegapignore.h b/onegapignore.h
deleted file mode 100644 (file)
index fdbc196..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef ONEIGNOREGAPS_H
-#define ONEIGNOREGAPS_H
-/*
- *  onegapignore.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 5/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "dist.h"
-
-/**************************************************************************************************/
-
-class oneGapIgnoreTermGapDist : public Dist {
-       
-public:
-       
-       oneGapIgnoreTermGapDist() {}
-       
-       void calcDist(Sequence A, Sequence B){
-               
-               int difference = 0;
-               int openGapA = 0;
-               int openGapB = 0;
-               int minLength = 0;
-               int start = 0;
-               int end = 0;
-               bool overlap = false;
-               
-               string seqA = A.getAligned();
-               string seqB = B.getAligned();
-               int alignLength = seqA.length();
-
-               // this assumes that sequences start and end with '.'s instead of'-'s.
-               for(int i=0;i<alignLength;i++){
-                       if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
-                               start = i;
-//                             cout << "start: " << start << endl;
-                               overlap = true;
-                               break;
-                       }
-               }
-               for(int i=alignLength-1;i>=0;i--){
-                       if(seqA[i] != '.' && seqB[i] != '.' && seqA[i] != '-' && seqB[i] != '-' ){
-                               end = i;
-//                             cout << "end: " << end << endl;
-                               overlap = true;
-                               break;
-                       }
-               }
-               
-               for(int i=start;i<=end;i++){
-                       if(seqA[i] == '-' && seqB[i] == '-'){   ;       }
-                       else if(seqB[i] != '-' && seqA[i] == '-'){
-                               if(openGapA == 0){
-                                       difference++;
-                                       minLength++;
-                                       openGapA = 1;
-                                       openGapB = 0;
-                               }
-                       }
-                       else if(seqA[i] != '-' && seqB[i] == '-'){
-                               if(openGapB == 0){
-                                       difference++;
-                                       minLength++;
-                                       openGapA = 0;
-                                       openGapB = 1;
-                               }
-                       }
-                       else if(seqA[i] != '-' && seqB[i] != '-'){
-                               if(seqA[i] != seqB[i]){
-                                       difference++;
-                               }
-                               minLength++;
-                               openGapA = 0;
-                               openGapB = 0;
-                       }
-               }
-               
-               //non-overlapping sequences
-               if (!overlap) { minLength = 0; }
-               
-               if(minLength == 0)      {       dist = 1.0000;                                                  }
-               else                            {       dist = (double)difference / minLength;  }
-       }
-
-};
-
-/**************************************************************************************************/
-
-#endif
-
diff --git a/optionparser.cpp b/optionparser.cpp
deleted file mode 100644 (file)
index 0d6ed2d..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *  optionparser.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "optionparser.h"
-
-/***********************************************************************/
-
-OptionParser::OptionParser(string option) {
-       try {
-               m = MothurOut::getInstance();
-               if (option != "") {
-                       
-                       string key, value;              
-                       //reads in parameters and values
-                       while((option.find_first_of(',') != -1)) {  //while there are parameters
-                               m->splitAtComma(value, option);
-                               m->splitAtEquals(key, value);
-                               if ((key == "candidate") || (key == "query")) { key = "fasta"; }
-                               if (key == "template") { key = "reference"; }
-                               parameters[key] = value;
-                       }
-                       
-                       //in case there is no comma and to get last parameter after comma
-                       m->splitAtEquals(key, option);
-                       if ((key == "candidate") || (key == "query")) { key = "fasta"; }
-                       if (key == "template") { key = "reference"; }
-                       parameters[key] = option;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OptionParser", "OptionParser");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-map<string, string> OptionParser::getParameters() {    
-       try {
-               
-               //loop through parameters and look for "current" so you can return the appropriate file
-               //doing it here to avoid code duplication in each of the commands
-               
-               map<string, string>::iterator it;
-               for (it = parameters.begin(); it != parameters.end();) {
-                       
-                       if (it->second == "current") {
-                               
-                               //look for file types
-                               if (it->first == "fasta") {
-                                       it->second = m->getFastaFile();
-                               }else if (it->first == "qfile") {
-                                       it->second = m->getQualFile();
-                               }else if (it->first == "phylip") {
-                                       it->second = m->getPhylipFile();
-                               }else if (it->first == "column") {
-                                       it->second = m->getColumnFile();
-                               }else if (it->first == "list") {
-                                       it->second = m->getListFile();
-                               }else if (it->first == "rabund") {
-                                       it->second = m->getRabundFile();
-                               }else if (it->first == "sabund") {
-                                       it->second = m->getSabundFile();
-                               }else if (it->first == "name") {
-                                       it->second = m->getNameFile();
-                               }else if (it->first == "group") {
-                                       it->second = m->getGroupFile();
-                               }else if (it->first == "order") {
-                                       it->second = m->getOrderFile();
-                               }else if (it->first == "ordergroup") {
-                                       it->second = m->getOrderGroupFile();
-                               }else if (it->first == "tree") {
-                                       it->second = m->getTreeFile();
-                               }else if (it->first == "shared") {
-                                       it->second = m->getSharedFile();
-                               }else if (it->first == "relabund") {
-                                       it->second = m->getRelAbundFile();
-                               }else if (it->first == "design") {
-                                       it->second = m->getDesignFile();
-                               }else if (it->first == "sff") {
-                                       it->second = m->getSFFFile();
-                               }else if (it->first == "oligos") {
-                                       it->second = m->getOligosFile();
-                               }else if (it->first == "accnos") {
-                                       it->second = m->getAccnosFile();
-                               }else if (it->first == "taxonomy") {
-                                       it->second = m->getTaxonomyFile();
-                }else if (it->first == "biom") {
-                        it->second = m->getBiomFile();
-                               }else {
-                                       m->mothurOut("[ERROR]: mothur does not save a current file for " + it->first); m->mothurOutEndLine();
-                               }
-                               
-                               if (it->second == "") { //no file was saved for that type, warn and remove from parameters
-                                       m->mothurOut("[WARNING]: no file was saved for " + it->first + " parameter."); m->mothurOutEndLine();
-                                       parameters.erase(it++);
-                               }else {
-                                       m->mothurOut("Using " + it->second + " as input file for the " + it->first + " parameter."); m->mothurOutEndLine();
-                                       it++;
-                               }
-                       }else{ it++; }
-               }
-               
-               return parameters;      
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OptionParser", "getParameters");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//pass a vector of filenames that may match the current namefile.  
-//this function will look at each one, if the rootnames match, mothur will warn 
-//the user that they may have neglected to provide a namefile.
-//stops when it finds a match.
-bool OptionParser::getNameFile(vector<string> files) { 
-       try {
-               string namefile = m->getNameFile();
-               bool match = false;
-               
-               if ((namefile != "")&&(!m->mothurCalling)) {
-                       string temp = m->getRootName(m->getSimpleName(namefile));
-                       vector<string> rootName;
-                       m->splitAtChar(temp, rootName, '.');
-                       
-                       for (int i = 0; i < files.size(); i++) {
-                               temp = m->getRootName(m->getSimpleName(files[i]));
-                               vector<string> root;
-                               m->splitAtChar(temp, root, '.');
-                               
-                               int smallest = rootName.size();
-                               if (root.size() < smallest) { smallest = root.size(); }
-                               
-                               int numMatches = 0;
-                               for(int j = 0; j < smallest; j++) {
-                                       if (root[j] == rootName[j]) { numMatches++; }
-                               }
-                               
-                               if (smallest > 0) {
-                                       if ((numMatches >= (smallest-2)) && (root[0] == rootName[0])) {
-                                               m->mothurOut("[WARNING]: This command can take a namefile and you did not provide one. The current namefile is " + namefile + " which seems to match " + files[i] + ".");
-                                               m->mothurOutEndLine();
-                                               match = true;
-                                               break;
-                                       }
-                               }
-                       }
-                       
-               }
-               
-               
-               return match;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OptionParser", "getNameFile");
-               exit(1);
-       }
-}
-
-                               
-/***********************************************************************/
diff --git a/optionparser.h b/optionparser.h
deleted file mode 100644 (file)
index facd1f8..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef OPTIONPARSER_H
-#define OPTIONPARSER_H
-
-/*
- *  optionparser.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 6/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "command.hpp"
-
-/***********************************************************************/
-
-class OptionParser {
-public:
-       OptionParser(string);
-       ~OptionParser() {}
-       map<string, string> getParameters();
-       bool getNameFile(vector<string>);
-private:
-       map<string, string> parameters;
-       MothurOut* m;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/ordervector.cpp b/ordervector.cpp
deleted file mode 100644 (file)
index a6dff32..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- *  order.cpp
- *  
- *
- *  Created by Pat Schloss on 8/8/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "ordervector.hpp"
-
-
-/***********************************************************************/
-
-OrderVector::OrderVector() : DataVector() {}
-
-/***********************************************************************/
-
-//OrderVector::OrderVector(int ns) : DataVector(), data(ns, -1) {}
-
-/***********************************************************************/
-
-OrderVector::OrderVector(string id, vector<int> ov) : 
-                                                                                       DataVector(id), data(ov)
-{
-       updateStats();  
-}
-
-/***********************************************************************/
-
-OrderVector::OrderVector(ifstream& f) : DataVector() {
-       try {
-               int hold;
-       
-               f >> label;
-               f >> hold;
-       
-               data.assign(hold, -1);
-       
-               int inputData;
-       
-               for(int i=0;i<hold;i++){
-                       f >> inputData;
-                       set(i, inputData);
-               }
-       
-               updateStats();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OrderVector", "OrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-int OrderVector::getNumBins(){
-       if(needToUpdate == 1){  updateStats();  }
-       return numBins;
-}
-
-/***********************************************************************/
-
-int OrderVector::getNumSeqs(){
-       if(needToUpdate == 1){  updateStats();  }
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int OrderVector::getMaxRank(){
-       if(needToUpdate == 1){  updateStats();  }
-       return maxRank;
-}
-/***********************************************************************/
-
-void OrderVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-}
-/***********************************************************************/
-
-
-
-void OrderVector::set(int index, int binNumber){
-       
-       data[index] = binNumber;
-       needToUpdate = 1;
-       
-}
-
-/***********************************************************************/
-
-int OrderVector::get(int index){
-       return data[index];                     
-}
-
-/***********************************************************************/
-
-void OrderVector::push_back(int index){
-
-       data.push_back(index);
-       needToUpdate = 1;
-       
-}
-
-/***********************************************************************/
-
-void OrderVector::print(ostream& output){
-       try {
-               output << label << '\t' << numSeqs << '\t';
-       
-               for(int i=0;i<data.size();i++){
-                       output << data[i] << '\t';
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OrderVector", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void OrderVector::print(string prefix, ostream& output){
-       try {
-               output << prefix << '\t' << numSeqs << '\t';
-       
-               for(int i=0;i<numSeqs;i++){
-                       output << data[i] << '\t';
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OrderVector", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void OrderVector::resize(int){
-       m->mothurOut("resize() did nothing in class OrderVector");
-}
-
-/***********************************************************************/
-
-int OrderVector::size(){
-       return data.size();                                     
-}
-
-/***********************************************************************/
-
-vector<int>::iterator OrderVector::begin(){
-       return data.begin();    
-}
-
-/***********************************************************************/
-
-vector<int>::iterator OrderVector::end(){
-       return data.end();              
-}
-
-/***********************************************************************/
-
-RAbundVector OrderVector::getRAbundVector(){
-       try {
-               RAbundVector rav(data.size());
-       
-               for(int i=0;i<numSeqs;i++){
-                       rav.set(data[i], rav.get(data[i]) + 1);
-               }       
-               sort(rav.rbegin(), rav.rend());
-               for(int i=numSeqs-1;i>=0;i--){
-                       if(rav.get(i) == 0){    rav.pop_back(); }
-                       else{
-                               break;
-                       }
-               }
-               rav.setLabel(label);
-
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OrderVector", "getRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SAbundVector OrderVector::getSAbundVector(){
-       
-       RAbundVector rav(this->getRAbundVector());
-       return rav.getSAbundVector();
-
-}
-
-/***********************************************************************/
-
-OrderVector OrderVector::getOrderVector(map<string,int>* hold = 0){
-       return *this;                   
-}
-
-/***********************************************************************/
-
-void OrderVector::updateStats(){
-       try {
-               needToUpdate = 0;
-       //      int maxBinVectorLength = 0;
-               numSeqs = 0;
-               numBins = 0;
-               maxRank = 0;
-       
-               for(int i=0;i<data.size();i++){
-                       if(data[i] != -1){
-                               numSeqs++;
-                       }
-               }
-       
-               vector<int> hold(numSeqs);
-       
-               for(int i=0;i<numSeqs;i++){
-                       if(data[i] != -1){
-                               hold[data[i]] = hold[data[i]]+1;
-                       }
-               }       
-               for(int i=0;i<numSeqs;i++){
-                       if(hold[i] > 0)                 {       numBins++;                      }
-                       if(hold[i] > maxRank)   {       maxRank = hold[i];      }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OrderVector", "updateStats");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/ordervector.hpp b/ordervector.hpp
deleted file mode 100644 (file)
index 0139a64..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef ORDER_H
-#define ORDER_H
-
-#include "datavector.hpp"
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
-
-/* This class is a child to datavector.  It represents OTU information at a certain distance. 
-       A order vector can be converted into and listvector, rabundvector or sabundvector.
-       Each member of the internal container "data" represents the OTU from which it came. 
-       So in the example below since there are 6 sequences in OTU 1 there are six 1's in the ordervector.
-       and since there are 2 sequences in OTU 3 there are two 3's in the ordervector.
-       example: listvector             =       a,b,c,d,e,f             g,h,i           j,k             l               m  
-                        rabundvector   =       6                               3                       2               1               1
-                        sabundvector   =       2               1               1               0               0               1
-                        ordervector    =       1       1       1       1       1       1       2       2       2       3       3       4       5       */
-
-
-class OrderVector : public DataVector {
-       
-public:
-       OrderVector();
-//     OrderVector(int);
-//     OrderVector(const OrderVector& ov);
-       OrderVector(int ns, int nb=0, int mr=0) : DataVector(), data(ns, -1), maxRank(0), numBins(0), numSeqs(0) {};
-       OrderVector(const OrderVector& ov)      : DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){     updateStats();}};
-
-
-       OrderVector(string, vector<int>);
-       OrderVector(ifstream&);
-       ~OrderVector(){};
-       
-       void set(int, int);
-       int get(int);
-       void push_back(int);
-       void resize(int);
-       int size();
-       void clear();
-       void print(string, ostream&);
-       vector<int>::iterator begin();
-       vector<int>::iterator end();
-
-       void print(ostream&);
-
-       int getNumBins();
-       int getNumSeqs();
-       int getMaxRank();
-               
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       
-private:
-       vector<int> data;
-       int maxRank;
-       int numBins;
-       int numSeqs;
-       bool needToUpdate;
-       void updateStats();
-};
-
-#endif
diff --git a/otuassociationcommand.cpp b/otuassociationcommand.cpp
deleted file mode 100644 (file)
index 0d41e63..0000000
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- *  otuassociationcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 1/19/12.
- *  Copyright 2012 Schloss Lab. All rights reserved.
- *
- */
-
-#include "otuassociationcommand.h"
-#include "linearalgebra.h"
-
-//**********************************************************************************************************************
-vector<string> OTUAssociationCommand::setParameters(){ 
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "SharedRelMeta", "SharedRelMeta", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmethod("method", "Multiple", "pearson-spearman-kendall", "pearson", "", "", "",false,false); parameters.push_back(pmethod);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string OTUAssociationCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The otu.association command reads a shared or relabund file and calculates the correlation coefficients between otus.\n";
-               helpString += "The otu.association command parameters are shared, relabund, groups, method and label.  The shared or relabund parameter is required.\n";
-               helpString += "The groups parameter allows you to specify which of the groups you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distances level you would like used, and are also separated by dashes.\n";
-               helpString += "The method parameter allows you to select what method you would like to use. Options are pearson, spearman and kendall. Default=pearson.\n";
-               helpString += "The otu.association command should be in the following format: otu.association(shared=yourSharedFile, method=yourMethod).\n";
-               helpString += "Example otu.association(shared=genus.pool.shared, method=kendall).\n";
-               helpString += "The otu.association command outputs a .otu.corr file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-OTUAssociationCommand::OTUAssociationCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["otu.corr"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "OTUAssociationCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-OTUAssociationCommand::OTUAssociationCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       vector<string> tempOutNames;
-                       outputTypes["otu.corr"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters                 
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; }
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else { inputFileName = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { abort = true; }
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else { inputFileName = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "";  pickedGroups = false;  }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups); 
-                       }                       
-                       m->setGroups(Groups);
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputFileName);  }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       if ((relabundfile == "") && (sharedfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then relabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputFileName = sharedfile; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       relabundfile = m->getRelAbundFile(); 
-                                       if (relabundfile != "") { inputFileName = relabundfile;  m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You must provide either a shared or relabund file."); m->mothurOutEndLine(); abort = true; 
-                                       }
-                               }
-                       }       
-                       
-                       
-                       if ((relabundfile != "") && (sharedfile != "")) { m->mothurOut("You may only use one of the following : shared or relabund file."); m->mothurOutEndLine(); abort = true;  }
-                       
-                       method = validParameter.validFile(parameters, "method", false);         if (method == "not found"){     method = "pearson";             }
-                       
-                       if ((method != "pearson") && (method != "spearman") && (method != "kendall")) { m->mothurOut(method + " is not a valid method. Valid methods are pearson, spearman, and kendall."); m->mothurOutEndLine(); abort = true; }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "OTUAssociationCommand");               
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int OTUAssociationCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //function are identical just different datatypes
-               if (sharedfile != "")                   {  processShared();             } 
-               else if (relabundfile != "")    {  processRelabund();   }
-                               
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "execute");     
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int OTUAssociationCommand::processShared(){
-       try {
-               InputData* input = new InputData(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  delete input; return 0;  }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){  
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               
-               if (m->control_pressed) { delete input; return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i];       } } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       process(lookup);
-               }       
-               
-               delete input;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "processShared");       
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int OTUAssociationCommand::process(vector<SharedRAbundVector*>& lookup){
-       try {
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr";
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               //column headings
-               out << "OTUA\tOTUB\t" << method << "Coef\tSignificance\n";
-               
-               vector< vector<double> > xy; xy.resize(lookup[0]->getNumBins());
-               for (int i = 0; i < lookup[0]->getNumBins(); i++) { for (int j = 0; j < lookup.size(); j++) { xy[i].push_back(lookup[j]->getAbundance(i)); } }
-               
-               LinearAlgebra linear;
-               for (int i = 0; i < xy.size(); i++) {
-                       
-                       for (int k = 0; k < i; k++) {
-                               
-                               if (m->control_pressed) { out.close(); return 0; }
-
-                               double coef = 0.0;
-                               double sig = 0.0;
-                               if (method == "spearman")               {   coef = linear.calcSpearman(xy[i], xy[k], sig);      }
-                               else if (method == "pearson")   {       coef = linear.calcPearson(xy[i], xy[k], sig);   }
-                               else if (method == "kendall")   {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
-                               else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       
-                out << m->binLabelsInFile[i] << '\t' << m->binLabelsInFile[k] << '\t' << coef << '\t' << sig << endl;
-                       }
-               }
-               
-               out.close();
-               
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "process");     
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int OTUAssociationCommand::processRelabund(){
-       try {
-               InputData* input = new InputData(relabundfile, "relabund");
-               vector<SharedRAbundFloatVector*> lookup = input->getSharedRAbundFloatVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  delete input; return 0;  }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){  
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundFloatVectors();
-               }
-               
-               
-               if (m->control_pressed) { delete input; return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i];       } } 
-                       lookup = input->getSharedRAbundFloatVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       process(lookup);
-               }       
-               
-               delete input;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "processRelabund");     
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int OTUAssociationCommand::process(vector<SharedRAbundFloatVector*>& lookup){
-       try {
-               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(inputFileName)) + lookup[0]->getLabel() + "." + method + ".otu.corr";
-               outputNames.push_back(outputFileName); outputTypes["shared"].push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               //column headings
-               out << "OTUA\tOTUB\t" << method << "Coef\tSignificance\n";
-               
-               vector< vector<double> > xy; xy.resize(lookup[0]->getNumBins());
-               for (int i = 0; i < lookup[0]->getNumBins(); i++) { for (int j = 0; j < lookup.size(); j++) { xy[i].push_back(lookup[j]->getAbundance(i)); } }
-               
-               LinearAlgebra linear;
-               for (int i = 0; i < xy.size(); i++) {
-                       
-                       for (int k = 0; k < i; k++) {
-                               
-                               if (m->control_pressed) { out.close(); return 0; }
-                               
-                               double coef = 0.0;
-                               double sig = 0.0;
-                               if (method == "spearman")               {   coef = linear.calcSpearman(xy[i], xy[k], sig);      }
-                               else if (method == "pearson")   {       coef = linear.calcPearson(xy[i], xy[k], sig);   }
-                               else if (method == "kendall")   {       coef = linear.calcKendall(xy[i], xy[k], sig);   }                   
-                               else { m->mothurOut("[ERROR]: invalid method, choices are spearman, pearson or kendall."); m->mothurOutEndLine(); m->control_pressed = true; }
-                               
-                out << m->binLabelsInFile[i] << '\t' << m->binLabelsInFile[k] << '\t' << coef << '\t' << sig << endl; 
-                       }
-               }
-               
-               out.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OTUAssociationCommand", "process");     
-               exit(1);
-       }
-}
-/*****************************************************************/
-
-
-
-
-
-
-
-
diff --git a/otuassociationcommand.h b/otuassociationcommand.h
deleted file mode 100644 (file)
index 7aaa88a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef OTUASSOCIATIONCOMMAND_H
-#define OTUASSOCIATIONCOMMAND_H
-
-/*
- *  otuassociationcommand.h
- *  Mothur
- *
- *  Created by westcott on 1/19/12.
- *  Copyright 2012 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sharedrabundfloatvector.h"
-#include "inputdata.h"
-
-
-class OTUAssociationCommand : public Command {
-public:
-       OTUAssociationCommand(string);
-       OTUAssociationCommand();
-       ~OTUAssociationCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "otu.association";                     }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Otu.association"; }
-       string getDescription()         { return "calculate the correlation coefficient for the otus in a shared/relabund file"; }
-       
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }  
-private:
-       
-       string sharedfile, relabundfile, groups, label, inputFileName, outputDir, method;
-       bool abort, pickedGroups, allLines;
-       set<string> labels;
-       
-       vector<string> outputNames, Groups;
-       int processShared();
-       int process(vector<SharedRAbundVector*>&);
-       int processRelabund();
-       int process(vector<SharedRAbundFloatVector*>&);
-       
-};
-
-
-#endif
-
-
-
diff --git a/otuhierarchycommand.cpp b/otuhierarchycommand.cpp
deleted file mode 100644 (file)
index 2f99aa6..0000000
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- *  otuhierarchycommand.cpp
- *  Mothur
- *
- *  Created by westcott on 1/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "otuhierarchycommand.h"
-
-//**********************************************************************************************************************
-vector<string> OtuHierarchyCommand::setParameters(){   
-       try {
-               CommandParameter poutput("output", "Multiple", "name-number", "name", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string OtuHierarchyCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The otu.hierarchy command is used to see how otus relate at two distances. \n";
-               helpString += "The otu.hierarchy command parameters are list, label and output.  list and label parameters are required. \n";
-               helpString += "The output parameter allows you to output the names of the sequence in the OTUs or the OTU numbers. Options are name and number, default is name. \n";
-               helpString += "The otu.hierarchy command should be in the following format: \n";
-               helpString += "otu.hierarchy(list=yourListFile, label=yourLabels).\n";
-               helpString += "Example otu.hierarchy(list=amazon.fn.list, label=0.01-0.03).\n";
-               helpString += "The otu.hierarchy command outputs a .otu.hierarchy file which is described on the wiki.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-OtuHierarchyCommand::OtuHierarchyCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["otuheirarchy"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-OtuHierarchyCommand::OtuHierarchyCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["otuheirarchy"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       listFile = validParameter.validFile(parameters, "list", true);
-                       if (listFile == "not found") { 
-                               listFile = m->getListFile(); 
-                               if (listFile != "") {  m->mothurOut("Using " + listFile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current list file. You must provide a list file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               }
-                       }else if (listFile == "not open") { abort = true; }     
-                       else { m->setListFile(listFile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(listFile); //if user entered a file with a path then preserve it        
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { m->mothurOut("label is a required parameter for the otu.hierarchy command."); m->mothurOutEndLine(); abort = true; }
-                       else { 
-                               m->splitAtDash(label, labels);
-                               if (labels.size() != 2) { m->mothurOut("You must provide 2 labels."); m->mothurOutEndLine(); abort = true; }
-                       }       
-                       
-                       output = validParameter.validFile(parameters, "output", false);                 if (output == "not found") { output = "name"; }
-                       
-                       if ((output != "name") && (output != "number")) { m->mothurOut("output options are name and number. I will use name."); m->mothurOutEndLine(); output = "name"; }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "OtuHierarchyCommand");
-               exit(1);
-       }                       
-}
-//**********************************************************************************************************************
-
-int OtuHierarchyCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get listvectors that correspond to labels requested, (or use smart distancing to get closest listvector)
-               vector<ListVector> lists = getListVectors();
-               
-               if (m->control_pressed) { outputTypes.clear(); return 0; }
-               
-               //determine which is little and which is big, putting little first
-               if (lists.size() == 2) {
-                       //if big is first swap them
-                       if (lists[0].getNumBins() < lists[1].getNumBins()) {
-                               reverse(lists.begin(), lists.end());
-                       }
-               }else{
-                       m->mothurOut("error getting listvectors, unable to read 2 different vectors, check your label inputs."); m->mothurOutEndLine(); return 0;
-               }
-               
-               //map sequences to bin number in the "little" otu
-               map<string, int> littleBins; 
-               for (int i = 0; i < lists[0].getNumBins(); i++) {
-               
-                       if (m->control_pressed) {  return 0; }
-                       
-                       string names = lists[0].get(i); 
-                       
-                       //parse bin
-                       while (names.find_first_of(',') != -1) { 
-                               string name = names.substr(0,names.find_first_of(','));
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                               littleBins[name] = i;  
-                       }
-                       
-                       //get last name
-                       littleBins[names] = i;
-               }
-               
-               ofstream out;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + lists[0].getLabel() + "-" + lists[1].getLabel() + ".otu.hierarchy";
-               m->openOutputFile(outputFileName, out);
-               
-               //go through each bin in "big" otu and output the bins in "little" otu which created it
-               for (int i = 0; i < lists[1].getNumBins(); i++) {
-               
-                       if (m->control_pressed) { outputTypes.clear(); out.close(); m->mothurRemove(outputFileName); return 0; }
-                       
-                       string names = lists[1].get(i);
-                       
-                       //output column 1
-                       if (output == "name")   {   out << names << '\t';       }
-                       else                                    {       out << i << '\t';               }
-                       
-                       map<int, int> bins; //bin numbers in little that are in this bin in big
-                       map<int, int>::iterator it;
-                       
-                       //parse bin
-                       while (names.find_first_of(',') != -1) { 
-                               string name = names.substr(0,names.find_first_of(','));
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                               bins[littleBins[name]] = littleBins[name];  
-                       }
-                       
-                       //get last name
-                       bins[littleBins[names]] = littleBins[names]; 
-                       
-                       string col2 = "";
-                       for (it = bins.begin(); it != bins.end(); it++) {
-                               if (output == "name")   {   col2 += lists[0].get(it->first) + "\t";     }
-                               else                                    {       col2 += toString(it->first) + "\t";             }
-                       }
-                       
-                       //output column 2
-                       out << col2 << endl;
-               }
-               
-               out.close();
-               
-               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFileName); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    outputNames.push_back(outputFileName); outputTypes["otuheirarchy"].push_back(outputFileName); 
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-//returns a vector of listVectors where "little" vector is first
-vector<ListVector> OtuHierarchyCommand::getListVectors() {
-       try {
-               
-               int pos; //to use in smart distancing, position of last read in file
-               int lastPos;
-               vector<ListVector> lists;
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-               //open file
-               ifstream in;
-               m->openInputFile(listFile, in);
-               
-               //get first list vector in file
-               ListVector* list = NULL;
-               string lastLabel = "";
-               if (!in.eof())  {
-                       pos = in.tellg();
-                       lastPos = pos;
-                       list = new ListVector(in);  
-                       m->gobble(in);
-                       lastLabel = list->getLabel();
-               }
-               
-               while ((list != NULL) && (userLabels.size() != 0)) {
-               
-                       if (m->control_pressed) {  in.close(); delete list;  return lists; }
-                       
-                       //is this a listvector that we want?
-                       if(labels.count(list->getLabel()) == 1){
-                               
-                               //make copy of listvector
-                               ListVector temp(*list);
-                               lists.push_back(temp);
-                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-               
-                       //you have a label the user want that is smaller than this label and the last label has not already been processed 
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               int savePos = in.tellg();
-                               
-                               //get smart distance line
-                               delete list;
-                               in.seekg(lastPos);
-                               if (!in.eof())  {       
-                                       list = new ListVector(in);  
-                               }else { list = NULL; }
-                               
-                               //make copy of listvector
-                               ListVector temp(*list);
-                               lists.push_back(temp);
-                                       
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());                                     
-                                                                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                               in.seekg(savePos);
-                       }
-                       
-                       lastLabel = list->getLabel();
-                       lastPos = pos;
-                       
-                       //get next line
-                       delete list;
-                       if (!in.eof())  {       
-                               pos = in.tellg();
-                               list = new ListVector(in);  
-                               m->gobble(in);
-                       }else { list = NULL; }
-               }
-               
-               if (m->control_pressed) { in.close();  return lists; }                          
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) {  in.close(); return lists; }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       
-                       in.seekg(lastPos);
-                       if (!in.eof())  {       
-                               list = new ListVector(in); 
-                               
-                               //make copy of listvector
-                               ListVector temp(*list);
-                               lists.push_back(temp);
-                               
-                               delete list;
-                       }
-               }
-               
-               in.close();
-               return lists;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "OtuHierarchyCommand", "getListVectors");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
-
-
diff --git a/otuhierarchycommand.h b/otuhierarchycommand.h
deleted file mode 100644 (file)
index 8a2c862..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef OTUHIERARCHYCOMMAND_H
-#define OTUHIERARCHYCOMMAND_H
-/*
- *  otuhierarchycommand.h
- *  Mothur
- *
- *  Created by westcott on 1/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "listvector.hpp"
-
-//**********************************************************************************************************************
-
-class OtuHierarchyCommand : public Command {
-
-public:
-       OtuHierarchyCommand(string);
-       OtuHierarchyCommand();
-       ~OtuHierarchyCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "otu.hierarchy";                       }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Otu.hierarchy"; }
-       string getDescription()         { return "relates OTUs at different distances"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       bool abort;
-       set<string> labels; //holds labels to be used
-       string label, listFile, outputDir, output;
-       vector<string> outputNames;
-       
-       vector<ListVector> getListVectors();
-               
-};
-
-//**********************************************************************************************************************
-
-#endif
-
-
diff --git a/overlap.cpp b/overlap.cpp
deleted file mode 100644 (file)
index 40b49f8..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *  overlap.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class cleans up the alignment at the 3' end of the alignments.  Because the Gotoh and Needleman-Wunsch
- *     algorithms start the traceback from the lower-right corner of the dynamic programming matrix, there may be a lot of
- *     scattered bases in the alignment near the 3' end of the alignment.  Here we basically look for the largest score
- *     in the last column and row to determine whether there should be exta gaps in sequence A or sequence B.  The gap
- *     issues at the 5' end of the alignment seem to take care of themselves in the traceback.
- *
- */
-
-#include "alignmentcell.hpp"
-#include "overlap.hpp"
-
-
-/**************************************************************************************************/
-
-int Overlap::maxRow(vector<vector<AlignmentCell> >& alignment, const int band){
-       
-       float max = -100;
-       int end = lA - 1;
-       int index = end;
-       
-       for(int i=band;i<lB;i++){                                       //      find the row where the right most column has the highest alignment
-               if(alignment[i][end].cValue >= max){    //      score.
-                       index = i;
-                       max = alignment[i][end].cValue;
-               }
-       }
-       return index;
-}
-
-/**************************************************************************************************/
-
-int Overlap::maxColumn(vector<vector<AlignmentCell> >& alignment, const int band){
-       
-       float max = -100;
-       int end = lB - 1;
-       int index = end;
-       
-       for(int i=band;i<lA;i++){                                       //      find the column where the bottom most column has the highest
-               if(alignment[end][i].cValue >= max){    //      alignment score.
-                       index = i;
-                       max = alignment[end][i].cValue;
-               }
-       }
-       return index;
-}
-
-/**************************************************************************************************/
-
-void Overlap::setOverlap(vector<vector<AlignmentCell> >& alignment, const int nA, const int nB, const int band=0){
-       
-       lA = nA;
-       lB = nB;        
-       
-       int rowIndex = maxRow(alignment, band);         //      get the index for the row with the highest right hand side score
-       int colIndex = maxColumn(alignment, band);      //      get the index for the column with the highest bottom row score
-               
-       int row = lB-1;
-       int column = lA-1;
-       
-       if(colIndex == column && rowIndex == row){}     //      if the max values are the lower right corner, then we're good
-       else if(alignment[row][colIndex].cValue < alignment[rowIndex][column].cValue){
-               for(int i=rowIndex+1;i<lB;i++){                 //      decide whether sequence A or B needs the gaps at the end either set 
-                       alignment[i][column].prevCell = 'u';//  the pointer upwards or...
-               }
-               
-       }
-       else {
-               for(int i=colIndex+1;i<lA;i++){
-                       alignment[row][i].prevCell = 'l';       //      ...to the left
-               }
-       }
-}                                                                                              //      the traceback should take care of the gaps at the 5' end
-
-/**************************************************************************************************/
-
diff --git a/overlap.hpp b/overlap.hpp
deleted file mode 100644 (file)
index f87f808..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef OVERLAP_H
-#define OVERLAP_H
-
-/*
- *  overlap.hpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This class cleans up the alignment at the 3' end of the alignments.  Because the Gotoh and Needleman-Wunsch
- *     algorithms start the traceback from the lower-right corner of the dynamic programming matrix, there may be a lot of
- *     scattered bases in the alignment near the 3' end of the alignment.  Here we basically look for the largest score
- *     in the last column and row to determine whether there should be exta gaps in sequence A or sequence B.  The gap
- *     issues at the 5' end of the alignment seem to take care of themselves in the traceback.
- *
- */
-
-#include "mothur.h"
-
-/**************************************************************************************************/
-
-class Overlap {
-       
-public:
-       Overlap(){};
-       ~Overlap(){};
-       void setOverlap(vector<vector<AlignmentCell> >&, const int, const int, const int);
-private:
-       int maxRow(vector<vector<AlignmentCell> >&, const int);
-       int maxColumn(vector<vector<AlignmentCell> >&, const int);
-       int lA, lB;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp
deleted file mode 100644 (file)
index a4ccbf8..0000000
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*
- *  pairwiseseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "pairwiseseqscommand.h"
-
-//**********************************************************************************************************************
-vector<string> PairwiseSeqsCommand::setParameters(){   
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter palign("align", "Multiple", "needleman-gotoh-blast-noalign", "needleman", "", "", "",false,false); parameters.push_back(palign);
-               CommandParameter pmatch("match", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pmatch);
-               CommandParameter pmismatch("mismatch", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pmismatch);
-               CommandParameter pgapopen("gapopen", "Number", "", "-2.0", "", "", "",false,false); parameters.push_back(pgapopen);
-               CommandParameter pgapextend("gapextend", "Number", "", "-1.0", "", "", "",false,false); parameters.push_back(pgapextend);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter poutput("output", "Multiple", "column-lt-square", "column", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pcalc("calc", "Multiple", "nogaps-eachgap-onegap", "onegap", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pcountends("countends", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pcountends);
-               CommandParameter pcompress("compress", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcompress);
-               CommandParameter pcutoff("cutoff", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PairwiseSeqsCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The pairwise.seqs command reads a fasta file and creates distance matrix.\n";
-               helpString += "The pairwise.seqs command parameters are fasta, align, match, mismatch, gapopen, gapextend, calc, output, cutoff and processors.\n";
-               helpString += "The fasta parameter is required. You may enter multiple fasta files by separating their names with dashes. ie. fasta=abrecovery.fasta-amzon.fasta \n";
-               helpString += "The align parameter allows you to specify the alignment method to use.  Your options are: gotoh, needleman, blast and noalign. The default is needleman.\n";
-               helpString += "The match parameter allows you to specify the bonus for having the same base. The default is 1.0.\n";
-               helpString += "The mistmatch parameter allows you to specify the penalty for having different bases.  The default is -1.0.\n";
-               helpString += "The gapopen parameter allows you to specify the penalty for opening a gap in an alignment. The default is -2.0.\n";
-               helpString += "The gapextend parameter allows you to specify the penalty for extending a gap in an alignment.  The default is -1.0.\n";
-               helpString += "The calc parameter allows you to specify the method of calculating the distances.  Your options are: nogaps, onegap or eachgap. The default is onegap.\n";
-               helpString += "The countends parameter allows you to specify whether to include terminal gaps in distance.  Your options are: T or F. The default is T.\n";
-               helpString += "The cutoff parameter allows you to specify maximum distance to keep. The default is 1.0.\n";
-               helpString += "The output parameter allows you to specify format of your distance matrix. Options are column, lt, and square. The default is column.\n";
-               helpString += "The compress parameter allows you to indicate that you want the resulting distance file compressed.  The default is false.\n";
-               helpString += "The pairwise.seqs command should be in the following format: \n";
-               helpString += "pairwise.seqs(fasta=yourfastaFile, align=yourAlignmentMethod) \n";
-               helpString += "Example pairwise.seqs(fasta=candidate.fasta, align=blast)\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-PairwiseSeqsCommand::PairwiseSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["phylip"] = tempOutNames;
-               outputTypes["column"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "PairwiseSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-PairwiseSeqsCommand::PairwiseSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter("pairwise.seqs");
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["phylip"] = tempOutNames;
-                       outputTypes["column"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       
-                       if (inputDir == "not found"){   inputDir = "";          }
-
-                       fastaFileName = validParameter.validFile(parameters, "fasta", false);
-                       if (fastaFileName == "not found") {                             
-                               //if there is a current fasta file, use it
-                               string filename = m->getFastaFile(); 
-                               if (filename != "") { fastaFileNames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else { 
-                               m->splitAtDash(fastaFileName, fastaFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < fastaFileNames.size(); i++) {
-                                       
-                                       bool ignore = false;
-                                       if (fastaFileNames[i] == "current") { 
-                                               fastaFileNames[i] = m->getFastaFile(); 
-                                               if (fastaFileNames[i] != "") {  m->mothurOut("Using " + fastaFileNames[i] + " as input file for the fasta parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current fastafile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(fastaFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       fastaFileNames[i] = inputDir + fastaFileNames[i];               }
-                                               }
-               
-                                               int ableToOpen;
-                                               ifstream in;
-
-                                               ableToOpen = m->openInputFile(fastaFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try output location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(fastaFileNames[i]);
-                                                               m->mothurOut("Unable to open " + fastaFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               fastaFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();                                     
-
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + fastaFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); 
-                                                       //erase from file list
-                                                       fastaFileNames.erase(fastaFileNames.begin()+i);
-                                                       i--;
-                                               }else {
-                                                       m->setFastaFile(fastaFileNames[i]);
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (fastaFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "match", false);            if (temp == "not found"){       temp = "1.0";                   }
-                       m->mothurConvert(temp, match);  
-                       
-                       temp = validParameter.validFile(parameters, "mismatch", false);         if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, misMatch);  
-            if (misMatch > 0) { m->mothurOut("[ERROR]: mismatch must be negative.\n"); abort=true; }
-                       
-                       temp = validParameter.validFile(parameters, "gapopen", false);          if (temp == "not found"){       temp = "-2.0";                  }
-                       m->mothurConvert(temp, gapOpen);  
-            if (gapOpen > 0) { m->mothurOut("[ERROR]: gapopen must be negative.\n"); abort=true; }
-                       
-                       temp = validParameter.validFile(parameters, "gapextend", false);        if (temp == "not found"){       temp = "-1.0";                  }
-                       m->mothurConvert(temp, gapExtend); 
-            if (gapExtend > 0) { m->mothurOut("[ERROR]: gapextend must be negative.\n"); abort=true; }
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);           if(temp == "not found"){        temp = "1.0"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       temp = validParameter.validFile(parameters, "countends", false);        if(temp == "not found"){        temp = "T";     }
-                       countends = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "compress", false);         if(temp == "not found"){  temp = "F"; }
-                       compress = m->isTrue(temp); 
-                       
-                       align = validParameter.validFile(parameters, "align", false);           if (align == "not found"){      align = "needleman";    }
-                       
-                       output = validParameter.validFile(parameters, "output", false);         if(output == "not found"){      output = "column"; }
-                       if ((output != "column") && (output != "lt") && (output != "square")) { m->mothurOut(output + " is not a valid output form. Options are column, lt and square. I will use column."); m->mothurOutEndLine(); output = "column"; }
-                       
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "onegap";  }
-                       else { 
-                                if (calc == "default")  {  calc = "onegap";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "PairwiseSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int PairwiseSeqsCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               longestBase = 2000; //will need to update this in driver if we find sequences with more bases.  hardcoded so we don't have the pre-read user fasta file.
-               
-               cutoff += 0.005;
-               
-               for (int s = 0; s < fastaFileNames.size(); s++) {
-                       if (m->control_pressed) { outputTypes.clear(); return 0; }
-                       
-                       m->mothurOut("Processing sequences from " + fastaFileNames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       if (outputDir == "") {  outputDir += m->hasPath(fastaFileNames[s]); }
-                       
-                       ifstream inFASTA;
-                       m->openInputFile(fastaFileNames[s], inFASTA);
-                       alignDB = SequenceDB(inFASTA); 
-                       inFASTA.close();
-                       
-                       int numSeqs = alignDB.getNumSeqs();
-                       int startTime = time(NULL);
-                       string outputFile = "";
-                               
-                       if (output == "lt") { //does the user want lower triangle phylip formatted file 
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "phylip.dist";
-                               m->mothurRemove(outputFile); outputTypes["phylip"].push_back(outputFile);
-                       }else if (output == "column") { //user wants column format
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "dist";
-                               outputTypes["column"].push_back(outputFile);
-                               m->mothurRemove(outputFile);
-                       }else { //assume square
-                               outputFile = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "square.dist";
-                               m->mothurRemove(outputFile);
-                               outputTypes["phylip"].push_back(outputFile);
-                       }
-                       
-                       #ifdef USE_MPI
-               
-                       int pid, start, end; 
-                       int tag = 2001;
-                                       
-                       MPI_Status status; 
-                       MPI_Comm_size(MPI_COMM_WORLD, &processors); //set processors to the number of mpi processes running
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                       
-                       //each process gets where it should start and stop in the file
-                       if (output != "square") {
-                               start = int (sqrt(float(pid)/float(processors)) * numSeqs);
-                               end = int (sqrt(float(pid+1)/float(processors)) * numSeqs);
-                       }else{
-                               start = int ((float(pid)/float(processors)) * numSeqs);
-                               end = int ((float(pid+1)/float(processors)) * numSeqs);
-                       }
-                       
-                       if (output == "column") {
-                               MPI_File outMPI;
-                               int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-                       char filename[1024];
-                               strcpy(filename, outputFile.c_str());
-                               
-                               MPI_File_open(MPI_COMM_WORLD, filename, amode, MPI_INFO_NULL, &outMPI);
-
-                               if (pid == 0) { //you are the root process 
-                               
-                                       //do your part
-                                       string outputMyPart;
-                                       
-                                       driverMPI(start, end, outMPI, cutoff); 
-                                       
-                                       if (m->control_pressed) { outputTypes.clear(); MPI_File_close(&outMPI);  m->mothurRemove(outputFile); return 0; }
-                               
-                                       //wait on chidren
-                                       for(int i = 1; i < processors; i++) { 
-                                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);   m->mothurRemove(outputFile);  return 0; }
-                                               
-                                               char buf[5];
-                                               MPI_Recv(buf, 5, MPI_CHAR, i, tag, MPI_COMM_WORLD, &status); 
-                                       }
-                               }else { //you are a child process
-                                       //do your part
-                                       driverMPI(start, end, outMPI, cutoff); 
-                                       
-                                       if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);  m->mothurRemove(outputFile);  return 0; }
-                               
-                                       char buf[5];
-                                       strcpy(buf, "done"); 
-                                       //tell parent you are done.
-                                       MPI_Send(buf, 5, MPI_CHAR, 0, tag, MPI_COMM_WORLD);
-                               }
-                               
-                               MPI_File_close(&outMPI);
-                               
-                       }else { //lower triangle format
-                               if (pid == 0) { //you are the root process 
-                               
-                                       //do your part
-                                       string outputMyPart;
-                                       unsigned long long mySize;
-                                       
-                                       if (output != "square"){ driverMPI(start, end, outputFile, mySize); }
-                                       else { driverMPI(start, end, outputFile, mySize, output); }
-               
-                                       if (m->control_pressed) {  outputTypes.clear();   m->mothurRemove(outputFile);   return 0; }
-                                       
-                                       int amode=MPI_MODE_APPEND|MPI_MODE_WRONLY|MPI_MODE_CREATE; //
-                                       MPI_File outMPI;
-                                       MPI_File inMPI;
-
-                                       char filename[1024];
-                                       strcpy(filename, outputFile.c_str());
-
-                                       MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-
-                                       //wait on chidren
-                                       for(int b = 1; b < processors; b++) { 
-                                               unsigned long long fileSize;
-                                               
-                                               if (m->control_pressed) { outputTypes.clear();  MPI_File_close(&outMPI);  m->mothurRemove(outputFile);   return 0; }
-                                               
-                                               MPI_Recv(&fileSize, 1, MPI_LONG, b, tag, MPI_COMM_WORLD, &status); 
-                                               
-                                               string outTemp = outputFile + toString(b) + ".temp";
-
-                                               char* buf = new char[outTemp.length()];
-                                               memcpy(buf, outTemp.c_str(), outTemp.length());
-                                               
-                                               MPI_File_open(MPI_COMM_SELF, buf, MPI_MODE_DELETE_ON_CLOSE|MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);
-                                               delete buf;
-
-                                               int count = 0;
-                                               while (count < fileSize) { 
-                                                       char buf2[1];
-                                                       MPI_File_read(inMPI, buf2, 1, MPI_CHAR, &status);
-                                                       MPI_File_write(outMPI, buf2, 1, MPI_CHAR, &status);
-                                                       count += 1;
-                                               }
-                                               
-                                               MPI_File_close(&inMPI); //deleted on close
-                                       }
-                                       
-                                       MPI_File_close(&outMPI);
-                               }else { //you are a child process
-                                       //do your part
-                                       unsigned long long size;
-                                       if (output != "square"){ driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size); }
-                                       else { driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size, output); }
-                                       
-                                       if (m->control_pressed) {  return 0; }
-                               
-                                       //tell parent you are done.
-                                       MPI_Send(&size, 1, MPI_LONG, 0, tag, MPI_COMM_WORLD);
-                               }
-                       }
-                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-       #else           
-                                       
-               //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       //if you don't need to fork anything
-                       if(processors == 1){
-                               if (output != "square") {  driver(0, numSeqs, outputFile, cutoff); }
-                               else { driver(0, numSeqs, outputFile, "square");  }
-                       }else{ //you have multiple processors
-                               
-                               for (int i = 0; i < processors; i++) {
-                                       distlinePair tempLine;
-                                       lines.push_back(tempLine);
-                                       if (output != "square") {
-                                               lines[i].start = int (sqrt(float(i)/float(processors)) * numSeqs);
-                                               lines[i].end = int (sqrt(float(i+1)/float(processors)) * numSeqs);
-                                       }else{
-                                               lines[i].start = int ((float(i)/float(processors)) * numSeqs);
-                                               lines[i].end = int ((float(i+1)/float(processors)) * numSeqs);
-                                       }
-                               }
-                               
-                               createProcesses(outputFile); 
-                       }
-               //#else
-                       //ifstream inFASTA;
-                       //if (output != "square") {  driver(0, numSeqs, outputFile, cutoff); }
-                       //else { driver(0, numSeqs, outputFile, "square");  }
-               //#endif
-               
-       #endif
-                       if (m->control_pressed) { outputTypes.clear();   m->mothurRemove(outputFile); return 0; }
-                       
-                       #ifdef USE_MPI
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                               
-                               if (pid == 0) { //only one process should output to screen
-                       #endif
-                       
-                       ifstream fileHandle;
-                       fileHandle.open(outputFile.c_str());
-                       if(fileHandle) {
-                               m->gobble(fileHandle);
-                               if (fileHandle.eof()) { m->mothurOut(outputFile + " is blank. This can result if there are no distances below your cutoff.");  m->mothurOutEndLine(); }
-                       }
-                       
-                       if (compress) {
-                               m->mothurOut("Compressing..."); m->mothurOutEndLine();
-                               m->mothurOut("(Replacing " + outputFile + " with " + outputFile + ".gz)"); m->mothurOutEndLine();
-                               system(("gzip -v " + outputFile).c_str());
-                               outputNames.push_back(outputFile + ".gz");
-                       }else { outputNames.push_back(outputFile); }
-                       
-                       #ifdef USE_MPI
-                               }
-                       #endif
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - startTime) + " to calculate the distances for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine();
-                       
-                       if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(outputFile); return 0; }
-               }
-               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("phylip");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
-               }
-               
-               //set column file as new current columnfile
-               itTypes = outputTypes.find("column");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-void PairwiseSeqsCommand::createProcesses(string filename) {
-       try {
-        int process = 1;
-               processIDS.clear();
-        
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid); 
-                               process++;
-                       }else if (pid == 0){
-                               if (output != "square") {  driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", cutoff); }
-                               else { driver(lines[process].start, lines[process].end, filename + toString(getpid()) + ".temp", "square"); }
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i=0;i<processIDS.size();i++) { int temp = processIDS[i]; kill (temp, SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent do my part
-               if (output != "square") {  driver(lines[0].start, lines[0].end, filename, cutoff); }
-               else { driver(lines[0].start, lines[0].end, filename, "square"); }
-
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-#else     
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the distanceData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //that's why the distance calculator was moved inside of the driver to make separate copies.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<pairwiseData*> pDataArray; //[processors-1];
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor-1 worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       string extension = toString(i) + ".temp";
-
-                       // Allocate memory for thread data.
-                       pairwiseData* tempDist = new pairwiseData((filename+extension), align, "square", Estimators[0], countends, output, alignDB, m, lines[i+1].start, lines[i+1].end, match, misMatch, gapOpen, gapExtend, longestBase, i);
-                       pDataArray.push_back(tempDist);
-                       processIDS.push_back(i);
-                       
-                       if (output != "square") { hThreadArray[i] = CreateThread(NULL, 0, MyPairwiseThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);  } 
-            else { hThreadArray[i] = CreateThread(NULL, 0, MyPairwiseSquareThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);  }
-               }
-               
-               //do your part
-               if (output != "square") {  driver(lines[0].start, lines[0].end, filename, cutoff); }
-               else { driver(lines[0].start, lines[0].end, filename, "square"); }
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-
-#endif
-        
-        //append and remove temp files
-               for (int i=0;i<processIDS.size();i++) { 
-                       m->appendFiles((filename + toString(processIDS[i]) + ".temp"), filename);
-                       m->mothurRemove((filename + toString(processIDS[i]) + ".temp"));
-               }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int PairwiseSeqsCommand::driver(int startLine, int endLine, string dFileName, float cutoff){
-       try {
-
-               int startTime = time(NULL);
-        
-        Alignment* alignment;
-        if(align == "gotoh")                   {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-        
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (countends) {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")                 {       distCalculator = new ignoreGaps();      }
-                else if (Estimators[0] == "eachgap")   {       distCalculator = new eachGapDist();     }
-                else if (Estimators[0] == "onegap")            {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")         {       distCalculator = new ignoreGaps();                                      }
-                else if (Estimators[0] == "eachgap"){  distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (Estimators[0] == "onegap")    {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-               
-               //column file
-               ofstream outFile(dFileName.c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               if((output == "lt") && startLine == 0){ outFile << alignDB.getNumSeqs() << endl;        }
-               
-               for(int i=startLine;i<endLine;i++){
-                       if(output == "lt")      {       
-                               string name = alignDB.get(i).getName();
-                               if (name.length() < 10) { //pad with spaces to make compatible
-                                       while (name.length() < 10) {  name += " ";  }
-                               }
-                               outFile << name << '\t';        
-                       }
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { outFile.close(); delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(alignDB.get(i).getName(), alignDB.get(i).getAligned());
-                               Sequence seqJ(alignDB.get(j).getName(), alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                               
-                               if(dist <= cutoff){
-                                       if (output == "column") { outFile << alignDB.get(i).getName() << ' ' << alignDB.get(j).getName() << ' ' << dist << endl; }
-                               }
-                               if (output == "lt") {  outFile << dist << '\t'; }
-                       }
-                       
-                       if (output == "lt") { outFile << endl; }
-                       
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                       }
-                       
-               }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               
-               outFile.close();
-        delete alignment;
-        delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int PairwiseSeqsCommand::driver(int startLine, int endLine, string dFileName, string square){
-       try {
-
-               int startTime = time(NULL);
-        
-        Alignment* alignment;
-        if(align == "gotoh")                   {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-               
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (countends) {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")                 {       distCalculator = new ignoreGaps();      }
-                else if (Estimators[0] == "eachgap")   {       distCalculator = new eachGapDist();     }
-                else if (Estimators[0] == "onegap")            {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")         {       distCalculator = new ignoreGaps();                                      }
-                else if (Estimators[0] == "eachgap"){  distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (Estimators[0] == "onegap")    {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-
-               //column file
-               ofstream outFile(dFileName.c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               if(startLine == 0){     outFile << alignDB.getNumSeqs() << endl;        }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       //pad with spaces to make compatible
-                       if (name.length() < 10) { while (name.length() < 10) {  name += " ";  } }
-                               
-                       outFile << name << '\t';        
-                       
-                       for(int j=0;j<alignDB.getNumSeqs();j++){
-                               
-                               if (m->control_pressed) { outFile.close(); delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(alignDB.get(i).getName(), alignDB.get(i).getAligned());
-                               Sequence seqJ(alignDB.get(j).getName(), alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                                                               
-                               outFile << dist << '\t'; 
-                       }
-                       
-                       outFile << endl; 
-                       
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                       }
-                       
-               }
-               m->mothurOut(toString(endLine-1) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-               
-               outFile.close();
-        delete alignment;
-        delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "driver");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int PairwiseSeqsCommand::driverMPI(int startLine, int endLine, MPI_File& outMPI, float cutoff){
-       try {
-               MPI_Status status;
-               int startTime = time(NULL);
-        
-        Alignment* alignment;
-        if(align == "gotoh")                   {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-               
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (countends) {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")                 {       distCalculator = new ignoreGaps();      }
-                else if (Estimators[0] == "eachgap")   {       distCalculator = new eachGapDist();     }
-                else if (Estimators[0] == "onegap")            {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")         {       distCalculator = new ignoreGaps();                                      }
-                else if (Estimators[0] == "eachgap"){  distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (Estimators[0] == "onegap")    {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-
-               string outputString = "";
-               
-               for(int i=startLine;i<endLine;i++){
-       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(alignDB.get(i).getName(), alignDB.get(i).getAligned());
-                               Sequence seqJ(alignDB.get(j).getName(), alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                               
-                               if(dist <= cutoff){
-                                        outputString += (alignDB.get(i).getName() + ' ' + alignDB.get(j).getName() + ' ' + toString(dist) + '\n'); 
-                               }
-                       }
-                       
-                       if(i % 100 == 0){
-                               //m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); m->mothurOutEndLine();
-                               cout << i << '\t' << (time(NULL) - startTime) << endl;
-                       }
-                       
-                        
-                       //send results to parent
-                       int length = outputString.length();
-
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write_shared(outMPI, buf, length, MPI_CHAR, &status);
-                       outputString = "";
-                       delete buf;
-                       
-               }
-               delete alignment;
-        delete distCalculator;
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "driverMPI");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int PairwiseSeqsCommand::driverMPI(int startLine, int endLine, string file, unsigned long long& size){
-       try {
-               MPI_Status status;
-               
-               MPI_File outMPI;
-               int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-               char filename[1024];
-               strcpy(filename, file.c_str());
-
-               MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-
-               Alignment* alignment;
-        if(align == "gotoh")                   {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-        
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (countends) {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")                 {       distCalculator = new ignoreGaps();      }
-                else if (Estimators[0] == "eachgap")   {       distCalculator = new eachGapDist();     }
-                else if (Estimators[0] == "onegap")            {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")         {       distCalculator = new ignoreGaps();                                      }
-                else if (Estimators[0] == "eachgap"){  distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (Estimators[0] == "onegap")    {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-
-               
-               string outputString = "";
-               size = 0;
-               
-               if(startLine == 0){     outputString += toString(alignDB.getNumSeqs()) + "\n";  }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       if (name.length() < 10) { //pad with spaces to make compatible
-                               while (name.length() < 10) {  name += " ";  }
-                       }
-                       outputString += name + "\t";    
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (m->control_pressed) { delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(alignDB.get(i).getName(), alignDB.get(i).getAligned());
-                               Sequence seqJ(alignDB.get(j).getName(), alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                               
-                               outputString += toString(dist) + "\t"; 
-                       }
-                       
-                       outputString += "\n"; 
-                       
-                       //send results to parent
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write(outMPI, buf, length, MPI_CHAR, &status);
-                       size += outputString.length();
-                       outputString = "";
-                       delete buf;
-               }
-               
-               MPI_File_close(&outMPI);
-        delete alignment;
-        delete distCalculator;
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "driverMPI");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/////// need to fix to work with calcs and sequencedb
-int PairwiseSeqsCommand::driverMPI(int startLine, int endLine, string file, unsigned long long& size, string square){
-       try {
-               MPI_Status status;
-               
-               MPI_File outMPI;
-               int amode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-
-               char filename[1024];
-               strcpy(filename, file.c_str());
-
-               MPI_File_open(MPI_COMM_SELF, filename, amode, MPI_INFO_NULL, &outMPI);
-               
-               Alignment* alignment;
-        if(align == "gotoh")                   {       alignment = new GotohOverlap(gapOpen, gapExtend, match, misMatch, longestBase);                 }
-               else if(align == "needleman")   {       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);                                }
-               else if(align == "blast")               {       alignment = new BlastAlignment(gapOpen, gapExtend, match, misMatch);            }
-               else if(align == "noalign")             {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       m->mothurOut(align + " is not a valid alignment option. I will run the command using needleman.");
-                       m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase);
-               }
-               
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (countends) {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")                 {       distCalculator = new ignoreGaps();      }
-                else if (Estimators[0] == "eachgap")   {       distCalculator = new eachGapDist();     }
-                else if (Estimators[0] == "onegap")            {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { 
-                if (Estimators[0] == "nogaps")         {       distCalculator = new ignoreGaps();                                      }
-                else if (Estimators[0] == "eachgap"){  distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (Estimators[0] == "onegap")    {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-        
-               string outputString = "";
-               size = 0;
-               
-               if(startLine == 0){     outputString += toString(alignDB.getNumSeqs()) + "\n";  }
-               
-               for(int i=startLine;i<endLine;i++){
-                               
-                       string name = alignDB.get(i).getName();
-                       if (name.length() < 10) { //pad with spaces to make compatible
-                               while (name.length() < 10) {  name += " ";  }
-                       }
-                       outputString += name + "\t";    
-                       
-                       for(int j=0;j<alignDB.getNumSeqs();j++){
-                               
-                               if (m->control_pressed) {  delete alignment; return 0;  }
-                               
-                               if (alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(alignDB.get(i).getName(), alignDB.get(i).getAligned());
-                               Sequence seqJ(alignDB.get(j).getName(), alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                               
-                               outputString += toString(dist) + "\t"; 
-                       }
-                       
-                       outputString += "\n"; 
-
-                       //send results to parent
-                       int length = outputString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outputString.c_str(), length);
-                       
-                       MPI_File_write(outMPI, buf, length, MPI_CHAR, &status);
-                       size += outputString.length();
-                       outputString = "";
-                       delete buf;
-               }
-               
-               MPI_File_close(&outMPI);
-               
-        delete alignment;
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PairwiseSeqsCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-
diff --git a/pairwiseseqscommand.h b/pairwiseseqscommand.h
deleted file mode 100644 (file)
index e75f63c..0000000
+++ /dev/null
@@ -1,323 +0,0 @@
-#ifndef PAIRWISESEQSCOMMAND_H
-#define PAIRWISESEQSCOMMAND_H
-
-/*
- *  pairwiseseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 10/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "database.hpp"
-#include "alignment.hpp"
-#include "validcalculator.h"
-#include "dist.h"
-#include "sequencedb.h"
-#include "sequence.hpp"
-
-#include "gotohoverlap.hpp"
-#include "needlemanoverlap.hpp"
-#include "blastalign.hpp"
-#include "noalign.hpp"
-
-#include "ignoregaps.h"
-#include "eachgapdist.h"
-#include "eachgapignore.h"
-#include "onegapdist.h"
-#include "onegapignore.h"
-
-class PairwiseSeqsCommand : public Command {
-       
-public:
-       PairwiseSeqsCommand(string);    
-       PairwiseSeqsCommand();
-       ~PairwiseSeqsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pairwise.seqs";               }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "Needleman SB, Wunsch CD (1970). A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 48: 443-53. [ for needleman ]\nGotoh O (1982). An improved algorithm for matching biological sequences. J Mol Biol 162: 705-8. [ for gotoh ] \nhttp://www.mothur.org/wiki/Pairwise.seqs"; }
-       string getDescription()         { return "calculates pairwise distances from an unaligned fasta file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       struct distlinePair {
-               int start;
-               int end;
-       };
-       
-       vector<int> processIDS;   //end line, processid
-       vector<distlinePair> lines;
-       
-       SequenceDB alignDB;
-       
-       void createProcesses(string);
-       int driver(int, int, string, float);
-       int driver(int, int, string, string);
-       
-       #ifdef USE_MPI 
-       int driverMPI(int, int, MPI_File&, float);
-       int driverMPI(int, int, string, unsigned long long&);
-       int driverMPI(int, int, string, unsigned long long&, string);
-       #endif
-       
-       string fastaFileName, align, calc, outputDir, output;
-       float match, misMatch, gapOpen, gapExtend, cutoff;
-       int processors, longestBase;
-       vector<string> fastaFileNames, Estimators;
-       vector<string> outputNames;
-       
-       bool abort, countends, compress;
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct pairwiseData {
-    string outputFileName;
-       string align, square, distcalcType, output;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       float match, misMatch, gapOpen, gapExtend, cutoff;
-       int count, threadID, longestBase;
-    bool countends;
-    SequenceDB alignDB;
-       
-       pairwiseData(){}
-       pairwiseData(string ofn, string al, string sq, string di, bool co, string op, SequenceDB DB, MothurOut* mout, unsigned long long st, unsigned long long en, float ma, float misMa, float gapO, float gapE, int thr, int tid) {
-               outputFileName = ofn;
-               m = mout;
-               start = st;
-               end = en;
-               match = ma; 
-               misMatch = misMa;
-               gapOpen = gapO; 
-               gapExtend = gapE; 
-               longestBase = thr;
-               align = al;
-        square = sq;
-        distcalcType = di;
-        countends = co;
-        alignDB = DB;
-               count = 0;
-        output = op;
-               threadID = tid;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyPairwiseSquareThreadFunction(LPVOID lpParam){ 
-       pairwiseData* pDataArray;
-       pDataArray = (pairwiseData*)lpParam;
-       
-       try {
-               ofstream outFile((pDataArray->outputFileName).c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-               pDataArray->count = pDataArray->end;
-        
-        int startTime = time(NULL);
-        
-        Alignment* alignment;
-        if(pDataArray->align == "gotoh")                       {       alignment = new GotohOverlap(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);                     }
-               else if(pDataArray->align == "needleman")       {       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);                                }
-               else if(pDataArray->align == "blast")           {       alignment = new BlastAlignment(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch);            }
-               else if(pDataArray->align == "noalign")         {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       pDataArray->m->mothurOut(pDataArray->align + " is not a valid alignment option. I will run the command using needleman.");
-                       pDataArray->m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);
-               }
-               
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (pDataArray->countends) {
-            if (validCalculator.isValidCalculator("distance", pDataArray->distcalcType) == true) { 
-                if (pDataArray->distcalcType == "nogaps")                      {       distCalculator = new ignoreGaps();      }
-                else if (pDataArray->distcalcType == "eachgap")        {       distCalculator = new eachGapDist();     }
-                else if (pDataArray->distcalcType == "onegap")         {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", pDataArray->distcalcType) == true) { 
-                if (pDataArray->distcalcType == "nogaps")              {       distCalculator = new ignoreGaps();                                      }
-                else if (pDataArray->distcalcType == "eachgap"){       distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (pDataArray->distcalcType == "onegap") {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-
-        if(pDataArray->start == 0){    outFile << pDataArray->alignDB.getNumSeqs() << endl;    }
-               
-               for(int i=pDataArray->start;i<pDataArray->end;i++){
-            
-                       string name = pDataArray->alignDB.get(i).getName();
-                       //pad with spaces to make compatible
-                       if (name.length() < 10) { while (name.length() < 10) {  name += " ";  } }
-            
-                       outFile << name << '\t';        
-                       
-                       for(int j=0;j<pDataArray->alignDB.getNumSeqs();j++){
-                               
-                               if (pDataArray->m->control_pressed) { outFile.close(); delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (pDataArray->alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(pDataArray->alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (pDataArray->alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(pDataArray->alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(pDataArray->alignDB.get(i).getName(), pDataArray->alignDB.get(i).getAligned());
-                               Sequence seqJ(pDataArray->alignDB.get(j).getName(), pDataArray->alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                
-                               outFile << dist << '\t'; 
-                       }
-                       
-                       outFile << endl; 
-                       
-                       if(i % 100 == 0){
-                               pDataArray->m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-                       }
-                       
-               }
-               pDataArray->m->mothurOut(toString(pDataArray->end-1) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-               
-               outFile.close();
-        delete alignment;
-        delete distCalculator;
-
-        
-    }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "PairwiseSeqsCommand", "MyPairwiseSquareThreadFunction");
-               exit(1);
-       }
-} 
-
-/**************************************************************************************************/
-static DWORD WINAPI MyPairwiseThreadFunction(LPVOID lpParam){ 
-       pairwiseData* pDataArray;
-       pDataArray = (pairwiseData*)lpParam;
-       
-       try {
-               ofstream outFile((pDataArray->outputFileName).c_str(), ios::trunc);
-               outFile.setf(ios::fixed, ios::showpoint);
-               outFile << setprecision(4);
-               
-        pDataArray->count = pDataArray->end;
-        
-        int startTime = time(NULL);
-        
-        Alignment* alignment;
-        if(pDataArray->align == "gotoh")                       {       alignment = new GotohOverlap(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);                     }
-               else if(pDataArray->align == "needleman")       {       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);                                }
-               else if(pDataArray->align == "blast")           {       alignment = new BlastAlignment(pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch);            }
-               else if(pDataArray->align == "noalign")         {       alignment = new NoAlign();                                                                                                      }
-               else {
-                       pDataArray->m->mothurOut(pDataArray->align + " is not a valid alignment option. I will run the command using needleman.");
-                       pDataArray->m->mothurOutEndLine();
-                       alignment = new NeedlemanOverlap(pDataArray->gapOpen, pDataArray->match, pDataArray->misMatch, pDataArray->longestBase);
-               }
-               
-        ValidCalculators validCalculator;
-        Dist* distCalculator;
-        if (pDataArray->countends) {
-            if (validCalculator.isValidCalculator("distance", pDataArray->distcalcType) == true) { 
-                if (pDataArray->distcalcType == "nogaps")                      {       distCalculator = new ignoreGaps();      }
-                else if (pDataArray->distcalcType == "eachgap")        {       distCalculator = new eachGapDist();     }
-                else if (pDataArray->distcalcType == "onegap")         {       distCalculator = new oneGapDist();      }
-            }
-        }else {
-            if (validCalculator.isValidCalculator("distance", pDataArray->distcalcType) == true) { 
-                if (pDataArray->distcalcType == "nogaps")              {       distCalculator = new ignoreGaps();                                      }
-                else if (pDataArray->distcalcType == "eachgap"){       distCalculator = new eachGapIgnoreTermGapDist();        }
-                else if (pDataArray->distcalcType == "onegap") {       distCalculator = new oneGapIgnoreTermGapDist();         }
-            }
-        }
-        
-        if((pDataArray->output == "lt") && pDataArray->start == 0){    outFile << pDataArray->alignDB.getNumSeqs() << endl;    }
-               
-               for(int i=pDataArray->start;i<pDataArray->end;i++){
-            
-                       if(pDataArray->output == "lt")  {       
-                               string name = pDataArray->alignDB.get(i).getName();
-                               if (name.length() < 10) { //pad with spaces to make compatible
-                                       while (name.length() < 10) {  name += " ";  }
-                               }
-                               outFile << name << '\t';        
-                       }
-
-                       
-                       for(int j=0;j<i;j++){
-                               
-                               if (pDataArray->m->control_pressed) { outFile.close(); delete alignment; delete distCalculator; return 0;  }
-                               
-                               if (pDataArray->alignDB.get(i).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(pDataArray->alignDB.get(i).getUnaligned().length()+1);
-                               }
-                               
-                               if (pDataArray->alignDB.get(j).getUnaligned().length() > alignment->getnRows()) {
-                                       alignment->resize(pDataArray->alignDB.get(j).getUnaligned().length()+1);
-                               }
-                               
-                               Sequence seqI(pDataArray->alignDB.get(i).getName(), pDataArray->alignDB.get(i).getAligned());
-                               Sequence seqJ(pDataArray->alignDB.get(j).getName(), pDataArray->alignDB.get(j).getAligned());
-                               
-                               alignment->align(seqI.getUnaligned(), seqJ.getUnaligned());
-                               seqI.setAligned(alignment->getSeqAAln());
-                               seqJ.setAligned(alignment->getSeqBAln());
-                               
-                               distCalculator->calcDist(seqI, seqJ);
-                               double dist = distCalculator->getDist();
-                
-                               if(dist <= pDataArray->cutoff){
-                                       if (pDataArray->output == "column") { outFile << pDataArray->alignDB.get(i).getName() << ' ' << pDataArray->alignDB.get(j).getName() << ' ' << dist << endl; }
-                               }
-                               if (pDataArray->output == "lt") {  outFile << dist << '\t'; }
-                       }
-                       
-                       if (pDataArray->output == "lt") { outFile << endl; }
-                       
-                       if(i % 100 == 0){
-                               pDataArray->m->mothurOut(toString(i) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-                       }
-                       
-               }
-               pDataArray->m->mothurOut(toString(pDataArray->end-1) + "\t" + toString(time(NULL) - startTime)); pDataArray->m->mothurOutEndLine();
-               
-               outFile.close();
-        delete alignment;
-        delete distCalculator;
-        
-        
-    }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "PairwiseSeqsCommand", "MyPairwiseThreadFunction");
-               exit(1);
-       }
-} 
-
-#endif
-
-
-#endif
-
diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp
deleted file mode 100644 (file)
index e6d7ce6..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *  parsefastaqcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "parsefastaqcommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> ParseFastaQCommand::setParameters(){    
-       try {
-               CommandParameter pfastq("fastq", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfastq);
-               CommandParameter pfasta("fasta", "Bool", "", "T", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pqual("qfile", "Bool", "", "T", "", "", "",false,false); parameters.push_back(pqual);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ParseFastaQCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The fastq.info command reads a fastq file and creates a fasta and quality file.\n";
-               helpString += "The fastq.info command parameters are fastq, fasta and qfile; fastq is required.\n";
-               helpString += "The fastq.info command should be in the following format: fastq.info(fastaq=yourFastaQFile).\n";
-        helpString += "The fasta parameter allows you to indicate whether you want a fasta file generated. Default=T.\n";
-        helpString += "The qfile parameter allows you to indicate whether you want a quality file generated. Default=T.\n";
-               helpString += "Example fastq.info(fastaq=test.fastaq).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fastq), '=' and yourFastQFile.\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ParseFastaQCommand::ParseFastaQCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "ParseFastaQCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ParseFastaQCommand::ParseFastaQCommand(string option){
-       try {
-               abort = false; calledHelp = false;   
-               
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fastq");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fastq"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       fastaQFile = validParameter.validFile(parameters, "fastq", true);
-                       if (fastaQFile == "not found") {        m->mothurOut("fastq is a required parameter for the fastq.info command.");      m->mothurOutEndLine();  abort = true;   }
-                       else if (fastaQFile == "not open")      {       fastaQFile = ""; abort = true;  }       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);   if (outputDir == "not found"){  outputDir = m->hasPath(fastaQFile);     }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "fasta", false);    if(temp == "not found"){        temp = "T";     }
-                       fasta = m->isTrue(temp); 
-
-                       temp = validParameter.validFile(parameters, "qfile", false);    if(temp == "not found"){        temp = "T";     }
-                       qual = m->isTrue(temp); 
-                       
-                       if ((!fasta) && (!qual)) { m->mothurOut("[ERROR]: no outputs selected. Aborting."); m->mothurOutEndLine(); abort=true; }
-
-               }               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "ParseFastaQCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ParseFastaQCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //open Output Files
-               string fastaFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "fasta";
-               string qualFile = outputDir + m->getRootName(m->getSimpleName(fastaQFile)) + "qual";
-               ofstream outFasta, outQual;
-               
-               if (fasta) { m->openOutputFile(fastaFile, outFasta);  outputNames.push_back(fastaFile); outputTypes["fasta"].push_back(fastaFile);      }
-               if (qual) { m->openOutputFile(qualFile, outQual);       outputNames.push_back(qualFile);  outputTypes["qfile"].push_back(qualFile);             }
-               
-               ifstream in;
-               m->openInputFile(fastaQFile, in);
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-               
-                       //read sequence name
-                       string name = m->getline(in); m->gobble(in);
-                       if (name == "") {  m->mothurOut("[ERROR]: Blank fasta name."); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       else if (name[0] != '@') { m->mothurOut("[ERROR]: reading " + name + " expected a name with @ as a leading character."); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       else { name = name.substr(1); }
-                       
-                       //read sequence
-                       string sequence = m->getline(in); m->gobble(in);
-                       if (sequence == "") {  m->mothurOut("[ERROR]: missing sequence for " + name); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       
-                       //read sequence name
-                       string name2 = m->getline(in); m->gobble(in);
-                       if (name2 == "") {  m->mothurOut("[ERROR]: Blank quality name."); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       else if (name2[0] != '+') { m->mothurOut("[ERROR]: reading " + name2 + " expected a name with + as a leading character."); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       else { name2 = name2.substr(1);  }
-                       
-                       //read quality scores
-                       string quality = m->getline(in); m->gobble(in);
-                       if (quality == "") {  m->mothurOut("[ERROR]: missing quality for " + name2); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       
-                       //sanity check sequence length and number of quality scores match
-                       if (name2 != "") { if (name != name2) { m->mothurOut("[ERROR]: names do not match. read " + name + " for fasta and " + name2 + " for quality."); m->mothurOutEndLine(); m->control_pressed = true; break; } }
-                       if (quality.length() != sequence.length()) { m->mothurOut("[ERROR]: Lengths do not match for sequence " + name + ". Read " + toString(sequence.length()) + " characters for fasta and " + toString(quality.length()) + " characters for quality scores."); m->mothurOutEndLine(); m->control_pressed = true; break; }
-                       
-                       //print sequence info to files
-                       if (fasta) { outFasta << ">" << name << endl << sequence << endl; }
-                       
-                       if (qual) { 
-                               vector<int> qualScores = convertQual(quality);
-                               outQual << ">" << name << endl;
-                               for (int i = 0; i < qualScores.size(); i++) { outQual << qualScores[i] << " "; }
-                               outQual << endl;
-                       }
-               }
-               
-               in.close();
-               if (fasta)      { outFasta.close();     }
-               if (qual)       { outQual.close();      }
-               
-               if (m->control_pressed) { outputTypes.clear(); m->mothurRemove(fastaFile); m->mothurRemove(qualFile); return 0; }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("qfile");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-               }               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<int> ParseFastaQCommand::convertQual(string qual) {
-       try {
-               vector<int> qualScores;
-               
-               int controlChar = int('!');
-               
-               for (int i = 0; i < qual.length(); i++) { 
-                       int temp = int(qual[i]);
-                       temp -= controlChar;
-                       
-                       qualScores.push_back(temp);
-               }
-               
-               return qualScores;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseFastaQCommand", "convertQual");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/parsefastaqcommand.h b/parsefastaqcommand.h
deleted file mode 100644 (file)
index 6feabce..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef PARSEFASTAQCOMMAND_H
-#define PARSEFASTAQCOMMAND_H
-
-/*
- *  parsefastaqcommand.h
- *  Mothur
- *
- *  Created by westcott on 9/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-class ParseFastaQCommand : public Command {
-
-public:
-       ParseFastaQCommand(string);
-       ParseFastaQCommand();
-       ~ParseFastaQCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "parse.fastq";         }
-       string getCommandCategory()             { return "Sequence Processing"; }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Parse.fastq"; }
-       string getDescription()         { return "reads a fastq file and creates a fasta and quality file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-private:
-
-       vector<string> outputNames;     
-       string outputDir, fastaQFile;
-       bool abort, fasta, qual;
-       
-       vector<int> convertQual(string);
-};
-
-#endif
-
-
diff --git a/parselistscommand.cpp b/parselistscommand.cpp
deleted file mode 100644 (file)
index bb096d8..0000000
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- *  parselistcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 2/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "parselistscommand.h"
-
-//**********************************************************************************************************************
-vector<string> ParseListCommand::setParameters(){      
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ParseListCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The parse.list command reads a list and group file and generates a list file for each group in the groupfile. \n";
-               helpString += "The parse.list command parameters are list, group and label.\n";
-               helpString += "The list and group parameters are required.\n";
-               helpString += "The label parameter is used to read specific labels in your input you want to use.\n";
-               helpString += "The parse.list command should be used in the following format: parse.list(list=yourListFile, group=yourGroupFile, label=yourLabels).\n";
-               helpString += "Example: parse.list(list=abrecovery.fn.list, group=abrecovery.groups, label=0.03).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ParseListCommand::ParseListCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "ParseListCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ParseListCommand::ParseListCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;                     
-                                                                                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { 
-                               listfile = m->getListFile(); 
-                               if (listfile != "") {  m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current list file. You must provide a list file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                                               
-                               }
-                       }else { m->setListFile(listfile); }     
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { 
-                               groupfile = m->getListFile(); 
-                               if (groupfile != "") {  
-                                       m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); 
-                                       groupMap = new GroupMap(groupfile);
-                                       
-                                       int error = groupMap->readMap();
-                                       if (error == 1) { abort = true; }
-                               }else { m->mothurOut("No valid current group file. You must provide a group file."); m->mothurOutEndLine();  abort = true; } 
-                       }else {  
-                               m->setGroupFile(groupfile);
-                               groupMap = new GroupMap(groupfile);
-                               
-                               int error = groupMap->readMap();
-                               if (error == 1) { abort = true; }
-                       }
-                       
-                       //do you have all files needed
-                       if ((listfile == "") || (groupfile == "")) { m->mothurOut("You must enter both a listfile and groupfile for the parse.list command. "); m->mothurOutEndLine(); abort = true;  }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = "";  allLines = 1; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "ParseListCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ParseListCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //set fileroot
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
-               
-               //fill filehandles with neccessary ofstreams
-               int i;
-               ofstream* temp;
-               vector<string> gGroups = groupMap->getNamesOfGroups();
-               for (i=0; i<gGroups.size(); i++) {
-                       temp = new ofstream;
-                       filehandles[gGroups[i]] = temp;
-                       
-                       string filename = fileroot +  gGroups[i] + ".list";
-                       outputNames.push_back(filename); outputTypes["list"].push_back(filename);
-                       m->openOutputFile(filename, *temp);
-               }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;        
-       
-               input = new InputData(listfile, "list");
-               list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               if (m->control_pressed) { 
-                       delete input; delete list; delete groupMap;
-                       vector<string> gGroups = groupMap->getNamesOfGroups();
-                       for (i=0; i<gGroups.size(); i++) {  (*(filehandles[gGroups[i]])).close();  delete filehandles[gGroups[i]]; } 
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                       return 0;
-               }
-               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-               
-                       if (m->control_pressed) { 
-                               delete input; delete list; delete groupMap;
-                               for (i=0; i<gGroups.size(); i++) {  (*(filehandles[gGroups[i]])).close();  delete filehandles[gGroups[i]]; } 
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                               return 0;
-                       }
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){
-                                       
-                                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                       parse(list);
-                                                                               
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = list->getLabel();
-                                       
-                                       delete list;
-                                       list = input->getListVector(lastLabel); //get new list vector to process
-                                       
-                                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                       parse(list);
-                                       
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       list->setLabel(saveLabel);
-                       }
-                       
-               
-                       lastLabel = list->getLabel();
-                               
-                       delete list;
-                       list = input->getListVector(); //get new list vector to process
-               }
-               
-               if (m->control_pressed) { 
-                       delete input; delete groupMap;
-                       for (i=0; i<gGroups.size(); i++) {  (*(filehandles[gGroups[i]])).close();  delete filehandles[gGroups[i]]; } 
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                       return 0;
-               }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-
-               }
-               
-               if (m->control_pressed) { 
-                       delete input; delete groupMap;
-                       for (i=0; i<gGroups.size(); i++) {  (*(filehandles[gGroups[i]])).close();  delete filehandles[gGroups[i]]; } 
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                       return 0;
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       list = input->getListVector(lastLabel); //get new list vector to process
-                       
-                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                       parse(list);            
-                       
-                       delete list;
-               }
-               
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       (*(filehandles[it3->first])).close();
-                       delete it3->second;
-               }
-               
-               
-               delete groupMap;
-               delete input;
-               
-               if (m->control_pressed) { 
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                       return 0;
-               }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-                       
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "execute");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int ParseListCommand::parse(ListVector* thisList) {
-       try {
-       
-               map<string, string> groupVector;
-               map<string, string>::iterator itGroup;
-               map<string, int> groupNumBins;
-               
-               //print label
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       groupNumBins[it3->first] = 0;
-                       groupVector[it3->first] = "";
-               }
-
-               
-               for (int i = 0; i < thisList->getNumBins(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       map<string, string> groupBins;
-                       string bin = list->get(i); 
-                       
-                       vector<string> names;
-                       m->splitAtComma(bin, names);  //parses bin into individual sequence names
-                       
-                       //parse bin into list of sequences in each group
-                       for (int j = 0; j < names.size(); j++) {
-                               string group = groupMap->getGroup(names[j]);
-                               
-                               if (group == "not found") { m->mothurOut(names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); exit(1); }
-                               
-                               itGroup = groupBins.find(group);
-                               if(itGroup == groupBins.end()) {
-                                       groupBins[group] = names[j];  //add first name
-                                       groupNumBins[group]++;
-                               }else{ //add another name
-                                       groupBins[group] = groupBins[group] + "," + names[j];
-                               }
-                       }
-                       
-                       //print parsed bin info to files
-                       for (itGroup = groupBins.begin(); itGroup != groupBins.end(); itGroup++) {
-                               groupVector[itGroup->first] +=  itGroup->second + '\t'; 
-                       }
-               
-               }
-               
-               //end list vector
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       (*(filehandles[it3->first])) << thisList->getLabel() << '\t' << groupNumBins[it3->first] << '\t' << groupVector[it3->first] << endl;  // label numBins  listvector for that group
-               }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParseListCommand", "parse");
-               exit(1);
-       }
-}
-
-/**********************************************************************************************************************/
-
-
diff --git a/parselistscommand.h b/parselistscommand.h
deleted file mode 100644 (file)
index 9356299..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef PARSELISTCOMMAND_H
-#define PARSELISTCOMMAND_H
-/*
- *  parselistcommand.h
- *  Mothur
- *
- *  Created by westcott on 2/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "groupmap.h"
-#include "inputdata.h"
-#include "listvector.hpp"
-
-/***************************************************************************************/
-
-class ParseListCommand : public Command {
-       
-public:
-       ParseListCommand(string);
-       ParseListCommand();     
-       ~ParseListCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "parse.list";                          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Parse.list"; }
-       string getDescription()         { return "parses a list file by group"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       int parse(ListVector*);
-               
-       ListVector* list;
-       GroupMap* groupMap;
-       InputData* input;
-       
-       ofstream out;
-       string outputDir, listfile, groupfile, label;
-       set<string> labels;
-       bool abort, allLines;
-       vector<string> outputNames;
-       
-       map<string, ofstream*> filehandles;
-       map<string, ofstream*>::iterator it3;
-
-};
-
-/***************************************************************************************/
-
-#endif
-
diff --git a/parsimony.cpp b/parsimony.cpp
deleted file mode 100644 (file)
index 3b0f317..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- *  parsimony.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "parsimony.h"
-
-/**************************************************************************************************/
-
-EstOutput Parsimony::getValues(Tree* t, int p, string o) {
-       try {
-               processors = p;
-               outputDir = o;
-        TreeMap* tmap = t->getTreeMap();
-               
-               //if the users enters no groups then give them the score of all groups
-               vector<string> mGroups = m->getGroups();
-               int numGroups = mGroups.size();
-               
-               //calculate number of comparsions
-               int numComp = 0;
-               vector< vector<string> > namesOfGroupCombos;
-               for (int r=0; r<numGroups; r++) { 
-                       for (int l = 0; l < r; l++) {
-                               numComp++;
-                               vector<string> groups; groups.push_back(mGroups[r]); groups.push_back(mGroups[l]);
-                               //cout << globaldata->Groups[r] << '\t' << globaldata->Groups[l] << endl;
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-
-               //numComp+1 for AB, AC, BC, ABC
-               if (numComp != 1) {
-                       vector<string> groups;
-                       if (numGroups == 0) {
-                               //get score for all users groups
-                               vector<string> tGroups = tmap->getNamesOfGroups();
-                               for (int i = 0; i < tGroups.size(); i++) {
-                                       if (tGroups[i] != "xxx") {
-                                               groups.push_back(tGroups[i]);
-                                               //cout << tmap->namesOfGroups[i] << endl;
-                                       }
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }else {
-                               for (int i = 0; i < mGroups.size(); i++) {
-                                       groups.push_back(mGroups[i]);
-                                       //cout << globaldata->Groups[i] << endl;
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-               
-       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               if(processors == 1){
-                       data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-               }else{
-                       lines.clear();
-                       int numPairs = namesOfGroupCombos.size();
-                       
-                       int numPairsPerProcessor = numPairs / processors;
-                       
-                       for (int i = 0; i < processors; i++) {
-                               int startPos = i * numPairsPerProcessor;
-                               
-                               if(i == processors - 1){
-                                       numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                               }
-                               
-                               lines.push_back(linePair(startPos, numPairsPerProcessor));
-                       }
-                       
-                       data = createProcesses(t, namesOfGroupCombos, tmap);
-               }
-       #else
-               data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-       #endif
-               
-               return data;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Parsimony", "getValues");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-EstOutput Parsimony::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, TreeMap* tmap) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               EstOutput myresults;
-                               myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, tmap);
-                               
-                               if (m->control_pressed) { exit(0); }
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputDir + toString(getpid()) + ".pars.results.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << myresults.size() << endl;
-                               for (int i = 0; i < myresults.size(); i++) {  out << myresults[i] << '\t';  } out << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0); 
-                       }
-               }
-               
-               results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, tmap);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               if (m->control_pressed) { return results; }
-                       
-               //get data created by processes
-               for (int i=0;i<processIDS.size();i++) { 
-                       ifstream in;
-                       string s = outputDir + toString(processIDS[i]) + ".pars.results.temp";
-                       m->openInputFile(s, in);
-                       
-                       //get scores
-                       if (!in.eof()) {
-                               int num;
-                               in >> num; m->gobble(in);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               double w; 
-                               for (int j = 0; j < num; j++) {
-                                       in >> w;
-                                       results.push_back(w);
-                               }
-                               m->gobble(in);
-                       }
-                       in.close();
-                       m->mothurRemove(s);
-               }
-               
-               return results;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Parsimony", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-EstOutput Parsimony::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, TreeMap* tmap) { 
-       try {
-               
-               EstOutput results; results.resize(num);
-               
-               Tree* copyTree = new Tree(tmap);
-               int count = 0;
-               
-               for (int h = start; h < (start+num); h++) {
-                                       
-                       if (m->control_pressed) { delete copyTree; return results; }
-       
-                       int score = 0;
-                       
-                       //groups in this combo
-                       vector<string> groups = namesOfGroupCombos[h];
-                       
-                       //copy users tree so that you can redo pgroups 
-                       copyTree->getCopy(t);
-                       
-                       //create pgroups that reflect the groups the user want to use
-                       for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
-                               copyTree->tree[i].pGroups = (copyTree->mergeUserGroups(i, groups));
-                       }
-                       
-                       for(int i=copyTree->getNumLeaves();i<copyTree->getNumNodes();i++){
-                               
-                               if (m->control_pressed) { return data; }
-                               
-                               int lc = copyTree->tree[i].getLChild();
-                               int rc = copyTree->tree[i].getRChild();
-                               
-                               int iSize = copyTree->tree[i].pGroups.size();
-                               int rcSize = copyTree->tree[rc].pGroups.size();
-                               int lcSize = copyTree->tree[lc].pGroups.size();
-                               
-                               //if isize are 0 then that branch is to be ignored
-                               if (iSize == 0) { }
-                               else if ((rcSize == 0) || (lcSize == 0)) { }
-                               //if you have more groups than either of your kids then theres been a change.
-                               else if(iSize > rcSize || iSize > lcSize){
-                                       score++;
-                               }
-                       } 
-                       
-                       results[count] = score;
-                       count++;
-               }
-                                       
-               delete copyTree;
-                       
-               return results; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Parsimony", "driver");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
diff --git a/parsimony.h b/parsimony.h
deleted file mode 100644 (file)
index 7316d50..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef PARSIMONY_H
-#define PARSIMONY_H
-
-
-/*
- *  parsimony.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treecalculator.h"
-#include "treemap.h"
-
-/***********************************************************************/
-
-class Parsimony : public TreeCalculator  {
-       
-       public:
-               Parsimony() {};
-               ~Parsimony() {};
-               EstOutput getValues(Tree*, int, string);
-               
-       private:
-               struct linePair {
-                       int start;
-                       int num;
-                       linePair(int i, int j) : start(i), num(j) {}
-               };
-               vector<linePair> lines;
-       
-               EstOutput data;
-               int processors;
-               string outputDir;
-       
-               EstOutput driver(Tree*, vector< vector<string> >, int, int, TreeMap*); 
-               EstOutput createProcesses(Tree*, vector< vector<string> >, TreeMap*);
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/parsimonycommand.cpp b/parsimonycommand.cpp
deleted file mode 100644 (file)
index 50e1bfa..0000000
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- *  parsimonycommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "parsimonycommand.h"
-#include "treereader.h"
-
-//**********************************************************************************************************************
-vector<string> ParsimonyCommand::setParameters(){      
-       try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter prandom("random", "String", "", "", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ParsimonyCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The parsimony command parameters are tree, group, name, random, groups, processors and iters.  tree parameter is required unless you have valid current tree file or are using random.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 1 valid group.\n";
-               helpString += "The group names are separated by dashes.  The iters parameter allows you to specify how many random trees you would like compared to your tree.\n";
-               helpString += "The parsimony command should be in the following format: parsimony(random=yourOutputFilename, groups=yourGroups, iters=yourIters).\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "Example parsimony(random=out, iters=500).\n";
-               helpString += "The default value for random is "" (meaning you want to use the trees in your inputfile, randomtree=out means you just want the random distribution of trees outputted to out.rd_parsimony),\n";
-               helpString += "and iters is 1000.  The parsimony command output two files: .parsimony and .psummary their descriptions are in the manual.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. random), '=' and parameters (i.e.yourOutputFilename).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ParsimonyCommand::ParsimonyCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["parsimony"] = tempOutNames;
-               outputTypes["psummary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-ParsimonyCommand::ParsimonyCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               Groups.clear();
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["parsimony"] = tempOutNames;
-                       outputTypes["psummary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       randomtree = validParameter.validFile(parameters, "random", false);             if (randomtree == "not found") { randomtree = ""; }
-                       
-                       //are you trying to use parsimony without reading a tree or saying you want random distribution
-                       if (randomtree == "")  {
-                               //check for required parameters
-                               treefile = validParameter.validFile(parameters, "tree", true);
-                               if (treefile == "not open") { treefile = ""; abort = true; }
-                               else if (treefile == "not found") {                             //if there is a current design file, use it
-                                       treefile = m->getTreeFile(); 
-                                       if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                                       else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                               }else { m->setTreeFile(treefile); }     
-                               
-                               //check for required parameters
-                               groupfile = validParameter.validFile(parameters, "group", true);
-                               if (groupfile == "not open") { abort = true; }
-                               else if (groupfile == "not found") { groupfile = ""; }
-                               else { m->setGroupFile(groupfile); }
-                               
-                               namefile = validParameter.validFile(parameters, "name", true);
-                               if (namefile == "not open") { namefile = ""; abort = true; }
-                               else if (namefile == "not found") { namefile = ""; }
-                               else { m->setNameFile(namefile); }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       string outputDir = validParameter.validFile(parameters, "outputdir", false);            if (outputDir == "not found"){  outputDir = ""; if (randomtree == "")  { outputDir += m->hasPath(treefile); } }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; m->clearGroups(); }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                               
-                       itersString = validParameter.validFile(parameters, "iters", false);                     if (itersString == "not found") { itersString = "1000"; }
-                       m->mothurConvert(itersString, iters); 
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(treefile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "ParsimonyCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-int ParsimonyCommand::execute() {
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               
-               //randomtree will tell us if user had their own treefile or if they just want the random distribution
-               //user has entered their own tree
-               if (randomtree == "") { 
-                       
-                       m->setTreeFile(treefile);
-                       
-            TreeReader* reader = new TreeReader(treefile, groupfile, namefile);
-            T = reader->getTrees();
-            tmap = T[0]->getTreeMap();
-            delete reader;
-       
-                       if(outputDir == "") { outputDir += m->hasPath(treefile); }
-                       output = new ColumnFile(outputDir + m->getSimpleName(treefile)  +  ".parsimony", itersString);
-                       outputNames.push_back(outputDir + m->getSimpleName(treefile)  +  ".parsimony");
-                       outputTypes["parsimony"].push_back(outputDir + m->getSimpleName(treefile)  +  ".parsimony");
-                               
-                       sumFile = outputDir + m->getSimpleName(treefile) + ".psummary";
-                       m->openOutputFile(sumFile, outSum);
-                       outputNames.push_back(sumFile);
-                       outputTypes["psummary"].push_back(sumFile);
-               }else { //user wants random distribution
-                       getUserInput();
-                               
-                       if(outputDir == "") { outputDir += m->hasPath(randomtree); }
-                       output = new ColumnFile(outputDir+ m->getSimpleName(randomtree), itersString);
-                       outputNames.push_back(outputDir+ m->getSimpleName(randomtree));
-                       outputTypes["parsimony"].push_back(outputDir+ m->getSimpleName(randomtree));
-               }
-                       
-               //set users groups to analyze
-               SharedUtil util;
-               vector<string> mGroups = m->getGroups();
-               vector<string> tGroups = tmap->getNamesOfGroups();
-               util.setGroups(mGroups, tGroups, allGroups, numGroups, "parsimony");    //sets the groups the user wants to analyze
-               util.getCombos(groupComb, mGroups, numComp);
-               m->setGroups(mGroups);
-                       
-               if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
-                       
-               Parsimony pars;
-               counter = 0;
-       
-               Progress* reading;
-               reading = new Progress("Comparing to random:", iters);
-               
-               if (m->control_pressed) { 
-                       delete reading; delete output;
-                       delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
-                       if (randomtree == "") {  outSum.close();  }
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                       m->clearGroups();
-                       return 0;
-               }
-                       
-               
-               //get pscore for users tree
-               userData.resize(numComp,0);  //data = AB, AC, BC, ABC.
-               randomData.resize(numComp,0);  //data = AB, AC, BC, ABC.
-               rscoreFreq.resize(numComp);  
-               uscoreFreq.resize(numComp);  
-               rCumul.resize(numComp);  
-               uCumul.resize(numComp);  
-               userTreeScores.resize(numComp);  
-               UScoreSig.resize(numComp); 
-                               
-               if (randomtree == "") {
-                       //get pscores for users trees
-                       for (int i = 0; i < T.size(); i++) {
-                               userData = pars.getValues(T[i], processors, outputDir);  //data = AB, AC, BC, ABC.
-                               
-                               if (m->control_pressed) { 
-                                       delete reading; delete output;
-                                       delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
-                                       if (randomtree == "") {  outSum.close();  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                                       m->clearGroups();
-                                       return 0;
-                               }
-
-
-                               //output scores for each combination
-                               for(int k = 0; k < numComp; k++) {
-
-                                       //update uscoreFreq
-                                       map<int,double>::iterator it = uscoreFreq[k].find(userData[k]);
-                                       if (it == uscoreFreq[k].end()) {//new score
-                                               uscoreFreq[k][userData[k]] = 1;
-                                       }else{ uscoreFreq[k][userData[k]]++; }
-                                       
-                                       //add users score to valid scores
-                                       validScores[userData[k]] = userData[k];
-                                       
-                                       //save score for summary file
-                                       userTreeScores[k].push_back(userData[k]);
-                               }
-                       }
-                       
-                       //get pscores for random trees
-                       for (int j = 0; j < iters; j++) {
-                                                               
-                               //create new tree with same num nodes and leaves as users
-                               randT = new Tree(tmap);
-
-                               //create random relationships between nodes
-                               randT->assembleRandomTree();
-
-                               //get pscore of random tree
-                               randomData = pars.getValues(randT, processors, outputDir);
-                               
-                               if (m->control_pressed) { 
-                                       delete reading;  delete output; delete randT;
-                                       if (randomtree == "") {  outSum.close();  }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                                       delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
-                                       m->clearGroups();
-                                       return 0;
-                               }
-                                       
-                               for(int r = 0; r < numComp; r++) {
-                                       //add trees pscore to map of scores
-                                       map<int,double>::iterator it = rscoreFreq[r].find(randomData[r]);
-                                       if (it != rscoreFreq[r].end()) {//already have that score
-                                               rscoreFreq[r][randomData[r]]++;
-                                       }else{//first time we have seen this score
-                                               rscoreFreq[r][randomData[r]] = 1;
-                                       }
-                       
-                                       //add randoms score to validscores
-                                       validScores[randomData[r]] = randomData[r];
-                               }
-                               
-                               //update progress bar
-                               reading->update(j);
-                               
-                               delete randT;
-                       }
-
-               }else {
-                       //get pscores for random trees
-                       for (int j = 0; j < iters; j++) {
-                                                               
-                               //create new tree with same num nodes and leaves as users
-                               randT = new Tree(tmap);
-                               //create random relationships between nodes
-
-                               randT->assembleRandomTree();
-                               
-                               if (m->control_pressed) { 
-                                       delete reading; delete output; delete randT; delete tmap; 
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;
-                               }
-
-
-                               //get pscore of random tree
-                               randomData = pars.getValues(randT, processors, outputDir);
-                               
-                               if (m->control_pressed) { 
-                                       delete reading; delete output; delete randT; delete tmap; 
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;
-                               }
-                       
-                               for(int r = 0; r < numComp; r++) {
-                                       //add trees pscore to map of scores
-                                       map<int,double>::iterator it = rscoreFreq[r].find(randomData[r]);
-                                       if (it != rscoreFreq[r].end()) {//already have that score
-                                               rscoreFreq[r][randomData[r]]++;
-                                       }else{//first time we have seen this score
-                                               rscoreFreq[r][randomData[r]] = 1;
-                                       }
-                       
-                                       //add randoms score to validscores
-                                       validScores[randomData[r]] = randomData[r];
-                               }
-                               
-                               //update progress bar
-                               reading->update(j);
-                               
-                               delete randT;
-                       }
-               }
-
-               for(int a = 0; a < numComp; a++) {
-                       float rcumul = 0.0000;
-                       float ucumul = 0.0000;
-                       //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
-                       for (map<int,double>::iterator it = validScores.begin(); it != validScores.end(); it++) { 
-                               if (randomtree == "") {
-                                       map<int,double>::iterator it2 = uscoreFreq[a].find(it->first);
-                                       //user data has that score 
-                                       if (it2 != uscoreFreq[a].end()) { uscoreFreq[a][it->first] /= T.size(); ucumul+= it2->second;  }
-                                       else { uscoreFreq[a][it->first] = 0.0000; } //no user trees with that score
-                                       //make uCumul map
-                                       uCumul[a][it->first] = ucumul;
-                               }
-                       
-                               //make rscoreFreq map and rCumul
-                               map<int,double>::iterator it2 = rscoreFreq[a].find(it->first);
-                               //get percentage of random trees with that info
-                               if (it2 != rscoreFreq[a].end()) {  rscoreFreq[a][it->first] /= iters; rcumul+= it2->second;  }
-                               else { rscoreFreq[a][it->first] = 0.0000; } //no random trees with that score
-                               rCumul[a][it->first] = rcumul;
-                       }
-                       
-                       //find the signifigance of each user trees score when compared to the random trees and save for printing the summary file
-                       for (int h = 0; h < userTreeScores[a].size(); h++) {
-                               UScoreSig[a].push_back(rCumul[a][userTreeScores[a][h]]);
-                       }
-               }
-               
-               if (m->control_pressed) { 
-                               delete reading; delete output;
-                               delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
-                               if (randomtree == "") {  outSum.close();  }
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } outputTypes.clear();
-                               return 0;
-               }
-               
-               //finish progress bar
-               reading->finish();
-               delete reading;
-               
-               printParsimonyFile();
-               if (randomtree == "") { printUSummaryFile(); }
-                               
-        delete output; delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;}
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "execute");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-void ParsimonyCommand::printParsimonyFile() {
-       try {
-               vector<double> data;
-               vector<string> tags;
-               
-               if (randomtree == "") {
-                       tags.push_back("Score"); tags.push_back("UserFreq"); tags.push_back("UserCumul"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
-               }else {
-                       tags.push_back("Score"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
-               }
-
-               for(int a = 0; a < numComp; a++) {
-                       output->initFile(groupComb[a], tags);
-                       //print each line
-                       for (map<int,double>::iterator it = validScores.begin(); it != validScores.end(); it++) { 
-                               if (randomtree == "") {
-                                       data.push_back(it->first);  data.push_back(uscoreFreq[a][it->first]); data.push_back(uCumul[a][it->first]); data.push_back(rscoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); 
-                               }else{
-                                       data.push_back(it->first);  data.push_back(rscoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); 
-                               }
-                               output->output(data);
-                               data.clear();
-                       } 
-                       output->resetFile();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "printParsimonyFile");
-               exit(1);
-       }
-}
-/***********************************************************/
-int ParsimonyCommand::printUSummaryFile() {
-       try {
-               //column headers
-               outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "ParsScore" << '\t' << "ParsSig" <<  endl;
-               m->mothurOut("Tree#\tGroups\tParsScore\tParsSig"); m->mothurOutEndLine();
-               
-               //format output
-               outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
-               
-               
-               //print each line
-               for (int i = 0; i< T.size(); i++) {
-                       for(int a = 0; a < numComp; a++) {
-                               if (m->control_pressed) {  outSum.close(); return 0; }
-                               if (UScoreSig[a][i] > (1/(float)iters)) {
-                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << UScoreSig[a][i] << endl;
-                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a]  << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << UScoreSig[a][i] << endl;
-                                       m->mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString(UScoreSig[a][i])); m->mothurOutEndLine();
-                               }else {
-                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length())  << '\t' << "<" << (1/float(iters)) << endl;
-                                       cout << setprecision(6) << i+1 << '\t' << groupComb[a] << '\t' << userTreeScores[a][i] << setprecision(itersString.length()) << '\t' << "<" << (1/float(iters)) << endl;
-                                       m->mothurOutJustToLog(toString(i+1) + "\t" + groupComb[a] + "\t" + toString(userTreeScores[a][i]) + "\t" + toString((1/float(iters)))); m->mothurOutEndLine();
-                               }
-                       }
-               }
-               
-               outSum.close();
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "printUSummaryFile");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-void ParsimonyCommand::getUserInput() {
-       try {
-       
-               //create treemap
-               tmap = new TreeMap();
-
-               m->mothurOut("Please enter the number of groups you would like to analyze: ");
-               cin >> numGroups;
-               m->mothurOutJustToLog(toString(numGroups)); m->mothurOutEndLine();
-                               
-               int num, count;
-               count = 1;
-               numEachGroup.resize(numGroups, 0);  
-               
-               
-               for (int i = 1; i <= numGroups; i++) {
-                       m->mothurOut("Please enter the number of sequences in group " + toString(i) +  ": ");
-                       cin >> num;
-                       m->mothurOutJustToLog(toString(num)); m->mothurOutEndLine();
-                               
-                       //set tmaps seqsPerGroup
-                       tmap->seqsPerGroup[toString(i)] = num;
-                       tmap->addGroup(toString(i));
-                       
-                       //set tmaps namesOfSeqs
-                       for (int j = 0; j < num; j++) {
-                               tmap->namesOfSeqs.push_back(toString(count));
-                               tmap->treemap[toString(count)].groupname = toString(i);
-                               count++;
-                       }
-               }
-               
-               //clears buffer so next command doesn't have error
-               string s;       
-               getline(cin, s);
-               
-               m->Treenames = tmap->namesOfSeqs; 
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ParsimonyCommand", "getUserInput");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
diff --git a/parsimonycommand.h b/parsimonycommand.h
deleted file mode 100644 (file)
index 9172556..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef PARSIMONYCOMMAND_H
-#define PARSIMONYCOMMAND_H
-/*
- *  parsimonycommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "parsimony.h"
-#include "treemap.h"
-#include "progress.hpp"
-#include "sharedutilities.h"
-#include "fileoutput.h"
-#include "readtree.h"
-
-
-class ParsimonyCommand : public Command {
-
-public:
-       ParsimonyCommand(string);       
-       ParsimonyCommand();
-       ~ParsimonyCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "parsimony";                           }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "Slatkin M, Maddison WP (1989). A cladistic measure of gene flow inferred from the phylogenies of alleles. Genetics 123: 603-13. \nSlatkin M, Maddison WP (1990). Detecting isolation by distance using phylogenies of genes. Genetics 126: 249-60. \nMartin AP (2002). Phylogenetic approaches for describing and comparing the diversity of microbial communities. Appl Environ Microbiol 68: 3673-82. \nSchloss PD, Handelsman J (2006). Introducing TreeClimber, a test to compare microbial community structure. Appl Environ Microbiol 72: 2379-84.\nhttp://www.mothur.org/wiki/Parsimony"; }
-       string getDescription()         { return "generic test that describes whether two or more communities have the same structure"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       FileOutput* output;
-       vector<Tree*> T;           //user trees
-       Tree* randT;  //random tree
-       Tree* copyUserTree; 
-       TreeMap* tmap; 
-       TreeMap* savetmap;
-       vector<string> groupComb; // AB. AC, BC...
-       string sumFile, randomtree, allGroups, outputDir, treefile, groupfile, namefile;
-       int iters, numGroups, numComp, counter, processors, numUniquesInName;
-       vector<int> numEachGroup; //vector containing the number of sequences in each group the users wants for random distrib.
-       vector< vector<float> > userTreeScores; //scores for users trees for each comb.
-       vector< vector<float> > UScoreSig;  //tree score signifigance when compared to random trees - percentage of random trees with that score or lower.
-       EstOutput userData;                     //pscore info for user tree
-       EstOutput randomData;           //pscore info for random trees
-       map<int, double>  validScores;  //map contains scores from both user and random
-       vector< map<int, double> > rscoreFreq;  //map <pscore, number of random trees with that score.> -vector entry for each combination.
-       vector< map<int, double> > uscoreFreq;  //map <pscore, number of user trees with that score.> -vector entry for each combination.
-       vector< map<int, double> > rCumul;  //map <pscore, cumulative percentage of number of random trees with that score or lower.> -vector entry for each combination.
-       vector< map<int, double> > uCumul;  //map <pscore, cumulative percentage of number of user trees with that score or lower .> -vector entry for each combination.
-       
-       ofstream outSum;
-       bool abort;
-       string groups, itersString;
-       vector<string> Groups, outputNames; //holds groups to be used
-       map<string, string> nameMap;
-       
-       void printParsimonyFile();  
-       int printUSummaryFile();
-       void getUserInput();
-       int readNamesFile();
-       
-};
-
-
-#endif
diff --git a/pcacommand.cpp b/pcacommand.cpp
deleted file mode 100644 (file)
index 27e448b..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- *  pcacommand.cpp
- *  mothur
- *
- *  Created by westcott on 1/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "pcacommand.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> PCACommand::setParameters(){    
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PCACommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The pca command parameters are shared, relabund, label, groups and metric.  shared or relabund is required unless you have a valid current file."; 
-               helpString += "The label parameter is used to analyze specific labels in your input. Default is the first label in your shared or relabund file. Multiple labels may be separated by dashes.\n";
-               helpString += "The groups parameter allows you to specify which groups you would like analyzed. Groupnames are separated by dashes.\n";
-               helpString += "The metric parameter allows you to indicate if would like the pearson correlation coefficient calculated. Default=True";
-               helpString += "Example pca(groups=yourGroups).\n";
-               helpString += "Example pca(groups=A-B-C).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-PCACommand::PCACommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["pca"] = tempOutNames;
-               outputTypes["loadings"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "PCACommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-PCACommand::PCACommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser. getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["pca"] = tempOutNames;
-                       outputTypes["loadings"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  mode = "sharedfile"; inputFile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { relabundfile = ""; abort = true; }    
-                       else if (relabundfile == "not found") { relabundfile = ""; }
-                       else {  mode = "relabund"; inputFile = relabundfile; m->setRelAbundFile(relabundfile); }
-                       
-                       
-                       if ((sharedfile == "") && (relabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputFile = sharedfile; mode = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       relabundfile = m->getRelAbundFile(); 
-                                       if (relabundfile != "") { inputFile = relabundfile; mode = "relabund"; m->mothurOut("Using " + relabundfile + " as input file for the relabund parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a relabund or shared file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                               
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(inputFile); //if user entered a file with a path then preserve it       
-                       }
-                                               
-                       string temp = validParameter.validFile(parameters, "metric", false);    if (temp == "not found"){       temp = "T";                             }
-                       metric = m->isTrue(temp); 
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; if(labels.size() == 0) {  m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); } }
-                       else { m->splitAtDash(label, labels); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "";  }
-                       else { m->splitAtDash(groups, Groups);  }                       
-                       m->setGroups(Groups);                   
-                       
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "PCACommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PCACommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               cout.setf(ios::fixed, ios::floatfield);
-               cout.setf(ios::showpoint);
-               cerr.setf(ios::fixed, ios::floatfield);
-               cerr.setf(ios::showpoint);
-               
-               //get first line of shared file
-               vector< vector<double> > matrix;
-               InputData* input;
-               if (mode == "sharedfile")                       {  
-                       input = new InputData(inputFile, "sharedfile");
-               }else if (mode == "relabund")   { 
-                       input = new InputData(inputFile, "relabund");
-               }else {  m->mothurOut("[ERROR]: filetype not recognized."); m->mothurOutEndLine();  return 0; }
-               
-               vector<SharedRAbundFloatVector*> lookupFloat = input->getSharedRAbundFloatVectors();
-               string lastLabel = lookupFloat[0]->getLabel();
-                       
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //if the user gave no labels, then use the first one read
-               if (labels.size() == 0) { 
-                       label = lastLabel;  
-                       
-                       process(lookupFloat);
-               }
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookupFloat[0] != NULL) && (userLabels.size() != 0)) {
-                       
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } delete input; for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  lookupFloat.clear(); return 0;  }
-                       
-                       if(labels.count(lookupFloat[0]->getLabel()) == 1){
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               
-                               process(lookupFloat);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookupFloat[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookupFloat[0]->getLabel();
-                               
-                               for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  }  lookupFloat.clear();
-                               lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                               
-                               process(lookupFloat);
-                               
-                               processedLabels.insert(lookupFloat[0]->getLabel());
-                               userLabels.erase(lookupFloat[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookupFloat[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookupFloat[0]->getLabel();                 
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } lookupFloat.clear();
-                       lookupFloat = input->getSharedRAbundFloatVectors();
-               }
-               
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } delete input; for (int i = 0; i < lookupFloat.size(); i++) {  delete lookupFloat[i];  } lookupFloat.clear(); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookupFloat.size(); i++) {  if (lookupFloat[i] != NULL) {   delete lookupFloat[i];  } }  lookupFloat.clear();
-                       lookupFloat = input->getSharedRAbundFloatVectors(lastLabel);
-                       
-                       process(lookupFloat);
-                       
-                       for (int i = 0; i < lookupFloat.size(); i++) {  if (lookupFloat[i] != NULL) {   delete lookupFloat[i];  } } lookupFloat.clear();
-               }       
-               
-               for (int i = 0; i < lookupFloat.size(); i++) {  if (lookupFloat[i] != NULL) {   delete lookupFloat[i];  } } lookupFloat.clear();
-               delete input;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "execute");
-               exit(1);
-       }
-}
-
-/**********************************************************************************************************************
-vector< vector<double> > PCACommand::createMatrix(vector<SharedRAbundFloatVector*> lookupFloat){
-       try {
-               vector< vector<double> > matrix; matrix.resize(lookupFloat.size());
-               
-               //fill matrix with shared files relative abundances
-               for (int i = 0; i < lookupFloat.size(); i++) {
-                       for (int j = 0; j < lookupFloat[i]->getNumBins(); j++) {
-                               matrix[i].push_back(lookupFloat[i]->getAbundance(j));
-                       }
-               }
-               
-               vector< vector<double> > transposeMatrix; transposeMatrix.resize(matrix[0].size());
-               for (int i = 0; i < transposeMatrix.size(); i++) {
-                       for (int j = 0; j < matrix.size(); j++) {
-                               transposeMatrix[i].push_back(matrix[j][i]);
-                       }
-               }
-               
-               matrix = linearCalc.matrix_mult(matrix, transposeMatrix);
-               
-               return matrix;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "createMatrix");   
-               exit(1);
-       }
-}*/
-//**********************************************************************************************************************
-
-int PCACommand::process(vector<SharedRAbundFloatVector*>& lookupFloat){
-       try {
-               m->mothurOut("\nProcessing " + lookupFloat[0]->getLabel()); m->mothurOutEndLine();
-       
-               int numOTUs = lookupFloat[0]->getNumBins();
-               int numSamples = lookupFloat.size();
-               
-               vector< vector<double> > matrix(numSamples);
-               vector<double> colMeans(numOTUs);
-               
-               //fill matrix with shared relative abundances, re-center
-               for (int i = 0; i < lookupFloat.size(); i++) {
-                       matrix[i].resize(numOTUs, 0);
-                       
-                       for (int j = 0; j < numOTUs; j++) {
-                               matrix[i][j] = lookupFloat[i]->getAbundance(j);
-                               colMeans[j] += matrix[i][j];
-                       }
-               }
-               
-
-               for(int j=0;j<numOTUs;j++){
-                       colMeans[j] = colMeans[j] / (double)numSamples;
-               }
-               
-               vector<vector<double> > centered = matrix;
-               for(int i=0;i<numSamples;i++){
-                       for(int j=0;j<numOTUs;j++){
-                               centered[i][j] = centered[i][j] - colMeans[j];                          
-                       }
-               }
-
-               
-               vector< vector<double> > transpose(numOTUs);
-               for (int i = 0; i < numOTUs; i++) {
-                       transpose[i].resize(numSamples, 0);
-                       
-                       for (int j = 0; j < numSamples; j++) {
-                               transpose[i][j] = centered[j][i];
-                       }
-               }
-
-               vector<vector<double> > crossProduct = linearCalc.matrix_mult(transpose, centered);     
-               
-               vector<double> d;
-               vector<double> e;
-
-               linearCalc.tred2(crossProduct, d, e);           if (m->control_pressed) { return 0; }
-               linearCalc.qtli(d, e, crossProduct);            if (m->control_pressed) { return 0; }
-               
-               vector<vector<double> > X = linearCalc.matrix_mult(centered, crossProduct);
-               
-               if (m->control_pressed) { return 0; }
-               
-               string fbase = outputDir + m->getRootName(m->getSimpleName(inputFile));
-               string outputFileName = fbase + lookupFloat[0]->getLabel();
-               output(outputFileName, m->getGroups(), X, d);
-               
-               if (metric) {   
-                       
-                       vector<vector<double> > observedEuclideanDistance = linearCalc.getObservedEuclideanDistance(centered);
-                       
-                       for (int i = 1; i < 4; i++) {
-                               
-                               vector< vector<double> > PCAEuclidDists = linearCalc.calculateEuclidianDistance(X, i); //G is the pca file
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-
-                               double corr = linearCalc.calcPearson(PCAEuclidDists, observedEuclideanDistance);
-                                                               
-                               m->mothurOut("Rsq " + toString(i) + " axis: " + toString(corr * corr)); m->mothurOutEndLine();
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "process");        
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-
-void PCACommand::output(string fnameRoot, vector<string> name_list, vector<vector<double> >& G, vector<double> d) {
-       try {
-
-               int numEigenValues = d.size();
-               double dsum = 0.0000;
-               for(int i=0;i<numEigenValues;i++){
-                       dsum += d[i];
-               }
-               
-               ofstream pcaData((fnameRoot+".pca.axes").c_str(), ios::trunc);
-               pcaData.setf(ios::fixed, ios::floatfield);
-               pcaData.setf(ios::showpoint);   
-               outputNames.push_back(fnameRoot+".pca.axes");
-               outputTypes["pca"].push_back(fnameRoot+".pca.axes");
-               
-               ofstream pcaLoadings((fnameRoot+".pca.loadings").c_str(), ios::trunc);
-               pcaLoadings.setf(ios::fixed, ios::floatfield);
-               pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+".pca.loadings");
-               outputTypes["loadings"].push_back(fnameRoot+".pca.loadings");   
-               
-               pcaLoadings << "axis\tloading\n";
-               for(int i=0;i<numEigenValues;i++){
-                       pcaLoadings << i+1 << '\t' << d[i] * 100.0 / dsum << endl;
-               }
-               
-               pcaData << "group";
-               for(int i=0;i<numEigenValues;i++){
-                       pcaData << '\t' << "axis" << i+1;
-               }
-               pcaData << endl;
-               
-               for(int i=0;i<name_list.size();i++){
-                       pcaData << name_list[i] << '\t';
-                       for(int j=0;j<numEigenValues;j++){
-                               pcaData << G[i][j] << '\t';
-                       }
-                       pcaData << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCACommand", "output");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-
-
diff --git a/pcacommand.h b/pcacommand.h
deleted file mode 100644 (file)
index d16e896..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef PCACOMMAND_H
-#define PCACOMMAND_H
-
-/*
- *  pcacommand.h
- *  mothur
- *
- *  Created by westcott on 1/7/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "linearalgebra.h"
-#include "sharedrabundfloatvector.h"
-
-/*****************************************************************/
-class PCACommand : public Command {
-       
-public:
-       PCACommand(string);     
-       PCACommand();
-       ~PCACommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pca";                                 }
-       string getCommandCategory()             { return "Hypothesis Testing";  }
-       string getHelpString(); 
-       string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Pca"; }
-       string getDescription()         { return "pca"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-
-       bool abort, metric;
-       string outputDir, mode, inputFile, label, groups, sharedfile, relabundfile;
-       vector<string> outputNames, Groups;
-       set<string> labels;
-       LinearAlgebra linearCalc;
-       
-       //vector< vector<double> > createMatrix(vector<SharedRAbundFloatVector*>);
-       int process(vector<SharedRAbundFloatVector*>&);
-       void output(string, vector<string>, vector<vector<double> >&, vector<double>);
-       
-};
-
-/*****************************************************************/
-
-#endif
-
-
diff --git a/pcoacommand.cpp b/pcoacommand.cpp
deleted file mode 100644 (file)
index 02e165e..0000000
+++ /dev/null
@@ -1,270 +0,0 @@
-
-/*
- *  pcacommand.cpp
- *  Mothur
- *
- *  Created by westcott on 1/4/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "pcoacommand.h"
-#include "readphylipvector.h"
-
-
-//**********************************************************************************************************************
-vector<string> PCOACommand::setParameters(){   
-       try {
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pphylip);
-               CommandParameter pmetric("metric", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pmetric);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PCOACommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The pcoa command parameters are phylip and metric"; 
-               helpString += "The phylip parameter allows you to enter your distance file.";
-               helpString += "The metric parameter allows indicate you if would like the pearson correlation coefficient calculated. Default=True"; 
-               helpString += "Example pcoa(phylip=yourDistanceFile).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. phylip), '=' and parameters (i.e.yourDistanceFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-PCOACommand::PCOACommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["pcoa"] = tempOutNames;
-               outputTypes["loadings"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "PCOACommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-PCOACommand::PCOACommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser. getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["pcoa"] = tempOutNames;
-                       outputTypes["loadings"] = tempOutNames;
-                       
-                       //required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") {                   
-                               //if there is a current phylip file, use it
-                               phylipfile = m->getPhylipFile(); 
-                               if (phylipfile != "") { m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current phylip file and the phylip parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setPhylipFile(phylipfile); } 
-                       
-                       filename = phylipfile;  
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(phylipfile); //if user entered a file with a path then preserve it      
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "metric", false);    if (temp == "not found"){       temp = "T";                             }
-                       metric = m->isTrue(temp); 
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "PCOACommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PCOACommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               cout.setf(ios::fixed, ios::floatfield);
-               cout.setf(ios::showpoint);
-               cerr.setf(ios::fixed, ios::floatfield);
-               cerr.setf(ios::showpoint);
-               
-               vector<string> names;
-               vector<vector<double> > D;
-       
-               fbase = outputDir + m->getRootName(m->getSimpleName(filename));
-               
-               ReadPhylipVector readFile(filename);
-               names = readFile.read(D);
-               
-               if (m->control_pressed) { return 0; }
-       
-               double offset = 0.0000;
-               vector<double> d;
-               vector<double> e;
-               vector<vector<double> > G = D;
-               //vector<vector<double> > copy_G;
-                               
-               m->mothurOut("\nProcessing...\n");
-               
-               for(int count=0;count<2;count++){
-                       linearCalc.recenter(offset, D, G);              if (m->control_pressed) { return 0; }
-                       linearCalc.tred2(G, d, e);                              if (m->control_pressed) { return 0; }
-                       linearCalc.qtli(d, e, G);                               if (m->control_pressed) { return 0; }
-                       offset = d[d.size()-1];
-                       if(offset > 0.0) break;
-               } 
-               
-               if (m->control_pressed) { return 0; }
-               
-               output(fbase, names, G, d);
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               if (metric) {   
-                       
-                       for (int i = 1; i < 4; i++) {
-                                                       
-                               vector< vector<double> > EuclidDists = linearCalc.calculateEuclidianDistance(G, i); //G is the pcoa file
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-                               
-                               double corr = linearCalc.calcPearson(EuclidDists, D); //G is the pcoa file, D is the users distance matrix
-                               
-                               m->mothurOut("Rsq " + toString(i) + " axis: " + toString(corr * corr)); m->mothurOutEndLine();
-                               
-                               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-                       }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "execute");
-               exit(1);
-       }
-}
-/*********************************************************************************************************************************/
-
-void PCOACommand::get_comment(istream& f, char begin, char end){
-       try {
-               char d=f.get();
-               while(d != end){        d = f.get();    }
-               d = f.peek();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "get_comment");
-               exit(1);
-       }
-}      
-/*********************************************************************************************************************************/
-
-void PCOACommand::output(string fnameRoot, vector<string> name_list, vector<vector<double> >& G, vector<double> d) {
-       try {
-               int rank = name_list.size();
-               double dsum = 0.0000;
-               for(int i=0;i<rank;i++){
-                       dsum += d[i];
-                       for(int j=0;j<rank;j++){
-                               if(d[j] >= 0)   {       G[i][j] *= pow(d[j],0.5);       }
-                               else                    {       G[i][j] = 0.00000;                      }
-                       }
-               }
-               
-               ofstream pcaData((fnameRoot+"pcoa.axes").c_str(), ios::trunc);
-               pcaData.setf(ios::fixed, ios::floatfield);
-               pcaData.setf(ios::showpoint);   
-               outputNames.push_back(fnameRoot+"pcoa.axes");
-               outputTypes["pcoa"].push_back(fnameRoot+"pcoa.axes");
-               
-               ofstream pcaLoadings((fnameRoot+"pcoa.loadings").c_str(), ios::trunc);
-               pcaLoadings.setf(ios::fixed, ios::floatfield);
-               pcaLoadings.setf(ios::showpoint);
-               outputNames.push_back(fnameRoot+"pcoa.loadings");
-               outputTypes["loadings"].push_back(fnameRoot+"pcoa.loadings");   
-               
-               pcaLoadings << "axis\tloading\n";
-               for(int i=0;i<rank;i++){
-                       pcaLoadings << i+1 << '\t' << d[i] * 100.0 / dsum << endl;
-               }
-               
-               pcaData << "group";
-               for(int i=0;i<rank;i++){
-                       pcaData << '\t' << "axis" << i+1;
-               }
-               pcaData << endl;
-               
-               for(int i=0;i<rank;i++){
-                       pcaData << name_list[i] << '\t';
-                       for(int j=0;j<rank;j++){
-                               pcaData << G[i][j] << '\t';
-                       }
-                       pcaData << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PCOACommand", "output");
-               exit(1);
-       }
-}
-
-/*********************************************************************************************************************************/
-
diff --git a/pcoacommand.h b/pcoacommand.h
deleted file mode 100644 (file)
index 3d24f6a..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef PCOACOMMAND_H
-#define PCOACOMMAND_H
-
-/*
- *  pcoacommand.h
- *  Mothur
- *
- *  Created by westcott on 1/4/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "linearalgebra.h"
-
-
-/*****************************************************************/
-class PCOACommand : public Command {
-       
-public:
-       PCOACommand(string);    
-       PCOACommand();
-       ~PCOACommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pcoa";                                        }
-       string getCommandCategory()             { return "Hypothesis Testing";          }
-       string getHelpString(); 
-       string getCitation() { return "McCune B, Grace JB, Urban DL (2002). Analysis of ecological communities. MjM Software Design: Gleneden Beach, OR. \nLegendre P, Legendre L (1998). Numerical Ecology. Elsevier: New York. \nhttp://www.mothur.org/wiki/Pcoa"; }
-       string getDescription()         { return "pcoa"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-
-       bool abort, metric;
-       string phylipfile, filename, fbase, outputDir;
-       vector<string> outputNames;
-       LinearAlgebra linearCalc;
-       
-       void get_comment(istream&, char, char);
-       void output(string, vector<string>, vector<vector<double> >&, vector<double>);
-       
-};
-       
-/*****************************************************************/
-       
-#endif
-
diff --git a/pcrseqscommand.h b/pcrseqscommand.h
deleted file mode 100644 (file)
index 420a5eb..0000000
+++ /dev/null
@@ -1,385 +0,0 @@
-#ifndef Mothur_pcrseqscommand_h
-#define Mothur_pcrseqscommand_h
-
-//
-//  pcrseqscommand.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 3/14/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-
-#include "command.hpp"
-#include "sequence.hpp"
-#include "trimoligos.h"
-#include "alignment.hpp"
-#include "needlemanoverlap.hpp"
-
-class PcrSeqsCommand : public Command {
-public:
-       PcrSeqsCommand(string);
-       PcrSeqsCommand();
-       ~PcrSeqsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pcr.seqs";    }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Pcr.seqs"; }
-       string getDescription()         { return "pcr.seqs"; }
-    
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-    
-    struct linePair {
-        unsigned long long start;
-        unsigned long long end;
-        linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-        linePair() {}
-    };
-    
-    vector<linePair> lines;
-       bool getOligos(vector<vector<string> >&, vector<vector<string> >&, vector<vector<string> >&);
-    bool abort, keepprimer, keepdots;
-       string fastafile, oligosfile, taxfile, groupfile, namefile, ecolifile, outputDir, nomatch;
-       int start, end, processors, length;
-       
-    vector<string> revPrimer, outputNames;
-       vector<string> primers;
-    
-    int writeAccnos(set<string>);
-    int readName(set<string>&);
-    int readGroup(set<string>);
-    int readTax(set<string>);
-    bool readOligos();
-    bool readEcoli();
-       int driverPcr(string, string, string, set<string>&, linePair);  
-       int createProcesses(string, string, string, set<string>&);
-    bool findForward(Sequence&, int&, int&);
-    bool findReverse(Sequence&, int&, int&);
-    bool isAligned(string, map<int, int>&);
-    bool compareDNASeq(string, string);
-    string reverseOligo(string);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct pcrData {
-       string filename; 
-    string goodFasta, badFasta, oligosfile, ecolifile, nomatch;
-       unsigned long long fstart;
-       unsigned long long fend;
-       int count, start, end, length;
-       MothurOut* m;
-       vector<string> primers;
-    vector<string> revPrimer;
-    set<string> badSeqNames;
-    bool keepprimer, keepdots;
-       
-       
-       pcrData(){}
-       pcrData(string f, string gf, string bfn, MothurOut* mout, string ol, string ec, vector<string> pr, vector<string> rpr, string nm, bool kp, bool kd, int st, int en, int l, unsigned long long fst, unsigned long long fen) {
-               filename = f;
-        goodFasta = gf;
-        badFasta = bfn;
-               m = mout;
-        oligosfile = ol;
-        ecolifile = ec;
-        primers = pr;
-        revPrimer = rpr;
-        nomatch = nm;
-        keepprimer = kp;
-        keepdots = kd;
-               start = st;
-               end = en;
-        length = l;
-               fstart = fst;
-        fend = fen;
-               count = 0;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyPcrThreadFunction(LPVOID lpParam){ 
-       pcrData* pDataArray;
-       pDataArray = (pcrData*)lpParam;
-       
-       try {
-        ofstream goodFile;
-               pDataArray->m->openOutputFile(pDataArray->goodFasta, goodFile);
-        
-        ofstream badFile;
-               pDataArray->m->openOutputFile(pDataArray->badFasta, badFile);
-               
-               ifstream inFASTA;
-               pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
-        
-               //print header if you are process 0
-               if ((pDataArray->fstart == 0) || (pDataArray->fstart == 1)) {
-                       inFASTA.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       inFASTA.seekg(pDataArray->fstart-1); pDataArray->m->gobble(inFASTA); 
-               }
-        
-        set<int> lengths;
-               pDataArray->count = pDataArray->fend;
-               for(int i = 0; i < pDataArray->fend; i++){ //end is the number of sequences to process
-            
-                       if (pDataArray->m->control_pressed) {  break; }
-                       
-                       Sequence currSeq(inFASTA); pDataArray->m->gobble(inFASTA);
-          
-            string trashCode = "";
-                       if (currSeq.getName() != "") {
-                
-                bool goodSeq = true;
-                if (pDataArray->oligosfile != "") {
-                    map<int, int> mapAligned;
-                    //bool aligned = isAligned(currSeq.getAligned(), mapAligned);
-                    ///////////////////////////////////////////////////////////////
-                    bool aligned = false;
-                    string seq = currSeq.getAligned(); 
-                    int countBases = 0;
-                    for (int k = 0; k < seq.length(); k++) {
-                        if (!isalpha(seq[k])) { aligned = true; }
-                        else { mapAligned[countBases] = k; countBases++; } //maps location in unaligned -> location in aligned.
-                    }                                                   //ie. the 3rd base may be at spot 10 in the alignment
-                                                                        //later when we trim we want to trim from spot 10.
-                    ///////////////////////////////////////////////////////////////
-                    
-                    //process primers
-                    if (pDataArray->primers.size() != 0) {
-                        int primerStart = 0; int primerEnd = 0;
-                        //bool good = findForward(currSeq, primerStart, primerEnd);
-                        ///////////////////////////////////////////////////////////////
-                        bool good = false;
-                        string rawSequence = currSeq.getUnaligned();
-                        
-                        for(int j=0;j<pDataArray->primers.size();j++){
-                            string oligo = pDataArray->primers[j];
-                            
-                            if (pDataArray->m->control_pressed) {  primerStart = 0; primerEnd = 0; good = false; break; }
-                            
-                            if(rawSequence.length() < oligo.length()) {  break;  }
-                            
-                            //search for primer
-                            int olength = oligo.length();
-                            for (int l = 0; l < rawSequence.length()-olength; l++){
-                                if (pDataArray->m->control_pressed) {  primerStart = 0; primerEnd = 0; good = false; break; }
-                                string rawChunk = rawSequence.substr(l, olength);
-                                //compareDNASeq(oligo, rawChunk)
-                                ////////////////////////////////////////////////////////
-                                bool success = 1;
-                                for(int k=0;k<olength;k++){
-                                    
-                                    if(oligo[k] != rawChunk[k]){
-                                        if(oligo[k] == 'A' || oligo[k] == 'T' || oligo[k] == 'G' || oligo[k] == 'C')   {       success = 0;    }
-                                        else if((oligo[k] == 'N' || oligo[k] == 'I') && (rawChunk[k] == 'N'))                          {       success = 0;    }
-                                        else if(oligo[k] == 'R' && (rawChunk[k] != 'A' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'Y' && (rawChunk[k] != 'C' && rawChunk[k] != 'T'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'M' && (rawChunk[k] != 'C' && rawChunk[k] != 'A'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'K' && (rawChunk[k] != 'T' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'W' && (rawChunk[k] != 'T' && rawChunk[k] != 'A'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'S' && (rawChunk[k] != 'C' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'B' && (rawChunk[k] != 'C' && rawChunk[k] != 'T' && rawChunk[k] != 'G'))   {       success = 0;    }
-                                        else if(oligo[k] == 'D' && (rawChunk[k] != 'A' && rawChunk[k] != 'T' && rawChunk[k] != 'G'))   {       success = 0;    }
-                                        else if(oligo[k] == 'H' && (rawChunk[k] != 'A' && rawChunk[k] != 'T' && rawChunk[k] != 'C'))   {       success = 0;    }
-                                        else if(oligo[k] == 'V' && (rawChunk[k] != 'A' && rawChunk[k] != 'C' && rawChunk[k] != 'G'))   {       success = 0;    }                       
-                                        
-                                        if(success == 0)       {       break;   }
-                                    }
-                                    else{
-                                        success = 1;
-                                    }
-                                }
-                                
-                                ////////////////////////////////////////////////////////////////////
-                                if(success) {
-                                    primerStart = j;
-                                    primerEnd = primerStart + olength;
-                                    good = true; break;
-                                }
-                            }
-                            if (good) { break; }
-                        }      
-                        
-                        if (!good) { primerStart = 0; primerEnd = 0; }
-                        ///////////////////////////////////////////////////////////////
-                        
-                        
-                        if(!good){     if (pDataArray->nomatch == "reject") { goodSeq = false; } trashCode += "f";     }
-                        else{
-                            //are you aligned
-                            if (aligned) { 
-                                if (!pDataArray->keepprimer)    {  
-                                    if (pDataArray->keepdots)   { currSeq.filterToPos(mapAligned[primerEnd]);   }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(mapAligned[primerEnd]));                                              }
-                                } 
-                                else                {  
-                                    if (pDataArray->keepdots)   { currSeq.filterToPos(mapAligned[primerStart]);  }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(mapAligned[primerStart]));                                              }
-                                }
-                            }else { 
-                                if (!pDataArray->keepprimer)    { currSeq.setAligned(currSeq.getUnaligned().substr(primerEnd)); } 
-                                else                { currSeq.setAligned(currSeq.getUnaligned().substr(primerStart)); } 
-                            }
-                        }
-                    }
-                    
-                    //process reverse primers
-                    if (pDataArray->revPrimer.size() != 0) {
-                        int primerStart = 0; int primerEnd = 0;
-                        bool good = false;
-                        //findReverse(currSeq, primerStart, primerEnd);
-                         ///////////////////////////////////////////////////////////////
-                        string rawSequence = currSeq.getUnaligned();
-                        
-                        for(int j=0;j<pDataArray->revPrimer.size();j++){
-                            string oligo = pDataArray->revPrimer[j];
-                            if (pDataArray->m->control_pressed) {  primerStart = 0; primerEnd = 0; good = false; break; }
-                            if(rawSequence.length() < oligo.length()) {  break;  }
-                            
-                            //search for primer
-                            int olength = oligo.length();
-                            for (int l = rawSequence.length()-olength; l >= 0; l--){
-                                
-                                string rawChunk = rawSequence.substr(l, olength);
-                                //compareDNASeq(oligo, rawChunk)
-                                ////////////////////////////////////////////////////////
-                                bool success = 1;
-                                for(int k=0;k<olength;k++){
-                                    
-                                    if(oligo[k] != rawChunk[k]){
-                                        if(oligo[k] == 'A' || oligo[k] == 'T' || oligo[k] == 'G' || oligo[k] == 'C')   {       success = 0;    }
-                                        else if((oligo[k] == 'N' || oligo[k] == 'I') && (rawChunk[k] == 'N'))                          {       success = 0;    }
-                                        else if(oligo[k] == 'R' && (rawChunk[k] != 'A' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'Y' && (rawChunk[k] != 'C' && rawChunk[k] != 'T'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'M' && (rawChunk[k] != 'C' && rawChunk[k] != 'A'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'K' && (rawChunk[k] != 'T' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'W' && (rawChunk[k] != 'T' && rawChunk[k] != 'A'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'S' && (rawChunk[k] != 'C' && rawChunk[k] != 'G'))                                 {       success = 0;    }
-                                        else if(oligo[k] == 'B' && (rawChunk[k] != 'C' && rawChunk[k] != 'T' && rawChunk[k] != 'G'))   {       success = 0;    }
-                                        else if(oligo[k] == 'D' && (rawChunk[k] != 'A' && rawChunk[k] != 'T' && rawChunk[k] != 'G'))   {       success = 0;    }
-                                        else if(oligo[k] == 'H' && (rawChunk[k] != 'A' && rawChunk[k] != 'T' && rawChunk[k] != 'C'))   {       success = 0;    }
-                                        else if(oligo[k] == 'V' && (rawChunk[k] != 'A' && rawChunk[k] != 'C' && rawChunk[k] != 'G'))   {       success = 0;    }                       
-                                        
-                                        if(success == 0)       {       break;   }
-                                    }
-                                    else{
-                                        success = 1;
-                                    }
-                                }
-                                
-                                ////////////////////////////////////////////////////////////////////
-                                if(success) {
-                                    primerStart = j;
-                                    primerEnd = primerStart + olength;
-                                    good = true; break;
-                                }
-                            }
-                            if (good) { break; }
-                        }      
-                        
-                        if (!good) { primerStart = 0; primerEnd = 0; }
-
-                         ///////////////////////////////////////////////////////////////
-                        if(!good){     if (pDataArray->nomatch == "reject") { goodSeq = false; } trashCode += "r";     }
-                        else{ 
-                            //are you aligned
-                            if (aligned) { 
-                                if (!pDataArray->keepprimer)    {  
-                                    if (pDataArray->keepdots)   { currSeq.filterFromPos(mapAligned[primerStart]); }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(0, mapAligned[primerStart]));   }
-                                } 
-                                else                {  
-                                    if (pDataArray->keepdots)   { currSeq.filterFromPos(mapAligned[primerEnd]); }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(0, mapAligned[primerEnd]));   }
-                                }                             }
-                            else { 
-                                if (!pDataArray->keepprimer)    { currSeq.setAligned(currSeq.getUnaligned().substr(0, primerStart));   } 
-                                else                { currSeq.setAligned(currSeq.getUnaligned().substr(0, primerEnd));     }
-                            }
-                        }
-                    }
-                }else if (pDataArray->ecolifile != "") {
-                    //make sure the seqs are aligned
-                    lengths.insert(currSeq.getAligned().length());
-                    if (lengths.size() > 1) { pDataArray->m->mothurOut("[ERROR]: seqs are not aligned. When using start and end your sequences must be aligned.\n"); pDataArray->m->control_pressed = true; break; }
-                    else if (currSeq.getAligned().length() != pDataArray->length) {
-                        pDataArray->m->mothurOut("[ERROR]: seqs are not the same length as ecoli seq. When using ecoli option your sequences must be aligned and the same length as the ecoli sequence.\n"); pDataArray->m->control_pressed = true; break; 
-                    }else {
-                        if (pDataArray->keepdots)   { 
-                            currSeq.filterToPos(pDataArray->start); 
-                            currSeq.filterFromPos(pDataArray->end);
-                        }else {
-                            string seqString = currSeq.getAligned().substr(0, pDataArray->end);
-                            seqString = seqString.substr(pDataArray->start);
-                            currSeq.setAligned(seqString); 
-                        }
-                    }
-                }else{ //using start and end to trim
-                    //make sure the seqs are aligned
-                    lengths.insert(currSeq.getAligned().length());
-                    if (lengths.size() > 1) { pDataArray->m->mothurOut("[ERROR]: seqs are not aligned. When using start and end your sequences must be aligned.\n"); pDataArray->m->control_pressed = true; break; }
-                    else {
-                        if (pDataArray->end != -1) {
-                            if (pDataArray->end > currSeq.getAligned().length()) {  pDataArray->m->mothurOut("[ERROR]: end is longer than your sequence length, aborting.\n"); pDataArray->m->control_pressed = true; break; }
-                            else {
-                                if (pDataArray->keepdots)   { currSeq.filterFromPos(pDataArray->end); }
-                                else {
-                                    string seqString = currSeq.getAligned().substr(0, pDataArray->end);
-                                    currSeq.setAligned(seqString); 
-                                }
-                            }
-                        }
-                        if (pDataArray->start != -1) { 
-                            if (pDataArray->keepdots)   {  currSeq.filterToPos(pDataArray->start);  }
-                            else {
-                                string seqString = currSeq.getAligned().substr(pDataArray->start);
-                                currSeq.setAligned(seqString); 
-                            }
-                        }
-                        
-                    }
-                }
-                
-                               if(goodSeq == 1)    {   currSeq.printSequence(goodFile);        }
-                               else {  
-                    pDataArray->badSeqNames.insert(currSeq.getName()); 
-                    currSeq.setName(currSeq.getName() + '|' + trashCode);
-                    currSeq.printSequence(badFile); 
-                }
-                       }
-                                               
-                       //report progress
-                       if((i+1) % 100 == 0){   pDataArray->m->mothurOut("Processing sequence: " + toString(i+1)); pDataArray->m->mothurOutEndLine();           }
-               }
-               //report progress
-               if((pDataArray->count) % 100 != 0){     pDataArray->m->mothurOut("Thread Processing sequence: " + toString(pDataArray->count)); pDataArray->m->mothurOutEndLine();              }
-               
-               goodFile.close();
-               inFASTA.close();
-        badFile.close();
-        
-        return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "PcrSeqsCommand", "MyPcrThreadFunction");
-               exit(1);
-       }
-} 
-
-#endif
-
-/**************************************************************************************************/
-
-
-
-#endif
diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp
deleted file mode 100644 (file)
index 3db101a..0000000
+++ /dev/null
@@ -1,653 +0,0 @@
-/*
- *  phylodiversitycommand.cpp
- *  Mothur
- *
- *  Created by westcott on 4/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "phylodiversitycommand.h"
-#include "treereader.h"
-
-//**********************************************************************************************************************
-vector<string> PhyloDiversityCommand::setParameters(){ 
-       try {
-
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prarefy("rarefy", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prarefy);
-               CommandParameter psummary("summary", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(psummary);
-               CommandParameter pcollect("collect", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pcollect);
-               CommandParameter pscale("scale", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pscale);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PhyloDiversityCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The phylo.diversity command parameters are tree, group, name, groups, iters, freq, processors, scale, rarefy, collect and summary.  tree and group are required, unless you have valid current files.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed. The group names are separated by dashes. By default all groups are used.\n";
-               helpString += "The iters parameter allows you to specify the number of randomizations to preform, by default iters=1000, if you set rarefy to true.\n";
-               helpString += "The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n";
-               helpString += "The scale parameter is used indicate that you want your output scaled to the number of sequences sampled, default = false. \n";
-               helpString += "The rarefy parameter allows you to create a rarefaction curve. The default is false.\n";
-               helpString += "The collect parameter allows you to create a collectors curve. The default is false.\n";
-               helpString += "The summary parameter allows you to create a .summary file. The default is true.\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "The phylo.diversity command should be in the following format: phylo.diversity(groups=yourGroups, rarefy=yourRarefy, iters=yourIters).\n";
-               helpString += "Example phylo.diversity(groups=A-B-C, rarefy=T, iters=500).\n";
-               helpString += "The phylo.diversity command output two files: .phylo.diversity and if rarefy=T, .rarefaction.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-PhyloDiversityCommand::PhyloDiversityCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["phylodiv"] = tempOutNames;
-               outputTypes["rarefy"] = tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "PhyloDiversityCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-PhyloDiversityCommand::PhyloDiversityCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();;
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["phylodiv"] = tempOutNames;
-                       outputTypes["rarefy"] = tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { treefile = ""; abort = true; }
-                       else if (treefile == "not found") {                             
-                               //if there is a current design file, use it
-                               treefile = m->getTreeFile(); 
-                               if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }else { m->setTreeFile(treefile); }     
-                       
-                       //check for required parameters
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(treefile);       }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, freq); 
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-                       
-                       temp = validParameter.validFile(parameters, "rarefy", false);                   if (temp == "not found") { temp = "F"; }
-                       rarefy = m->isTrue(temp);
-                       if (!rarefy) { iters = 1;  }
-                       
-                       temp = validParameter.validFile(parameters, "summary", false);                  if (temp == "not found") { temp = "T"; }
-                       summary = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "scale", false);                    if (temp == "not found") { temp = "F"; }
-                       scale = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "collect", false);                  if (temp == "not found") { temp = "F"; }
-                       collect = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "";  }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       if ((!collect) && (!rarefy) && (!summary)) { m->mothurOut("No outputs selected. You must set either collect, rarefy or summary to true, summary=T by default."); m->mothurOutEndLine(); abort=true; }
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(treefile);
-                               parser.getNameFile(files);
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "PhyloDiversityCommand");
-               exit(1);
-       }                       
-}
-//**********************************************************************************************************************
-
-int PhyloDiversityCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               m->setTreeFile(treefile);
-        TreeReader* reader = new TreeReader(treefile, groupfile, namefile);
-        vector<Tree*> trees = reader->getTrees();
-        tmap = trees[0]->getTreeMap();
-        delete reader;
-
-               SharedUtil util;
-               vector<string> mGroups = m->getGroups();
-               vector<string> tGroups = tmap->getNamesOfGroups();
-               util.setGroups(mGroups, tGroups, "phylo.diversity");    //sets the groups the user wants to analyze
-               
-               //incase the user had some mismatches between the tree and group files we don't want group xxx to be analyzed
-               for (int i = 0; i < mGroups.size(); i++) { if (mGroups[i] == "xxx") { mGroups.erase(mGroups.begin()+i);  break; }  }
-               m->setGroups(mGroups);
-                
-               vector<string> outputNames;
-               
-               //for each of the users trees
-               for(int i = 0; i < trees.size(); i++) {
-               
-                       if (m->control_pressed) { delete tmap; for (int j = 0; j < trees.size(); j++) { delete trees[j]; } for (int j = 0; j < outputNames.size(); j++) {       m->mothurRemove(outputNames[j]);        } return 0; }
-                       
-                       ofstream outSum, outRare, outCollect;
-                       string outSumFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + ".phylodiv.summary";
-                       string outRareFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + ".phylodiv.rarefaction";
-                       string outCollectFile = outputDir + m->getRootName(m->getSimpleName(treefile))  + toString(i+1) + ".phylodiv";
-                       
-                       if (summary)    { m->openOutputFile(outSumFile, outSum); outputNames.push_back(outSumFile);             outputTypes["summary"].push_back(outSumFile);                   }
-                       if (rarefy)             { m->openOutputFile(outRareFile, outRare); outputNames.push_back(outRareFile);  outputTypes["rarefy"].push_back(outRareFile);                   }
-                       if (collect)    { m->openOutputFile(outCollectFile, outCollect); outputNames.push_back(outCollectFile);  outputTypes["phylodiv"].push_back(outCollectFile);  }
-                       
-                       int numLeafNodes = trees[i]->getNumLeaves();
-                       
-                       //create a vector containing indexes of leaf nodes, randomize it, select nodes to send to calculator
-                       vector<int> randomLeaf;
-                       for (int j = 0; j < numLeafNodes; j++) {  
-                               if (m->inUsersGroups(trees[i]->tree[j].getGroup(), mGroups) == true) { //is this a node from the group the user selected.
-                                       randomLeaf.push_back(j); 
-                               }
-                       }
-                       
-                       numLeafNodes = randomLeaf.size();  //reset the number of leaf nodes you are using 
-                       
-                       //each group, each sampling, if no rarefy iters = 1;
-                       map<string, vector<float> > diversity;
-                       
-                       //each group, each sampling, if no rarefy iters = 1;
-                       map<string, vector<float> > sumDiversity;
-                       
-                       //find largest group total 
-                       int largestGroup = 0;
-                       for (int j = 0; j < mGroups.size(); j++) {  
-                               if (tmap->seqsPerGroup[mGroups[j]] > largestGroup) { largestGroup = tmap->seqsPerGroup[mGroups[j]]; }
-                               
-                               //initialize diversity
-                               diversity[mGroups[j]].resize(tmap->seqsPerGroup[mGroups[j]]+1, 0.0);            //numSampled
-                                                                                                                                                                                                                       //groupA                0.0                     0.0
-                                                                                                                                                                                                                       
-                               //initialize sumDiversity
-                               sumDiversity[mGroups[j]].resize(tmap->seqsPerGroup[mGroups[j]]+1, 0.0);
-                       }       
-
-                       //convert freq percentage to number
-                       int increment = 100;
-                       if (freq < 1.0) {  increment = largestGroup * freq;  
-                       }else { increment = freq;  }
-                       
-                       //initialize sampling spots
-                       set<int> numSampledList;
-                       for(int k = 1; k <= largestGroup; k++){  if((k == 1) || (k % increment == 0)){  numSampledList.insert(k); }   }
-                       if(largestGroup % increment != 0){      numSampledList.insert(largestGroup);   }
-                       
-                       //add other groups ending points
-                       for (int j = 0; j < mGroups.size(); j++) {  
-                               if (numSampledList.count(diversity[mGroups[j]].size()-1) == 0) {  numSampledList.insert(diversity[mGroups[j]].size()-1); }
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               if(processors == 1){
-                                       driver(trees[i], diversity, sumDiversity, iters, increment, randomLeaf, numSampledList, outCollect, outSum, true);      
-                               }else{
-                                       if (rarefy) {
-                                               vector<int> procIters;
-                                               
-                                               int numItersPerProcessor = iters / processors;
-                                               
-                                               //divide iters between processes
-                                               for (int h = 0; h < processors; h++) {
-                                                       if(h == processors - 1){
-                                                               numItersPerProcessor = iters - h * numItersPerProcessor;
-                                                       }
-                                                       procIters.push_back(numItersPerProcessor);
-                                               }
-                                               
-                                               createProcesses(procIters, trees[i], diversity, sumDiversity, iters, increment, randomLeaf, numSampledList, outCollect, outSum); 
-                                               
-                                       }else{ //no need to paralellize if you dont want to rarefy
-                                               driver(trees[i], diversity, sumDiversity, iters, increment, randomLeaf, numSampledList, outCollect, outSum, true);      
-                                       }
-                               }
-
-                       #else
-                               driver(trees[i], diversity, sumDiversity, iters, increment, randomLeaf, numSampledList, outCollect, outSum, true);      
-                       #endif
-
-                       if (rarefy) {   printData(numSampledList, sumDiversity, outRare, iters);        }
-               }
-               
-       
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PhyloDiversityCommand::createProcesses(vector<int>& procIters, Tree* t, map< string, vector<float> >& div, map<string, vector<float> >& sumDiv, int numIters, int increment, vector<int>& randomLeaf, set<int>& numSampledList, ofstream& outCollect, ofstream& outSum){
-       try {
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               
-               vector<int> processIDS;
-               map< string, vector<float> >::iterator itSum;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               driver(t, div, sumDiv, procIters[process], increment, randomLeaf, numSampledList, outCollect, outSum, false);
-                               
-                               string outTemp = outputDir + toString(getpid()) + ".sumDiv.temp";
-                               ofstream out;
-                               m->openOutputFile(outTemp, out);
-                               
-                               //output the sumDIversity
-                               for (itSum = sumDiv.begin(); itSum != sumDiv.end(); itSum++) {
-                                       out << itSum->first << '\t' << (itSum->second).size() << '\t';
-                                       for (int k = 0; k < (itSum->second).size(); k++) { 
-                                               out << (itSum->second)[k] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               driver(t, div, sumDiv, procIters[0], increment, randomLeaf, numSampledList, outCollect, outSum, true);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       
-                       //input the sumDIversity
-                       string inTemp = outputDir + toString(processIDS[i]) + ".sumDiv.temp";
-                       ifstream in;
-                       m->openInputFile(inTemp, in);
-                               
-                       //output the sumDIversity
-                       for (int j = 0; j < sumDiv.size(); j++) { 
-                               string group = "";
-                               int size = 0;
-                               
-                               in >> group >> size; m->gobble(in);
-                               
-                               for (int k = 0; k < size; k++) { 
-                                       float tempVal;
-                                       in >> tempVal;
-                                       
-                                       sumDiv[group][k] += tempVal;
-                               }
-                               m->gobble(in);
-                       }
-                               
-                       in.close();
-                       m->mothurRemove(inTemp);
-               }
-               
-#endif
-
-       return 0;               
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "createProcesses");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PhyloDiversityCommand::driver(Tree* t, map< string, vector<float> >& div, map<string, vector<float> >& sumDiv, int numIters, int increment, vector<int>& randomLeaf, set<int>& numSampledList, ofstream& outCollect, ofstream& outSum, bool doSumCollect){
-       try {
-               int numLeafNodes = randomLeaf.size();
-               vector<string> mGroups = m->getGroups();
-       
-               for (int l = 0; l < numIters; l++) {
-                               random_shuffle(randomLeaf.begin(), randomLeaf.end());
-               
-                               //initialize counts
-                               map<string, int> counts;
-                               map< string, set<int> > countedBranch;  
-                               for (int j = 0; j < mGroups.size(); j++) {  counts[mGroups[j]] = 0; countedBranch[mGroups[j]].insert(-2);  }  //add dummy index to initialize countedBranch sets
-                               
-                               for(int k = 0; k < numLeafNodes; k++){
-                                               
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       //calc branch length of randomLeaf k
-                                       vector<float> br = calcBranchLength(t, randomLeaf[k], countedBranch);
-                       
-                                       //for each group in the groups update the total branch length accounting for the names file
-                                       vector<string> groups = t->tree[randomLeaf[k]].getGroup();
-                                       
-                                       for (int j = 0; j < groups.size(); j++) {
-                                               int numSeqsInGroupJ = 0;
-                                               map<string, int>::iterator it;
-                                               it = t->tree[randomLeaf[k]].pcount.find(groups[j]);
-                                               if (it != t->tree[randomLeaf[k]].pcount.end()) { //this leaf node contains seqs from group j
-                                                       numSeqsInGroupJ = it->second;
-                                               }
-                                               
-                                               if (numSeqsInGroupJ != 0) {     div[groups[j]][(counts[groups[j]]+1)] = div[groups[j]][counts[groups[j]]] + br[j];  }
-                                               
-                                               for (int s = (counts[groups[j]]+2); s <= (counts[groups[j]]+numSeqsInGroupJ); s++) {
-                                                       div[groups[j]][s] = div[groups[j]][s-1];  //update counts, but don't add in redundant branch lengths
-                                               }
-                                               counts[groups[j]] += numSeqsInGroupJ;
-                                       }
-                               }
-                               
-                               if (rarefy) {
-                                       //add this diversity to the sum
-                                       for (int j = 0; j < mGroups.size(); j++) {  
-                                               for (int g = 0; g < div[mGroups[j]].size(); g++) {
-                                                       sumDiv[mGroups[j]][g] += div[mGroups[j]][g];
-                                               }
-                                       }
-                               }
-                               
-                               if ((collect) && (l == 0) && doSumCollect) {  printData(numSampledList, div, outCollect, 1);  }
-                               if ((summary) && (l == 0) && doSumCollect) {  printSumData(div, outSum, 1);  }
-                       }
-                       
-                       return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "driver");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-void PhyloDiversityCommand::printSumData(map< string, vector<float> >& div, ofstream& out, int numIters){
-       try {
-               
-               out << "Groups\tnumSampled\tphyloDiversity" << endl;
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               vector<string> mGroups = m->getGroups();
-               for (int j = 0; j < mGroups.size(); j++) {
-                       int numSampled = (div[mGroups[j]].size()-1);
-                       out << mGroups[j] << '\t' << numSampled << '\t';
-               
-                        
-                       float score;
-                       if (scale)      {  score = (div[mGroups[j]][numSampled] / (float)numIters) / (float)numSampled; }
-                       else            {       score = div[mGroups[j]][numSampled] / (float)numIters;  }
-                               
-                       out << setprecision(4) << score << endl;
-               }
-                                       
-               out.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "printSumData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-void PhyloDiversityCommand::printData(set<int>& num, map< string, vector<float> >& div, ofstream& out, int numIters){
-       try {
-               
-               out << "numSampled\t";
-               vector<string> mGroups = m->getGroups();
-               for (int i = 0; i < mGroups.size(); i++) { out << mGroups[i] << '\t';  }
-               out << endl;
-               
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               
-               for (set<int>::iterator it = num.begin(); it != num.end(); it++) {  
-                       int numSampled = *it;
-                       
-                       out << numSampled << '\t';  
-               
-                       for (int j = 0; j < mGroups.size(); j++) {
-                               if (numSampled < div[mGroups[j]].size()) { 
-                                       float score;
-                                       if (scale)      {  score = (div[mGroups[j]][numSampled] / (float)numIters) / (float)numSampled; }
-                                       else            {       score = div[mGroups[j]][numSampled] / (float)numIters;  }
-
-                                       out << setprecision(4) << score << '\t';
-                               }else { out << "NA" << '\t'; }
-                       }
-                       out << endl;
-               }
-               
-               out.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "printData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//need a vector of floats one branch length for every group the node represents.
-vector<float> PhyloDiversityCommand::calcBranchLength(Tree* t, int leaf, map< string, set<int> >& counted){
-       try {
-
-               //calc the branch length
-               //while you aren't at root
-               vector<float> sums; 
-               int index = leaf;
-               
-               vector<string> groups = t->tree[leaf].getGroup();
-               sums.resize(groups.size(), 0.0);
-               
-               map<string, map<int, double> > tempTotals; //maps node to total Branch Length
-               map< string, set<int> > tempCounted;
-               set<int>::iterator it;
-       
-               //you are a leaf
-               if(t->tree[index].getBranchLength() != -1){     
-                       for (int k = 0; k < groups.size(); k++) { 
-                               sums[k] += abs(t->tree[index].getBranchLength());       
-                               counted[groups[k]].insert(index);
-                       }
-               }
-               
-               for (int k = 0; k < groups.size(); k++) { 
-                       tempTotals[groups[k]][index] = 0.0;     
-               }
-               
-               index = t->tree[index].getParent();     
-                       
-               //while you aren't at root
-               while(t->tree[index].getParent() != -1){
-
-                       if (m->control_pressed) {  return sums; }
-                       
-                       int pcountSize = 0;     
-                       for (int k = 0; k < groups.size(); k++) {
-                               map<string, int>::iterator itGroup = t->tree[index].pcount.find(groups[k]);
-                               if (itGroup != t->tree[index].pcount.end()) { pcountSize++;  } 
-                       
-                               //do both your chidren have have descendants from the users groups? 
-                               int lc = t->tree[index].getLChild();
-                               int rc = t->tree[index].getRChild();
-                       
-                               int LpcountSize = 0;
-                               itGroup = t->tree[lc].pcount.find(groups[k]);
-                               if (itGroup != t->tree[lc].pcount.end()) { LpcountSize++;  } 
-                                                       
-                               int RpcountSize = 0;
-                               itGroup = t->tree[rc].pcount.find(groups[k]);
-                               if (itGroup != t->tree[rc].pcount.end()) { RpcountSize++;  } 
-                                                               
-                               //if yes, add your childrens tempTotals
-                               if ((LpcountSize != 0) && (RpcountSize != 0)) {
-                                       sums[k] += tempTotals[groups[k]][lc] + tempTotals[groups[k]][rc]; 
-                                       
-                                       for (it = tempCounted[groups[k]].begin(); it != tempCounted[groups[k]].end(); it++) { counted[groups[k]].insert(*it); }
-
-                                       //cout << "added to total " << tempTotals[lc] << '\t' << tempTotals[rc] << endl;
-                                       if (t->tree[index].getBranchLength() != -1) {
-                                               if (counted[groups[k]].count(index) == 0) {
-                                                       tempTotals[groups[k]][index] = abs(t->tree[index].getBranchLength());
-                                                       tempCounted[groups[k]].insert(index);
-                                               }else{
-                                                       tempTotals[groups[k]][index] = 0.0;
-                                               }
-                                       }else {
-                                               tempTotals[groups[k]][index] = 0.0;
-                                       }
-                               }else { //if no, your tempTotal is your childrens temp totals + your branch length
-                                       tempTotals[groups[k]][index] = tempTotals[groups[k]][lc] + tempTotals[groups[k]][rc]; 
-                                                                       
-                                       if (counted[groups[k]].count(index) == 0) {
-                                               tempTotals[groups[k]][index] += abs(t->tree[index].getBranchLength());
-                                               tempCounted[groups[k]].insert(index);
-                                       }
-
-                               }
-                               //cout << "temptotal = "<< tempTotals[i] << endl;
-                       }
-                       
-                       index = t->tree[index].getParent();     
-               }
-
-               return sums;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloDiversityCommand", "calcBranchLength");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/phylodiversitycommand.h b/phylodiversitycommand.h
deleted file mode 100644 (file)
index 5d0cccf..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef PHYLODIVERSITYCOMMAND_H
-#define PHYLODIVERSITYCOMMAND_H
-
-/*
- *  phylodiversitycommand.h
- *  Mothur
- *
- *  Created by westcott on 4/30/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "treemap.h"
-#include "sharedutilities.h"
-#include "tree.h"
-
-class PhyloDiversityCommand : public Command {
-       
-       public:
-               PhyloDiversityCommand(string);
-               PhyloDiversityCommand();
-               ~PhyloDiversityCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "phylo.diversity";                     }
-               string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
-               string getCitation() { return "Faith DP (1994). Phylogenetic pattern and the quantification of organismal biodiversity. Philos Trans R Soc Lond B Biol Sci 345: 45-58. \nhttp://www.mothur.org/wiki/Phylo.diversity"; }
-               string getDescription()         { return "phylo.diversity"; }
-
-               int execute();
-               void help() { m->mothurOut(getHelpString()); }
-private:
-               TreeMap* tmap;
-               float freq;
-               int iters, processors, numUniquesInName;  
-               bool abort, rarefy, summary, collect, scale;
-               string groups, outputDir, treefile, groupfile, namefile;
-               vector<string> Groups, outputNames; //holds groups to be used, and outputFile names
-               
-               int readNamesFile();
-               void printData(set<int>&, map< string, vector<float> >&, ofstream&, int);
-               void printSumData(map< string, vector<float> >&, ofstream&, int);
-               vector<float> calcBranchLength(Tree*, int, map< string, set<int> >&);
-               int driver(Tree*, map< string, vector<float> >&, map<string, vector<float> >&, int, int, vector<int>&, set<int>&, ofstream&, ofstream&, bool);
-               int createProcesses(vector<int>&, Tree*, map< string, vector<float> >&, map<string, vector<float> >&, int, int, vector<int>&, set<int>&, ofstream&, ofstream&);
-
-};
-
-#endif
-
diff --git a/phylosummary.cpp b/phylosummary.cpp
deleted file mode 100644 (file)
index 2f56515..0000000
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- *  rawTrainingDataMaker.cpp
- *  Mothur
- *
- *  Created by westcott on 4/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "phylosummary.h"
-
-/**************************************************************************************************/
-
-PhyloSummary::PhyloSummary(string refTfile, string groupFile){
-       try {
-               m = MothurOut::getInstance();
-               maxLevel = 0;
-               ignore = false;
-               
-               if (groupFile != "") {
-                       groupmap = new GroupMap(groupFile);
-                       groupmap->readMap();
-               }else{
-                       groupmap = NULL;
-               }
-                               
-               //check for necessary files
-               string taxFileNameTest = m->getFullPathName((refTfile.substr(0,refTfile.find_last_of(".")+1) + "tree.sum"));
-               ifstream FileTest(taxFileNameTest.c_str());
-               
-               if (!FileTest) { 
-                       m->mothurOut("Error: can't find " + taxFileNameTest + "."); m->mothurOutEndLine(); exit(1);
-               }else{
-                       readTreeStruct(FileTest);
-               }
-               
-               tree[0].rank = "0";
-               assignRank(0);
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "PhyloSummary");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-PhyloSummary::PhyloSummary(string groupFile){
-       try {
-               m = MothurOut::getInstance();
-               maxLevel = 0;
-               ignore = true;
-               
-               if (groupFile != "") {
-                       groupmap = new GroupMap(groupFile);
-                       groupmap->readMap();
-               }else{
-                       groupmap = NULL;
-               }
-               
-               tree.push_back(rawTaxNode("Root"));
-               tree[0].rank = "0";
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "PhyloSummary");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int PhyloSummary::summarize(string userTfile){
-       try {
-               
-               ifstream in;
-               m->openInputFile(userTfile, in);
-               
-               //read in users taxonomy file and add sequences to tree
-               string name, tax;
-               int numSeqs = 0;
-               while(!in.eof()){
-                       in >> name >> tax; m->gobble(in);
-                       
-                       addSeqToTree(name, tax);
-                       numSeqs++;
-                       
-                       if (m->control_pressed) { break;  }
-               }
-               in.close();
-               
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "summarize");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string PhyloSummary::getNextTaxon(string& heirarchy){
-       try {
-               string currentLevel = "";
-               if(heirarchy != ""){
-                       int pos = heirarchy.find_first_of(';');
-                       currentLevel=heirarchy.substr(0,pos);
-                       if (pos != (heirarchy.length()-1)) {  heirarchy=heirarchy.substr(pos+1);  }
-                       else { heirarchy = ""; }
-               }
-               return currentLevel;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "getNextTaxon");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int PhyloSummary::addSeqToTree(string seqName, string seqTaxonomy){
-       try {
-                               
-               numSeqs++;
-               
-               map<string, int>::iterator childPointer;
-               
-               int currentNode = 0;
-               string taxon;
-               
-               int level = 0;
-               
-               //are there confidence scores, if so remove them
-               if (seqTaxonomy.find_first_of('(') != -1) {  m->removeConfidences(seqTaxonomy); }
-               
-               while (seqTaxonomy != "") {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //somehow the parent is getting one too many accnos
-                       //use print to reassign the taxa id
-                       taxon = getNextTaxon(seqTaxonomy);
-                       
-                       childPointer = tree[currentNode].children.find(taxon);
-                       
-                       if(childPointer != tree[currentNode].children.end()){   //if the node already exists, update count and move on
-                               if (groupmap != NULL) {
-                                       //find out the sequences group
-                                       string group = groupmap->getGroup(seqName);
-                                       
-                                       if (group == "not found") {  m->mothurOut("[WARNING]: " + seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine();  }
-                                       
-                                       //do you have a count for this group?
-                                       map<string, int>::iterator itGroup = tree[childPointer->second].groupCount.find(group);
-                                       
-                                       //if yes, increment it - there should not be a case where we can't find it since we load group in read
-                                       if (itGroup != tree[childPointer->second].groupCount.end()) {
-                                               tree[childPointer->second].groupCount[group]++;
-                                       }
-                               }
-                               
-                               tree[childPointer->second].total++;
-
-                               currentNode = childPointer->second;
-                       }else{  
-                               if (ignore) {
-                                               
-                                       tree.push_back(rawTaxNode(taxon));
-                                       int index = tree.size() - 1;
-                               
-                                       tree[index].parent = currentNode;
-                                       tree[index].level = (level+1);
-                                       tree[index].total = 1;
-                                       tree[currentNode].children[taxon] = index;
-                                       
-                                       //initialize groupcounts
-                                       if (groupmap != NULL) {
-                                               vector<string> mGroups = groupmap->getNamesOfGroups();
-                                               for (int j = 0; j < mGroups.size(); j++) {
-                                                       tree[index].groupCount[mGroups[j]] = 0;
-                                               }
-                                               
-                                               //find out the sequences group
-                                               string group = groupmap->getGroup(seqName);
-                                               
-                                               if (group == "not found") {  m->mothurOut("[WARNING]: " + seqName + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine();  }
-                                               
-                                               //do you have a count for this group?
-                                               map<string, int>::iterator itGroup = tree[index].groupCount.find(group);
-                                               
-                                               //if yes, increment it - there should not be a case where we can't find it since we load group in read
-                                               if (itGroup != tree[index].groupCount.end()) {
-                                                       tree[index].groupCount[group]++;
-                                               }                                               
-                                       }
-                                       
-                                       currentNode = index;
-                                       
-                               }else{ //otherwise, error
-                                       m->mothurOut("Warning: cannot find taxon " + taxon + " in reference taxonomy tree at level " + toString(tree[currentNode].level) + " for " + seqName + ". This may cause totals of daughter levels not to add up in summary file."); m->mothurOutEndLine();
-                                       break;
-                               }
-                       }
-                       
-                       level++;
-                       
-                       if ((seqTaxonomy == "") && (level < maxLevel)) {  //if you think you are done and you are not.
-                               for (int k = level; k < maxLevel; k++) {  seqTaxonomy += "unclassified;";   }
-                       }
-               }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "addSeqToTree");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int PhyloSummary::addSeqToTree(string seqTaxonomy, vector<string> names){
-       try {
-               numSeqs++;
-               
-               map<string, int>::iterator childPointer;
-               
-               int currentNode = 0;
-               string taxon;
-               
-               int level = 0;
-               
-               //are there confidence scores, if so remove them
-               if (seqTaxonomy.find_first_of('(') != -1) {  m->removeConfidences(seqTaxonomy); }
-               
-               while (seqTaxonomy != "") {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //somehow the parent is getting one too many accnos
-                       //use print to reassign the taxa id
-                       taxon = getNextTaxon(seqTaxonomy);
-                       
-                       childPointer = tree[currentNode].children.find(taxon);
-                       
-                       if(childPointer != tree[currentNode].children.end()){   //if the node already exists, update count and move on
-                               if (groupmap != NULL) {
-                                       
-                                       map<string, bool> containsGroup; 
-                                       vector<string> mGroups = groupmap->getNamesOfGroups();
-                                       for (int j = 0; j < mGroups.size(); j++) {
-                                               containsGroup[mGroups[j]] = false;
-                                       }
-                                       
-                                       for (int k = 0; k < names.size(); k++) {
-                                               //find out the sequences group
-                                               string group = groupmap->getGroup(names[k]);
-                                       
-                                               if (group == "not found") {  m->mothurOut("[WARNING]: " + names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine();  }
-                                               else {
-                                                       containsGroup[group] = true;
-                                               }
-                                       }
-                                       
-                                       for (map<string, bool>::iterator itGroup = containsGroup.begin(); itGroup != containsGroup.end(); itGroup++) {
-                                               if (itGroup->second == true) {
-                                                       tree[childPointer->second].groupCount[itGroup->first]++;
-                                               }
-                                       }
-                                       
-                               }
-                               
-                               tree[childPointer->second].total++;
-                               
-                               currentNode = childPointer->second;
-                       }else{  
-                               if (ignore) {
-                                       
-                                       tree.push_back(rawTaxNode(taxon));
-                                       int index = tree.size() - 1;
-                                       
-                                       tree[index].parent = currentNode;
-                                       tree[index].level = (level+1);
-                                       tree[index].total = 1;
-                                       tree[currentNode].children[taxon] = index;
-                                       
-                                       //initialize groupcounts
-                                       if (groupmap != NULL) {
-                                               map<string, bool> containsGroup; 
-                                               vector<string> mGroups = groupmap->getNamesOfGroups();
-                                               for (int j = 0; j < mGroups.size(); j++) {
-                                                       tree[index].groupCount[mGroups[j]] = 0;
-                                                       containsGroup[mGroups[j]] = false;
-                                               }
-                                               
-                                               
-                                               for (int k = 0; k < names.size(); k++) {
-                                                       //find out the sequences group
-                                                       string group = groupmap->getGroup(names[k]);
-                                                       
-                                                       if (group == "not found") {  m->mothurOut("[WARNING]: " + names[k] + " is not in your groupfile, and will be included in the overall total, but not any group total."); m->mothurOutEndLine();  }
-                                                       else {
-                                                               containsGroup[group] = true;
-                                                       }
-                                               }
-                                               
-                                               for (map<string, bool>::iterator itGroup = containsGroup.begin(); itGroup != containsGroup.end(); itGroup++) {
-                                                       if (itGroup->second == true) {
-                                                               tree[index].groupCount[itGroup->first]++;
-                                                       }
-                                               }
-                                       }
-                                       
-                                       currentNode = index;
-                                       
-                               }else{ //otherwise, error
-                                       m->mothurOut("Warning: cannot find taxon " + taxon + " in reference taxonomy tree at level " + toString(tree[currentNode].level) + ". This may cause totals of daughter levels not to add up in summary file."); m->mothurOutEndLine();
-                                       break;
-                               }
-                       }
-                       
-                       level++;
-                       
-                       if ((seqTaxonomy == "") && (level < maxLevel)) {  //if you think you are done and you are not.
-                               for (int k = level; k < maxLevel; k++) {  seqTaxonomy += "unclassified;";   }
-                       }
-               }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "addSeqToTree");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void PhyloSummary::assignRank(int index){
-       try {
-               map<string,int>::iterator it;
-               int counter = 1;
-               
-               for(it=tree[index].children.begin();it!=tree[index].children.end();it++){
-                       tree[it->second].rank = tree[index].rank + '.' + toString(counter);
-                       counter++;
-                                                                       
-                       assignRank(it->second);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "assignRank");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void PhyloSummary::print(ofstream& out){
-       try {
-               
-               if (ignore) { assignRank(0); }
-       
-               //print labels
-               out << "taxlevel\t rankID\t taxon\t daughterlevels\t total\t";
-               if (groupmap != NULL) {
-                       //so the labels match the counts below, since the map sorts them automatically...
-                       //sort(groupmap->namesOfGroups.begin(), groupmap->namesOfGroups.end());
-                       vector<string> mGroups = groupmap->getNamesOfGroups();
-                       for (int i = 0; i < mGroups.size(); i++) {
-                               out << mGroups[i] << '\t';
-                       }
-               }
-               
-               out << endl;
-               
-               int totalChildrenInTree = 0;
-               map<string, int>::iterator itGroup;
-               
-               map<string,int>::iterator it;
-               for(it=tree[0].children.begin();it!=tree[0].children.end();it++){   
-                       if (tree[it->second].total != 0)  {   
-                               totalChildrenInTree++; 
-                               tree[0].total += tree[it->second].total;
-                               
-                               if (groupmap != NULL) {
-                                       vector<string> mGroups = groupmap->getNamesOfGroups();
-                                       for (int i = 0; i < mGroups.size(); i++) { tree[0].groupCount[mGroups[i]] += tree[it->second].groupCount[mGroups[i]]; } 
-                               }
-                       }
-               }
-               
-               //print root
-               out << tree[0].level << "\t" << tree[0].rank << "\t" << tree[0].name << "\t" << totalChildrenInTree << "\t" << tree[0].total << "\t";
-               
-               
-               if (groupmap != NULL) {
-                       //for (itGroup = tree[0].groupCount.begin(); itGroup != tree[0].groupCount.end(); itGroup++) {
-                       //      out << itGroup->second << '\t';
-                       //}
-                       vector<string> mGroups = groupmap->getNamesOfGroups();
-                       for (int i = 0; i < mGroups.size(); i++) {  out << tree[0].groupCount[mGroups[i]] << '\t'; } 
-               }
-               out << endl;
-               
-               //print rest
-               print(0, out);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "print");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void PhyloSummary::print(int i, ofstream& out){
-       try {
-               map<string,int>::iterator it;
-               for(it=tree[i].children.begin();it!=tree[i].children.end();it++){
-                       
-                       if (tree[it->second].total != 0)  {
-                       
-                               int totalChildrenInTree = 0;
-               
-                               map<string,int>::iterator it2;
-                               for(it2=tree[it->second].children.begin();it2!=tree[it->second].children.end();it2++){   
-                                       if (tree[it2->second].total != 0)  {   totalChildrenInTree++; }
-                               }
-                       
-                               out << tree[it->second].level << "\t" << tree[it->second].rank << "\t" << tree[it->second].name << "\t" << totalChildrenInTree << "\t" << tree[it->second].total << "\t";
-                               
-                               map<string, int>::iterator itGroup;
-                               if (groupmap != NULL) {
-                                       //for (itGroup = tree[it->second].groupCount.begin(); itGroup != tree[it->second].groupCount.end(); itGroup++) {
-                                       //      out << itGroup->second << '\t';
-                                       //}
-                                       vector<string> mGroups = groupmap->getNamesOfGroups();
-                                       for (int i = 0; i < mGroups.size(); i++) {  out << tree[it->second].groupCount[mGroups[i]] << '\t'; } 
-                               }
-                               out << endl;
-                               
-                       }
-                       
-                       print(it->second, out);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "print");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void PhyloSummary::readTreeStruct(ifstream& in){
-       try {
-       
-               //read version
-               string line = m->getline(in); m->gobble(in);
-               
-               int num;
-               
-               in >> num; m->gobble(in);
-               
-               tree.resize(num);
-               
-               in >> maxLevel; m->gobble(in);
-       
-               //read the tree file
-               for (int i = 0; i < tree.size(); i++) {
-       
-                       in >> tree[i].level >> tree[i].name >> num; //num contains the number of children tree[i] has
-                       
-                       //set children
-                       string childName;
-                       int childIndex;
-                       for (int j = 0; j < num; j++) {
-                               in >> childName >> childIndex;
-                               tree[i].children[childName] = childIndex;
-                       }
-                       
-                       //initialize groupcounts
-                       if (groupmap != NULL) {
-                               for (int j = 0; j < (groupmap->getNamesOfGroups()).size(); j++) {
-                                       tree[i].groupCount[(groupmap->getNamesOfGroups())[j]] = 0;
-                               }
-                       }
-                       
-                       tree[i].total = 0;
-                       
-                       m->gobble(in);
-                       
-                       //if (tree[i].level > maxLevel) {  maxLevel = tree[i].level;  }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloSummary", "readTreeStruct");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
-       
diff --git a/phylosummary.h b/phylosummary.h
deleted file mode 100644 (file)
index cdec0d0..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef RAWTRAININGDATAMAKER_H
-#define RAWTRAININGDATAMAKER_H
-
-/*
- *  rawTrainingDataMaker.h
- *  Mothur
- *
- *  Created by westcott on 4/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "groupmap.h"
-
-/**************************************************************************************************/
-
-struct rawTaxNode {
-       map<string, int> children;  //childs name to index in tree
-       int parent, level;
-       string name, rank;
-       map<string, int> groupCount;
-       int total;
-       
-       rawTaxNode(string n) : name(n), level(0), parent(-1), total(0) {}
-       rawTaxNode(){}
-};
-
-/**************************************************************************************************/
-//doesn't use MPI ifdefs since only pid 0 uses this class
-class PhyloSummary {
-
-public:
-       PhyloSummary(string);
-       PhyloSummary(string, string);
-       ~PhyloSummary() { if (groupmap != NULL)  {  delete groupmap;  }  }
-       
-       int summarize(string);  //pass it a taxonomy file and a group file and it makes the tree
-       int addSeqToTree(string, string);
-       int addSeqToTree(string, vector<string>);
-       void print(ofstream&);
-       int getMaxLevel() { return maxLevel; }
-       
-private:
-       string getNextTaxon(string&);
-       vector<rawTaxNode> tree;
-       void print(int, ofstream&);
-       void assignRank(int);
-       void readTreeStruct(ifstream&);
-       GroupMap* groupmap;
-       bool ignore;
-       
-       int numNodes;
-       int numSeqs;
-       int maxLevel;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
-
-
diff --git a/phylotree.cpp b/phylotree.cpp
deleted file mode 100644 (file)
index a9ef6cb..0000000
+++ /dev/null
@@ -1,656 +0,0 @@
-/*
- *  doTaxonomy.cpp
- *  
- *
- *  Created by Pat Schloss on 6/17/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "phylotree.h"
-
-/**************************************************************************************************/
-
-PhyloTree::PhyloTree(){
-       try {
-               m = MothurOut::getInstance();
-               numNodes = 1;
-               numSeqs = 0;
-               tree.push_back(TaxNode("Root"));
-               tree[0].heirarchyID = "0";
-               maxLevel = 0;
-               calcTotals = true;
-               addSeqToTree("unknown", "unknown;");
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "PhyloTree");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-PhyloTree::PhyloTree(ifstream& in, string filename){
-       try {
-               m = MothurOut::getInstance();
-               calcTotals = false;
-               numNodes = 0;
-               numSeqs = 0;
-               
-               #ifdef USE_MPI
-                       MPI_File inMPI;
-                       MPI_Offset size;
-                       MPI_Status status;
-
-                       char inFileName[1024];
-                       strcpy(inFileName, filename.c_str());
-
-                       MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
-                       MPI_File_get_size(inMPI, &size);
-                       
-                       char* buffer = new char[size];
-                       MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-
-                       string tempBuf = buffer;
-                       if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buffer;
-                       
-                       //read version
-                       m->getline(iss); m->gobble(iss);
-                       
-                       iss >> numNodes; m->gobble(iss);
-                       
-                       tree.resize(numNodes);
-                       
-                       for (int i = 0; i < tree.size(); i++) {
-                               iss >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(iss);
-                       }
-                       
-                       //read genus nodes
-                       int numGenus = 0;
-                       iss >> numGenus; m->gobble(iss);
-                       
-                       int gnode, gsize;
-                       totals.clear();
-                       for (int i = 0; i < numGenus; i++) {
-                               iss >> gnode >> gsize; m->gobble(iss);
-                               
-                               uniqueTaxonomies[gnode] = gnode;
-                               totals.push_back(gsize);
-                       }
-                       
-                       MPI_File_close(&inMPI);
-                       
-               #else
-                       //read version
-                       string line = m->getline(in); m->gobble(in);
-                       
-                       in >> numNodes; m->gobble(in);
-                       
-                       tree.resize(numNodes);
-                       
-                       for (int i = 0; i < tree.size(); i++) {
-                               in >> tree[i].name >> tree[i].level >> tree[i].parent; m->gobble(in);
-                       }
-                       
-                       //read genus nodes
-                       int numGenus = 0;
-                       in >> numGenus; m->gobble(in);
-                       
-                       int gnode, gsize;
-                       totals.clear();
-                       for (int i = 0; i < numGenus; i++) {
-                               in >> gnode >> gsize; m->gobble(in);
-                               
-                               uniqueTaxonomies[gnode] = gnode;
-                               totals.push_back(gsize);
-                       }
-                       
-                       in.close();
-                       
-               #endif
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "PhyloTree");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-PhyloTree::PhyloTree(string tfile){
-       try {
-               m = MothurOut::getInstance();
-               numNodes = 1;
-               numSeqs = 0;
-               tree.push_back(TaxNode("Root"));
-               tree[0].heirarchyID = "0";
-               maxLevel = 0;
-               calcTotals = true;
-               string name, tax;
-               
-               #ifdef USE_MPI
-                       int pid, num, processors;
-                       vector<unsigned long long> positions;
-                       
-                       MPI_Status status; 
-                       MPI_File inMPI;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                       MPI_Comm_size(MPI_COMM_WORLD, &processors);
-
-                       char inFileName[1024];
-                       strcpy(inFileName, tfile.c_str());
-
-                       MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-
-                       if (pid == 0) {
-                               positions = m->setFilePosEachLine(tfile, num);
-                               
-                               //send file positions to all processes
-                               for(int i = 1; i < processors; i++) { 
-                                       MPI_Send(&num, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                       MPI_Send(&positions[0], (num+1), MPI_LONG, i, 2001, MPI_COMM_WORLD);
-                               }
-                       }else{
-                               MPI_Recv(&num, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                               positions.resize(num+1);
-                               MPI_Recv(&positions[0], (num+1), MPI_LONG, 0, 2001, MPI_COMM_WORLD, &status);
-                       }
-               
-                       //read file 
-                       for(int i=0;i<num;i++){
-                               //read next sequence
-                               int length = positions[i+1] - positions[i];
-                               char* buf4 = new char[length];
-
-                               MPI_File_read_at(inMPI, positions[i], buf4, length, MPI_CHAR, &status);
-
-                               string tempBuf = buf4;
-                               if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); }
-                               delete buf4;
-
-                               istringstream iss (tempBuf,istringstream::in);
-                               iss >> name >> tax;
-                               addSeqToTree(name, tax);
-                       }
-                       
-                       MPI_File_close(&inMPI);
-                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-               
-               #else
-                       ifstream in;
-                       m->openInputFile(tfile, in);
-                       
-                       //read in users taxonomy file and add sequences to tree
-                       while(!in.eof()){
-                               in >> name >> tax; m->gobble(in);
-                       
-                               addSeqToTree(name, tax);
-                       }
-                       in.close();
-               #endif
-       
-               assignHeirarchyIDs(0);
-        
-        
-        string unknownTax = "unknown;";
-        //added last taxon until you get desired level
-               for (int i = 1; i < maxLevel; i++) {
-                       unknownTax += "unclassfied;";
-               }
-        
-        addSeqToTree("unknown", unknownTax);
-        
-               //create file for summary if needed
-               setUp(tfile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "PhyloTree");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string PhyloTree::getNextTaxon(string& heirarchy, string seqname){
-       try {
-               string currentLevel = "";
-               if(heirarchy != ""){
-                       int pos = heirarchy.find_first_of(';');
-                       
-                       if (pos == -1) { //you can't find another ;
-                               currentLevel = heirarchy;
-                               heirarchy = "";
-                               m->mothurOut(seqname + " is missing a ;, please check for other errors."); m->mothurOutEndLine();
-                       }else{
-                               currentLevel=heirarchy.substr(0,pos);
-                               if (pos != (heirarchy.length()-1)) {  heirarchy=heirarchy.substr(pos+1);  }
-                               else { heirarchy = ""; }
-                       }
-                       
-               }
-               return currentLevel;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "getNextTaxon");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int PhyloTree::addSeqToTree(string seqName, string seqTaxonomy){
-       try {
-               numSeqs++;
-               
-               map<string, int>::iterator childPointer;
-               
-               int currentNode = 0;
-               int level = 1;
-               
-               tree[0].accessions.push_back(seqName);
-               m->removeConfidences(seqTaxonomy);
-               
-               string taxon;// = getNextTaxon(seqTaxonomy);
-       
-               while(seqTaxonomy != ""){
-                       
-                       level++;
-               
-                       if (m->control_pressed) { return 0; }
-                       
-                       //somehow the parent is getting one too many accnos
-                       //use print to reassign the taxa id
-                       taxon = getNextTaxon(seqTaxonomy, seqName);
-                       
-                       if (taxon == "") {  m->mothurOut(seqName + " has an error in the taxonomy.  This may be due to a ;;"); m->mothurOutEndLine(); if (currentNode != 0) {  uniqueTaxonomies[currentNode] = currentNode; } break;  }
-                       
-                       childPointer = tree[currentNode].children.find(taxon);
-                       
-                       if(childPointer != tree[currentNode].children.end()){   //if the node already exists, move on
-                               currentNode = childPointer->second;
-                               tree[currentNode].accessions.push_back(seqName);
-                               name2Taxonomy[seqName] = currentNode;
-                       }
-                       else{                                                                                   //otherwise, create it
-                               tree.push_back(TaxNode(taxon));
-                               numNodes++;
-                               tree[currentNode].children[taxon] = numNodes-1;
-                               tree[numNodes-1].parent = currentNode;
-                               
-                               currentNode = tree[currentNode].children[taxon];
-                               tree[currentNode].accessions.push_back(seqName);
-                               name2Taxonomy[seqName] = currentNode;
-                       }
-       
-                       if (seqTaxonomy == "") {   uniqueTaxonomies[currentNode] = currentNode; }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "addSeqToTree");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<int> PhyloTree::getGenusNodes() {
-       try {
-               genusIndex.clear();
-               //generate genusIndexes
-               map<int, int>::iterator it2;
-               for (it2=uniqueTaxonomies.begin(); it2!=uniqueTaxonomies.end(); it2++) {  genusIndex.push_back(it2->first);     }
-               
-               return genusIndex;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "getGenusNodes");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<int> PhyloTree::getGenusTotals()        {
-       try {
-       
-               if (calcTotals) {
-                       totals.clear();
-                       //reset counts because we are on a new word
-                       for (int j = 0; j < genusIndex.size(); j++) {
-                               totals.push_back(tree[genusIndex[j]].accessions.size());
-                       }
-                       return totals;
-               }else{
-                       return totals;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "getGenusNodes");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void PhyloTree::assignHeirarchyIDs(int index){
-       try {
-               map<string,int>::iterator it;
-               int counter = 1;
-               
-               for(it=tree[index].children.begin();it!=tree[index].children.end();it++){
-                       tree[it->second].heirarchyID = tree[index].heirarchyID + '.' + toString(counter);
-                       counter++;
-                       tree[it->second].level = tree[index].level + 1;
-                                               
-                       //save maxLevel for binning the unclassified seqs
-                       if (tree[it->second].level > maxLevel) { maxLevel = tree[it->second].level; } 
-                       
-                       assignHeirarchyIDs(it->second);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "assignHeirarchyIDs");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void PhyloTree::setUp(string tfile){
-       try{
-               string taxFileNameTest = tfile.substr(0,tfile.find_last_of(".")+1) + "tree.sum";
-               
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-                       if (pid == 0) {  binUnclassified(taxFileNameTest);  }
-               
-               #else
-                       binUnclassified(taxFileNameTest); 
-               #endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "setUp");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void PhyloTree::binUnclassified(string file){
-       try {
-       
-               ofstream out;
-               m->openOutputFile(file, out);
-               
-               map<string, int>::iterator itBin;
-               map<string, int>::iterator childPointer;
-               
-               vector<TaxNode> copy = tree;
-               
-               //fill out tree
-               fillOutTree(0, copy);
-       
-               //get leaf nodes that may need extension
-               for (int i = 0; i < copy.size(); i++) {  
-
-                       if (copy[i].children.size() == 0) {
-                               leafNodes[i] = i;
-                       }
-               }
-               
-               int copyNodes = copy.size();
-       
-               //go through the seqs and if a sequence finest taxon is not the same level as the most finely defined taxon then classify it as unclassified where necessary
-               map<int, int>::iterator itLeaf;
-               for (itLeaf = leafNodes.begin(); itLeaf != leafNodes.end(); itLeaf++) {
-                       
-                       if (m->control_pressed) {  out.close(); break;  }
-                       
-                       int level = copy[itLeaf->second].level;
-                       int currentNode = itLeaf->second;
-                       
-                       //this sequence is unclassified at some levels
-                       while(level < maxLevel){
-               
-                               level++;
-                       
-                               string taxon = "unclassified";  
-                               
-                               //does the parent have a child names 'unclassified'?
-                               childPointer = copy[currentNode].children.find(taxon);
-                               
-                               if(childPointer != copy[currentNode].children.end()){   //if the node already exists, move on
-                                       currentNode = childPointer->second; //currentNode becomes 'unclassified'
-                               }
-                               else{                                                                                   //otherwise, create it
-                                       copy.push_back(TaxNode(taxon));
-                                       copyNodes++;
-                                       copy[currentNode].children[taxon] = copyNodes-1;
-                                       copy[copyNodes-1].parent = currentNode;
-                                       copy[copyNodes-1].level = copy[currentNode].level + 1;
-                                                                       
-                                       currentNode = copy[currentNode].children[taxon];
-                               }
-                       }
-               }
-               
-               if (!m->control_pressed) {
-                       //print copy tree
-                       print(out, copy);
-               }
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "binUnclassified");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void PhyloTree::fillOutTree(int index, vector<TaxNode>& copy) {
-       try {
-       
-               map<string,int>::iterator it;
-               
-               it = copy[index].children.find("unclassified");
-               if (it == copy[index].children.end()) { //no unclassified at this level
-                       string taxon = "unclassified";
-                       copy.push_back(TaxNode(taxon));
-                       copy[index].children[taxon] = copy.size()-1;
-                       copy[copy.size()-1].parent = index;
-                       copy[copy.size()-1].level = copy[index].level + 1;
-               }
-               
-               if (tree[index].level < maxLevel) {
-                       for(it=tree[index].children.begin();it!=tree[index].children.end();it++){ //check your children
-                               fillOutTree(it->second, copy);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "fillOutTree");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string PhyloTree::getFullTaxonomy(string seqName) {
-       try {
-               string tax = "";
-               
-               int currentNode = name2Taxonomy[seqName];
-               
-               while (tree[currentNode].parent != -1) {
-                       tax = tree[currentNode].name + ";" + tax;
-                       currentNode = tree[currentNode].parent;
-               }
-               
-               return tax;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "getFullTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void PhyloTree::print(ofstream& out, vector<TaxNode>& copy){
-       try {
-               
-               //output mothur version
-               out << "#" << m->getVersion() << endl;
-               
-               out << copy.size() << endl;
-               
-               out << maxLevel << endl;
-                               
-               for (int i = 0; i < copy.size(); i++) {
-                               
-                       out << copy[i].level << '\t'<< copy[i].name << '\t' << copy[i].children.size() << '\t';
-                       
-                       map<string,int>::iterator it;
-                       for(it=copy[i].children.begin();it!=copy[i].children.end();it++){
-                               out << it->first << '\t' << it->second << '\t';
-                       }
-                       out << endl;
-               }
-               
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "print");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void PhyloTree::printTreeNodes(string treefilename) {
-       try {
-       
-               #ifdef USE_MPI
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-                       if (pid == 0) {  
-               
-               #endif
-
-                       ofstream outTree;
-                       m->openOutputFile(treefilename, outTree);
-                       
-                       //output mothur version
-                       outTree << "#" << m->getVersion() << endl;
-                       
-                       //print treenodes
-                       outTree << tree.size() << endl;
-                       for (int i = 0; i < tree.size(); i++) {
-                               outTree << tree[i].name << '\t' << tree[i].level << '\t' << tree[i].parent << endl;
-                       }
-                       
-                       //print genus nodes
-                       outTree << endl << uniqueTaxonomies.size() << endl;
-                       map<int, int>::iterator it2;
-                       for (it2=uniqueTaxonomies.begin(); it2!=uniqueTaxonomies.end(); it2++) {  outTree << it2->first << '\t' << tree[it2->first].accessions.size() << endl;  }
-                       outTree << endl;
-                       
-                       outTree.close();
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "printTreeNodes");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-TaxNode PhyloTree::get(int i ){
-       try {
-               if (i < tree.size()) {  return tree[i];  }
-               else {  cout << i << '\t' << tree.size() << endl ; m->mothurOut("Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1); }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "get");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-TaxNode PhyloTree::get(string seqName){
-       try {
-               map<string, int>::iterator itFind = name2Taxonomy.find(seqName);
-       
-               if (itFind != name2Taxonomy.end()) {  return tree[name2Taxonomy[seqName]];  }
-               else { m->mothurOut("Cannot find " + seqName + ". Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1);}
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "get");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string PhyloTree::getName(int i ){
-       try {
-               if (i < tree.size()) {  return tree[i].name;     }
-               else { m->mothurOut("Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1); }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "get");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PhyloTree::getIndex(string seqName){
-       try {
-               map<string, int>::iterator itFind = name2Taxonomy.find(seqName);
-       
-               if (itFind != name2Taxonomy.end()) {  return name2Taxonomy[seqName];  }
-               else { m->mothurOut("Cannot find " + seqName + ". Mismatch with taxonomy and template files. Cannot continue."); m->mothurOutEndLine(); exit(1);}
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "get");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-bool PhyloTree::ErrorCheck(vector<string> templateFileNames){
-       try {
-       
-               bool okay = true;
-               templateFileNames.push_back("unknown");
-               
-               map<string, int>::iterator itFind;
-               map<string, int> taxonomyFileNames = name2Taxonomy;
-               
-               for (int i = 0; i < templateFileNames.size(); i++) {
-                       itFind = taxonomyFileNames.find(templateFileNames[i]);
-                       
-                       if (itFind != taxonomyFileNames.end()) { //found it so erase it
-                               taxonomyFileNames.erase(itFind);
-                       }else {
-                               m->mothurOut(templateFileNames[i] + " is in your template file and is not in your taxonomy file. Please correct."); m->mothurOutEndLine();
-                               okay = false;
-                       }
-                       
-                       //templateFileNames.erase(templateFileNames.begin()+i);
-                       //i--;
-               }
-               templateFileNames.clear();
-               
-               if (taxonomyFileNames.size() > 0) { //there are names in tax file that are not in template
-                       okay = false;
-                       
-                       for (itFind = taxonomyFileNames.begin(); itFind != taxonomyFileNames.end(); itFind++) {
-                               m->mothurOut(itFind->first + " is in your taxonomy file and is not in your template file. Please correct."); m->mothurOutEndLine();
-                       }
-               }
-               
-               return okay;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhyloTree", "ErrorCheck");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-       
-
-
-       
diff --git a/phylotree.h b/phylotree.h
deleted file mode 100644 (file)
index 7aae8f1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef DOTAXONOMY_H
-#define DOTAXONOMY_H
-
-/*
- * phylotree.h
- *  
- *
- *  Created by Pat Schloss on 6/17/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/**************************************************************************************************/
-
-struct TaxNode {
-       vector<string> accessions;      //names of seqs in this branch of tree
-       map<string, int> children;  //childs name to index in tree
-       int parent, childNumber, level;
-       string name, heirarchyID;
-       
-       TaxNode(string n) : name(n), level(0), parent(-1) {             }
-       TaxNode(){}
-};
-
-/**************************************************************************************************/
-
-class PhyloTree {
-
-public:
-       PhyloTree();
-       PhyloTree(string);  //pass it a taxonomy file and it makes the tree
-       PhyloTree(ifstream&, string);  //pass it a taxonomy file and it makes the train.tree
-       ~PhyloTree() {};
-       int addSeqToTree(string, string);
-       void assignHeirarchyIDs(int);
-       void printTreeNodes(string); //used by bayesian to save time
-       vector<int> getGenusNodes();
-       vector<int> getGenusTotals();   
-       void setUp(string);  //used to create file needed for summary file if you use () constructor and add seqs manually instead of passing taxonomyfile
-               
-       TaxNode get(int i);                             
-       TaxNode get(string seqName);
-       string getName(int i);                  
-       int getIndex(string seqName);   
-       string getFullTaxonomy(string);  //pass a sequence name return taxonomy
-       
-       int getMaxLevel()               {       return maxLevel;        }
-       int getNumSeqs()                {       return numSeqs;         }
-       int getNumNodes()               {       return tree.size();     }
-       
-       bool ErrorCheck(vector<string>);
-       
-private:
-       string getNextTaxon(string&, string);
-       void print(ofstream&, vector<TaxNode>&); //used to create static reference taxonomy file
-       void fillOutTree(int, vector<TaxNode>&); //used to create static reference taxonomy file
-       void binUnclassified(string);
-       
-       vector<TaxNode> tree;
-       vector<int> genusIndex; //holds the indexes in tree where the genus level taxonomies are stored
-       vector<int> totals; //holds the numSeqs at each genus level taxonomy
-       map<string, int> name2Taxonomy;  //maps name to index in tree
-       map<int, int> uniqueTaxonomies;  //map of unique taxonomies
-       map<int, int> leafNodes; //used to create static reference taxonomy file
-       //void print(int, ofstream&);
-       int numNodes;
-       int numSeqs;
-       int maxLevel;
-       bool calcTotals;
-       MothurOut* m;
-};
-
-/**************************************************************************************************/
-
-#endif
-
-
diff --git a/phylotypecommand.cpp b/phylotypecommand.cpp
deleted file mode 100644 (file)
index 2d2db08..0000000
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
- *  phylotypecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/20/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "phylotypecommand.h"
-#include "phylotree.h"
-#include "listvector.hpp"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-
-//**********************************************************************************************************************
-vector<string> PhylotypeCommand::setParameters(){      
-       try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pcutoff("cutoff", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PhylotypeCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The phylotype command reads a taxonomy file and outputs a .list, .rabund and .sabund file. \n";
-               helpString += "The phylotype command parameter options are taxonomy, cutoff and label. The taxonomy parameter is required.\n";
-               helpString += "The cutoff parameter allows you to specify the level you want to stop at.  The default is the highest level in your taxonomy file. \n";
-               helpString += "For example: taxonomy = Bacteria;Bacteroidetes-Chlorobi;Bacteroidetes; - cutoff=2, would truncate the taxonomy to Bacteria;Bacteroidetes-Chlorobi; \n";
-               helpString += "For the cutoff parameter levels count up from the root of the phylotree. This enables you to look at the grouping down to a specific resolution, say the genus level.\n";
-               helpString += "The label parameter allows you to specify which level you would like, and are separated by dashes.  The default all levels in your taxonomy file. \n";
-               helpString += "For the label parameter, levels count down from the root to keep the output similiar to mothur's other commands which report information from finer resolution to coarser resolutions.\n";
-               helpString += "The phylotype command should be in the following format: \n";
-               helpString += "phylotype(taxonomy=yourTaxonomyFile, cutoff=yourCutoff, label=yourLabels) \n";
-               helpString += "Eaxample: phylotype(taxonomy=amazon.taxonomy, cutoff=5, label=1-3-5).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-PhylotypeCommand::PhylotypeCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "PhylotypeCommand");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-PhylotypeCommand::PhylotypeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       taxonomyFileName = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxonomyFileName == "not found") { 
-                               taxonomyFileName = m->getTaxonomyFile(); 
-                               if (taxonomyFileName != "") {  m->mothurOut("Using " + taxonomyFileName + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current files. taxonomy is a required parameter."); m->mothurOutEndLine(); 
-                                       abort = true; 
-                               }
-                       }else if (taxonomyFileName == "not open") { taxonomyFileName = ""; abort = true; }      
-                       else { m->setTaxonomyFile(taxonomyFileName); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { readNamesFile(); m->setNameFile(namefile); }     
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(taxonomyFileName); //if user entered a file with a path then preserve it        
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "cutoff", false);
-                       if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; allLines = 1; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(taxonomyFileName);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "PhylotypeCommand");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-
-int PhylotypeCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //reads in taxonomy file and makes all the taxonomies the same length 
-               //by appending the last taxon to a given taxonomy as many times as needed to 
-               //make it as long as the longest taxonomy in the file 
-               TaxEqualizer* taxEqual = new TaxEqualizer(taxonomyFileName, cutoff, outputDir);
-               
-               if (m->control_pressed) { delete taxEqual; return 0; }
-               
-               string equalizedTaxFile = taxEqual->getEqualizedTaxFile();
-               
-               delete taxEqual;
-               
-               //build taxonomy tree from equalized file
-               PhyloTree* tree = new PhyloTree(equalizedTaxFile);
-               vector<int> leaves = tree->getGenusNodes();
-               
-               //store leaf nodes in current map
-               for (int i = 0; i < leaves.size(); i++)         {       currentNodes[leaves[i]] = leaves[i];    }
-               
-               bool done = false;
-               if (tree->get(leaves[0]).parent == -1) {  m->mothurOut("Empty Tree"); m->mothurOutEndLine();    done = true;    }
-               
-               if (m->control_pressed) { delete tree; return 0; }
-               
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(taxonomyFileName));
-               
-               ofstream outList;
-               string outputListFile = fileroot + "tx.list";
-               m->openOutputFile(outputListFile, outList);
-               ofstream outSabund;
-               string outputSabundFile = fileroot + "tx.sabund";
-               m->openOutputFile(outputSabundFile, outSabund);
-               ofstream outRabund;
-               string outputRabundFile = fileroot + "tx.rabund";
-               m->openOutputFile(outputRabundFile, outRabund);
-               
-               outputNames.push_back(outputListFile); outputTypes["list"].push_back(outputListFile);
-               outputNames.push_back(outputSabundFile); outputTypes["sabund"].push_back(outputSabundFile);
-               outputNames.push_back(outputRabundFile); outputTypes["rabund"].push_back(outputRabundFile);
-               
-               int count = 1;          
-               //start at leaves of tree and work towards root, processing the labels the user wants
-               while((!done) && ((allLines == 1) || (labels.size() != 0))) {
-               
-                       string level = toString(count); 
-                       count++;
-                       
-                       if (m->control_pressed) { 
-                               outRabund.close(); outSabund.close(); outList.close();
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                               delete tree; return 0; 
-                       }
-                       
-                       //is this a level the user want output for
-                       if(allLines == 1 || labels.count(level) == 1){  
-                               
-                               //output level
-                               m->mothurOut(level); m->mothurOutEndLine();
-                               
-                               ListVector list;
-                               list.setLabel(level);
-                
-                               //go through nodes and build listvector 
-                               for (itCurrent = currentNodes.begin(); itCurrent != currentNodes.end(); itCurrent++) {
-                       
-                                       //get parents
-                                       TaxNode node = tree->get(itCurrent->first);
-                                       parentNodes[node.parent] = node.parent;
-                                       
-                                       vector<string> names = node.accessions;
-                                       
-                                       //make the names compatable with listvector
-                                       string name = "";
-                                       for (int i = 0; i < names.size(); i++) {  
-                        
-                        if (names[i] != "unknown") {
-                            if (namefile != "") {      
-                                map<string, string>::iterator itNames = namemap.find(names[i]);  //make sure this name is in namefile
-                                
-                                if (itNames != namemap.end()) {  name += namemap[names[i]] + ",";   } //you found it in namefile
-                                else { m->mothurOut(names[i] + " is not in your namefile, please correct."); m->mothurOutEndLine(); exit(1);  }
-                                
-                            }else{   name += names[i] + ",";   }
-                        }
-                                       }
-                                       name = name.substr(0, name.length()-1);  //rip off extra ','
-                                       //add bin to list vector
-                                       if (name != "") { list.push_back(name); } //caused by unknown
-                               }       
-                               
-                               //print listvector
-                               list.print(outList);
-                               //print rabund
-                               list.getRAbundVector().print(outRabund);
-                               //print sabund
-                               list.getSAbundVector().print(outSabund);
-                       
-                               labels.erase(level);
-                               
-                       }else {
-                               
-                               //just get parents
-                               for (itCurrent = currentNodes.begin(); itCurrent != currentNodes.end(); itCurrent++) {
-                                       int parent = tree->get(itCurrent->first).parent;
-                                       parentNodes[parent] = parent;
-                               }
-                       }
-                       
-                       //move up a level
-                       currentNodes = parentNodes;
-                       parentNodes.clear();
-                       
-                       //have we reached the rootnode
-                       if (tree->get(currentNodes.begin()->first).parent == -1)  {  done = true;  }
-               }
-                       
-               outList.close();
-               outSabund.close();
-               outRabund.close();      
-               
-               delete tree;
-               
-               if (m->control_pressed) { 
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                       return 0; 
-               }
-               
-               //set list file as new current listfile
-               string current = "";
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               //set rabund file as new current rabundfile
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               //set sabund file as new current sabundfile
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "execute");
-               exit(1);
-       }
-}
-/*****************************************************************/
-int PhylotypeCommand::readNamesFile() {
-       try {
-                               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               string first, second;
-               map<string, string>::iterator itNames;
-               
-               while(!in.eof()) {
-                       in >> first >> second; m->gobble(in);
-                       
-                       itNames = namemap.find(first);
-                       if (itNames == namemap.end()) {  
-                               namemap[first] = second; 
-                       }else {  m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); namemap.clear(); namefile = ""; return 1; }                   
-               }
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PhylotypeCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
-/**********************************************************************************************************************/
diff --git a/phylotypecommand.h b/phylotypecommand.h
deleted file mode 100644 (file)
index ecc7376..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef PHYLOTYPECOMMAND_H
-#define PHYLOTYPECOMMAND_H
-
-
-/*
- *  phylotypecommand.h
- *  Mothur
- *
- *  Created by westcott on 11/20/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "taxonomyequalizer.h"
-#include "command.hpp"
-
-/*************************************************************************/
-
-class PhylotypeCommand : public Command {
-       
-public:
-       PhylotypeCommand(string);       
-       PhylotypeCommand();
-       ~PhylotypeCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "phylotype";           }
-       string getCommandCategory()             { return "Clustering";          }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Phylotype"; }
-       string getDescription()         { return "cluster your sequences into OTUs based on their classifications"; }
-
-       int execute();
-       void help() { m->mothurOut(getHelpString()); }
-       
-private:
-       bool abort, allLines;
-       string taxonomyFileName, label, outputDir, namefile;
-       set<string> labels; //holds labels to be used
-       int cutoff;
-       map<string, string> namemap;
-       vector<string> outputNames;
-       map<string, vector<string> > outputTypes;
-       
-       map<int, int> currentNodes;
-       map<int, int> parentNodes;
-       map<int, int>::iterator itCurrent;
-       
-       int readNamesFile();
-
-};
-
-
-/*************************************************************************/
-
-
-#endif
-
-
-
diff --git a/pintail.cpp b/pintail.cpp
deleted file mode 100644 (file)
index b9f2434..0000000
+++ /dev/null
@@ -1,775 +0,0 @@
-/*
- *  pintail.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "pintail.h"
-#include "ignoregaps.h"
-#include "eachgapdist.h"
-
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareQuanMembers(quanMember left, quanMember right){
-       return (left.score < right.score);      
-} 
-//***************************************************************************************************************
-
-Pintail::Pintail(string filename, string temp, bool f, int p, string mask, string cons, string q, int win, int inc, string o) : Chimera() { 
-       try {
-       
-               fastafile = filename; 
-               templateFileName = temp; templateSeqs = readSeqs(temp);
-               filter = f;
-               processors = p;
-               setMask(mask);
-               consfile = cons;
-               quanfile = q;
-               window = win;
-               increment = inc; 
-               outputDir = o; 
-               
-               distcalculator = new eachGapDist();
-               decalc = new DeCalculator();
-               
-               doPrep();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "Pintail");
-               exit(1);
-       }
-
-}
-//***************************************************************************************************************
-
-Pintail::~Pintail() {
-       try {
-               
-               delete distcalculator;
-               delete decalc; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "~Pintail");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int Pintail::doPrep() {
-       try {
-               
-               mergedFilterString = "";
-               windowSizesTemplate.resize(templateSeqs.size(), window);
-               quantiles.resize(100);  //one for every percent mismatch
-               quantilesMembers.resize(100);  //one for every percent mismatch
-               
-               //if the user does not enter a mask then you want to keep all the spots in the alignment
-               if (seqMask.length() == 0)      {       decalc->setAlignmentLength(templateSeqs[0]->getAligned().length());     }
-               else                                            {       decalc->setAlignmentLength(seqMask.length());                                           }
-               
-               decalc->setMask(seqMask);
-               
-       #ifdef USE_MPI
-               //do nothing
-       #else
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       //find breakup of templatefile for quantiles
-                       if (processors == 1) {   templateLines.push_back(new linePair(0, templateSeqs.size()));  }
-                       else { 
-                               for (int i = 0; i < processors; i++) {
-                                       templateLines.push_back(new linePair());
-                                       templateLines[i]->start = int (sqrt(float(i)/float(processors)) * templateSeqs.size());
-                                       templateLines[i]->end = int (sqrt(float(i+1)/float(processors)) * templateSeqs.size());
-                               }
-                       }
-               #else
-                       templateLines.push_back(new linePair(0, templateSeqs.size()));
-               #endif
-       #endif
-               
-               m->mothurOut("Getting conservation... "); cout.flush();
-               if (consfile == "") { 
-                       m->mothurOut("Calculating probability of conservation for your template sequences.  This can take a while...  I will output the frequency of the highest base in each position to a .freq file so that you can input them using the conservation parameter next time you run this command.  Providing the .freq file will improve speed.    "); cout.flush();
-                       probabilityProfile = decalc->calcFreq(templateSeqs, templateFileName); 
-                       if (m->control_pressed) {  return 0;  }
-                       m->mothurOut("Done."); m->mothurOutEndLine();
-               }else                           {   probabilityProfile = readFreq();    m->mothurOut("Done.");            }
-               m->mothurOutEndLine();
-               
-               //make P into Q
-               for (int i = 0; i < probabilityProfile.size(); i++)  { probabilityProfile[i] = 1 - probabilityProfile[i];  }  //
-               
-               bool reRead = false;
-               //create filter if needed for later
-               if (filter) {
-                                               
-                       //read in all query seqs
-                       vector<Sequence*> tempQuerySeqs = readSeqs(fastafile);
-                               
-                       vector<Sequence*> temp;
-                       //merge query seqs and template seqs
-                       temp = templateSeqs;
-                       for (int i = 0; i < tempQuerySeqs.size(); i++) {  temp.push_back(tempQuerySeqs[i]);  }
-       
-                       if (seqMask != "") {
-                           reRead = true;
-                               //mask templates
-                               for (int i = 0; i < temp.size(); i++) {
-                                       if (m->control_pressed) {  
-                                               for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i];  }
-                                               return 0; 
-                                       }
-                                       decalc->runMask(temp[i]);
-                               }
-                       }
-
-                       mergedFilterString = createFilter(temp, 0.5);
-                       
-                       if (m->control_pressed) {  
-                               for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i];  }
-                               return 0; 
-                       }
-                       
-                       //reread template seqs
-                       for (int i = 0; i < tempQuerySeqs.size(); i++) { delete tempQuerySeqs[i];  }
-               }
-               
-               
-               //quantiles are used to determine whether the de values found indicate a chimera
-               //if you have to calculate them, its time intensive because you are finding the de and deviation values for each 
-               //combination of sequences in the template
-               if (quanfile != "") {  
-                       quantiles = readQuantiles(); 
-               }else {
-                       if ((!filter) && (seqMask != "")) { //if you didn't filter but you want to mask. if you filtered then you did mask first above.
-                               reRead = true;
-                               //mask templates
-                               for (int i = 0; i < templateSeqs.size(); i++) {
-                                       if (m->control_pressed) {  return 0;  }
-                                       decalc->runMask(templateSeqs[i]);
-                               }
-                       }
-                       
-                       if (filter) { 
-                               reRead = true;
-                               for (int i = 0; i < templateSeqs.size(); i++) {
-                                       if (m->control_pressed) {  return 0;  }
-                                       runFilter(templateSeqs[i]);
-                               }
-                       }
-                       
-                       m->mothurOut("Calculating quantiles for your template.  This can take a while...  I will output the quantiles to a .quan file that you can input them using the quantiles parameter next time you run this command.  Providing the .quan file will dramatically improve speed.    "); cout.flush();
-                       if (processors == 1) { 
-                               quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size());
-                       }else {         createProcessesQuan();          }
-               
-                       if (m->control_pressed) {  return 0;  }
-                       
-                       string noOutliers, outliers;
-                       
-                       if ((!filter) && (seqMask == "")) {
-                               noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.quan";
-                       }else if ((!filter) && (seqMask != "")) { 
-                               noOutliers =m->getRootName(m->getSimpleName(templateFileName)) + "pintail.masked.quan";
-                       }else if ((filter) && (seqMask != "")) { 
-                               noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "masked.quan";
-                       }else if ((filter) && (seqMask == "")) { 
-                               noOutliers = m->getRootName(m->getSimpleName(templateFileName)) + "pintail.filtered." + m->getSimpleName(m->getRootName(fastafile)) + "quan";
-                       }
-
-                       decalc->removeObviousOutliers(quantilesMembers, templateSeqs.size());
-                       
-                       if (m->control_pressed) {  return 0;  }
-               
-                       string outputString = "#" + m->getVersion() + "\n";
-                       
-                       //adjust quantiles
-                       for (int i = 0; i < quantilesMembers.size(); i++) {
-                               vector<float> temp;
-                               
-                               if (quantilesMembers[i].size() == 0) {
-                                       //in case this is not a distance found in your template files
-                                       for (int g = 0; g < 6; g++) {
-                                               temp.push_back(0.0);
-                                       }
-                               }else{
-                                       
-                                       sort(quantilesMembers[i].begin(), quantilesMembers[i].end());
-                                       
-                                       //save 10%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.10)]);
-                                       //save 25%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.25)]);
-                                       //save 50%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.5)]);
-                                       //save 75%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.75)]);
-                                       //save 95%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.95)]);
-                                       //save 99%
-                                       temp.push_back(quantilesMembers[i][int(quantilesMembers[i].size() * 0.99)]);
-                                       
-                               }
-                               
-                               //output quan value
-                               outputString += toString(i+1) + "\t";                           
-                               for (int u = 0; u < temp.size(); u++) {   outputString += toString(temp[u]) + "\t"; }
-                               outputString += "\n";
-                               
-                               quantiles[i] = temp;
-                               
-                       }
-                       
-                       printQuanFile(noOutliers, outputString);
-                       
-                       //free memory
-                       quantilesMembers.clear();
-                       
-                       m->mothurOut("Done."); m->mothurOutEndLine();
-               }
-               
-               if (reRead) {
-                       for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i];  }
-                       templateSeqs.clear();
-                       templateSeqs = readSeqs(templateFileName);
-               }
-
-               
-               //free memory
-               for (int i = 0; i < templateLines.size(); i++) { delete templateLines[i];  }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "doPrep");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-Sequence Pintail::print(ostream& out, ostream& outAcc) {
-       try {
-               
-               int index = ceil(deviation);
-               
-               //is your DE value higher than the 95%
-               string chimera;
-               if (index != 0) {  //if index is 0 then its an exact match to a template seq
-                       if (quantiles[index][4] == 0.0) {
-                               chimera = "Your template does not include sequences that provide quantile values at distance " + toString(index);
-                       }else {
-                               if (DE > quantiles[index][4])           {       chimera = "Yes";        }
-                               else                                                            {       chimera = "No";         }
-                       }
-               }else{ chimera = "No";          }
-               
-               out << querySeq->getName() << '\t' << "div: " << deviation << "\tstDev: " << DE << "\tchimera flag: " << chimera << endl;
-               if (chimera == "Yes") {
-                       m->mothurOut(querySeq->getName() + "\tdiv: " + toString(deviation) + "\tstDev: " + toString(DE) + "\tchimera flag: " + chimera); m->mothurOutEndLine();
-                       outAcc << querySeq->getName() << endl;
-               }
-               out << "Observed\t";
-               
-               for (int j = 0; j < obsDistance.size(); j++) {  out << obsDistance[j] << '\t';  }
-               out << endl;
-               
-               out << "Expected\t";
-               
-               for (int m = 0; m < expectedDistance.size(); m++) {  out << expectedDistance[m] << '\t';  }
-               out << endl;
-               
-               return *querySeq;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "print");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-//***************************************************************************************************************
-Sequence Pintail::print(MPI_File& out, MPI_File& outAcc) {
-       try {
-               
-               string outputString = "";
-               int index = ceil(deviation);
-               
-               //is your DE value higher than the 95%
-               string chimera;
-               if (index != 0) {  //if index is 0 then its an exact match to a template seq
-                       if (quantiles[index][4] == 0.0) {
-                               chimera = "Your template does not include sequences that provide quantile values at distance " + toString(index);
-                       }else {
-                               if (DE > quantiles[index][4])           {       chimera = "Yes";        }
-                               else                                                            {       chimera = "No";         }
-                       }
-               }else{ chimera = "No";          }
-
-               outputString += querySeq->getName() + "\tdiv: " + toString(deviation) + "\tstDev: " + toString(DE) + "\tchimera flag: " + chimera + "\n";
-               if (chimera == "Yes") {
-                       cout << querySeq->getName() << "\tdiv: " << toString(deviation) << "\tstDev: " << toString(DE) << "\tchimera flag: " << chimera << endl;
-                       string outAccString = querySeq->getName() + "\n";
-                       
-                       MPI_Status statusAcc;
-                       int length = outAccString.length();
-                       char* buf = new char[length];
-                       memcpy(buf, outAccString.c_str(), length);
-                               
-                       MPI_File_write_shared(outAcc, buf, length, MPI_CHAR, &statusAcc);
-                       delete buf;
-
-                       return *querySeq;
-               }
-               outputString += "Observed\t";
-               
-               for (int j = 0; j < obsDistance.size(); j++) {  outputString += toString(obsDistance[j]) + "\t";  }
-               outputString += "\n";
-               
-               outputString += "Expected\t";
-               
-               for (int m = 0; m < expectedDistance.size(); m++) {  outputString += toString(expectedDistance[m]) + "\t";  }
-               outputString += "\n";
-               
-               MPI_Status status;
-               int length = outputString.length();
-               char* buf2 = new char[length];
-               memcpy(buf2, outputString.c_str(), length);
-                               
-               MPI_File_write_shared(out, buf2, length, MPI_CHAR, &status);
-               delete buf2;
-               
-               return *querySeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "print");
-               exit(1);
-       }
-}
-#endif
-//***************************************************************************************************************
-int Pintail::getChimeras(Sequence* query) {
-       try {
-               querySeq = query;
-               trimmed.clear();
-               windowSizes = window;
-                                                       
-               //find pairs has to be done before a mask
-               bestfit = findPairs(query);
-               
-               if (m->control_pressed) {  return 0; } 
-               
-               //if they mask  
-               if (seqMask != "") {
-                       decalc->runMask(query);
-                       decalc->runMask(bestfit);
-               }
-
-               if (filter) { //must be done after a mask
-                       runFilter(query);
-                       runFilter(bestfit);
-               }
-               
-                               
-               //trim seq
-               decalc->trimSeqs(query, bestfit, trimmed);  
-               
-               //find windows
-               it = trimmed.begin();
-               windowsForeachQuery = decalc->findWindows(query, it->first, it->second, windowSizes, increment);
-
-               //find observed distance
-               obsDistance = decalc->calcObserved(query, bestfit, windowsForeachQuery, windowSizes);
-               
-               if (m->control_pressed) {  return 0; } 
-                               
-               Qav = decalc->findQav(windowsForeachQuery, windowSizes, probabilityProfile);
-               
-               if (m->control_pressed) {  return 0; } 
-
-               //find alpha                    
-               seqCoef = decalc->getCoef(obsDistance, Qav);
-               
-               //calculating expected distance
-               expectedDistance = decalc->calcExpected(Qav, seqCoef);
-               
-               if (m->control_pressed) {  return 0; } 
-               
-               //finding de
-               DE = decalc->calcDE(obsDistance, expectedDistance);
-               
-               if (m->control_pressed) {  return 0; } 
-               
-               //find distance between query and closest match
-               it = trimmed.begin();
-               deviation = decalc->calcDist(query, bestfit, it->first, it->second); 
-               
-               delete bestfit;
-                                                                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "getChimeras");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-vector<float> Pintail::readFreq() {
-       try {
-               //read in probabilities and store in vector
-               int pos; float num; 
-
-               vector<float> prob;
-               set<int> h = decalc->getPos();  //positions of bases in masking sequence
-               
-       #ifdef USE_MPI
-               
-               MPI_File inMPI;
-               MPI_Offset size;
-               MPI_Status status;
-
-               //char* inFileName = new char[consfile.length()];
-               //memcpy(inFileName, consfile.c_str(), consfile.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, consfile.c_str());
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
-               MPI_File_get_size(inMPI, &size);
-               //delete inFileName;
-
-               char* buffer = new char[size];
-               MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-
-               string tempBuf = buffer;
-               delete buffer;
-
-               if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-               istringstream iss (tempBuf,istringstream::in);
-               
-               //read version
-               string line = m->getline(iss); m->gobble(iss);
-               
-               while(!iss.eof()) {
-                       iss >> pos >> num;
-       
-                       if (h.count(pos) > 0) {
-                               float Pi;
-                               Pi =  (num - 0.25) / 0.75; 
-                       
-                               //cannot have probability less than 0.
-                               if (Pi < 0) { Pi = 0.0; }
-
-                               //do you want this spot
-                               prob.push_back(Pi);  
-                       }
-                       
-                       m->gobble(iss);
-               }
-       
-               MPI_File_close(&inMPI);
-               
-       #else   
-
-               ifstream in;
-               m->openInputFile(consfile, in);
-               
-               //read version
-               string line = m->getline(in); m->gobble(in);
-                               
-               while(!in.eof()){
-                       
-                       in >> pos >> num;
-                       
-                       if (h.count(pos) > 0) {
-                               float Pi;
-                               Pi =  (num - 0.25) / 0.75; 
-                       
-                               //cannot have probability less than 0.
-                               if (Pi < 0) { Pi = 0.0; }
-
-                               //do you want this spot
-                               prob.push_back(Pi);  
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               
-       #endif
-       
-               return prob;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "readFreq");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-//calculate the distances from each query sequence to all sequences in the template to find the closest sequence
-Sequence* Pintail::findPairs(Sequence* q) {
-       try {
-               
-               Sequence* seqsMatches;  
-               
-               seqsMatches = decalc->findClosest(q, templateSeqs);
-               return seqsMatches;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "findPairs");
-               exit(1);
-       }
-}
-//**************************************************************************************************
-void Pintail::createProcessesQuan() {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  
-                               process++;
-                       }else if (pid == 0){
-                               
-                               quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, templateLines[process]->start, templateLines[process]->end);
-                               
-                               //write out data to file so parent can read it
-                               ofstream out;
-                               string s = toString(getpid()) + ".temp";
-                               m->openOutputFile(s, out);
-                                                               
-                               //output observed distances
-                               for (int i = 0; i < quantilesMembers.size(); i++) {
-                                       out << quantilesMembers[i].size() << '\t';
-                                       for (int j = 0; j < quantilesMembers[i].size(); j++) {
-                                               out << quantilesMembers[i][j] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent does its part
-               quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, templateLines[0]->start, templateLines[0]->end);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       ifstream in;
-                       string s = toString(processIDS[i]) + ".temp";
-                       m->openInputFile(s, in);
-                       
-                       vector< vector<float> > quan; 
-                       quan.resize(100);
-                       
-                       //get quantiles
-                       for (int h = 0; h < quan.size(); h++) {
-                               int num;
-                               in >> num; 
-                               
-                               m->gobble(in);
-
-                               vector<float> q;  float w; 
-                               for (int j = 0; j < num; j++) {
-                                       in >> w;
-                                       q.push_back(w);
-                               }
-
-                               quan[h] = q;
-                               m->gobble(in);
-                       }
-                       
-       
-                       //save quan in quantiles
-                       for (int j = 0; j < quan.size(); j++) {
-                               //put all values of q[i] into quan[i]
-                               for (int l = 0; l < quan[j].size(); l++) {  quantilesMembers[j].push_back(quan[j][l]);   }
-                               //quantilesMembers[j].insert(quantilesMembers[j].begin(), quan[j].begin(), quan[j].end());
-                       }
-                                       
-                       in.close();
-                       m->mothurRemove(s);
-               }
-
-#else
-               quantilesMembers = decalc->getQuantiles(templateSeqs, windowSizesTemplate, window, probabilityProfile, increment, 0, templateSeqs.size());
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "createProcessesQuan");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-vector< vector<float> > Pintail::readQuantiles() {
-       try {
-               int num; 
-               float ten, twentyfive, fifty, seventyfive, ninetyfive, ninetynine; 
-               
-               vector< vector<float> > quan;
-               vector <float> temp; temp.resize(6, 0);
-               
-               //to fill 0
-               quan.push_back(temp); 
-
-       #ifdef USE_MPI
-               
-               MPI_File inMPI;
-               MPI_Offset size;
-               MPI_Status status;
-               
-               //char* inFileName = new char[quanfile.length()];
-               //memcpy(inFileName, quanfile.c_str(), quanfile.length());
-               
-               char inFileName[1024];
-               strcpy(inFileName, quanfile.c_str());
-
-               MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  
-               MPI_File_get_size(inMPI, &size);
-               //delete inFileName;
-
-
-               char* buffer = new char[size];
-               MPI_File_read(inMPI, buffer, size, MPI_CHAR, &status);
-
-               string tempBuf = buffer;
-               if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-               istringstream iss (tempBuf,istringstream::in);
-               delete buffer;
-               
-               //read version
-               string line = m->getline(iss); m->gobble(iss);
-               
-               while(!iss.eof()) {
-                       iss >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine; 
-                       
-                       temp.clear();
-                       
-                       temp.push_back(ten); 
-                       temp.push_back(twentyfive);
-                       temp.push_back(fifty);
-                       temp.push_back(seventyfive);
-                       temp.push_back(ninetyfive);
-                       temp.push_back(ninetynine);
-                       
-                       quan.push_back(temp);  
-                       
-                       m->gobble(iss);
-               }
-       
-               MPI_File_close(&inMPI);
-               
-       #else   
-
-               ifstream in;
-               m->openInputFile(quanfile, in);
-               
-               //read version
-               string line = m->getline(in); m->gobble(in);
-                       
-               while(!in.eof()){
-                       
-                       in >> num >> ten >> twentyfive >> fifty >> seventyfive >> ninetyfive >> ninetynine; 
-                       
-                       temp.clear();
-                       
-                       temp.push_back(ten); 
-                       temp.push_back(twentyfive);
-                       temp.push_back(fifty);
-                       temp.push_back(seventyfive);
-                       temp.push_back(ninetyfive);
-                       temp.push_back(ninetynine);
-                       
-                       quan.push_back(temp);  
-       
-                       m->gobble(in);
-               }
-               in.close();
-       #endif
-       
-               return quan;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "readQuantiles");
-               exit(1);
-       }
-}
-//***************************************************************************************************************/
-
-void Pintail::printQuanFile(string file, string outputString) {
-       try {
-       
-               #ifdef USE_MPI
-               
-                       MPI_File outQuan;
-                       MPI_Status status;
-                       
-                       int pid;
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-                       int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY;
-
-                       //char* FileName = new char[file.length()];
-                       //memcpy(FileName, file.c_str(), file.length());
-                       
-                       char FileName[1024];
-                       strcpy(FileName, file.c_str());
-                       
-                       if (pid == 0) {
-                               MPI_File_open(MPI_COMM_SELF, FileName, outMode, MPI_INFO_NULL, &outQuan);  //comm, filename, mode, info, filepointer
-                               
-                               int length = outputString.length();
-                               char* buf = new char[length];
-                               memcpy(buf, outputString.c_str(), length);
-                                       
-                               MPI_File_write(outQuan, buf, length, MPI_CHAR, &status);
-                               delete buf;
-
-                               MPI_File_close(&outQuan);
-                       }
-
-                       //delete FileName;
-               #else
-                       ofstream outQuan;
-                       m->openOutputFile(file, outQuan);
-                       
-                       outQuan << outputString;
-                       
-                       outQuan.close();
-               #endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Pintail", "printQuanFile");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************/
-
-
-
diff --git a/pintail.h b/pintail.h
deleted file mode 100644 (file)
index 92c3998..0000000
--- a/pintail.h
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef PINTAIL_H
-#define PINTAIL_H
-
-/*
- *  pintail.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "chimera.h"
-#include "dist.h"
-#include "decalc.h"
-
-/***********************************************************/
-//This class was created using the algorythms described in the 
-// "At Least 1 in 20 16S rRNA Sequence Records Currently Held in the Public Repositories is Estimated To Contain Substantial Anomalies" paper 
-//by Kevin E. Ashelford 1, Nadia A. Chuzhanova 3, John C. Fry 1, Antonia J. Jones 2 and Andrew J. Weightman 1.
-
-/***********************************************************/
-
-class Pintail : public Chimera {
-       
-       public:
-               Pintail(string, string, bool, int, string, string, string, int, int, string); //fastafile, templatefile, filter, processors, mask, conservation, quantile, window, increment, outputDir)        
-               ~Pintail();
-               
-               int getChimeras(Sequence*);
-               Sequence print(ostream&, ostream&);
-               
-               void setCons(string c)          { consfile = c;  }
-               void setQuantiles(string q) { quanfile = q;  }
-               
-               #ifdef USE_MPI
-               Sequence print(MPI_File&, MPI_File&);
-               #endif
-               
-       private:
-       
-               Dist* distcalculator;
-               DeCalculator* decalc;
-               int iters, window, increment, processors;
-               string fastafile, quanfile, consfile;
-               
-               vector<linePair*> templateLines;
-               Sequence* querySeq;
-                               
-               Sequence* bestfit;  //closest match to query in template
-               
-               vector<float>  obsDistance;  //obsDistance is the vector of observed distances for query 
-               vector<float>  expectedDistance;  //expectedDistance is the vector of expected distances for query
-               float deviation;  //deviation is the percentage of mismatched pairs over the whole seq between query and its best match.
-               vector<int>  windowsForeachQuery;  // windowsForeachQuery is a vector containing the starting spot in query aligned sequence for each window.
-                                                                               //this is needed so you can move by bases and not just spots in the alignment
-                                                                               
-               int  windowSizes;                       //windowSizes = window size of query
-               vector<int> windowSizesTemplate;    //windowSizesTemplate[0] = window size of templateSeqs[0]
-               
-               map<int, int> trimmed;    //trimmed = start and stop of trimmed sequences for query
-               map<int, int>::iterator it;
-               
-               vector<float>  Qav;     //Qav is the vector of average variablility for query
-               float  seqCoef;         //seqCoef is the coeff for query
-               float DE;                       //DE is the deviaation for query
-               vector<float> probabilityProfile;
-               vector< vector<float> > quantiles;  //quantiles[0] is the vector of deviations with ceiling score of 1, quantiles[1] is the vector of deviations with ceiling score of 2...
-               vector< vector<float> > quantilesMembers;  //quantiles[0] is the vector of deviations with ceiling score of 1, quantiles[1] is the vector of deviations with ceiling score of 2...
-               set<int>  h;
-               string mergedFilterString;
-               
-               vector< vector<float> > readQuantiles();
-               vector<float> readFreq();
-               Sequence* findPairs(Sequence*);
-                       
-               void createProcessesQuan();
-               int doPrep();
-               void printQuanFile(string, string);
-               
-};
-
-/***********************************************************/
-
-#endif
-
diff --git a/pipelinepdscommand.cpp b/pipelinepdscommand.cpp
deleted file mode 100644 (file)
index 968ba4f..0000000
+++ /dev/null
@@ -1,810 +0,0 @@
-/*
- *  pipelinepdscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/5/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "pipelinepdscommand.h"
-#include "sffinfocommand.h"
-#include "commandoptionparser.hpp"
-
-//**********************************************************************************************************************
-vector<string> PipelineCommand::setParameters(){       
-       try {
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(psff);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(poligos);
-               CommandParameter palign("align", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(palign);
-               CommandParameter pchimera("chimera", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(pchimera);
-               CommandParameter pclassify("classify", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(pclassify);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "oneRequired", "pipe",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter ppipeline("pipeline", "InputTypes", "", "", "none", "oneRequired", "none",false,false); parameters.push_back(ppipeline);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PipelineCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The pipeline.pds command is designed to guide you through your analysis using mothur.\n"; 
-               helpString += "The pipeline.pds command parameters are pipeline, sff, oligos, align, chimera, classify, taxonomy and processors.\n"; 
-               helpString += "The sff parameter allows you to enter your sff file. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The oligos parameter allows you to enter your oligos file. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The align parameter allows you to enter a template to use with the aligner. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The chimera parameter allows you to enter a template to use for chimera detection. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The classify parameter allows you to enter a template to use for classification. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The taxonomy parameter allows you to enter a taxonomy file for the classify template to use for classification. It is required, if not using pipeline parameter.\n"; 
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "The pipeline parameter allows you to enter your own pipeline file. This file should look like a mothur batchfile, but where you would be using a mothur generated file, you can use current instead.\n"; 
-               helpString += "Example: trim.seqs(processors=8, allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, fasta=may1.v13.fasta, oligos=may1.v13.oligos, qfile=may1.v13.qual)\n";
-               helpString += "then, you could enter unique.seqs(fasta=current), and mothur would use the .trim.fasta file from the trim.seqs command. \n";
-               helpString += "then you could enter align.seqs(candidate=current, template=silva.v13.align, processors=8). , and mothur would use the .trim.unique.fasta file from the unique.seqs command. \n";
-               helpString += "If no pipeline file is given then mothur will use Pat's pipeline. \n";
-               helpString += "Here is a list of the commands used in Pat's pipeline.\n"; 
-               helpString += "All paralellized commands will use the processors you entered.\n"; 
-               helpString += "The sffinfo command takes your sff file and extracts the fasta and quality files.\n"; 
-               helpString += "The trim.seqs command uses your oligos file and the quality and fasta files generated by sffinfo.\n"; 
-               helpString += "The trim.seqs command sets the following parameters: allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50.\n"; 
-               helpString += "The unique.seqs command uses the trimmed fasta file and removes redundant sequences, don't worry the names file generated by unique.seqs will be used in the pipeline to make sure they are included.\n"; 
-               helpString += "The align.seqs command aligns the unique sequences using the aligners default options. \n"; 
-               helpString += "The screen.seqs command screens the sequences using optimize=end-minlength. \n"; 
-               helpString += "The pipeline uses chimera.slayer to detect chimeras using the default options. \n";
-               helpString += "The pipeline removes all sequences determined to be chimeric by chimera.slayer. \n";
-               helpString += "The filter.seqs command filters the sequences using vertical=T, trump=. \n"; 
-               helpString += "The unique.seqs command uses the filtered fasta file and name file to remove sequences that have become redundant after filtering.\n"; 
-               helpString += "The pre.cluster command clusters sequences that have no more than 2 differences.\n"; 
-               helpString += "The dist.seqs command is used to generate a column and phylip formatted distance matrix using cutoff=0.20 for column.\n"; 
-               helpString += "The pipeline uses cluster with method=average, hard=T. \n";
-               helpString += "The classify.seqs command is used to classify the sequences using the bayesian method with a cutoff of 80.\n"; 
-               helpString += "The phylotype command is used to cluster the sequences based on their classification.\n"; 
-               helpString += "The clearcut command is used to generate a tree using neighbor=T. \n";
-               helpString += "The summary.single and summary.shared commands are run on the otu files from cluster and phylotype commands. \n";
-               helpString += "The summary.shared command uses calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc. \n";
-               helpString += "The summary.single command uses calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson. \n";
-               helpString += "The classify.otu command is used to get the concensus taxonomy for otu files from cluster and phylotype commands. \n";
-               helpString += "The phylo.diversity command run on the tree generated by clearcut with rarefy=T, iters=100. \n";
-               helpString += "The unifrac commands are also run on the tree generated by clearcut with random=F, distance=T. \n";
-               helpString += "\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-PipelineCommand::PipelineCommand(string option) {
-       try {
-               cFactory = CommandFactory::getInstance();
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters(); 
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("sff");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sff"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("oligos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("align");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["align"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("chimera");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["chimera"] = inputDir + it->second;          }
-                               }
-                               
-                               it = parameters.find("classify");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["classify"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("pipeline");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["pipeline"] = inputDir + it->second;         }
-                               }
-                       }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       pipeFilename = validParameter.validFile(parameters, "pipeline", true);
-                       if (pipeFilename == "not found") { pipeFilename = "";  }
-                       else if (pipeFilename == "not open") { pipeFilename = ""; abort = true; }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       if (pipeFilename != "") {
-                               abort = readUsersPipeline();
-                       }else{
-                               sffFile = validParameter.validFile(parameters, "sff", true);
-                               if (sffFile == "not found") { m->mothurOut("sff is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
-                               else if (sffFile == "not open") { sffFile = ""; abort = true; }
-                               else { m->setSFFFile(sffFile); }
-                                       
-                               oligosFile = validParameter.validFile(parameters, "oligos", true);
-                               if (oligosFile == "not found") { m->mothurOut("oligos is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
-                               else if (oligosFile == "not open") { oligosFile = ""; abort = true; }
-                                       
-                               alignFile = validParameter.validFile(parameters, "align", true);
-                               if (alignFile == "not found") { m->mothurOut("align is a required parameter for the pipeline command. Please provide the template to align with."); m->mothurOutEndLine(); abort = true;  }
-                               else if (alignFile == "not open") { alignFile = ""; abort = true; }
-
-                               chimeraFile = validParameter.validFile(parameters, "chimera", true);
-                               if (chimeraFile == "not found") { m->mothurOut("chimera is a required parameter for the pipeline command. Please provide the template to check for chimeras with."); m->mothurOutEndLine(); abort = true;  }
-                               else if (chimeraFile == "not open") { chimeraFile = ""; abort = true; }
-
-                               classifyFile = validParameter.validFile(parameters, "classify", true);
-                               if (classifyFile == "not found") { m->mothurOut("classify is a required parameter for the pipeline command. Please provide the template to use with the classifier."); m->mothurOutEndLine(); abort = true;  }
-                               else if (classifyFile == "not open") { classifyFile = ""; abort = true; }
-
-                               taxonomyFile = validParameter.validFile(parameters, "taxonomy", true);
-                               if (taxonomyFile == "not found") { m->mothurOut("taxonomy is a required parameter for the pipeline command."); m->mothurOutEndLine(); abort = true;  }
-                               else if (taxonomyFile == "not open") { taxonomyFile = ""; abort = true; }
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "PipelineCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int PipelineCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int start = time(NULL);
-               
-               if (pipeFilename == "") { 
-                       createPatsPipeline(); 
-                       
-                       //run Pats pipeline
-                       for (int i = 0; i < commands.size(); i++) {
-                               m->mothurOutEndLine(); m->mothurOut("mothur > " + commands[i]); m->mothurOutEndLine();
-                                                       
-                               if (m->control_pressed) { return 0; }
-
-                               CommandOptionParser parser(commands[i]);
-                               string commandName = parser.getCommandString();
-                               string options = parser.getOptionString();
-                                       
-                               #ifdef USE_MPI
-                                       int pid;
-                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                                       if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
-                               #endif
-                               
-                               //executes valid command
-                               Command* command = cFactory->getCommand(commandName, options, "pipe");
-                               command->execute();
-                               
-                               //add output files to list
-                               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
-                               map<string, vector<string> >::iterator itMade;
-                               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
-                                       vector<string> temp = itMade->second; 
-                                       for (int j = 0; j < temp.size(); j++) { outputNames.push_back(temp[j]); }
-                               }
-                                                                       
-                               #ifdef USE_MPI
-                                       }
-                               #endif
-                       }
-                       
-               }else {  runUsersPipeline(); }
-               
-               if (m->control_pressed) { return 0; }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run the pipeline analysis."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-bool PipelineCommand::readUsersPipeline(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(pipeFilename, in);
-               
-               string nextCommand = "";
-               
-               map<string, vector<string> > mothurMadeFiles;
-               
-               while(!in.eof()) {
-                       nextCommand = m->getline(in); m->gobble(in);
-
-                       if (nextCommand[0] != '#') {
-                               bool error = false;
-                               
-                               string commandName, options;
-                               error = parseCommand(nextCommand, commandName, options);
-                               
-                               if (error) { in.close(); return error; }
-                               if (commandName == "pipeline.pds") { m->mothurOut("Cannot run the pipeline.pds command from inside the pipeline.pds command."); m->mothurOutEndLine(); in.close(); return true; }
-                               
-                               error = checkForValidAndRequiredParameters(commandName, options, mothurMadeFiles);
-                               
-                               if (error) { in.close(); return error; }
-                       }
-               }
-               
-               in.close();
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "readUsersPipeline");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-bool PipelineCommand::parseCommand(string nextCommand, string& name, string& options){
-       try {
-               CommandOptionParser parser(nextCommand);
-               name = parser.getCommandString();
-               options = parser.getOptionString();
-               
-               if (name == "") { return true; } //name == "" if () are not right
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "parseCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-bool PipelineCommand::checkForValidAndRequiredParameters(string name, string options, map<string, vector<string> >& mothurMadeFiles){
-       try {
-                               
-               if (name == "system") { return false; }
-               
-               //get shell of the command so we can check to make sure its valid without running it
-               Command* command = cFactory->getCommand(name);
-                       
-               //check to make sure all parameters are valid for command
-               vector<string> validParameters = command->setParameters();
-               
-               OptionParser parser(options);
-               map<string, string> parameters = parser.getParameters(); 
-                       
-               ValidParameters validParameter;
-               map<string, string>::iterator it;
-               map<string, vector<string> >::iterator itMade;
-                       
-               for (it = parameters.begin(); it != parameters.end(); it++) { 
-                       
-                       if (validParameter.isValidParameter(it->first, validParameters, it->second) != true) {  return true;  } // not valid
-                       if (it->second == "current") {
-                               itMade = mothurMadeFiles.find(it->first);
-                               
-                               if (itMade == mothurMadeFiles.end()) {  
-                                       m->mothurOut("You have the " + it->first + " listed as a current file for the " + name + " command, but it seems mothur will not make that file in your current pipeline, please correct."); m->mothurOutEndLine();
-                                       return true;
-                               }
-                       }
-               }
-                       
-               //is the command missing any required
-               vector<CommandParameter> commandParameters = command->getParameters();
-               vector<string> requiredParameters;
-               for (int i = 0; i < commandParameters.size(); i++) {
-                       if (commandParameters[i].required) {
-                               requiredParameters.push_back(commandParameters[i].name);
-                       }
-               }
-               
-               for (int i = 0; i < requiredParameters.size(); i++) { 
-                       it = parameters.find(requiredParameters[i]);
-                       
-                       if (it == parameters.end()) { 
-                               
-                               string paraToLookFor = requiredParameters[i];
-                               
-                               //does mothur have a current file for this?
-                               itMade = mothurMadeFiles.find(requiredParameters[i]);
-                               
-                               if (itMade == mothurMadeFiles.end()) {
-                                       m->mothurOut(name + " requires the " + requiredParameters[i] + " parameter, please correct."); m->mothurOutEndLine(); 
-                       
-                               }
-                       }
-               }
-
-               
-               //update MothurMade
-               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
-               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
-                       mothurMadeFiles[itMade->first] = itMade->second; //adds any new types
-               }
-                       
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "checkForValidAndRequiredParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PipelineCommand::runUsersPipeline(){
-       try {
-               ifstream in;
-               m->openInputFile(pipeFilename, in);
-               
-               string nextCommand = "";
-               
-               map<string, vector<string> > mothurMadeFiles;
-               
-               while(!in.eof()) {
-                       nextCommand = m->getline(in);  m->gobble(in);
-               
-                       if (nextCommand[0] != '#') {
-                               CommandOptionParser parser(nextCommand);
-                               string commandName = parser.getCommandString();
-                               string options = parser.getOptionString();
-                                       
-                               if ((options != "") && (commandName != "system")) {
-                                       bool error = fillInMothurMade(options, mothurMadeFiles);
-                                       if (error) { in.close(); return 0; }
-                               }
-                               
-                               m->mothurOutEndLine(); m->mothurOut("mothur > " + commandName + "(" + options + ")"); m->mothurOutEndLine();
-                                                               
-                               if (m->control_pressed) { return 0; }
-                                       
-                               #ifdef USE_MPI
-                                       int pid;
-                                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                                       if ((cFactory->MPIEnabled(commandName)) || (pid == 0)) {
-                               #endif
-                               
-                               //executes valid command
-                               Command* command = cFactory->getCommand(commandName, options, "pipe");
-                               command->execute();
-                               
-                               //add output files to list
-                               map<string, vector<string> > thisCommandsFile = command->getOutputFiles();
-                               map<string, vector<string> >::iterator itMade;
-                               map<string, vector<string> >::iterator it;
-                               for (itMade = thisCommandsFile.begin(); itMade != thisCommandsFile.end(); itMade++) { 
-               
-                                       vector<string> temp = itMade->second;
-                                       for (int k = 0; k < temp.size(); k++) { outputNames.push_back(temp[k]); }  //
-                                       
-                                       //update Mothur Made for each file
-                                       it = mothurMadeFiles.find(itMade->first);
-                                       
-                                       if (it == mothurMadeFiles.end()) { //new type
-                       
-                                               mothurMadeFiles[itMade->first] = temp;
-                               
-                                       }else{ //update existing type
-                                               vector<string> oldFileNames = it->second;
-                                               //look at new files, see if an old version of the file exists, if so update, else just add.
-                                               //for example you may have abrecovery.fasta and amazon.fasta as old files and you created a new amazon.trim.fasta.
-                                               
-                                               for (int k = 0; k < temp.size(); k++) {
-                                                       
-                                                       //get base name
-                                                       string root = m->getSimpleName(temp[k]);
-                                                       string individual = "";
-                                                       for(int i=0;i<root.length();i++){
-                                                               if(root[i] == '.'){
-                                                                       root = individual;
-                                                                       break;
-                                                               }else{
-                                                                       individual += root[i];
-                                                               }
-                                                       }
-                                                       
-                                                       //look for that base name in oldfiles
-                                                       int spot = -1;
-                                                       for (int l = 0; l < oldFileNames.size(); l++) {
-                                                               int pos = oldFileNames[l].find(root);
-                                                               if (pos != string::npos) {
-                                                                       spot = l;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       
-                                                       //if you found it update it, else add it
-                                                       if (spot != -1) {
-                                                               mothurMadeFiles[it->first][spot] = temp[k];
-                                                       }else{
-                                                               mothurMadeFiles[it->first].push_back(temp[k]);
-                                                       }
-                                               }
-                                       }
-                               }
-                                                                       
-                               #ifdef USE_MPI
-                                       }
-                               #endif
-                       }
-               }
-               
-               in.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "runUsersPipeline");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-bool PipelineCommand::fillInMothurMade(string& options, map<string, vector<string> >& mothurMadeFiles){
-       try {
-               
-               OptionParser parser(options);
-               map<string, string> parameters = parser.getParameters(); 
-               map<string, string>::iterator it;
-               map<string, vector<string> >::iterator itMade;
-               
-               options = "";
-               
-               //fill in mothurmade filenames
-               for (it = parameters.begin(); it != parameters.end(); it++) { 
-                       string paraType = it->first;
-                       string tempOption = it->second;
-                       
-                       if (tempOption == "current") {
-                       
-                               itMade = mothurMadeFiles.find(paraType);
-                               
-                               if (itMade == mothurMadeFiles.end()) { 
-                                       m->mothurOut("Looking for a current " + paraType + " file, but it seems mothur has not made that file type in your current pipeline, please correct."); m->mothurOutEndLine();
-                                       return true;
-                               }else{
-                                       vector<string> temp = itMade->second;
-                                       
-                                       if (temp.size() > 1) {
-                                               //ask user which file to use
-                                               m->mothurOut("More than one file has been created for the " + paraType + " parameter. "); m->mothurOutEndLine();
-                                               for (int i = 0; i < temp.size(); i++) {
-                                                       m->mothurOut(toString(i) + " - " + temp[i]); m->mothurOutEndLine();
-                                               }
-                                               
-                                               m->mothurOut("Please select the number of the file you would like to use: ");
-                                               int num = 0;
-                                               cin >> num;
-                                               m->mothurOutJustToLog(toString(num)); m->mothurOutEndLine();
-                                               
-                                               if ((num < 0) || (num > (temp.size()-1))) { m->mothurOut("Not a valid response, quitting."); m->mothurOutEndLine(); return true; }
-                                               else {
-                                                       tempOption = temp[num];
-                                               }
-                               
-                                               //clears buffer so next command doesn't have error
-                                               string s;       
-                                               getline(cin, s);
-                                               
-                                               vector<string> newTemp;
-                                               for (int i = 0; i < temp.size(); i++) {
-                                                       if (i == num) { newTemp.push_back(temp[i]); }
-                                                       else {
-                                                               m->mothurOut("Would you like to remove " + temp[i] + " as an option for " + paraType + ", (y/n): "); m->mothurOutEndLine();
-                                                               string response;
-                                                               cin >> response;
-                                                               m->mothurOutJustToLog(response); m->mothurOutEndLine();
-                                                       
-                                                               if (response == "n") {  newTemp.push_back(temp[i]); }
-                                                       
-                                                               //clears buffer so next command doesn't have error
-                                                               string s;       
-                                                               getline(cin, s);
-                                                       }
-                                               }
-                                               
-                                               mothurMadeFiles[paraType] = newTemp;
-                                               
-                                               
-                                       }else if (temp.size() == 0){
-                                               m->mothurOut("Sorry, we seem to think you created a " + paraType + " file, but it seems mothur doesn't have a filename."); m->mothurOutEndLine();
-                                               return true;
-                                       }else{
-                                               tempOption = temp[0];
-                                       }
-                               }
-                       }
-                       
-                       options += it->first + "=" + tempOption + ", ";
-               }
-               
-               //rip off extra comma
-               options = options.substr(0, (options.length()-2));
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "fillInMothurMade");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-void PipelineCommand::createPatsPipeline(){
-       try {
-               
-               //sff.info command
-               string thisCommand = "sffinfo(sff=" + sffFile + ")";
-               commands.push_back(thisCommand);
-               
-               //trim.seqs command
-               string fastaFile = m->getRootName(m->getSimpleName(sffFile)) + "fasta";
-               string qualFile = m->getRootName(m->getSimpleName(sffFile)) + "qual";
-               thisCommand = "trim.seqs(processors=" + toString(processors) + ", fasta=current, allfiles=T, maxambig=0, maxhomop=8, flip=T, bdiffs=1, pdiffs=2, qwindowaverage=35, qwindowsize=50, oligos=" + oligosFile + ", qfile=current)";
-               commands.push_back(thisCommand);
-               
-               //unique.seqs
-               string groupFile = m->getRootName(m->getSimpleName(fastaFile)) + "groups";
-               qualFile =  m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual";
-               fastaFile =  m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
-               thisCommand = "unique.seqs(fasta=current)"; 
-               commands.push_back(thisCommand);
-               
-               //align.seqs
-               string nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "names";
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "unique" + m->getExtension(fastaFile);
-               thisCommand = "align.seqs(processors=" + toString(processors) + ", candidate=current, template=" + alignFile + ")";
-               commands.push_back(thisCommand);
-               
-               //screen.seqs
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "align";
-               thisCommand = "screen.seqs(processors=" + toString(processors) + ", fasta=current, name=current, group=current, optimize=end-minlength)";
-               commands.push_back(thisCommand);
-               
-               //chimera.slayer
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "good" + m->getExtension(fastaFile);
-               nameFile = m->getRootName(m->getSimpleName(nameFile)) + "good" + m->getExtension(nameFile);
-               groupFile = m->getRootName(m->getSimpleName(groupFile)) + "good" + m->getExtension(groupFile);
-               thisCommand = "chimera.slayer(processors=" + toString(processors) + ", fasta=current, template=" + chimeraFile + ")";
-               commands.push_back(thisCommand);
-               
-               //remove.seqs
-               string accnosFile = m->getRootName(m->getSimpleName(fastaFile))  + "slayer.accnos";
-               thisCommand = "remove.seqs(fasta=current, name=current, group=current, accnos=current, dups=T)";
-               commands.push_back(thisCommand);
-               
-               //filter.seqs
-               nameFile = m->getRootName(m->getSimpleName(nameFile)) + "pick" + m->getExtension(nameFile);
-               groupFile = m->getRootName(m->getSimpleName(groupFile)) + "pick" + m->getExtension(groupFile);
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "pick" + m->getExtension(fastaFile);
-               thisCommand = "filter.seqs(processors=" + toString(processors) + ", fasta=current, vertical=T, trump=.)";
-               commands.push_back(thisCommand);
-               
-               //unique.seqs
-               fastaFile =  m->getRootName(m->getSimpleName(fastaFile)) + "filter.fasta";
-               thisCommand = "unique.seqs(fasta=current, name=current)"; 
-               commands.push_back(thisCommand);
-               
-               //pre.cluster
-               nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "names";
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "unique" + m->getExtension(fastaFile);
-               thisCommand = "pre.cluster(fasta=current, name=current, diffs=2)"; 
-               commands.push_back(thisCommand);
-               
-               //dist.seqs
-               nameFile = m->getRootName(m->getSimpleName(fastaFile)) + "precluster.names";
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "precluster" + m->getExtension(fastaFile);
-               thisCommand = "dist.seqs(processors=" + toString(processors) + ", fasta=current, cutoff=0.20)";
-               commands.push_back(thisCommand);
-               
-               //dist.seqs
-               string columnFile = m->getRootName(m->getSimpleName(fastaFile)) + "dist";
-               thisCommand = "dist.seqs(processors=" + toString(processors) + ", fasta=current, output=lt)";
-               commands.push_back(thisCommand);
-               
-               //read.dist
-               string phylipFile = m->getRootName(m->getSimpleName(fastaFile)) + "phylip.dist";
-               thisCommand = "read.dist(column=current, name=current)";
-               commands.push_back(thisCommand);
-               
-               //cluster
-               thisCommand = "cluster(method=average, hard=T)";
-               commands.push_back(thisCommand);
-               
-               string listFile = m->getRootName(m->getSimpleName(columnFile)) + "an.list";
-               string rabundFile = m->getRootName(m->getSimpleName(columnFile)) + "an.rabund";
-               
-               //degap.seqs
-               thisCommand = "degap.seqs(fasta=current)";
-               commands.push_back(thisCommand);
-               
-               //classify.seqs
-               fastaFile = m->getRootName(m->getSimpleName(fastaFile)) + "ng.fasta";
-               thisCommand = "classify.seqs(processors=" + toString(processors) + ", fasta=current, name=current, template=" + classifyFile + ", taxonomy=" + taxonomyFile + ", cutoff=80)";
-               commands.push_back(thisCommand);
-               
-               string RippedTaxName = m->getRootName(m->getSimpleName(taxonomyFile));
-               RippedTaxName = m->getExtension(RippedTaxName.substr(0, RippedTaxName.length()-1));
-               if (RippedTaxName[0] == '.') { RippedTaxName = RippedTaxName.substr(1, RippedTaxName.length()); }
-               RippedTaxName +=  "."; 
-               
-               string fastaTaxFile = m->getRootName(m->getSimpleName(fastaFile)) + RippedTaxName + "taxonomy";
-               string taxSummaryFile = m->getRootName(m->getSimpleName(fastaFile)) + RippedTaxName + "tax.summary";
-               
-               //phylotype
-               thisCommand = "phylotype(taxonomy=current, name=current)";
-               commands.push_back(thisCommand);
-               
-               string phyloListFile = m->getRootName(m->getSimpleName(fastaTaxFile)) + "tx.list";
-               string phyloRabundFile = m->getRootName(m->getSimpleName(fastaTaxFile)) + "tx.rabund";
-               
-               //clearcut
-               thisCommand = "clearcut(phylip=current, neighbor=T)";
-               commands.push_back(thisCommand);
-               
-               string treeFile = m->getRootName(m->getSimpleName(phylipFile)) + "tre";
-               
-               //read.otu
-               thisCommand = "make.shared(list=" + listFile + ", group=" + groupFile + ", label=0.03)";
-               commands.push_back(thisCommand);
-               
-               string sharedFile = m->getRootName(m->getSimpleName(listFile)) + "shared";
-               
-               //read.otu
-               thisCommand = "make.shared(list=" + phyloListFile + ", group=" + groupFile + ", label=1)";
-               commands.push_back(thisCommand);
-               
-               string phyloSharedFile = m->getRootName(m->getSimpleName(phyloListFile)) + "shared";
-               
-               //read.otu
-               thisCommand = "set.current(shared=" + sharedFile + ")";
-               commands.push_back(thisCommand);
-
-               //summary.single
-               thisCommand = "summary.single(shared=current, calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
-               commands.push_back(thisCommand);
-               
-               //summary.shared
-               thisCommand = "summary.shared(shared=current, calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc)";
-               commands.push_back(thisCommand);
-               
-               //read.otu
-               //thisCommand = "read.otu(rabund=" + rabundFile + ", label=0.03)";
-               //commands.push_back(thisCommand);
-               
-               //summary.single
-               thisCommand = "summary.single(rabund=" + rabundFile + ", label=0.03, calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
-               commands.push_back(thisCommand);
-               
-               //read.otu
-               thisCommand = "set.current(shared=" + phyloSharedFile + ")";
-               commands.push_back(thisCommand);
-               
-               //summary.single
-               thisCommand = "summary.single(shared=current, calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
-               commands.push_back(thisCommand);
-               
-               //summary.shared
-               thisCommand = "summary.shared(shared=current, calc=sharednseqs-sharedsobs-sharedchao-sharedace-anderberg-jclass-jest-kulczynski-kulczynskicody-lennon-ochiai-sorclass-sorest-whittaker-braycurtis-jabund-morisitahorn-sorabund-thetan-thetayc)";
-               commands.push_back(thisCommand);
-
-               //read.otu
-               //thisCommand = "read.otu(rabund=" + phyloRabundFile + ", label=1)";
-               //commands.push_back(thisCommand);
-               
-               //summary.single
-               thisCommand = "summary.single(rabund=" + phyloRabundFile + ", label=1, calc=nseqs-sobs-coverage-bergerparker-chao-ace-jack-bootstrap-boneh-efron-shen-solow-shannon-npshannon-invsimpson-qstat-simpsoneven-shannoneven-heip-smithwilson, size=5000)";
-               commands.push_back(thisCommand);
-               
-               //classify.otu
-               thisCommand = "classify.otu(taxonomy=" + fastaTaxFile + ", name=" + nameFile + ", list=" + listFile + ", cutoff=51, label=0.03)";
-               commands.push_back(thisCommand);
-               
-               //classify.otu
-               thisCommand = "classify.otu(taxonomy=" + fastaTaxFile + ", name=" + nameFile + ", list=" + phyloListFile + ", cutoff=51, label=1)";
-               commands.push_back(thisCommand);
-               
-               //read.tree
-               thisCommand = "set.current(tree=" + treeFile + ", name=" + nameFile + ", group=" + groupFile + ")";
-               commands.push_back(thisCommand);
-               
-               //phylo.diversity
-               thisCommand = "phylo.diversity(tree=current, group=current, name=current, iters=100,rarefy=T)";
-               commands.push_back(thisCommand);
-               
-               //unifrac.weighted
-               thisCommand = "unifrac.weighted(tree=current, group=current, name=current, random=false, distance=true, groups=all, processors=" + toString(processors) + ")";
-               commands.push_back(thisCommand);
-               
-               //unifrac.unweighted
-               thisCommand = "unifrac.unweighted(tree=current, group=current, name=current, random=false, distance=true, processors=" + toString(processors) + ")";
-               commands.push_back(thisCommand);
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PipelineCommand", "createPatsPipeline");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/pipelinepdscommand.h b/pipelinepdscommand.h
deleted file mode 100644 (file)
index 8abe0ea..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef PIPELINEPDSCOMMAND_H
-#define PIPELINEPDSCOMMAND_H
-
-/*
- *  pipelinepdscommand.h
- *  Mothur
- *
- *  Created by westcott on 10/5/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-/****************************************************/
-
-class PipelineCommand : public Command {
-       
-public:
-       PipelineCommand(string);
-       PipelineCommand() { abort = true; calledHelp = true; setParameters(); }
-       ~PipelineCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pipeline.pds";        }
-       string getCommandCategory()             { return "Hidden";                      }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Pipeline.pds"; }
-       string getDescription()         { return "pat's pipeline"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort;
-       CommandFactory* cFactory;
-       vector<string> outputNames;
-       vector<string> commands;
-       string outputDir, sffFile, alignFile, oligosFile, taxonomyFile, pipeFilename, classifyFile, chimeraFile;
-       int processors;
-       
-       bool readUsersPipeline();
-       int runUsersPipeline();
-       void createPatsPipeline();
-       bool parseCommand(string, string&, string&);
-       bool checkForValidAndRequiredParameters(string, string, map<string, vector<string> >&);
-       bool fillInMothurMade(string&, map<string, vector<string> >&);
-};
-
-/****************************************************/
-
-#endif
-
diff --git a/prcseqscommand.cpp b/prcseqscommand.cpp
deleted file mode 100644 (file)
index 725136b..0000000
+++ /dev/null
@@ -1,1069 +0,0 @@
-//
-//  prcseqscommand.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 3/14/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "pcrseqscommand.h"
-
-//**********************************************************************************************************************
-vector<string> PcrSeqsCommand::setParameters(){        
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "ecolioligos", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-        CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-        CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptax);
-        CommandParameter pecoli("ecoli", "InputTypes", "", "", "ecolioligos", "none", "none",false,false); parameters.push_back(pecoli);
-               CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart);
-               CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend);
-               CommandParameter pnomatch("nomatch", "Multiple", "reject-keep", "reject", "", "", "",false,false); parameters.push_back(pnomatch);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pkeepprimer("keepprimer", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepprimer);
-        CommandParameter pkeepdots("keepdots", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pkeepdots);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-        
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PcrSeqsCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The pcr.seqs command reads a fasta file.\n";
-        helpString += "The pcr.seqs command parameters are fasta, oligos, name, group, taxonomy, ecoli, start, end, nomatch, processors, keepprimer and keepdots.\n";
-               helpString += "The ecoli parameter is used to provide a fasta file containing a single reference sequence (e.g. for e. coli) this must be aligned. Mothur will trim to the start and end positions of the reference sequence.\n";
-        helpString += "The start parameter allows you to provide a starting position to trim to.\n";
-        helpString += "The end parameter allows you to provide a ending position to trim from.\n";
-        helpString += "The nomatch parameter allows you to decide what to do with sequences where the primer is not found. Default=reject, meaning remove from fasta file.  if nomatch=true, then do nothing to sequence.\n";
-        helpString += "The processors parameter allows you to use multiple processors.\n";
-        helpString += "The keepprimer parameter allows you to keep the primer, default=false.\n";
-        helpString += "The keepdots parameter allows you to keep the leading and trailing .'s, default=true.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Pcr.seqs .\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-
-PcrSeqsCommand::PcrSeqsCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-        outputTypes["accnos"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "PcrSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-PcrSeqsCommand::PcrSeqsCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-            outputTypes["accnos"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("oligos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
-                               }
-                
-                it = parameters.find("ecoli");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["ecoli"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                
-                it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                       }
-            
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else if (fastafile == "not open") { fastafile = ""; abort = true; }    
-                       else { m->setFastaFile(fastafile); }
-                       
-            //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(fastafile);      }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "keepprimer", false);  if (temp == "not found")    {        temp = "f";     }
-                       keepprimer = m->isTrue(temp);   
-            
-            temp = validParameter.validFile(parameters, "keepdots", false);  if (temp == "not found")    {     temp = "t";     }
-                       keepdots = m->isTrue(temp);     
-            
-                       temp = validParameter.validFile(parameters, "oligos", true);
-                       if (temp == "not found"){       oligosfile = "";                }
-                       else if(temp == "not open"){    oligosfile = ""; abort = true;  } 
-                       else                                    {       oligosfile = temp; m->setOligosFile(oligosfile);                }
-                       
-            ecolifile = validParameter.validFile(parameters, "ecoli", true);
-                       if (ecolifile == "not found"){  ecolifile = "";         }
-                       else if(ecolifile == "not open"){       ecolifile = ""; abort = true;   } 
-                       
-            namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not found"){   namefile = "";          }
-                       else if(namefile == "not open"){        namefile = ""; abort = true;    } 
-            else { m->setNameFile(namefile); }
-            
-            groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not found"){  groupfile = "";         }
-                       else if(groupfile == "not open"){       groupfile = ""; abort = true;   } 
-            else { m->setGroupFile(groupfile); }
-            
-            taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not found"){    taxfile = "";           }
-                       else if(taxfile == "not open"){ taxfile = ""; abort = true;     } 
-            else { m->setTaxonomyFile(taxfile); }
-                                               
-                       temp = validParameter.validFile(parameters, "start", false);    if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, start);
-            
-            temp = validParameter.validFile(parameters, "end", false); if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, end);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-            nomatch = validParameter.validFile(parameters, "nomatch", false);  if (nomatch == "not found") { nomatch = "reject"; }
-                       
-            if ((nomatch != "reject") && (nomatch != "keep")) { m->mothurOut("[ERROR]: " + nomatch + " is not a valid entry for nomatch. Choices are reject and keep.\n");  abort = true; }
-            
-            //didnt set anything
-                       if ((oligosfile == "") && (ecolifile == "") && (start == -1) && (end == -1)) {
-                m->mothurOut("[ERROR]: You did not set any options. Please provide an oligos or ecoli file, or set start or end.\n"); abort = true;
-            }
-            
-            if ((oligosfile == "") && (ecolifile == "") && (start < 0) && (end == -1)) { m->mothurOut("[ERROR]: Invalid start value.\n"); abort = true; }
-            
-            if ((ecolifile != "") && (start != -1) && (end != -1)) {
-                m->mothurOut("[ERROR]: You provided an ecoli file , but set the start or end parameters. Unsure what you intend.  When you provide the ecoli file, mothur thinks you want to use the start and end of the sequence in the ecoli file.\n"); abort = true;
-            }
-
-            
-            if ((oligosfile != "") && (ecolifile != "")) {
-                 m->mothurOut("[ERROR]: You can not use an ecoli file at the same time as an oligos file.\n"); abort = true;
-            }
-                       
-                       //check to make sure you didn't forget the name file by mistake                 
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "PcrSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int PcrSeqsCommand::execute(){
-       try{
-        
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-        int start = time(NULL);
-        
-        string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string trimSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pcr.fasta";
-               outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
-        
-        string badSeqFile = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pcr.scrap.fasta";
-               
-               
-        length = 0;
-               if(oligosfile != ""){    readOligos();     }  if (m->control_pressed) {  return 0; }
-        if(ecolifile != "") {    readEcoli();      }  if (m->control_pressed) {  return 0; }
-        
-        vector<unsigned long long> positions; 
-        int numFastaSeqs = 0;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-        positions = m->divideFile(fastafile, processors);
-        for (int i = 0; i < (positions.size()-1); i++) {       lines.push_back(linePair(positions[i], positions[(i+1)]));      }
-#else
-        if (processors == 1) {
-            lines.push_back(linePair(0, 1000));
-        }else {
-            positions = m->setFilePosFasta(fastafile, numFastaSeqs); 
-            if (positions.size() < processors) { processors = positions.size(); }
-            
-            //figure out how many sequences you have to process
-            int numSeqsPerProcessor = numFastaSeqs / processors;
-            for (int i = 0; i < processors; i++) {
-                int startIndex =  i * numSeqsPerProcessor;
-                if(i == (processors - 1)){     numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                lines.push_back(linePair(positions[startIndex], numSeqsPerProcessor));
-            }
-        }
-#endif
-        if (m->control_pressed) {  return 0; }
-
-        set<string> badNames;
-        if(processors == 1) {    numFastaSeqs = driverPcr(fastafile, trimSeqFile, badSeqFile, badNames, lines[0]);   }
-        else                {    numFastaSeqs = createProcesses(fastafile, trimSeqFile, badSeqFile, badNames);       } 
-               
-               if (m->control_pressed) {  return 0; }          
-        
-        //don't write or keep if blank
-        if (badNames.size() != 0)   { writeAccnos(badNames);        }   
-        if (m->isBlank(badSeqFile)) { m->mothurRemove(badSeqFile);  }
-        else { outputNames.push_back(badSeqFile); outputTypes["fasta"].push_back(badSeqFile); }
-        
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-        if (namefile != "")                    {               readName(badNames);             }   
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-        if (groupfile != "")           {               readGroup(badNames);    }
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-               if (taxfile != "")                      {               readTax(badNames);              }
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-        
-        m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
-               m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               itTypes = outputTypes.find("taxonomy");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-               }
-        
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to screen " + toString(numFastaSeqs) + " sequences.");
-               m->mothurOutEndLine();
-
-               
-               return 0;       
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PcrSeqsCommand::createProcesses(string filename, string goodFileName, string badFileName, set<string>& badSeqNames) {
-       try {
-        
-        vector<int> processIDS;   
-        int process = 1;
-               int num = 0;
-        
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-        
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverPcr(filename, goodFileName + toString(getpid()) + ".temp", badFileName + toString(getpid()) + ".temp", badSeqNames, lines[process]);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = filename + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << '\t' << badSeqNames.size() << endl;
-                for (set<string>::iterator it = badSeqNames.begin(); it != badSeqNames.end(); it++) {
-                    out << (*it) << endl;
-                }
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-        num = driverPcr(filename, goodFileName, badFileName, badSeqNames, lines[0]);
-        
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  filename + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-            int numBadNames = 0; string name = "";
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum >> numBadNames; num += tempNum; m->gobble(in); }
-            for (int j = 0; j < numBadNames; j++) {
-                in >> name; m->gobble(in);
-                badSeqNames.insert(name);
-            }
-                       in.close(); m->mothurRemove(tempFile);
-            
-            m->appendFiles((goodFileName + toString(processIDS[i]) + ".temp"), goodFileName);
-            m->mothurRemove((goodFileName + toString(processIDS[i]) + ".temp"));
-            
-            m->appendFiles((badFileName + toString(processIDS[i]) + ".temp"), badFileName);
-            m->mothurRemove((badFileName + toString(processIDS[i]) + ".temp"));
-               }
-    #else
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the sumScreenData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to badSeqNames.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<pcrData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-            
-            string extension = "";
-            if (i!=0) {extension += toString(i) + ".temp"; processIDS.push_back(i); }
-            
-                       // Allocate memory for thread data.
-                       pcrData* tempPcr = new pcrData(filename, goodFileName+extension, badFileName+extension, m, oligosfile, ecolifile, primers, revPrimer, nomatch, keepprimer, keepdots, start, end, length, lines[i].start, lines[i].end);
-                       pDataArray.push_back(tempPcr);
-                       
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MyPcrThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-        //do your part
-        num = driverPcr(filename, (goodFileName+toString(processors-1)+".temp"), (badFileName+toString(processors-1)+".temp"),badSeqNames, lines[processors-1]);
-        processIDS.push_back(processors-1);
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            for (set<string>::iterator it = pDataArray[i]->badSeqNames.begin(); it != pDataArray[i]->badSeqNames.end(); it++) {        badSeqNames.insert(*it);       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-        
-        for (int i = 0; i < processIDS.size(); i++) {
-            m->appendFiles((goodFileName + toString(processIDS[i]) + ".temp"), goodFileName);
-            m->mothurRemove((goodFileName + toString(processIDS[i]) + ".temp"));
-            
-            m->appendFiles((badFileName + toString(processIDS[i]) + ".temp"), badFileName);
-            m->mothurRemove((badFileName + toString(processIDS[i]) + ".temp"));
-               }
-        
-#endif 
-        
-        return num;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int PcrSeqsCommand::driverPcr(string filename, string goodFasta, string badFasta, set<string>& badSeqNames, linePair filePos){
-       try {
-               ofstream goodFile;
-               m->openOutputFile(goodFasta, goodFile);
-        
-        ofstream badFile;
-               m->openOutputFile(badFasta, badFile);
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-        
-               inFASTA.seekg(filePos.start);
-        
-               bool done = false;
-               int count = 0;
-        set<int> lengths;
-        
-               while (!done) {
-            
-                       if (m->control_pressed) {  break; }
-                       
-                       Sequence currSeq(inFASTA); m->gobble(inFASTA);
-            
-            string trashCode = "";
-                       if (currSeq.getName() != "") {
-                
-                bool goodSeq = true;
-                if (oligosfile != "") {
-                    map<int, int> mapAligned;
-                    bool aligned = isAligned(currSeq.getAligned(), mapAligned);
-                    
-                    //process primers
-                    if (primers.size() != 0) {
-                        int primerStart = 0; int primerEnd = 0;
-                        bool good = findForward(currSeq, primerStart, primerEnd);
-                        
-                        if(!good){     if (nomatch == "reject") { goodSeq = false; } trashCode += "f"; }
-                        else{
-                            //are you aligned
-                            if (aligned) { 
-                                if (!keepprimer)    {  
-                                    if (keepdots)   { currSeq.filterToPos(mapAligned[primerEnd]);   }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(mapAligned[primerEnd]));                                              }
-                                } 
-                                else                {  
-                                    if (keepdots)   { currSeq.filterToPos(mapAligned[primerStart]);  }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(mapAligned[primerStart]));                                              }
-                                }
-                            }else { 
-                                if (!keepprimer)    { currSeq.setAligned(currSeq.getUnaligned().substr(primerEnd)); } 
-                                else                { currSeq.setAligned(currSeq.getUnaligned().substr(primerStart)); } 
-                            }
-                        }
-                    }
-                    
-                    //process reverse primers
-                    if (revPrimer.size() != 0) {
-                        int primerStart = 0; int primerEnd = 0;
-                        bool good = findReverse(currSeq, primerStart, primerEnd);
-                        if(!good){     if (nomatch == "reject") { goodSeq = false; } trashCode += "r"; }
-                        else{ 
-                            //are you aligned
-                            if (aligned) { 
-                                if (!keepprimer)    {  
-                                    if (keepdots)   { currSeq.filterFromPos(mapAligned[primerStart]); }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(0, mapAligned[primerStart]));   }
-                                } 
-                                else                {  
-                                    if (keepdots)   { currSeq.filterFromPos(mapAligned[primerEnd]); }
-                                    else            { currSeq.setAligned(currSeq.getAligned().substr(0, mapAligned[primerEnd]));   }
-                                } 
-                            }
-                            else { 
-                                if (!keepprimer)    { currSeq.setAligned(currSeq.getUnaligned().substr(0, primerStart));   } 
-                                else                { currSeq.setAligned(currSeq.getUnaligned().substr(0, primerEnd));     }
-                            }
-                        }
-                    }
-                }else if (ecolifile != "") {
-                    //make sure the seqs are aligned
-                    lengths.insert(currSeq.getAligned().length());
-                    if (lengths.size() > 1) { m->mothurOut("[ERROR]: seqs are not aligned. When using start and end your sequences must be aligned.\n"); m->control_pressed = true; break; }
-                    else if (currSeq.getAligned().length() != length) {
-                        m->mothurOut("[ERROR]: seqs are not the same length as ecoli seq. When using ecoli option your sequences must be aligned and the same length as the ecoli sequence.\n"); m->control_pressed = true; break; 
-                    }else {
-                        if (keepdots)   { 
-                            currSeq.filterToPos(start); 
-                            currSeq.filterFromPos(end);
-                        }else {
-                            string seqString = currSeq.getAligned().substr(0, end);
-                            seqString = seqString.substr(start);
-                            currSeq.setAligned(seqString); 
-                        }
-                    }
-                }else{ //using start and end to trim
-                    //make sure the seqs are aligned
-                    lengths.insert(currSeq.getAligned().length());
-                    if (lengths.size() > 1) { m->mothurOut("[ERROR]: seqs are not aligned. When using start and end your sequences must be aligned.\n"); m->control_pressed = true; break; }
-                    else {
-                        if (end != -1) {
-                            if (end > currSeq.getAligned().length()) {  m->mothurOut("[ERROR]: end is longer than your sequence length, aborting.\n"); m->control_pressed = true; break; }
-                            else {
-                                if (keepdots)   { currSeq.filterFromPos(end); }
-                                else {
-                                    string seqString = currSeq.getAligned().substr(0, end);
-                                    currSeq.setAligned(seqString); 
-                                }
-                            }
-                        }
-                        if (start != -1) { 
-                            if (keepdots)   {  currSeq.filterToPos(start);  }
-                            else {
-                                string seqString = currSeq.getAligned().substr(start);
-                                currSeq.setAligned(seqString); 
-                            }
-                        }
-                    }
-                }
-                
-                //trimming removed all bases
-                if (currSeq.getUnaligned() == "") { goodSeq = false; }
-                
-                               if(goodSeq == 1)    {   currSeq.printSequence(goodFile);        }
-                               else {  
-                    badSeqNames.insert(currSeq.getName()); 
-                    currSeq.setName(currSeq.getName() + '|' + trashCode);
-                    currSeq.printSequence(badFile); 
-                }
-                count++;
-                       }
-                       
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-            unsigned long long pos = inFASTA.tellg();
-            if ((pos == -1) || (pos >= filePos.end)) { break; }
-#else
-            if (inFASTA.eof()) { break; }
-#endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-        badFile.close();
-               goodFile.close();
-               inFASTA.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "driverPcr");
-               exit(1);
-       }
-}
-//********************************************************************/
-bool PcrSeqsCommand::findForward(Sequence& seq, int& primerStart, int& primerEnd){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               
-               for(int j=0;j<primers.size();j++){
-                       string oligo = primers[j];
-                       
-                       if(rawSequence.length() < oligo.length()) {  break;  }
-                       
-                       //search for primer
-            int olength = oligo.length();
-            for (int j = 0; j < rawSequence.length()-olength; j++){
-                if (m->control_pressed) {  primerStart = 0; primerEnd = 0; return false; }
-                string rawChunk = rawSequence.substr(j, olength);
-                if(compareDNASeq(oligo, rawChunk)) {
-                    primerStart = j;
-                    primerEnd = primerStart + olength;
-                    return true;
-                }
-                
-            }
-        }      
-               
-        primerStart = 0; primerEnd = 0;
-               return false;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripForward");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool PcrSeqsCommand::findReverse(Sequence& seq, int& primerStart, int& primerEnd){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               
-               for(int i=0;i<revPrimer.size();i++){
-                       string oligo = revPrimer[i];
-                       if(rawSequence.length() < oligo.length()) {  break;  }
-                       
-                       //search for primer
-            int olength = oligo.length();
-            for (int j = rawSequence.length()-olength; j >= 0; j--){
-                 if (m->control_pressed) {  primerStart = 0; primerEnd = 0; return false; }
-                string rawChunk = rawSequence.substr(j, olength);
-            
-                if(compareDNASeq(oligo, rawChunk)) {
-                    primerStart = j;
-                    primerEnd = primerStart + olength;
-                    return true;
-                }
-                
-            }
-               }       
-               
-        primerStart = 0; primerEnd = 0;
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "findReverse");
-               exit(1);
-       }
-}
-//********************************************************************/
-bool PcrSeqsCommand::isAligned(string seq, map<int, int>& aligned){
-       try {
-        bool isAligned = false;
-        
-        int countBases = 0;
-        for (int i = 0; i < seq.length(); i++) {
-            if (!isalpha(seq[i])) { isAligned = true; }
-            else { aligned[countBases] = i; countBases++; } //maps location in unaligned -> location in aligned.
-        }                                                   //ie. the 3rd base may be at spot 10 in the alignment
-                                                            //later when we trim we want to trim from spot 10.
-        return isAligned;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "isAligned");
-               exit(1);
-       }
-}
-//********************************************************************/
-string PcrSeqsCommand::reverseOligo(string oligo){
-       try {
-        string reverse = "";
-       
-        for(int i=oligo.length()-1;i>=0;i--){
-            
-            if(oligo[i] == 'A')                {       reverse += 'T'; }
-            else if(oligo[i] == 'T'){  reverse += 'A'; }
-            else if(oligo[i] == 'U'){  reverse += 'A'; }
-            
-            else if(oligo[i] == 'G'){  reverse += 'C'; }
-            else if(oligo[i] == 'C'){  reverse += 'G'; }
-            
-            else if(oligo[i] == 'R'){  reverse += 'Y'; }
-            else if(oligo[i] == 'Y'){  reverse += 'R'; }
-            
-            else if(oligo[i] == 'M'){  reverse += 'K'; }
-            else if(oligo[i] == 'K'){  reverse += 'M'; }
-            
-            else if(oligo[i] == 'W'){  reverse += 'W'; }
-            else if(oligo[i] == 'S'){  reverse += 'S'; }
-            
-            else if(oligo[i] == 'B'){  reverse += 'V'; }
-            else if(oligo[i] == 'V'){  reverse += 'B'; }
-            
-            else if(oligo[i] == 'D'){  reverse += 'H'; }
-            else if(oligo[i] == 'H'){  reverse += 'D'; }
-
-            else                                               {       reverse += 'N'; }
-        }
-
-        
-        return reverse;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "reverseOligo");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-bool PcrSeqsCommand::readOligos(){
-       try {
-               ifstream inOligos;
-               m->openInputFile(oligosfile, inOligos);
-               
-               string type, oligo, group;
-               
-               while(!inOligos.eof()){
-            
-                       inOligos >> type; 
-            
-                       if(type[0] == '#'){ //ignore
-                               while (!inOligos.eof()) {       char c = inOligos.get();  if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                               m->gobble(inOligos);
-                       }else{
-                               m->gobble(inOligos);
-                               //make type case insensitive
-                               for(int i=0;i<type.length();i++){       type[i] = toupper(type[i]);  }
-                               
-                               inOligos >> oligo;
-                               
-                               for(int i=0;i<oligo.length();i++){
-                                       oligo[i] = toupper(oligo[i]);
-                                       if(oligo[i] == 'U')     {       oligo[i] = 'T'; }
-                               }
-                               
-                               if(type == "FORWARD"){
-                                       // get rest of line in case there is a primer name
-                                       while (!inOligos.eof()) {       
-                        char c = inOligos.get(); 
-                        if (c == 10 || c == 13){       break;  } 
-                        else if (c == 32 || c == 9){;} //space or tab
-                                       } 
-                                       primers.push_back(oligo);
-                }else if(type == "REVERSE"){
-                    string oligoRC = reverseOligo(oligo);
-                    revPrimer.push_back(oligoRC);
-                    //cout << "oligo = " << oligo << " reverse = " << oligoRC << endl;
-                               }else if(type == "BARCODE"){
-                                       inOligos >> group;
-                               }else if((type == "LINKER")||(type == "SPACER")) {;}
-                               else{   m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, linker, spacer and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine(); m->control_pressed = true; }
-                       }
-                       m->gobble(inOligos);
-               }       
-               inOligos.close();
-               
-               if ((primers.size() == 0) && (revPrimer.size() == 0)) {
-                       m->mothurOut("[ERROR]: your oligos file does not contain valid primers or reverse primers.  Please correct."); m->mothurOutEndLine();
-            m->control_pressed = true;
-                       return false;
-               }
-        
-        return true;
-        
-    }catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "readOligos");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-bool PcrSeqsCommand::readEcoli(){
-       try {
-               ifstream in;
-               m->openInputFile(ecolifile, in);
-               
-        //read seq
-        if (!in.eof()){ 
-            Sequence ecoli(in); 
-            length = ecoli.getAligned().length();
-            start = ecoli.getStartPos();
-            end = ecoli.getEndPos();
-        }else { in.close(); m->control_pressed = true; return false; }
-        in.close();    
-                       
-        return true;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "readEcoli");
-               exit(1);
-       }
-    
-}
-//***************************************************************************************************************
-int PcrSeqsCommand::writeAccnos(set<string> badNames){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
-        outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName);
-        
-        ofstream out;
-        m->openOutputFile(outputFileName, out);
-        
-        for (set<string>::iterator it = badNames.begin(); it != badNames.end(); it++) {
-            if (m->control_pressed) { break; }
-            out << (*it) << endl;
-        }
-        
-        out.close();
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "writeAccnos");
-               exit(1);
-       }
-    
-}
-//******************************************************************/
-bool PcrSeqsCommand::compareDNASeq(string oligo, string seq){
-       try {
-               bool success = 1;
-               int length = oligo.length();
-               
-               for(int i=0;i<length;i++){
-                       
-                       if(oligo[i] != seq[i]){
-                               if(oligo[i] == 'A' || oligo[i] == 'T' || oligo[i] == 'G' || oligo[i] == 'C')    {       success = 0;    }
-                               else if((oligo[i] == 'N' || oligo[i] == 'I') && (seq[i] == 'N'))                                {       success = 0;    }
-                               else if(oligo[i] == 'R' && (seq[i] != 'A' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'Y' && (seq[i] != 'C' && seq[i] != 'T'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'M' && (seq[i] != 'C' && seq[i] != 'A'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'K' && (seq[i] != 'T' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'W' && (seq[i] != 'T' && seq[i] != 'A'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'S' && (seq[i] != 'C' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'B' && (seq[i] != 'C' && seq[i] != 'T' && seq[i] != 'G'))   {       success = 0;    }
-                               else if(oligo[i] == 'D' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'G'))   {       success = 0;    }
-                               else if(oligo[i] == 'H' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'C'))   {       success = 0;    }
-                               else if(oligo[i] == 'V' && (seq[i] != 'A' && seq[i] != 'C' && seq[i] != 'G'))   {       success = 0;    }                       
-                               
-                               if(success == 0)        {       break;   }
-                       }
-                       else{
-                               success = 1;
-                       }
-               }
-               
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "compareDNASeq");
-               exit(1);
-       }
-       
-}
-//***************************************************************************************************************
-int PcrSeqsCommand::readName(set<string>& names){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pcr" + m->getExtension(namefile);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> firstCol;         m->gobble(in);          
-                       in >> secondCol;                        
-                       
-            string savedSecond = secondCol;
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;  validSecond.clear();
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) == 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-                       
-                       if (validSecond.size() != parsedNames.size()) {  //we want to get rid of someone, so get rid of everyone
-                               for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
-                               removedCount += parsedNames.size();
-                       }else {
-                out << firstCol << '\t' << savedSecond << endl;
-                wroteSomething = true;
-            }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your name file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "readName");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PcrSeqsCommand::readGroup(set<string> names){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pcr" + m->getExtension(groupfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                       }else {  removedCount++;  }
-            
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your group file."); m->mothurOutEndLine();
-        
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int PcrSeqsCommand::readTax(set<string> names){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pcr" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << tax << endl;
-                       }else {  removedCount++;  }
-            
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PcrSeqsCommand", "readTax");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-
-
diff --git a/preclustercommand.cpp b/preclustercommand.cpp
deleted file mode 100644 (file)
index bcff0fc..0000000
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- *  preclustercommand.cpp
- *  Mothur
- *
- *  Created by westcott on 12/21/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "preclustercommand.h"
-#include "deconvolutecommand.h"
-
-//**********************************************************************************************************************
-vector<string> PreClusterCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pdiffs("diffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string PreClusterCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The pre.cluster command groups sequences that are within a given number of base mismatches.\n";
-               helpString += "The pre.cluster command outputs a new fasta and name file.\n";
-               helpString += "The pre.cluster command parameters are fasta, names and diffs. The fasta parameter is required. \n";
-               helpString += "The names parameter allows you to give a list of seqs that are identical. This file is 2 columns, first column is name or representative sequence, second column is a list of its identical sequences separated by commas.\n";
-               helpString += "The group parameter allows you to provide a group file so you can cluster by group. \n";
-               helpString += "The diffs parameter allows you to specify maximum number of mismatched bases allowed between sequences in a grouping. The default is 1.\n";
-               helpString += "The pre.cluster command should be in the following format: \n";
-               helpString += "pre.cluster(fasta=yourFastaFile, names=yourNamesFile, diffs=yourMaxDiffs) \n";
-               helpString += "Example pre.cluster(fasta=amazon.fasta, diffs=2).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-PreClusterCommand::PreClusterCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["map"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-PreClusterCommand::PreClusterCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string, string>::iterator it2 = parameters.begin(); it2 != parameters.end(); it2++) { 
-                               if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["map"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (fastafile == "not open") { abort = true; }     
-                       else { m->setFastaFile(fastafile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not found") { namefile =  "";  }
-                       else if (namefile == "not open") { namefile = ""; abort = true; }       
-                       else {  m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not found") { groupfile =  "";  bygroup = false; }
-                       else if (groupfile == "not open") { abort = true; groupfile =  ""; }    
-                       else {   m->setGroupFile(groupfile); bygroup = true;  }
-                       
-                       string temp     = validParameter.validFile(parameters, "diffs", false);         if(temp == "not found"){        temp = "1"; }
-                       m->mothurConvert(temp, diffs); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "PreClusterCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int PreClusterCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int start = time(NULL);
-               
-               string fileroot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               string newFastaFile = fileroot + "precluster" + m->getExtension(fastafile);
-               string newNamesFile = fileroot + "precluster.names";
-               string newMapFile = fileroot + "precluster.map"; //add group name if by group
-               outputNames.push_back(newFastaFile); outputTypes["fasta"].push_back(newFastaFile);
-               outputNames.push_back(newNamesFile); outputTypes["name"].push_back(newNamesFile);
-               
-               
-               if (bygroup) {
-                       //clear out old files
-                       ofstream outFasta; m->openOutputFile(newFastaFile, outFasta); outFasta.close();
-                       ofstream outNames; m->openOutputFile(newNamesFile, outNames);  outNames.close();
-                       newMapFile = fileroot + "precluster.";
-                       
-                       //parse fasta and name file by group
-                       SequenceParser* parser;
-                       if (namefile != "") { parser = new SequenceParser(groupfile, fastafile, namefile);      }
-                       else                            { parser = new SequenceParser(groupfile, fastafile);                    }
-                       
-                       vector<string> groups = parser->getNamesOfGroups();
-                       
-                       if(processors == 1)     {       driverGroups(parser, newFastaFile, newNamesFile, newMapFile, 0, groups.size(), groups); }
-                       else                            {       createProcessesGroups(parser, newFastaFile, newNamesFile, newMapFile, groups);                  }
-                       
-                       delete parser;
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        }        return 0; }
-                       
-                       //run unique.seqs for deconvolute results
-                       string inputString = "fasta=" + newFastaFile;
-                       if (namefile != "") { inputString += ", name=" + newNamesFile; }
-                       m->mothurOutEndLine(); 
-                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-                       m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-                       m->mothurCalling = true;
-            
-                       Command* uniqueCommand = new DeconvoluteCommand(inputString);
-                       uniqueCommand->execute();
-                       
-                       map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-                       
-                       delete uniqueCommand;
-                       m->mothurCalling = false;
-                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-                       
-                       m->renameFile(filenames["fasta"][0], newFastaFile);
-            m->renameFile(filenames["name"][0], newNamesFile);
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run pre.cluster."); m->mothurOutEndLine(); 
-                               
-               }else {
-                       if (namefile != "") { readNameFile(); }
-               
-                       //reads fasta file and return number of seqs
-                       int numSeqs = readFASTA(); //fills alignSeqs and makes all seqs active
-               
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-       
-                       if (numSeqs == 0) { m->mothurOut("Error reading fasta file...please correct."); m->mothurOutEndLine(); return 0;  }
-                       if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); return 0;  }
-                       
-                       int count = process(newMapFile);
-                       outputNames.push_back(newMapFile); outputTypes["map"].push_back(newMapFile);
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }   
-                       
-                       m->mothurOut("Total number of sequences before precluster was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
-                       m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); 
-                       printData(newFastaFile, newNamesFile);
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); 
-               }
-                               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }               
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PreClusterCommand::createProcessesGroups(SequenceParser* parser, string newFName, string newNName, string newMFile, vector<string> groups) {
-       try {
-               
-               vector<int> processIDS;
-               int process = 1;
-               int num = 0;
-               
-               //sanity check
-               if (groups.size() < processors) { processors = groups.size(); }
-               
-               //divide the groups between the processors
-               vector<linePair> lines;
-               int numGroupsPerProcessor = groups.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numGroupsPerProcessor;
-                       int endIndex = (i+1) * numGroupsPerProcessor;
-                       if(i == (processors - 1)){      endIndex = groups.size();       }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                outputNames.clear();
-                               num = driverGroups(parser, newFName + toString(getpid()) + ".temp", newNName + toString(getpid()) + ".temp", newMFile, lines[process].start, lines[process].end, groups);
-                
-                string tempFile = toString(getpid()) + ".outputNames.temp";
-                ofstream outTemp;
-                m->openOutputFile(tempFile, outTemp);
-                
-                outTemp << outputNames.size();
-                for (int i = 0; i < outputNames.size(); i++) { outTemp << outputNames[i] << endl; }
-                outTemp.close();
-                
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driverGroups(parser, newFName, newNName, newMFile, lines[0].start, lines[0].end, groups);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-        
-        for (int i = 0; i < processIDS.size(); i++) {
-            string tempFile = toString(processIDS[i]) +  ".outputNames.temp";
-            ifstream intemp;
-            m->openInputFile(tempFile, intemp);
-            
-            int num;
-            intemp >> num;
-            for (int k = 0; k < num; k++) {
-                string name = "";
-                intemp >> name; m->gobble(intemp);
-                
-                outputNames.push_back(name); outputTypes["map"].push_back(name);
-            }
-            intemp.close();
-            m->mothurRemove(tempFile);
-        }
-#else
-               
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the preClusterData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<preClusterData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = toString(i) + ".temp";
-                       
-                       preClusterData* tempPreCluster = new preClusterData(fastafile, namefile, groupfile, (newFName+extension), (newNName+extension), newMFile, groups, m, lines[i].start, lines[i].end, diffs, i);
-                       pDataArray.push_back(tempPreCluster);
-                       processIDS.push_back(i);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyPreclusterThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-                               
-               //using the main process as a worker saves time and memory
-               num = driverGroups(parser, newFName, newNName, newMFile, lines[0].start, lines[0].end, groups);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       for (int j = 0; j < pDataArray[i]->mapFileNames.size(); j++) {
-                               outputNames.push_back(pDataArray[i]->mapFileNames[j]); outputTypes["map"].push_back(pDataArray[i]->mapFileNames[j]); 
-                       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-#endif         
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       //newFName = m->getFullPathName(".\\" + newFName);
-                       //newNName = m->getFullPathName(".\\" + newNName);
-                       
-                       m->appendFiles((newFName + toString(processIDS[i]) + ".temp"), newFName);
-                       m->mothurRemove((newFName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((newNName + toString(processIDS[i]) + ".temp"), newNName);
-                       m->mothurRemove((newNName + toString(processIDS[i]) + ".temp"));
-               }
-               
-               return num;     
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "createProcessesGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PreClusterCommand::driverGroups(SequenceParser* parser, string newFFile, string newNFile, string newMFile, int start, int end, vector<string> groups){
-       try {
-               
-               int numSeqs = 0;
-               
-               //precluster each group
-               for (int i = start; i < end; i++) {
-                       
-                       start = time(NULL);
-                       
-                       if (m->control_pressed) {  return 0; }
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[i] + ":"); m->mothurOutEndLine();
-                       
-                       map<string, string> thisNameMap;
-                       if (namefile != "") { thisNameMap = parser->getNameMap(groups[i]); }
-                       vector<Sequence> thisSeqs = parser->getSeqs(groups[i]);
-                       
-                       //fill alignSeqs with this groups info.
-                       numSeqs = loadSeqs(thisNameMap, thisSeqs);
-                       
-                       if (m->control_pressed) {   return 0; }
-                       
-                       if (diffs > length) { m->mothurOut("Error: diffs is greater than your sequence length."); m->mothurOutEndLine(); m->control_pressed = true; return 0;  }
-                       
-                       int count = process(newMFile+groups[i]+".map");
-                       outputNames.push_back(newMFile+groups[i]+".map"); outputTypes["map"].push_back(newMFile+groups[i]+".map");
-                       
-                       if (m->control_pressed) {  return 0; }
-                       
-                       m->mothurOut("Total number of sequences before pre.cluster was " + toString(alignSeqs.size()) + "."); m->mothurOutEndLine();
-                       m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine(); 
-                       printData(newFFile, newNFile);
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); 
-                       
-               }
-               
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "driverGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PreClusterCommand::process(string newMapFile){
-       try {
-               ofstream out;
-               m->openOutputFile(newMapFile, out);
-               
-               //sort seqs by number of identical seqs
-               sort(alignSeqs.begin(), alignSeqs.end(), comparePriority);
-               
-               int count = 0;
-               int numSeqs = alignSeqs.size();
-               
-               //think about running through twice...
-               for (int i = 0; i < numSeqs; i++) {
-                       
-                       //are you active
-                       //                      itActive = active.find(alignSeqs[i].seq.getName());
-                       
-                       if (alignSeqs[i].active) {  //this sequence has not been merged yet
-                               
-                               string chunk = alignSeqs[i].seq.getName() + "\t" + toString(alignSeqs[i].numIdentical) + "\t" + toString(0) + "\t" + alignSeqs[i].seq.getAligned() + "\n";
-                               
-                               //try to merge it with all smaller seqs
-                               for (int j = i+1; j < numSeqs; j++) {
-                                       
-                                       if (m->control_pressed) { out.close(); return 0; }
-                                       
-                                       if (alignSeqs[j].active) {  //this sequence has not been merged yet
-                                               //are you within "diff" bases
-                                               int mismatch = calcMisMatches(alignSeqs[i].seq.getAligned(), alignSeqs[j].seq.getAligned());
-                                               
-                                               if (mismatch <= diffs) {
-                                                       //merge
-                                                       alignSeqs[i].names += ',' + alignSeqs[j].names;
-                                                       alignSeqs[i].numIdentical += alignSeqs[j].numIdentical;
-                                                       
-                                                       chunk += alignSeqs[j].seq.getName() + "\t" + toString(alignSeqs[j].numIdentical) + "\t" + toString(mismatch) + "\t" + alignSeqs[j].seq.getAligned() + "\n";
-                                                       
-                                                       alignSeqs[j].active = 0;
-                                                       alignSeqs[j].numIdentical = 0;
-                                                       count++;
-                                               }
-                                       }//end if j active
-                               }//end for loop j
-                               
-                               //remove from active list 
-                               alignSeqs[i].active = 0;
-                               
-                               out << "ideal_seq_" << (i+1) << '\t' << alignSeqs[i].numIdentical << endl << chunk << endl;;
-                               
-                       }//end if active i
-                       if(i % 100 == 0)        { m->mothurOut(toString(i) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine(); }
-               }
-               out.close();
-               
-               if(numSeqs % 100 != 0)  { m->mothurOut(toString(numSeqs) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); m->mothurOutEndLine();   }       
-               
-               return count;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "process");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PreClusterCommand::readFASTA(){
-       try {
-               //ifstream inNames;
-               ifstream inFasta;
-               
-               //m->openInputFile(namefile, inNames);
-               m->openInputFile(fastafile, inFasta);
-               
-               //string firstCol, secondCol, nameString;
-               set<int> lengths;
-               
-               while (!inFasta.eof()) {
-                       
-                       if (m->control_pressed) { inFasta.close(); return 0; }
-                       
-                       //inNames >> firstCol >> secondCol;
-                       //nameString = secondCol;
-                       
-                       //m->gobble(inNames);
-                       //int size = 1;
-                       //while (secondCol.find_first_of(',') != -1) { 
-                       //      size++;
-                       //      secondCol = secondCol.substr(secondCol.find_first_of(',')+1, secondCol.length());
-                       //}
-                       
-                       Sequence seq(inFasta);  m->gobble(inFasta);
-                       
-                       if (seq.getName() != "") {  //can get "" if commented line is at end of fasta file
-                               if (namefile != "") {
-                                       itSize = sizes.find(seq.getName());
-                                       
-                                       if (itSize == sizes.end()) { m->mothurOut(seq.getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); exit(1); }
-                                       else{
-                                               seqPNode tempNode(itSize->second, seq, names[seq.getName()]);
-                                               alignSeqs.push_back(tempNode);
-                                               lengths.insert(seq.getAligned().length());
-                                       }       
-                               }else { //no names file, you are identical to yourself 
-                                       seqPNode tempNode(1, seq, seq.getName());
-                                       alignSeqs.push_back(tempNode);
-                                       lengths.insert(seq.getAligned().length());
-                               }
-                       }
-               }
-               inFasta.close();
-               //inNames.close();
-        
-        if (lengths.size() > 1) { m->control_pressed = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); }
-        else if (lengths.size() == 1) { length = *(lengths.begin()); }
-        
-               return alignSeqs.size();
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "readFASTA");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int PreClusterCommand::loadSeqs(map<string, string>& thisName, vector<Sequence>& thisSeqs){
-       try {
-               set<int> lengths;
-               alignSeqs.clear();
-               map<string, string>::iterator it;
-               bool error = false;
-                       
-               for (int i = 0; i < thisSeqs.size(); i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                                               
-                       if (namefile != "") {
-                               it = thisName.find(thisSeqs[i].getName());
-                               
-                               //should never be true since parser checks for this
-                               if (it == thisName.end()) { m->mothurOut(thisSeqs[i].getName() + " is not in your names file, please correct."); m->mothurOutEndLine(); error = true; }
-                               else{
-                                       //get number of reps
-                                       int numReps = 1;
-                                       for(int j=0;j<(it->second).length();j++){
-                                               if((it->second)[j] == ','){     numReps++;      }
-                                       }
-                                       
-                                       seqPNode tempNode(numReps, thisSeqs[i], it->second);
-                                       alignSeqs.push_back(tempNode);
-                    lengths.insert(thisSeqs[i].getAligned().length());
-                               }       
-                       }else { //no names file, you are identical to yourself 
-                               seqPNode tempNode(1, thisSeqs[i], thisSeqs[i].getName());
-                               alignSeqs.push_back(tempNode);
-                               lengths.insert(thisSeqs[i].getAligned().length());
-                       }
-               }
-               
-        if (lengths.size() > 1) { error = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); }
-        else if (lengths.size() == 1) { length = *(lengths.begin()); }
-        
-               //sanity check
-               if (error) { m->control_pressed = true; }
-               
-               thisSeqs.clear();
-               
-               return alignSeqs.size();
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "loadSeqs");
-               exit(1);
-       }
-}
-                               
-/**************************************************************************************************/
-
-int PreClusterCommand::calcMisMatches(string seq1, string seq2){
-       try {
-               int numBad = 0;
-               
-               for (int i = 0; i < seq1.length(); i++) {
-                       //do they match
-                       if (seq1[i] != seq2[i]) { numBad++; }
-                       if (numBad > diffs) { return length;  } //to far to cluster
-               }
-               
-               return numBad;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "calcMisMatches");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void PreClusterCommand::printData(string newfasta, string newname){
-       try {
-               ofstream outFasta;
-               ofstream outNames;
-               
-               if (bygroup) {
-                       m->openOutputFileAppend(newfasta, outFasta);
-                       m->openOutputFileAppend(newname, outNames);
-               }else {
-                       m->openOutputFile(newfasta, outFasta);
-                       m->openOutputFile(newname, outNames);
-               }
-               
-               for (int i = 0; i < alignSeqs.size(); i++) {
-                       if (alignSeqs[i].numIdentical != 0) {
-                               alignSeqs[i].seq.printSequence(outFasta); 
-                               outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
-                       }
-               }
-               
-               outFasta.close();
-               outNames.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "printData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void PreClusterCommand::readNameFile(){
-       try {
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string firstCol, secondCol;
-                               
-               while (!in.eof()) {
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       names[firstCol] = secondCol;
-                       int size = 1;
-
-                       for(int i=0;i<secondCol.size();i++){
-                               if(secondCol[i] == ','){        size++; }
-                       }
-                       sizes[firstCol] = size;
-               }
-               in.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "PreClusterCommand", "readNameFile");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-
diff --git a/preclustercommand.h b/preclustercommand.h
deleted file mode 100644 (file)
index 64efc7f..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-#ifndef PRECLUSTERCOMMAND_H
-#define PRECLUSTERCOMMAND_H
-
-
-/*
- *  preclustercommand.h
- *  Mothur
- *
- *  Created by westcott on 12/21/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sequence.hpp"
-#include "sequenceparser.h"
-
-/************************************************************/
-struct seqPNode {
-       int numIdentical;
-       Sequence seq;
-       string names;
-       bool active;
-       int diffs;
-       seqPNode() {}
-       seqPNode(int n, Sequence s, string nm) : numIdentical(n), seq(s), names(nm), active(1) { diffs = 0; }
-       ~seqPNode() {}
-};
-/************************************************************/
-inline bool comparePriority(seqPNode first, seqPNode second) {  return (first.numIdentical > second.numIdentical); }
-//************************************************************/
-
-class PreClusterCommand : public Command {
-       
-public:
-       PreClusterCommand(string);
-       PreClusterCommand();
-       ~PreClusterCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "pre.cluster";                         }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Pre.cluster"; }
-       string getDescription()         { return "implements a pseudo-single linkage algorithm with the goal of removing sequences that are likely due to pyrosequencing errors"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       struct linePair {
-               int start;
-               int end;
-               linePair(int i, int j) : start(i), end(j) {}
-       };
-       
-       int diffs, length, processors;
-       bool abort, bygroup;
-       string fastafile, namefile, outputDir, groupfile;
-       vector<seqPNode> alignSeqs; //maps the number of identical seqs to a sequence
-       map<string, string> names; //represents the names file first column maps to second column
-       map<string, int> sizes;  //this map a seq name to the number of identical seqs in the names file
-       map<string, int>::iterator itSize; 
-//     map<string, bool> active; //maps sequence name to whether it has already been merged or not.
-       vector<string> outputNames;
-       map<string, vector<string> > outputTypes;
-       
-       int readFASTA();
-       void readNameFile();
-       //int readNamesFASTA();
-       int calcMisMatches(string, string);
-       void printData(string, string); //fasta filename, names file name
-       int process(string);
-       int loadSeqs(map<string, string>&, vector<Sequence>&);
-       int driverGroups(SequenceParser*, string, string, string, int, int, vector<string> groups);
-       int createProcessesGroups(SequenceParser*, string, string, string, vector<string>);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct preClusterData {
-       string fastafile; 
-       string namefile; 
-       string groupfile;
-       string newFName, newNName, newMName;
-       MothurOut* m;
-       int start;
-       int end;
-       int diffs, threadID;
-       vector<string> groups;
-       vector<string> mapFileNames;
-       
-       preClusterData(){}
-       preClusterData(string f, string n, string g, string nff,  string nnf, string nmf, vector<string> gr, MothurOut* mout, int st, int en, int d, int tid) {
-               fastafile = f;
-               namefile = n;
-               groupfile = g;
-               newFName = nff;
-               newNName = nnf;
-               newMName = nmf;
-               m = mout;
-               start = st;
-               end = en;
-               diffs = d;
-               threadID = tid;
-               groups = gr;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){ 
-       preClusterData* pDataArray;
-       pDataArray = (preClusterData*)lpParam;
-       
-       try {
-               
-               //parse fasta and name file by group
-               SequenceParser* parser;
-               if (pDataArray->namefile != "") { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile);      }
-               else                                                    { parser = new SequenceParser(pDataArray->groupfile, pDataArray->fastafile);                                            }
-               
-               int numSeqs = 0;
-               vector<seqPNode> alignSeqs;
-               //clear out old files
-               ofstream outF; pDataArray->m->openOutputFile(pDataArray->newFName, outF); outF.close();
-               ofstream outN; pDataArray->m->openOutputFile(pDataArray->newNName, outN);  outN.close();
-               
-               //precluster each group
-               for (int k = pDataArray->start; k < pDataArray->end; k++) {
-                       
-                       int start = time(NULL);
-                       
-                       if (pDataArray->m->control_pressed) {  delete parser; return 0; }
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Processing group " + pDataArray->groups[k] + ":"); pDataArray->m->mothurOutEndLine();
-                       
-                       map<string, string> thisNameMap;
-                       if (pDataArray->namefile != "") { thisNameMap = parser->getNameMap(pDataArray->groups[k]); }
-                       vector<Sequence> thisSeqs = parser->getSeqs(pDataArray->groups[k]);
-                       
-                       //fill alignSeqs with this groups info.
-                       ////////////////////////////////////////////////////
-                       //numSeqs = loadSeqs(thisNameMap, thisSeqs); same function below
-                       
-                       int length = 0;
-                       alignSeqs.clear();
-                       map<string, string>::iterator it;
-                       bool error = false;
-                       
-                       for (int i = 0; i < thisSeqs.size(); i++) {
-                               
-                               if (pDataArray->m->control_pressed) { delete parser; return 0; }
-                               
-                               if (pDataArray->namefile != "") {
-                                       it = thisNameMap.find(thisSeqs[i].getName());
-                                       
-                                       //should never be true since parser checks for this
-                                       if (it == thisNameMap.end()) { pDataArray->m->mothurOut(thisSeqs[i].getName() + " is not in your names file, please correct."); pDataArray->m->mothurOutEndLine(); error = true; }
-                                       else{
-                                               //get number of reps
-                                               int numReps = 1;
-                                               for(int j=0;j<(it->second).length();j++){
-                                                       if((it->second)[j] == ','){     numReps++;      }
-                                               }
-                                               
-                                               seqPNode tempNode(numReps, thisSeqs[i], it->second);
-                                               alignSeqs.push_back(tempNode);
-                                               if (thisSeqs[i].getAligned().length() > length) {  length = thisSeqs[i].getAligned().length();  }
-                                       }       
-                               }else { //no names file, you are identical to yourself 
-                                       seqPNode tempNode(1, thisSeqs[i], thisSeqs[i].getName());
-                                       alignSeqs.push_back(tempNode);
-                                       if (thisSeqs[i].getAligned().length() > length) {  length = thisSeqs[i].getAligned().length();  }
-                               }
-                       }
-                       
-                       //sanity check
-                       if (error) { pDataArray->m->control_pressed = true; }
-                       
-                       thisSeqs.clear();
-                       numSeqs = alignSeqs.size();
-                       
-                       ////////////////////////////////////////////////////
-                       
-                       if (pDataArray->m->control_pressed) {   delete parser; return 0; }
-                       
-                       if (pDataArray->diffs > length) { pDataArray->m->mothurOut("Error: diffs is greater than your sequence length."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; return 0;  }
-                       
-                       ////////////////////////////////////////////////////
-                       //int count = process(); - same function below
-                       
-                       ofstream out;
-                       pDataArray->m->openOutputFile(pDataArray->newMName+pDataArray->groups[k]+".map", out);
-                       pDataArray->mapFileNames.push_back(pDataArray->newMName+pDataArray->groups[k]+".map");
-                       
-                       //sort seqs by number of identical seqs
-                       sort(alignSeqs.begin(), alignSeqs.end(), comparePriority);
-                       
-                       int count = 0;
-                       
-                       //think about running through twice...
-                       for (int i = 0; i < numSeqs; i++) {
-                               
-                               //are you active
-                               //                      itActive = active.find(alignSeqs[i].seq.getName());
-                               
-                               if (alignSeqs[i].active) {  //this sequence has not been merged yet
-                                       
-                                       string chunk = alignSeqs[i].seq.getName() + "\t" + toString(alignSeqs[i].numIdentical) + "\t" + toString(0) + "\t" + alignSeqs[i].seq.getAligned() + "\n";
-
-                                       //try to merge it with all smaller seqs
-                                       for (int j = i+1; j < numSeqs; j++) {
-                                               
-                                               if (pDataArray->m->control_pressed) { delete parser; return 0; }
-                                               
-                                               if (alignSeqs[j].active) {  //this sequence has not been merged yet
-                                                       //are you within "diff" bases
-                                                       //int mismatch = calcMisMatches(alignSeqs[i].seq.getAligned(), alignSeqs[j].seq.getAligned());
-                                                       int mismatch = 0;
-                                                       
-                                                       for (int k = 0; k < alignSeqs[i].seq.getAligned().length(); k++) {
-                                                               //do they match
-                                                               if (alignSeqs[i].seq.getAligned()[k] != alignSeqs[j].seq.getAligned()[k]) { mismatch++; }
-                                                               if (mismatch > pDataArray->diffs) { mismatch = length; break; } //to far to cluster
-                                                       }
-                                                       
-                                                       if (mismatch <= pDataArray->diffs) {
-                                                               //merge
-                                                               alignSeqs[i].names += ',' + alignSeqs[j].names;
-                                                               alignSeqs[i].numIdentical += alignSeqs[j].numIdentical;
-                                                               
-                                                               alignSeqs[j].active = 0;
-                                                               alignSeqs[j].numIdentical = 0;
-                                                               alignSeqs[j].diffs = mismatch;
-                                                               count++;
-                                                               chunk += alignSeqs[j].seq.getName() + "\t" + toString(alignSeqs[j].numIdentical) + "\t" + toString(mismatch) + "\t" + alignSeqs[j].seq.getAligned() + "\n";
-                                                       }
-                                               }//end if j active
-                                       }//end for loop j
-                                       
-                                       //remove from active list 
-                                       alignSeqs[i].active = 0;
-                                       
-                                       out << "ideal_seq_" << (i+1) << '\t' << alignSeqs[i].numIdentical << endl << chunk << endl;
-                                       
-                               }//end if active i
-                               if(i % 100 == 0)        { pDataArray->m->mothurOut(toString(i) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); pDataArray->m->mothurOutEndLine(); }
-                       }
-                       out.close();
-                       if(numSeqs % 100 != 0)  { pDataArray->m->mothurOut(toString(numSeqs) + "\t" + toString(numSeqs - count) + "\t" + toString(count)); pDataArray->m->mothurOutEndLine();   }       
-                       ////////////////////////////////////////////////////
-                       
-                       if (pDataArray->m->control_pressed) {  delete parser; return 0; }
-                       
-                       pDataArray->m->mothurOut("Total number of sequences before pre.cluster was " + toString(alignSeqs.size()) + ".");pDataArray-> m->mothurOutEndLine();
-                       pDataArray->m->mothurOut("pre.cluster removed " + toString(count) + " sequences."); pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOutEndLine(); 
-                       
-                       ////////////////////////////////////////////////////
-                       //printData(pDataArray->newFFile, pDataArray->newNFile); - same as below
-                       ofstream outFasta;
-                       ofstream outNames;
-                       
-                       pDataArray->m->openOutputFileAppend(pDataArray->newFName, outFasta);
-                       pDataArray->m->openOutputFileAppend(pDataArray->newNName, outNames);
-                                               
-                       for (int i = 0; i < alignSeqs.size(); i++) {
-                               if (alignSeqs[i].numIdentical != 0) {
-                                       alignSeqs[i].seq.printSequence(outFasta); 
-                                       outNames << alignSeqs[i].seq.getName() << '\t' << alignSeqs[i].names << endl;
-                               }
-                       }
-                       
-                       outFasta.close();
-                       outNames.close();
-                       ////////////////////////////////////////////////////
-                       
-                       pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to cluster " + toString(numSeqs) + " sequences."); pDataArray->m->mothurOutEndLine(); 
-                       
-               }
-               
-               return numSeqs;
-               
-
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "PreClusterCommand", "MyPreclusterThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-/**************************************************************************************************/
-
-
-#endif
-
-
diff --git a/prng.cpp b/prng.cpp
deleted file mode 100644 (file)
index 212f888..0000000
--- a/prng.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/* 
-   A C-program for MT19937, with initialization improved 2002/1/26.
-   Coded by Takuji Nishimura and Makoto Matsumoto.
-
-   Before using, initialize the state by using init_genrand(seed)  
-   or init_by_array(init_key, key_length).
-
-   Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
-   All rights reserved.                          
-
-   Redistribution and use in source and binary forms, with or without
-   modification, are permitted provided that the following conditions
-   are met:
-
-     1. Redistributions of source code must retain the above copyright
-        notice, this list of conditions and the following disclaimer.
-
-     2. Redistributions in binary form must reproduce the above copyright
-        notice, this list of conditions and the following disclaimer in the
-        documentation and/or other materials provided with the distribution.
-
-     3. The names of its contributors may not be used to endorse or promote 
-        products derived from this software without specific prior written 
-        permission.
-
-   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
-   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
-   Any feedback is very welcome.
-   http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
-   email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
-*/
-
-#include <stdio.h>
-
-#include "prng.h"
-
-/* Period parameters */  
-#define N 624
-#define M 397
-#define MATRIX_A 0x9908b0dfUL   /* constant vector a */
-#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
-
-#define NJ_RAND_MAX 0x7fffffffUL
-
-
-static unsigned long mt[N]; /* the array for the state vector  */
-static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
-
-/* initializes mt[N] with a seed */
-void init_genrand(unsigned long s)
-{
-    mt[0]= s & 0xffffffffUL;
-    for (mti=1; mti<N; mti++) {
-        mt[mti] = 
-           (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); 
-        /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
-        /* In the previous versions, MSBs of the seed affect   */
-        /* only MSBs of the array mt[].                        */
-        /* 2002/01/09 modified by Makoto Matsumoto             */
-        mt[mti] &= 0xffffffffUL;
-        /* for >32 bit machines */
-    }
-}
-
-/* initialize by an array with array-length */
-/* init_key is the array for initializing keys */
-/* key_length is its length */
-/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length)
-{
-    int i, j, k;
-    init_genrand(19650218UL);
-    i=1; j=0;
-    k = (N>key_length ? N : key_length);
-    for (; k; k--) {
-        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
-          + init_key[j] + j; /* non linear */
-        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
-        i++; j++;
-        if (i>=N) { mt[0] = mt[N-1]; i=1; }
-        if (j>=key_length) j=0;
-    }
-    for (k=N-1; k; k--) {
-        mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
-          - i; /* non linear */
-        mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
-        i++;
-        if (i>=N) { mt[0] = mt[N-1]; i=1; }
-    }
-
-    mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ 
-}
-
-/* generates a random number on [0,0xffffffff]-interval */
-unsigned long genrand_int32(void)
-{
-    unsigned long y;
-    static unsigned long mag01[2]={0x0UL, MATRIX_A};
-    /* mag01[x] = x * MATRIX_A  for x=0,1 */
-
-    if (mti >= N) { /* generate N words at one time */
-        int kk;
-
-        if (mti == N+1)   /* if init_genrand() has not been called, */
-            init_genrand(5489UL); /* a default initial seed is used */
-
-        for (kk=0;kk<N-M;kk++) {
-            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-            mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1UL];
-        }
-        for (;kk<N-1;kk++) {
-            y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
-            mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1UL];
-        }
-        y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
-        mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL];
-
-        mti = 0;
-    }
-  
-    y = mt[mti++];
-
-    /* Tempering */
-    y ^= (y >> 11);
-    y ^= (y << 7) & 0x9d2c5680UL;
-    y ^= (y << 15) & 0xefc60000UL;
-    y ^= (y >> 18);
-
-    return y;
-}
-
-/* generates a random number on [0,0x7fffffff]-interval */
-long int genrand_int31(void)
-{
-    return (long)(genrand_int32()>>1);
-}
-
-/* These real versions are due to Isaku Wada, 2002/01/09 added */
-
-/* generates a random number on [0,1]-real-interval */
-double genrand_real1(void)
-{
-    return genrand_int32()*(1.0/4294967295.0); 
-    /* divided by 2^32-1 */ 
-}
-
-/* generates a random number on [0,1)-real-interval */
-double genrand_real2(void)
-{
-    return genrand_int32()*(1.0/4294967296.0); 
-    /* divided by 2^32 */
-}
-
-/* generates a random number on (0,1)-real-interval */
-double genrand_real3(void)
-{
-    return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); 
-    /* divided by 2^32 */
-}
-
-/* generates a random number on [0,1) with 53-bit resolution*/
-double genrand_res53(void) 
-{ 
-    unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; 
-    return(a*67108864.0+b)*(1.0/9007199254740992.0); 
-} 
-
-
-
-
-/*
- * NJ_genrand_int31_top() - Returns an int in the range 0..top
- *
- * This function attempts to remove bias in selecting random 
- * integers in a range.
- *
- */
-long int
-NJ_genrand_int31_top(long int top) {
-
-  long int overflow;
-  long int r;
-  long int retval;
-
-  if(top <= 0) {
-    return(0); 
-  } else {
-    overflow = (NJ_RAND_MAX / top) * top;
-  }
-  
-  while(1) {
-    r = genrand_int31();
-    if(r < overflow) {
-      break;
-    }
-  }
-  
-  retval = r % top;
-  
-  return(retval);
-}
-
-
-
-
-
-
-
-
diff --git a/prng.h b/prng.h
deleted file mode 100644 (file)
index 9eb1510..0000000
--- a/prng.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * prng.h
- *
- * $Id$
- *
- *****************************************************************************
- *
- * Copyright (c) 2004,  Luke Sheneman
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without 
- * modification, are permitted provided that the following conditions 
- * are met:
- * 
- *  + Redistributions of source code must retain the above copyright 
- *    notice, this list of conditions and the following disclaimer. 
- *  + Redistributions in binary form must reproduce the above copyright 
- *    notice, this list of conditions and the following disclaimer in 
- *    the documentation and/or other materials provided with the 
- *    distribution. 
- *  + The names of its contributors may not be used to endorse or promote 
- *    products derived  from this software without specific prior 
- *    written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
- * POSSIBILITY OF SUCH DAMAGE.  
- *
- *****************************************************************************
- *
- * Some function prototypes for the Mersenne Twister PRNG
- *
- *****************************************************************************
- *
- * AUTHOR:
- * 
- *   Luke Sheneman
- *   sheneman@cs.uidaho.edu
- *
- */
-
-
-#ifndef _INC_PRNG_H_
-#define _INC_PRNG_H_ 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define NJ_RAND_MAX 0x7fffffffUL
-
-
-/* some function prototypes */
-void
-init_genrand(unsigned long s);
-
-void 
-init_by_array(unsigned long init_key[],
-             int key_length);
-
-unsigned long 
-genrand_int32(void);
-
-long int 
-genrand_int31(void);
-
-double 
-genrand_real1(void);
-
-double
-genrand_real2(void);
-
-double
-genrand_real3(void);
-
-double
-genrand_res53(void);
-
-long int
-NJ_genrand_int31_top(long int top);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _INC_PRNG_H_ */
-
-
-
-
diff --git a/progress.cpp b/progress.cpp
deleted file mode 100644 (file)
index ff93b34..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- *  progress.cpp
- *  
- *
- *  Created by Pat Schloss on 8/14/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-
-#include "progress.hpp"
-
-const int totalTicks = 50;
-const char marker = '|';
-
-
-/***********************************************************************/
-
-Progress::Progress(){
-       try {
-               m = MothurOut::getInstance();
-               m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#");
-               
-               nTicks = 0;
-               finalPos = 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Progress", "Progress");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-Progress::Progress(string job, int end){
-       try {
-               m = MothurOut::getInstance();
-               
-               m->mothurOut("********************#****#****#****#****#****#****#****#****#****#****#\n");
-               cout << setw(20) << left << job << setw(1) << marker;
-               m->mothurOutJustToLog(job);
-               m->mothurOut(toString(marker));
-               cout.flush();
-
-               nTicks = 0;
-               finalPos = end;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Progress", "Progress");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Progress::newLine(string job, int end){
-       try {
-               m->mothurOutEndLine();
-               cout << setw(20) << left << job << setw(1) << marker;
-               m->mothurOutJustToLog(job);
-               m->mothurOut(toString(marker));
-               cout.flush();
-               
-               nTicks = 0;
-               finalPos = end;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Progress", "newLine");
-               exit(1);
-       }
-}
-       
-/***********************************************************************/
-
-void Progress::update(const int currentPos){
-       try {
-               int ratio = int(totalTicks * (float)currentPos / finalPos);
-       
-               if(ratio > nTicks){
-                       for(int i=nTicks;i<ratio;i++){
-                               m->mothurOut(toString(marker));
-                               cout.flush();
-                       }
-                       nTicks = ratio;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Progress", "update");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void Progress::finish(){
-       try {
-               for(int i=nTicks;i<totalTicks;i++){
-                       m->mothurOut(toString(marker));
-                       cout.flush();
-               }
-       
-       
-               m->mothurOutEndLine();
-               m->mothurOut("***********************************************************************\n");
-               cout.flush();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Progress", "finish");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/progress.hpp b/progress.hpp
deleted file mode 100644 (file)
index f4d4fc3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef PROGRESS_H
-#define PROGRESS_H
-
-#include "mothur.h"
-#include "mothurout.h"
-
-class Progress {
-       
-public:
-       Progress();
-       Progress(string, int);
-       void update(int);
-       void newLine(string, int);
-       void finish();
-       
-private:
-       int nTicks;
-       int finalPos;
-       MothurOut* m;   
-};
-
-#endif
diff --git a/qstat.cpp b/qstat.cpp
deleted file mode 100644 (file)
index e07cdb3..0000000
--- a/qstat.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *  qstat.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/4/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "qstat.h"
-
-
-/***********************************************************************/
-
-EstOutput QStat::getValues(SAbundVector* rank){
-       try {
-               
-               /*test data VVV
-               int dstring[] = {0,0,1,4,2,0,2,1,1,1,1,1,0,1,1,2,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1};
-               vector<int> dvec;
-               for(int i = 0; i < 171; i++)
-                       dvec.push_back(dstring[i]);
-               int mr = 170;
-               int nb = 29;
-               int ns = 884;
-               SAbundVector rankw = SAbundVector(dvec, mr,nb,ns);
-               SAbundVector *rank = &rankw;*/
-               data.resize(1,0);
-               int numSpec = rank->getNumBins();
-               int r1 = -1;
-               int r3 = -1;
-               int r1Ind = 0;
-               int r3Ind = 0;
-               double sumSpec = 0;
-               double iqSum = 0;
-               for(int i = 1; i < rank->size(); i++) {
-                       if(r1 != -1 && r3 != -1)
-                               i = rank->size();
-                               
-                       sumSpec += rank->get(i);
-                       
-                       if(r1 == -1 && sumSpec >= numSpec*.25) {
-                               r1 = rank->get(i);
-                               r1Ind = i;
-                       }
-                       else if(r3 == -1 && sumSpec >= numSpec*.75) {
-                               r3 = rank->get(i);
-                               r3Ind = i;
-                       }
-                       else if(sumSpec >= numSpec*.25 && sumSpec < numSpec*.75)
-                               iqSum += rank->get(i);
-               }
-               
-               double qstat = (.5*r1 + iqSum + .5*r3)/log((double)r3Ind/r1Ind);
-               
-               data[0] = qstat;
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QStat", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/qstat.h b/qstat.h
deleted file mode 100644 (file)
index 699ba55..0000000
--- a/qstat.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef QSTAT_H
-#define QSTAT_H
-/*
- *  qstat.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/4/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/*This class implements the q statistic on single group. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class QStat : public Calculator  {
-       
-public:
-       QStat() : Calculator("qstat", 1, false) {};
-
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Qstat"; }
-
-private:
-       RAbundVector rdata;
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/qualityscores.cpp b/qualityscores.cpp
deleted file mode 100644 (file)
index 566b44c..0000000
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- *  qualityscores.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 7/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "qualityscores.h"
-
-/**************************************************************************************************/
-
-QualityScores::QualityScores(){
-       try {
-               m = MothurOut::getInstance();
-               seqName = "";
-               seqLength = -1;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "QualityScores");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-QualityScores::QualityScores(ifstream& qFile){
-       try {
-               
-               m = MothurOut::getInstance();
-               
-               seqName = "";
-               int score;
-               
-               qFile >> seqName; 
-               m->getline(qFile);
-               //cout << seqName << endl;      
-               if (seqName == "")      {
-                       m->mothurOut("Error reading quality file, name blank at position, " + toString(qFile.tellg()));
-                       m->mothurOutEndLine(); 
-               }
-               else{
-                       seqName = seqName.substr(1);
-               }
-               
-               string qScoreString = m->getline(qFile);
-               //cout << qScoreString << endl;
-               while(qFile.peek() != '>' && qFile.peek() != EOF){
-                       if (m->control_pressed) { break; }
-                       string temp = m->getline(qFile);
-                       //cout << temp << endl;
-                       qScoreString +=  ' ' + temp;
-               }
-               //cout << "done reading " << endl;      
-               istringstream qScoreStringStream(qScoreString);
-               int count = 0;
-               while(!qScoreStringStream.eof()){
-                       if (m->control_pressed) { break; }
-                       string temp;
-                       qScoreStringStream >> temp;  m->gobble(qScoreStringStream);
-                       
-                       //check temp to make sure its a number
-                       if (!m->isContainingOnlyDigits(temp)) { m->mothurOut("[ERROR]: In sequence " + seqName + "'s quality scores, expected a number and got " + temp + ", setting score to 0."); m->mothurOutEndLine(); temp = "0"; }
-                       convert(temp, score);
-                       
-                       //cout << count << '\t' << score << endl;
-                       qScores.push_back(score);
-                       count++;
-               }
-               //qScores.pop_back();
-               
-//             string scores = "";
-//             
-//             while(!qFile.eof()){    
-//                     
-//                     qFile >> seqName; 
-//                     
-//                     //get name
-//                     if (seqName.length() != 0) { 
-//                             seqName = seqName.substr(1);
-//                             while (!qFile.eof())    {       
-//                                     char c = qFile.get(); 
-//                                     //gobble junk on line
-//                                     if (c == 10 || c == 13){        break;  }
-//                             } 
-//                             m->gobble(qFile);
-//                     }
-//                     
-//                     //get scores
-//                     while(qFile){
-//                             char letter=qFile.get();
-//                             if((letter == '>')){    qFile.putback(letter);  break;  }
-//                             else if (isprint(letter)) { scores += letter; }
-//                     }
-//                     m->gobble(qFile);
-//                     
-//                     break;
-//             }
-//             
-//             //convert scores string to qScores
-//             istringstream qScoreStringStream(scores);
-//             
-//             int score;
-//             while(!qScoreStringStream.eof()){
-//                     
-//                     if (m->control_pressed) { break; }
-//                     
-//                     qScoreStringStream >> score;
-//                     qScores.push_back(score);
-//             }
-//             
-//             qScores.pop_back();
-
-               seqLength = qScores.size();
-               //cout << "seqlength = " << seqLength << '\t' << count << endl;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "QualityScores");
-               exit(1);
-       }                                                       
-       
-}
-
-/**************************************************************************************************/
-
-string QualityScores::getName(){
-       
-       try {
-               return seqName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "getName");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-void QualityScores::printQScores(ofstream& qFile){
-       try {
-               
-               double aveQScore = calculateAverage();
-               
-               qFile << '>' << seqName << '\t' << aveQScore << endl;
-               
-               for(int i=0;i<seqLength;i++){
-                       qFile << qScores[i] << ' ';
-               }
-               qFile << endl;
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "printQScores");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-void QualityScores::trimQScores(int start, int end){
-       try {
-               vector<int> hold;
-               
-
-               //cout << seqName << '\t' << start << '\t' << end << '\t' << qScores.size() << endl;
-               //for (int i = 0; i < qScores.size(); i++) { cout << qScores[i] << end; }
-               if(end == -1){          
-                       hold = vector<int>(qScores.begin()+start, qScores.end());
-                       qScores = hold;         
-               }
-               if(start == -1){
-                       if(qScores.size() > end){
-                               hold = vector<int>(qScores.begin(), qScores.begin()+end);
-                               qScores = hold;         
-                       }
-               }
-
-               seqLength = qScores.size();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "trimQScores");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-void QualityScores::flipQScores(){
-       try {
-               
-               vector<int> temp = qScores;
-               for(int i=0;i<seqLength;i++){
-                       qScores[seqLength - i - 1] = temp[i];
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "flipQScores");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-bool QualityScores::stripQualThreshold(Sequence& sequence, double qThreshold){
-       try {
-               string rawSequence = sequence.getUnaligned();
-               int seqLength = sequence.getNumBases();
-               
-               if(seqName != sequence.getName()){
-                       m->mothurOut("sequence name mismatch btwn fasta: " + sequence.getName() + " and qual file: " + seqName);
-                       m->mothurOutEndLine();  
-               }
-               
-               int end;
-               for(int i=0;i<seqLength;i++){
-                       end = i;
-                       if(qScores[i] < qThreshold){
-                               break;
-                       }
-               }
-               
-               //every score passed
-               if (end == (seqLength-1)) { end = seqLength; }
-               
-               sequence.setUnaligned(rawSequence.substr(0,end));
-               trimQScores(-1, end);
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "flipQScores");
-               exit(1);
-       }                                                       
-       
-}
-
-/**************************************************************************************************/
-
-bool QualityScores::stripQualRollingAverage(Sequence& sequence, double qThreshold){
-       try {
-               string rawSequence = sequence.getUnaligned();
-               int seqLength = sequence.getNumBases();
-               
-               if(seqName != sequence.getName()){
-                       m->mothurOut("sequence name mismatch btwn fasta: " + sequence.getName() + " and qual file: " + seqName);
-                       m->mothurOutEndLine();  
-               }
-               
-               int end = -1;
-               double rollingSum = 0.0000;
-               
-               for(int i=0;i<seqLength;i++){
-
-                       rollingSum += (double)qScores[i];
-                       
-                       if(rollingSum / (double)(i+1) < qThreshold){
-                               end = i;
-                               break;
-                       }
-               }
-               
-               if(end == -1){  end = seqLength;        }
-               
-               
-               sequence.setUnaligned(rawSequence.substr(0,end));
-               trimQScores(-1, end);
-               
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "flipQScores");
-               exit(1);
-       }                                                       
-       
-}
-
-/**************************************************************************************************/
-
-bool QualityScores::stripQualWindowAverage(Sequence& sequence, int stepSize, int windowSize, double qThreshold){
-       try {
-               string rawSequence = sequence.getUnaligned();
-               int seqLength = sequence.getNumBases();
-               
-               if(seqName != sequence.getName()){
-                       m->mothurOut("sequence name mismatch between fasta: " + sequence.getName() + " and qual file: " + seqName);
-                       m->mothurOutEndLine();
-               }
-               
-               int end = windowSize;
-               int start = 0;
-
-               if(seqLength < windowSize) {    return 0;       }
-                       
-               while((start+windowSize) < seqLength){
-                       double windowSum = 0.0000;
-
-                       for(int i=start;i<end;i++){
-                               windowSum += qScores[i];
-                       }
-                       double windowAverage = windowSum / (double)(end-start);
-                               
-                       if(windowAverage < qThreshold){
-                               end = end - stepSize;
-                               break;
-                       }
-                       
-                       start += stepSize;
-                       end = start + windowSize;
-                               
-                       if(end >= seqLength){   end = seqLength;        }
-                               
-               }
-       
-               if(end == -1){  end = seqLength;        }
-               
-               //failed first window
-               if (end < windowSize) { return 0; }
-                       
-               sequence.setUnaligned(rawSequence.substr(0,end));
-               trimQScores(-1, end);
-               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "stripQualWindowAverage");
-               exit(1);
-       }                                                       
-       
-}
-
-/**************************************************************************************************/
-
-double QualityScores::calculateAverage(){
-       
-       double aveQScore = 0.0000;
-       
-       for(int i=0;i<seqLength;i++){
-               aveQScore += (double) qScores[i];
-       }
-       aveQScore /= (double) seqLength;
-       
-       return aveQScore;
-}
-
-/**************************************************************************************************/
-
-bool QualityScores::cullQualAverage(Sequence& sequence, double qAverage){
-       try {
-               string rawSequence = sequence.getUnaligned();
-               bool success = 0;       //guilty until proven innocent
-               
-               if(seqName != sequence.getName())       {
-                       m->mothurOut("sequence name mismatch btwn fasta: " + sequence.getName() + " and qual file: " + seqName);
-                       m->mothurOutEndLine();  
-               } 
-                       
-               double aveQScore = calculateAverage();
-               
-               if(aveQScore >= qAverage)       {       success = 1;    }
-               else                                            {       success = 0;    }
-               
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "cullQualAverage");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void QualityScores::updateQScoreErrorMap(map<char, vector<int> >& qualErrorMap, string errorSeq, int start, int stop, int weight){
-       try {
-
-               int seqLength = errorSeq.size();
-               
-               int qIndex = start - 1;
-
-               for(int i=0;i<seqLength;i++){
-                       
-                       if(errorSeq[i] == 'm')          {       qualErrorMap['m'][qScores[qIndex]] += weight;   }
-                       else if(errorSeq[i] == 's')     {       qualErrorMap['s'][qScores[qIndex]] += weight;   }
-                       else if(errorSeq[i] == 'i')     {       qualErrorMap['i'][qScores[qIndex]] += weight;   }
-                       else if(errorSeq[i] == 'a')     {       qualErrorMap['a'][qScores[qIndex]] += weight;   /*if(qScores[qIndex] != 0){     cout << qIndex << '\t';         }*/     }
-                       else if(errorSeq[i] == 'd')     {       /*      there are no qScores for deletions      */              }
-
-                       if(errorSeq[i] != 'd')          {       qIndex++;       }
-                                               
-                       if(qIndex > stop){      break;  }
-               }       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "updateQScoreErrorMap");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void QualityScores::updateForwardMap(vector<vector<int> >& forwardMap, int start, int stop, int weight){
-       try {
-               
-               int index = 0;
-               for(int i=start-1;i<stop;i++){
-                       forwardMap[index++][qScores[i]] += weight;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "updateForwardMap");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void QualityScores::updateReverseMap(vector<vector<int> >& reverseMap, int start, int stop, int weight){
-       try {
-               
-               int index = 0;
-               for(int i=stop-1;i>=start;i--){
-                       reverseMap[index++][qScores[i]] += weight;
-               }
-               
-       }       
-       catch(exception& e) {
-               m->errorOut(e, "QualityScores", "updateForwardMap");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
diff --git a/qualityscores.h b/qualityscores.h
deleted file mode 100644 (file)
index 49034b8..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef QUALITYSCORES
-#define QUALITYSCORES
-
-/*
- *  qualityscores.h
- *  Mothur
- *
- *  Created by Pat Schloss on 7/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-//DataStructure for a quality file.
-
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "sequence.hpp"
-
-/**************************************************************************************************/
-
-class QualityScores {
-public:
-       QualityScores();
-       QualityScores(ifstream&);
-       string getName();
-       
-       vector<int> getQualityScores() { return qScores; }
-       void printQScores(ofstream&);
-       void trimQScores(int, int);
-       void flipQScores();
-       bool stripQualThreshold(Sequence&, double);
-       bool stripQualRollingAverage(Sequence&, double);
-       bool stripQualWindowAverage(Sequence&, int, int, double);
-       bool cullQualAverage(Sequence&, double);
-       void updateQScoreErrorMap(map<char, vector<int> >&, string, int, int, int);
-       void updateForwardMap(vector<vector<int> >&, int, int, int);
-       void updateReverseMap(vector<vector<int> >&, int, int, int);
-    void setName(string n) { seqName = n; }
-    void setScores(vector<int> qs) { qScores = qs; seqLength = qScores.size(); }
-    
-       
-private:
-       
-       double calculateAverage();
-       MothurOut* m;
-       vector<int> qScores;
-       
-       string seqName;
-       int seqLength;
-};
-       
-/**************************************************************************************************/
-
-#endif
diff --git a/quitcommand.cpp b/quitcommand.cpp
deleted file mode 100644 (file)
index 2c302e9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *  quitcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "quitcommand.h"
-
-//**********************************************************************************************************************
-QuitCommand::QuitCommand(string option) {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-
-}
-//**********************************************************************************************************************
-QuitCommand::~QuitCommand(){}
-//**********************************************************************************************************************
-int QuitCommand::execute(){
-       if (abort == true) { return 0; }
-       return 1;
-}
-//**********************************************************************************************************************
diff --git a/quitcommand.h b/quitcommand.h
deleted file mode 100644 (file)
index 6495800..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef QUITCOMMAND_H
-#define QUITCOMMAND_H
-/*
- *  quitcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-/* The quit() command:
-       The quit command terminates the mothur program. 
-       The quit command should be in the following format: quit ().   */
-
-
-class QuitCommand : public Command {
-       
-public:
-       QuitCommand(string);
-       QuitCommand() {}
-       ~QuitCommand();
-       
-       vector<string> setParameters()  { return outputNames;   } //dummy, doesn't really do anything   
-       string getCommandName()                 { return "quit";                }
-       string getCommandCategory()             { return "Hidden";              }
-       string getHelpString() { return "The quit command will terminate mothur and should be in the following format: quit() or quit. \n"; }   
-       string getCitation() { return "no citation"; }
-       string getDescription()         { return "quit"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       bool abort;
-       vector<string> outputNames;
-};
-
-#endif
diff --git a/rabundvector.cpp b/rabundvector.cpp
deleted file mode 100644 (file)
index 6cbaa0d..0000000
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- *  rabundvector.cpp
- *  
- *
- *  Created by Pat Schloss on 8/8/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "ordervector.hpp"
-#include "calculator.h"
-
-
-/***********************************************************************/
-
-RAbundVector::RAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {}
-
-/***********************************************************************/
-
-RAbundVector::RAbundVector(int n) : DataVector(), data(n,0) , maxRank(0), numBins(0), numSeqs(0) {}
-
-/***********************************************************************/
-
-//RAbundVector::RAbundVector(const RAbundVector& rav) : DataVector(rav), data(rav.data), (rav.label),  (rav.maxRank), (rav.numBins), (rav.numSeqs){}
-
-
-/***********************************************************************/
-
-RAbundVector::RAbundVector(string id, vector<int> rav) : DataVector(id), data(rav) {
-       try {
-               numBins = 0;
-               maxRank = 0;
-               numSeqs = 0;
-               
-               for(int i=0;i<data.size();i++){
-                       if(data[i] != 0)                {       numBins = i+1;          }
-                       if(data[i] > maxRank)   {       maxRank = data[i];      }
-                       numSeqs += data[i];
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "RAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-RAbundVector::RAbundVector(vector<int> rav, int mr, int nb, int ns) {
-       try {
-               numBins = nb;
-               maxRank = mr;
-               numSeqs = ns;
-               data = rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "RAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-RAbundVector::RAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               int hold;
-               f >> label >> hold;
-       
-               data.assign(hold, 0);
-               int inputData;
-       
-               for(int i=0;i<hold;i++){
-                       f >> inputData;
-                       set(i, inputData);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "RAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-RAbundVector::~RAbundVector() {
-
-}
-
-/***********************************************************************/
-
-void RAbundVector::set(int binNumber, int newBinSize){
-       try {
-               int oldBinSize = data[binNumber];
-               data[binNumber] = newBinSize;
-       
-               if(oldBinSize == 0)                     {       numBins++;                              }
-               if(newBinSize == 0)                     {       numBins--;                              }
-               if(newBinSize > maxRank)        {       maxRank = newBinSize;   }
-       
-               numSeqs += (newBinSize - oldBinSize);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-int RAbundVector::get(int index){
-       return data[index];
-       
-}
-/***********************************************************************/
-
-void RAbundVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-       
-}
-/***********************************************************************/
-
-void RAbundVector::push_back(int binSize){
-       try {
-               data.push_back(binSize);
-               numBins++;
-       
-               if(binSize > maxRank){
-                       maxRank = binSize;
-               }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void RAbundVector::pop_back(){
-
-       return data.pop_back();
-}
-
-/***********************************************************************/
-
-void RAbundVector::resize(int size){
-       
-       data.resize(size);
-}
-
-/***********************************************************************/
-
-int RAbundVector::size(){
-       return data.size();
-}
-
-/***********************************************************************/
-
-void RAbundVector::quicksort(){
-       sort(data.rbegin(), data.rend());
-}
-
-/***********************************************************************/
-
-int RAbundVector::sum(){
-       VecCalc vecCalc;
-       return vecCalc.sumElements(data);
-}
-
-/***********************************************************************/
-
-int RAbundVector::sum(int index){
-       VecCalc vecCalc;
-       return vecCalc.sumElements(data, index);
-}
-
-/***********************************************************************/
-
-int RAbundVector::numNZ(){
-       VecCalc vecCalc;
-       return vecCalc.numNZ(data);
-}
-
-/***********************************************************************/
-
-vector<int>::reverse_iterator RAbundVector::rbegin(){
-       return data.rbegin();                           
-}
-
-/***********************************************************************/
-
-vector<int>::reverse_iterator RAbundVector::rend(){
-       return data.rend();                                     
-}
-
-/***********************************************************************/
-void RAbundVector::nonSortedPrint(ostream& output){
-       try {   
-               output << label << '\t' << numBins << '\t';
-       
-               for(int i=0;i<numBins;i++){             output << data[i] << '\t';              }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "nonSortedPrint");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void RAbundVector::print(string prefix, ostream& output){
-       try {   
-               output << prefix << '\t' << numBins << '\t';
-       
-               vector<int> hold = data;
-               sort(hold.rbegin(), hold.rend());
-       
-               for(int i=0;i<numBins;i++){             output << hold[i] << '\t';              }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "print");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-void RAbundVector::print(ostream& output){
-       try {
-               output << label << '\t' << numBins << '\t';
-       
-               vector<int> hold = data;
-               sort(hold.rbegin(), hold.rend());
-               
-               for(int i=0;i<numBins;i++){             output << hold[i] << '\t';              }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-int RAbundVector::getNumBins(){
-       return numBins;
-}
-
-/***********************************************************************/
-
-int RAbundVector::getNumSeqs(){
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int RAbundVector::getMaxRank(){
-       return maxRank;
-}
-
-/***********************************************************************/
-
-RAbundVector RAbundVector::getRAbundVector(){
-       return *this;                   
-}
-
-/***********************************************************************/
-
-SAbundVector RAbundVector::getSAbundVector() {
-       try {
-               SAbundVector sav(maxRank+1);
-               
-               for(int i=0;i<data.size();i++){
-                       int abund = data[i];
-                       sav.set(abund, sav.get(abund) + 1);
-               }
-               sav.set(0, 0);
-               sav.setLabel(label);
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "getSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-OrderVector RAbundVector::getOrderVector(map<string,int>* nameMap = NULL) {
-       try {
-               OrderVector ov;
-
-               for(int i=0;i<data.size();i++){
-                       for(int j=0;j<data[i];j++){
-                               ov.push_back(i);
-                       }
-               }
-               random_shuffle(ov.begin(), ov.end());
-               ov.setLabel(label);     
-               ov.getNumBins();
-
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RAbundVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/rabundvector.hpp b/rabundvector.hpp
deleted file mode 100644 (file)
index c722229..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef RABUND_H
-#define RABUND_H
-
-#include "datavector.hpp"
-
-/*  Data Structure for a rabund file.
-    This class is a child to datavector.  It represents OTU information at a certain distance. 
-       A rabundvector can be converted into and ordervector, listvector or sabundvector.
-       Each member of the internal container "data" represents an individual OTU.
-       So data[0] = 6, because there are six member in that OTU.
-       example: listvector             =       a,b,c,d,e,f             g,h,i           j,k             l               m  
-                        rabundvector   =       6                               3                       2               1               1
-                        sabundvector   =       2               1               1               0               0               1
-                        ordervector    =       1       1       1       1       1       1       2       2       2       3       3       4       5 */
-
-//class SAbundVector;
-//class OrderVector;
-
-class RAbundVector : public DataVector {
-       
-public:
-       RAbundVector();
-       RAbundVector(int);
-       RAbundVector(vector<int>, int, int, int);
-//     RAbundVector(const RAbundVector&);
-       RAbundVector(string, vector<int>);
-       RAbundVector(const RAbundVector& bv) : DataVector(bv), data(bv.data), maxRank(bv.maxRank), numBins(bv.numBins), numSeqs(bv.numSeqs){};
-       RAbundVector(ifstream&);
-       ~RAbundVector();
-
-       int getNumBins();               
-       int getNumSeqs();                                                       
-       int getMaxRank();                                                       
-
-       void set(int, int);     
-       int get(int);
-       void push_back(int);
-       void pop_back();
-       void resize(int);
-       int size();
-       void quicksort();
-       int sum();
-       int sum(int);
-       int numNZ();
-       void clear();
-       vector<int>::reverse_iterator rbegin();
-       vector<int>::reverse_iterator rend();
-       
-       void print(ostream&);
-       void print(string, ostream&);
-       void nonSortedPrint(ostream&);
-       
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       
-private:
-       vector<int> data;
-       int maxRank;
-       int numBins;
-       int numSeqs;    
-};
-
-
-#endif
diff --git a/rarecalc.cpp b/rarecalc.cpp
deleted file mode 100644 (file)
index 9145061..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *  rarecalc.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "rarecalc.h"
-
-/***********************************************************************/
-
-EstOutput RareCalc::getValues(int n){
-       try {
-               EstOutput output(3,0);
-
-               double richness = (double)numBins;
-               double varS = 0.0000;
-       
-               double varTerm1 = 0.0000;
-               double varTerm2 = 0.0000;
-       
-               double rSummation = 0;
-               for(int i=0;i<numBins;i++){
-                       int N_ni = numSeqs - bins->get(i);
-                       rSummation += (bMatrix[N_ni][n]);
-               
-                       varTerm1 += (bMatrix[N_ni][n] * (1.0 - bMatrix[N_ni][n] / bMatrix[numSeqs][n]));
-
-                       for(int j=i+1;j<numBins;j++){
-                               varTerm2 += ( bMatrix[N_ni-bins->get(j)][n] - bMatrix[N_ni][n] * bMatrix[numSeqs-bins->get(j)][n] / bMatrix[numSeqs][n]);
-                       }
-               
-               }
-               richness -= (rSummation / bMatrix[numSeqs][n]);
-               varS = (varTerm1 + 2 * varTerm2) / bMatrix[numSeqs][n];
-               float sd = pow(varS, 0.5);
-       
-
-               output[0] = richness;
-               output[1] = richness - 1.96 * sd;       
-               output[2] = richness + 1.96 * sd;
-       
-               return output;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareCalc", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/rarecalc.h b/rarecalc.h
deleted file mode 100644 (file)
index 8a0fb72..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef RARECALC_H
-#define RARECALC_H
-/*
- *  rarecalc.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class is not currently used by Mothur */
-
-#include "calculator.h"
-
-/***********************************************************************/
-class RareCalc {
-
-public:
-       RareCalc(RAbundVector* b) : bins(b), numSeqs(b->getNumSeqs()), maxRank(b->getMaxRank()), numBins(b->getNumBins()) {     m = MothurOut::getInstance(); bMatrix = m->binomial(numSeqs+1); }
-       EstOutput getValues(int);
-       string getName()        {       return "rarecalc";      }
-private:
-       RAbundVector* bins;
-       vector<vector<double> > bMatrix;
-       int numSeqs, maxRank, numBins;
-       MothurOut* m;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/raredisplay.cpp b/raredisplay.cpp
deleted file mode 100644 (file)
index b82127c..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- *  raredisplay.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "raredisplay.h"
-
-/***********************************************************************/
-
-void RareDisplay::init(string label){
-       try {
-               this->label = label;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "init");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void RareDisplay::update(SAbundVector* rank){
-       try {
-               int newNSeqs = rank->getNumSeqs();
-               vector<double> data = estimate->getValues(rank);
-
-               if(nIters != 1){
-
-                       double oldS = var[index] * ( nIters - 2 );
-                       double delta = data[0] - results[index];
-                       double newMean = results[index] + delta / nIters;
-                       double newS = oldS + delta * ( data[0] - newMean );
-                       double newVar = newS / ( nIters - 1 );
-
-                       seqs[index] = newNSeqs;
-                       results[index] = newMean; 
-                       var[index] = newVar;
-                       
-                       index++;  
-               }
-               else{
-                       seqs.push_back(newNSeqs); 
-                       results.push_back(data[0]);
-                       var.push_back(0.0);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "update");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void RareDisplay::update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb) {
-       try {
-               vector<double> data = estimate->getValues(shared); 
-               double newNSeqs = data[0];
-               
-               if(nIters != 1){
-               
-                       double oldS = var[index] * ( nIters - 2 );
-                       double delta = data[0] - results[index];
-                       double newMean = results[index] + delta / nIters;
-                       double newS = oldS + delta * ( data[0] - newMean );
-                       double newVar = newS / ( nIters - 1 );
-                       seqs[index] = newNSeqs;
-                       results[index] = newMean; 
-                       var[index] = newVar;
-                       
-                       index++;  
-               }
-               else{
-                       
-                       seqs.push_back(newNSeqs); 
-                       results.push_back(data[0]);
-                       var.push_back(0.0);
-
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "update");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void RareDisplay::reset(){
-       try {
-               nIters++;
-               index = 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "reset");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void RareDisplay::close(){
-       try {
-               
-               output->initFile(label);
-       
-               for (int i = 0; i < seqs.size(); i++) {
-               
-                       vector<double> data(3,0);
-                       double variance = var[i];
-                       
-                       data[0] = results[i];
-                       
-                       double ci = 1.96 * pow(variance, 0.5);
-                       data[1] = data[0] - ci;
-                       data[2] = data[0] + ci;
-               
-                       output->output(seqs[i], data);
-               }
-               
-               nIters = 1;
-               index = 0;
-               
-               seqs.clear();
-               results.clear();
-               var.clear();
-               
-               output->resetFile();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "close");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void RareDisplay::inputTempFiles(string filename){
-       try {
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               int thisIters;
-               in >> thisIters; m->gobble(in);
-               
-               for (int i = 0; i < seqs.size(); i++) {
-                       double tempresult, tempvar;
-                       in >> tempresult >> tempvar; m->gobble(in);
-                       
-                       //find weighted result
-                       results[i] = ((nIters * results[i]) + (thisIters * tempresult)) / (float)(nIters + thisIters);
-                       
-                       var[i] = ((nIters * var[i]) + (thisIters * tempvar)) / (float)(nIters + thisIters);
-               }
-               
-               in.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "inputTempFiles");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void RareDisplay::outputTempFiles(string filename){
-       try {
-               ofstream out;
-               m->openOutputFile(filename, out);
-               
-               out << nIters << endl;
-               
-               for (int i = 0; i < seqs.size(); i++) {
-                       out << results[i] << '\t' << var[i] << endl;
-               }
-               
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareDisplay", "outputTempFiles");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
diff --git a/raredisplay.h b/raredisplay.h
deleted file mode 100644 (file)
index a875962..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef RAREDISPLAY_H
-#define RAREDISPLAY_H
-
-#include "sabundvector.hpp"
-#include "calculator.h"
-#include "fileoutput.h"
-#include "display.h"
-
-/***********************************************************************/
-
-class RareDisplay : public Display {
-       
-public:
-       RareDisplay(Calculator* calc, FileOutput* file) : estimate(calc), output(file), nIters(1), index(0) {};
-       ~RareDisplay()                                  {       delete estimate; delete output;         };
-       void init(string);
-       void reset();
-       void update(SAbundVector*);
-       void update(vector<SharedRAbundVector*> shared, int numSeqs, int numGroupComb);
-       void close();
-       bool isCalcMultiple() { return estimate->getMultiple(); }
-       
-       void outputTempFiles(string);
-       void inputTempFiles(string);
-       
-private:
-       Calculator* estimate;
-       FileOutput* output;
-       string label;
-       vector<int> seqs;  
-       vector<double> results;
-       vector<double> var;
-       int index, nIters;
-};
-
-#endif
-
diff --git a/rarefact.cpp b/rarefact.cpp
deleted file mode 100644 (file)
index 6a9cb31..0000000
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- *  rarefact.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 11/18/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "rarefact.h"
-//#include "ordervector.hpp"
-
-/***********************************************************************/
-
-int Rarefact::getCurve(float percentFreq = 0.01, int nIters = 1000){
-       try {
-               RarefactionCurveData* rcd = new RarefactionCurveData();
-               for(int i=0;i<displays.size();i++){
-                       rcd->registerDisplay(displays[i]);
-               }
-               
-               //convert freq percentage to number
-               int increment = 1;
-               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
-               else { increment = percentFreq;  }      
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               if(processors == 1){
-                                       driver(rcd, increment, nIters); 
-                               }else{
-                                       vector<int> procIters;
-                                       
-                                       int numItersPerProcessor = nIters / processors;
-                                       
-                                       //divide iters between processes
-                                       for (int i = 0; i < processors; i++) {
-                                               if(i == processors - 1){
-                                                       numItersPerProcessor = nIters - i * numItersPerProcessor;
-                                               }
-                                               procIters.push_back(numItersPerProcessor);
-                                       }
-                                       
-                                       createProcesses(procIters, rcd, increment); 
-                               }
-
-               #else
-                       driver(rcd, increment, nIters); 
-               #endif
-
-               for(int i=0;i<displays.size();i++){
-                       displays[i]->close();
-               }
-               
-               delete rcd;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Rarefact", "getCurve");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int Rarefact::driver(RarefactionCurveData* rcd, int increment, int nIters = 1000){
-       try {
-                       
-               for(int iter=0;iter<nIters;iter++){
-               
-                       for(int i=0;i<displays.size();i++){
-                               displays[i]->init(label);
-                       }
-               
-                       RAbundVector* lookup    = new RAbundVector(order->getNumBins());
-                       SAbundVector* rank      = new SAbundVector(order->getMaxRank()+1);
-                       random_shuffle(order->begin(), order->end());
-               
-                       for(int i=0;i<numSeqs;i++){
-                       
-                               if (m->control_pressed) { delete lookup; delete rank; delete rcd; return 0;  }
-                       
-                               int binNumber = order->get(i);
-                               int abundance = lookup->get(binNumber);
-                       
-                               rank->set(abundance, rank->get(abundance)-1);
-                               abundance++;
-               
-                               lookup->set(binNumber, abundance);
-                               rank->set(abundance, rank->get(abundance)+1);
-
-                               if((i == 0) || (i+1) % increment == 0){
-                                       rcd->updateRankData(rank);
-                               }
-                       }
-       
-                       if(numSeqs % increment != 0){
-                               rcd->updateRankData(rank);
-                       }
-
-                       for(int i=0;i<displays.size();i++){
-                               displays[i]->reset();
-                       }
-                       
-                       delete lookup;
-                       delete rank;
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Rarefact", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int Rarefact::createProcesses(vector<int>& procIters, RarefactionCurveData* rcd, int increment) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               driver(rcd, increment, procIters[process]);
-                       
-                               //pass numSeqs to parent
-                               for(int i=0;i<displays.size();i++){
-                                       string tempFile = toString(getpid()) + toString(i) + ".rarefact.temp";
-                                       displays[i]->outputTempFiles(tempFile);
-                               }
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               driver(rcd, increment, procIters[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       for(int j=0;j<displays.size();j++){
-                               string s = toString(processIDS[i]) + toString(j) + ".rarefact.temp";
-                               displays[j]->inputTempFiles(s);
-                               m->mothurRemove(s);
-                       }
-               }
-               
-               return 0;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Rarefact", "createProcesses");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int Rarefact::getSharedCurve(float percentFreq = 0.01, int nIters = 1000){
-try {
-               SharedRarefactionCurveData* rcd = new SharedRarefactionCurveData();
-               
-               label = lookup[0]->getLabel();
-               
-               //register the displays
-               for(int i=0;i<displays.size();i++){
-                       rcd->registerDisplay(displays[i]);
-               }
-               
-               //if jumble is false all iters will be the same
-               if (m->jumble == false)  {  nIters = 1;  }
-               
-               //convert freq percentage to number
-               int increment = 1;
-               if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
-               else { increment = percentFreq;  }
-               
-               for(int iter=0;iter<nIters;iter++){
-               
-                       for(int i=0;i<displays.size();i++){
-                               displays[i]->init(label);                 
-                       }
-                       
-                       if (m->jumble == true)  {
-                               //randomize the groups
-                               random_shuffle(lookup.begin(), lookup.end());
-                       }
-                       
-                       //make merge the size of lookup[0]
-                       SharedRAbundVector* merge = new SharedRAbundVector(lookup[0]->size());
-                       
-                       //make copy of lookup zero
-                       for(int i = 0; i<lookup[0]->size(); i++) {
-                               merge->set(i, lookup[0]->getAbundance(i), "merge");
-                       }
-                       
-                       vector<SharedRAbundVector*> subset;
-                       //send each group one at a time
-                       for (int k = 0; k < lookup.size(); k++) { 
-                               if (m->control_pressed) {  delete merge; delete rcd; return 0;  }
-                               
-                               subset.clear(); //clears out old pair of sharedrabunds
-                               //add in new pair of sharedrabunds
-                               subset.push_back(merge); subset.push_back(lookup[k]);
-                               
-                               rcd->updateSharedData(subset, k+1, numGroupComb);
-                               mergeVectors(merge, lookup[k]);
-                       }
-
-                       //resets output files
-                       for(int i=0;i<displays.size();i++){
-                               displays[i]->reset();
-                       }
-                       
-                       delete merge;
-               }
-               
-               for(int i=0;i<displays.size();i++){
-                       displays[i]->close();
-               }
-               
-               delete rcd;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Rarefact", "getSharedCurve");
-               exit(1);
-       }
-}
-
-/**************************************************************************************/
-void Rarefact::mergeVectors(SharedRAbundVector* shared1, SharedRAbundVector* shared2) {
-       try{
-               for (int k = 0; k < shared1->size(); k++) {
-                       //merge new species into shared1
-                       shared1->set(k, (shared1->getAbundance(k) + shared2->getAbundance(k)), "combo");  //set to 'combo' since this vector now contains multiple groups
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Rarefact", "mergeVectors");
-               exit(1);
-       }
-}
-
diff --git a/rarefact.h b/rarefact.h
deleted file mode 100644 (file)
index 5e42a78..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef RAREFACT_H
-#define RAREFACT_H
-
-#include "rarefactioncurvedata.h"
-#include "raredisplay.h"
-#include "ordervector.hpp"
-#include "mothur.h"
-
-
-class Rarefact {
-       
-public:
-       Rarefact(OrderVector* o, vector<Display*> disp, int p) :
-                       numSeqs(o->getNumSeqs()), order(o), displays(disp), label(o->getLabel()), processors(p)  { m = MothurOut::getInstance(); }
-       Rarefact(vector<SharedRAbundVector*> shared, vector<Display*> disp) :
-                                        lookup(shared), displays(disp) {  m = MothurOut::getInstance(); }
-
-       ~Rarefact(){};
-       int getCurve(float, int);
-       int getSharedCurve(float, int);
-       
-private:
-       
-       OrderVector* order;
-       vector<Display*> displays;
-       int numSeqs, numGroupComb, processors;
-       string label;
-       void mergeVectors(SharedRAbundVector*, SharedRAbundVector*);
-       vector<SharedRAbundVector*> lookup; 
-       MothurOut* m;
-       
-       int createProcesses(vector<int>&, RarefactionCurveData*, int);
-       int driver(RarefactionCurveData*, int, int);
-
-};
-
-
-#endif
-
diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp
deleted file mode 100644 (file)
index 82ff7fa..0000000
+++ /dev/null
@@ -1,656 +0,0 @@
-/*
- *  rarefactcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "rarefactcommand.h"
-#include "ace.h"
-#include "sobs.h"
-#include "nseqs.h"
-#include "chao1.h"
-#include "bootstrap.h"
-#include "simpson.h"
-#include "simpsoneven.h"
-#include "heip.h"
-#include "smithwilson.h"
-#include "invsimpson.h"
-#include "npshannon.h"
-#include "shannoneven.h"
-#include "shannon.h"
-#include "jackknife.h"
-#include "coverage.h"
-
-
-//**********************************************************************************************************************
-vector<string> RareFactCommand::setParameters(){       
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap", "sobs", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RareFactCommand::getHelpString(){       
-       try {
-               ValidCalculators validCalculator;
-               string helpString = "";
-               helpString += "The rarefaction.single command parameters are list, sabund, rabund, shared, label, iters, freq, calc, processors and abund.  list, sabund, rabund or shared is required unless you have a valid current file. \n";
-               helpString += "The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "The rarefaction.single command should be in the following format: \n";
-               helpString += "rarefaction.single(label=yourLabel, iters=yourIters, freq=yourFreq, calc=yourEstimators).\n";
-               helpString += "Example rarefaction.single(label=unique-.01-.03, iters=10000, freq=10, calc=sobs-rchao-race-rjack-rbootstrap-rshannon-rnpshannon-rsimpson).\n";
-               helpString += "The default values for iters is 1000, freq is 100, and calc is rarefaction which calculates the rarefaction curve for the observed richness.\n";
-               validCalculator.printCalc("rarefaction");
-               helpString += "If you are running rarefaction.single with a shared file and would like your results collated in one file, set groupmode=t. (Default=true).\n";
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-RareFactCommand::RareFactCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["rarefaction"] = tempOutNames;
-               outputTypes["r_chao"] = tempOutNames;
-               outputTypes["r_ace"] = tempOutNames;
-               outputTypes["r_jack"] = tempOutNames;
-               outputTypes["r_shannon"] = tempOutNames;
-               outputTypes["r_shannoneven"] = tempOutNames;
-               outputTypes["r_heip"] = tempOutNames;
-               outputTypes["r_smithwilson"] = tempOutNames;
-               outputTypes["r_npshannon"] = tempOutNames;
-               outputTypes["r_simpson"] = tempOutNames;
-               outputTypes["r_simpsoneven"] = tempOutNames;
-               outputTypes["r_invsimpson"] = tempOutNames;
-               outputTypes["r_bootstrap"] = tempOutNames;
-               outputTypes["r_coverage"] = tempOutNames;
-               outputTypes["r_nseqs"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "RareFactCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RareFactCommand::RareFactCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["rarefaction"] = tempOutNames;
-                       outputTypes["r_chao"] = tempOutNames;
-                       outputTypes["r_ace"] = tempOutNames;
-                       outputTypes["r_jack"] = tempOutNames;
-                       outputTypes["r_shannon"] = tempOutNames;
-                       outputTypes["r_shannoneven"] = tempOutNames;
-                       outputTypes["r_heip"] = tempOutNames;
-                       outputTypes["r_smithwilson"] = tempOutNames;
-                       outputTypes["r_npshannon"] = tempOutNames;
-                       outputTypes["r_simpson"] = tempOutNames;
-                       outputTypes["r_simpsoneven"] = tempOutNames;
-                       outputTypes["r_invsimpson"] = tempOutNames;
-                       outputTypes["r_bootstrap"] = tempOutNames;
-                       outputTypes["r_coverage"] = tempOutNames;
-                       outputTypes["r_nseqs"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                               
-                       if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               rabundfile = m->getRabundFile(); 
-                                               if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       sabundfile = m->getSabundFile(); 
-                                                       if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                                       else { 
-                                                               m->mothurOut("No valid current files. You must provide a list, sabund, rabund or shared file before you can use the collect.single command."); m->mothurOutEndLine(); 
-                                                               abort = true;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sobs";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sobs";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, freq); 
-                       
-                       temp = validParameter.validFile(parameters, "abund", false);                    if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, abund); 
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, nIters); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "groupmode", false);                if (temp == "not found") { temp = "T"; }
-                       groupMode = m->isTrue(temp);
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "RareFactCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RareFactCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if ((format != "sharedfile")) { inputFileNames.push_back(inputfile);  }
-               else {  inputFileNames = parseSharedFile(sharedfile);  format = "rabund"; }
-                               
-               if (m->control_pressed) { return 0; }
-               
-               map<int, string> file2Group; //index in outputNames[i] -> group
-               for (int p = 0; p < inputFileNames.size(); p++) {
-                       
-                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
-                                               
-                       if (m->control_pressed) {  outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }  m->clearGroups();  return 0; }
-                       
-                       if (inputFileNames.size() > 1) {
-                               m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       }
-                       int i;
-                       ValidCalculators validCalculator;
-                       
-                         
-                       for (i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("rarefaction", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "sobs") { 
-                                               rDisplays.push_back(new RareDisplay(new Sobs(), new ThreeColumnFile(fileNameRoot+"rarefaction")));
-                                               outputNames.push_back(fileNameRoot+"rarefaction"); outputTypes["rarefaction"].push_back(fileNameRoot+"rarefaction");
-                                       }else if (Estimators[i] == "chao") { 
-                                               rDisplays.push_back(new RareDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"r_chao")));
-                                               outputNames.push_back(fileNameRoot+"r_chao"); outputTypes["r_chao"].push_back(fileNameRoot+"r_chao");
-                                       }else if (Estimators[i] == "ace") { 
-                                               if(abund < 5)
-                                                       abund = 10;
-                                               rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace")));
-                                               outputNames.push_back(fileNameRoot+"r_ace"); outputTypes["r_ace"].push_back(fileNameRoot+"r_ace");
-                                       }else if (Estimators[i] == "jack") { 
-                                               rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack")));
-                                               outputNames.push_back(fileNameRoot+"r_jack"); outputTypes["r_jack"].push_back(fileNameRoot+"r_jack");
-                                       }else if (Estimators[i] == "shannon") { 
-                                               rDisplays.push_back(new RareDisplay(new Shannon(), new ThreeColumnFile(fileNameRoot+"r_shannon")));
-                                               outputNames.push_back(fileNameRoot+"r_shannon"); outputTypes["r_shannon"].push_back(fileNameRoot+"r_shannon");
-                                       }else if (Estimators[i] == "shannoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new ShannonEven(), new ThreeColumnFile(fileNameRoot+"r_shannoneven")));
-                                               outputNames.push_back(fileNameRoot+"r_shannoneven"); outputTypes["r_shannoneven"].push_back(fileNameRoot+"r_shannoneven");
-                                       }else if (Estimators[i] == "heip") { 
-                                               rDisplays.push_back(new RareDisplay(new Heip(), new ThreeColumnFile(fileNameRoot+"r_heip")));
-                                               outputNames.push_back(fileNameRoot+"r_heip"); outputTypes["r_heip"].push_back(fileNameRoot+"r_heip");
-                                       }else if (Estimators[i] == "smithwilson") { 
-                                               rDisplays.push_back(new RareDisplay(new SmithWilson(), new ThreeColumnFile(fileNameRoot+"r_smithwilson")));
-                                               outputNames.push_back(fileNameRoot+"r_smithwilson"); outputTypes["r_smithwilson"].push_back(fileNameRoot+"r_smithwilson");
-                                       }else if (Estimators[i] == "npshannon") { 
-                                               rDisplays.push_back(new RareDisplay(new NPShannon(), new ThreeColumnFile(fileNameRoot+"r_npshannon")));
-                                               outputNames.push_back(fileNameRoot+"r_npshannon"); outputTypes["r_npshannon"].push_back(fileNameRoot+"r_npshannon");
-                                       }else if (Estimators[i] == "simpson") { 
-                                               rDisplays.push_back(new RareDisplay(new Simpson(), new ThreeColumnFile(fileNameRoot+"r_simpson")));
-                                               outputNames.push_back(fileNameRoot+"r_simpson"); outputTypes["r_simpson"].push_back(fileNameRoot+"r_simpson");
-                                       }else if (Estimators[i] == "simpsoneven") { 
-                                               rDisplays.push_back(new RareDisplay(new SimpsonEven(), new ThreeColumnFile(fileNameRoot+"r_simpsoneven")));
-                                               outputNames.push_back(fileNameRoot+"r_simpsoneven"); outputTypes["r_simpsoneven"].push_back(fileNameRoot+"r_simpsoneven");
-                                       }else if (Estimators[i] == "invsimpson") { 
-                                               rDisplays.push_back(new RareDisplay(new InvSimpson(), new ThreeColumnFile(fileNameRoot+"r_invsimpson")));
-                                               outputNames.push_back(fileNameRoot+"r_invsimpson"); outputTypes["r_invsimpson"].push_back(fileNameRoot+"r_invsimpson");
-                                       }else if (Estimators[i] == "bootstrap") { 
-                                               rDisplays.push_back(new RareDisplay(new Bootstrap(), new ThreeColumnFile(fileNameRoot+"r_bootstrap")));
-                                               outputNames.push_back(fileNameRoot+"r_bootstrap"); outputTypes["r_bootstrap"].push_back(fileNameRoot+"r_bootstrap");
-                                       }else if (Estimators[i] == "coverage") { 
-                                               rDisplays.push_back(new RareDisplay(new Coverage(), new ThreeColumnFile(fileNameRoot+"r_coverage")));
-                                               outputNames.push_back(fileNameRoot+"r_coverage"); outputTypes["r_coverage"].push_back(fileNameRoot+"r_coverage");
-                                       }else if (Estimators[i] == "nseqs") { 
-                                               rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs")));
-                                               outputNames.push_back(fileNameRoot+"r_nseqs"); outputTypes["r_nseqs"].push_back(fileNameRoot+"r_nseqs");
-                                       }
-                    if (inputFileNames.size() > 1) { file2Group[outputNames.size()-1] = groups[p]; }
-                               }
-                       }
-                       
-                       
-                       //if the users entered no valid calculators don't execute command
-                       if (rDisplays.size() == 0) { for(int i=0;i<rDisplays.size();i++){       delete rDisplays[i];    }  return 0; }
-                       
-                       input = new InputData(inputFileNames[p], format);                       
-                       order = input->getOrderVector();
-                       string lastLabel = order->getLabel();
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                               if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;  delete order;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-
-                               
-                               if(allLines == 1 || labels.count(order->getLabel()) == 1){
-                                       
-                                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                                       rCurve = new Rarefact(order, rDisplays, processors);
-                                       rCurve->getCurve(freq, nIters);
-                                       delete rCurve;
-                                       
-                                       processedLabels.insert(order->getLabel());
-                                       userLabels.erase(order->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(order->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = order->getLabel();
-                                       
-                                       delete order;
-                                       order = (input->getOrderVector(lastLabel));
-                                       
-                                       m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                                       rCurve = new Rarefact(order, rDisplays, processors);
-                                       rCurve->getCurve(freq, nIters);
-                                       delete rCurve;
-                                       
-                                       processedLabels.insert(order->getLabel());
-                                       userLabels.erase(order->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       order->setLabel(saveLabel);
-                               }
-                               
-                               lastLabel = order->getLabel();          
-                               
-                               delete order;
-                               order = (input->getOrderVector());
-                       }
-                       
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;   for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it);
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       if (m->control_pressed) { for(int i=0;i<rDisplays.size();i++){  delete rDisplays[i];    }  delete input;   for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (order != NULL) {    delete order;   }
-                               order = (input->getOrderVector(lastLabel));
-                               
-                               m->mothurOut(order->getLabel()); m->mothurOutEndLine();
-                               rCurve = new Rarefact(order, rDisplays, processors);
-                               rCurve->getCurve(freq, nIters);
-                               delete rCurve;
-                               
-                               delete order;
-                       }
-                       
-                       
-                       for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
-                       rDisplays.clear();
-                       delete input;  
-               }
-               
-               
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-
-               //create summary file containing all the groups data for each label - this function just combines the info from the files already created.
-               if ((sharedfile != "") && (groupMode)) {   outputNames = createGroupFile(outputNames, file2Group);  }
-
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); } return 0; }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> RareFactCommand::createGroupFile(vector<string>& outputNames, map<int, string> file2Group) {
-       try {
-               
-               vector<string> newFileNames;
-               
-               //find different types of files
-               map<string, map<string, string> > typesFiles;
-               for (int i = 0; i < outputNames.size(); i++) {
-                       string extension = m->getExtension(outputNames[i]);
-                       
-                       ifstream in;
-                       m->openInputFile(outputNames[i], in);
-                       
-                       string labels = m->getline(in);
-                       string newLine = labels.substr(0, labels.find_first_of('\t'));
-                       
-                       newLine += "\tGroup" + labels.substr(labels.find_first_of('\t'));
-            
-            map<string, map<string, string> >::iterator itfind = typesFiles.find(extension);
-            if (itfind != typesFiles.end()) {
-                (itfind->second)[outputNames[i]] = file2Group[i];
-            }else {
-                map<string, string> temp;  
-                temp[outputNames[i]] = file2Group[i];
-                typesFiles[extension] = temp;
-            }
-                       
-                       string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + extension;
-                       
-                       //print headers
-                       ofstream out;
-                       m->openOutputFile(combineFileName, out);
-                       out << newLine << endl;
-                       out.close();
-                       
-               }
-               
-               //for each type create a combo file
-               map<int, int> lineToNumber; 
-               for (map<string, map<string, string> >::iterator it = typesFiles.begin(); it != typesFiles.end(); it++) {
-                       
-                       ofstream out;
-                       string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + it->first;
-                       m->openOutputFileAppend(combineFileName, out);
-                       newFileNames.push_back(combineFileName);
-                       map<string, string> thisTypesFiles = it->second;
-               
-                       //open each type summary file
-                       map<string, vector<string> > files; //maps file name to lines in file
-                       int maxLines = 0;
-                       int numColumns = 0;
-                       for (map<string, string>::iterator itFileNameGroup = thisTypesFiles.begin(); itFileNameGroup != thisTypesFiles.end(); itFileNameGroup++) {
-                
-                string thisfilename = itFileNameGroup->first;
-                string group = itFileNameGroup->second;
-               
-                               ifstream temp;
-                               m->openInputFile(thisfilename, temp);
-                               
-                               //read through first line - labels
-                               m->getline(temp);       m->gobble(temp);
-                               
-                               vector<string> thisFilesLines;
-                               
-                               thisFilesLines.push_back(group);
-                               int count = 1;
-                               while (!temp.eof()){
-                               
-                                       string thisLine = m->getline(temp);
-                                       
-                                       string numSampled = thisLine.substr(0, thisLine.find_first_of('\t'));
-                                       int num = 0;
-                                       convert(numSampled, num);
-                                       numColumns = m->getNumChar(thisLine, '\t');
-                                       lineToNumber[count] = num;
-                                       count++;
-                                                                       
-                                       thisFilesLines.push_back(thisLine);
-                                       m->gobble(temp);
-                               }
-                               
-                               files[thisfilename] = thisFilesLines;
-                               
-                               //save longest file for below
-                               if (maxLines < thisFilesLines.size()) { maxLines = thisFilesLines.size(); }
-                               
-                               temp.close();
-                               m->mothurRemove(thisfilename);
-                       }
-                       
-                       
-                       //for each label
-                       for (int k = 1; k < maxLines; k++) {
-                               
-                               //grab data for each group
-                               for (map<string, string>::iterator itFileNameGroup = thisTypesFiles.begin(); itFileNameGroup != thisTypesFiles.end(); itFileNameGroup++) {
-                    
-                                       string thisfilename = itFileNameGroup->first;
-                                       map<int, int>::iterator itLine = lineToNumber.find(k);
-                                       if (itLine != lineToNumber.end()) {
-                                               string output = toString(itLine->second);
-                                               if (k < files[thisfilename].size()) {
-                                                       string line = files[thisfilename][k];
-                                                       output = line.substr(0, line.find_first_of('\t'));
-                                                       output += '\t' + files[thisfilename][0] + '\t' + line.substr(line.find_first_of('\t'));
-                                               }else{
-                                                       output += '\t' + files[thisfilename][0] + '\t';
-                                                       for (int h = 0; h < numColumns; h++) {
-                                                               output += "NA\t";
-                                                       }
-                                               }
-                                               out << output << endl;
-                                       }else { m->mothurOut("[ERROR]: parsing results, cant find " + toString(k)); m->mothurOutEndLine(); }
-                               }
-                       }       
-                       
-                       out.close();
-                       
-               }
-               
-               //return combine file name
-               return newFileNames;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "createGroupFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> RareFactCommand::parseSharedFile(string filename) {
-       try {
-               vector<string> filenames;
-               
-               map<string, ofstream*> filehandles;
-               map<string, ofstream*>::iterator it3;
-               
-               input = new InputData(filename, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               
-               string sharedFileRoot = m->getRootName(filename);
-               
-               //clears file before we start to write to it below
-               for (int i=0; i<lookup.size(); i++) {
-                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-                       filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-               }
-               
-               ofstream* temp;
-               for (int i=0; i<lookup.size(); i++) {
-                       temp = new ofstream;
-                       filehandles[lookup[i]->getGroup()] = temp;
-                       groups.push_back(lookup[i]->getGroup());
-               }
-
-               while(lookup[0] != NULL) {
-               
-                       for (int i = 0; i < lookup.size(); i++) {
-                               RAbundVector rav = lookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
-                               rav.print(*(filehandles[lookup[i]->getGroup()]));
-                               (*(filehandles[lookup[i]->getGroup()])).close();
-                       }
-               
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               //free memory
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       delete it3->second;
-               }
-               
-               delete input;
-               m->clearGroups();
-
-               return filenames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactCommand", "parseSharedFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/rarefactcommand.h b/rarefactcommand.h
deleted file mode 100644 (file)
index 6aaa3de..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef RAREFACTCOMMAND_H
-#define RAREFACTCOMMAND_H
-/*
- *  rarefactcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "ordervector.hpp"
-#include "inputdata.h"
-#include "rarefact.h"
-#include "display.h"
-#include "validcalculator.h"
-
-class RareFactCommand : public Command {
-       
-public:
-       RareFactCommand(string);
-       RareFactCommand();      
-       ~RareFactCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "rarefaction.single";          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "Magurran AE (2004). Measuring biological diversity. Blackwell Pub.: Malden, Ma. \nhttp://www.mothur.org/wiki/Rarefaction.single"; }
-       string getDescription()         { return "generate intra-sample rarefaction curves using a re-sampling without replacement approach"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       vector<Display*> rDisplays;
-       OrderVector* order;
-       InputData* input;
-       Rarefact* rCurve;
-       int nIters, abund, processors;
-       float freq;
-       
-       bool abort, allLines, groupMode;
-       set<string> labels; //holds labels to be used
-       string label, calc, sharedfile, listfile, rabundfile, sabundfile, format, inputfile;
-       vector<string>  Estimators;
-       vector<string> inputFileNames, outputNames;
-       vector<string> groups;
-       string outputDir;
-       
-       vector<string> parseSharedFile(string);
-       vector<string> createGroupFile(vector<string>&, map<int, string>);
-};
-
-#endif
diff --git a/rarefactioncurvedata.h b/rarefactioncurvedata.h
deleted file mode 100644 (file)
index ecbdbfd..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef RAREFACTIONCURVEDATA_H
-#define RAREFACTIONCURVEDATA_H
-
-#include "mothur.h"
-#include "sabundvector.hpp"
-#include "display.h"
-#include "observable.h"
-
-/***********************************************************************/
-
-class RarefactionCurveData : public Observable {
-       
-public:
-       RarefactionCurveData() : rank(0) {};
-       
-       void registerDisplay(Display* o)        {       displays.insert(o);                             };
-       void removeDisplay(Display* o)          {       displays.erase(o);      delete o;       };
-       SAbundVector* getRankData()                     {       return rank;                                    };
-       void rankDataChanged()                          {       notifyDisplays();                               };
-       void updateRankData(SAbundVector* rv)   {       rank = rv; rankDataChanged();   };
-
-       void notifyDisplays(){  
-               for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                       (*pos)->update(rank);
-               }       
-       };
-       
-private:
-       set<Display*> displays;
-       SAbundVector* rank;
-       
-};
-
-/***********************************************************************/
-
-class SharedRarefactionCurveData : public Observable {
-       
-public:
-       SharedRarefactionCurveData() {}; //: shared1(0), shared2(0) 
-       
-       void registerDisplay(Display* o)        {       displays.insert(o);                             };
-       void removeDisplay(Display* o)          {       displays.erase(o);      delete o;       };
-       void SharedDataChanged()                        {       notifyDisplays();                               };
-       void updateSharedData(vector<SharedRAbundVector*> r, int numSeqs, int numGroupComb)     {       shared = r; NumSeqs = numSeqs; NumGroupComb = numGroupComb; SharedDataChanged(); };
-
-       void notifyDisplays(){  
-               for(set<Display*>::iterator pos=displays.begin();pos!=displays.end();pos++){
-                               (*pos)->update(shared, NumSeqs, NumGroupComb);
-               }       
-       };
-       
-private:
-       set<Display*> displays;
-       vector<SharedRAbundVector*> shared;
-       int NumSeqs, NumGroupComb;
-       
-};
-
-/***********************************************************************/
-
-
-#endif
-
diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp
deleted file mode 100644 (file)
index 64bdbb4..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- *  rarefactsharedcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "rarefactsharedcommand.h"
-#include "sharedsobs.h"
-#include "sharednseqs.h"
-
-//**********************************************************************************************************************
-vector<string> RareFactSharedCommand::setParameters(){ 
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pfreq("freq", "Number", "", "100", "", "", "",false,false); parameters.push_back(pfreq);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pcalc("calc", "Multiple", "sharednseqs-sharedobserved", "sharedobserved", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pjumble("jumble", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pjumble);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RareFactSharedCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The collect.shared command parameters are shared, label, freq, calc and groups.  shared is required if there is no current sharedfile. \n";
-               helpString += "The rarefaction.shared command parameters are shared, label, iters, groups, jumble and calc.  shared is required if there is no current sharedfile. \n";
-               helpString += "The rarefaction command should be in the following format: \n";
-               helpString += "rarefaction.shared(label=yourLabel, iters=yourIters, calc=yourEstimators, jumble=yourJumble, groups=yourGroups).\n";
-               helpString += "The freq parameter is used indicate when to output your data, by default it is set to 100. But you can set it to a percentage of the number of sequence. For example freq=0.10, means 10%. \n";
-               helpString += "Example rarefaction.shared(label=unique-0.01-0.03,  iters=10000, groups=B-C, jumble=T, calc=sharedobserved).\n";
-               helpString += "The default values for iters is 1000, freq is 100, and calc is sharedobserved which calculates the shared rarefaction curve for the observed richness.\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and jumble is true.\n";
-               helpString += validCalculator.printCalc("sharedrarefaction");
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. freq), '=' and parameters (i.e.yourFreq).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-RareFactSharedCommand::RareFactSharedCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["sharedrarefaction"] = tempOutNames;
-               outputTypes["sharedr_nseqs"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-RareFactSharedCommand::RareFactSharedCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["sharedrarefaction"] = tempOutNames;
-                       outputTypes["sharedr_nseqs"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-                       
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sharedobserved";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sharedobserved";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                       }
-                       m->setGroups(Groups);
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "freq", false);                     if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, freq); 
-                       
-                       temp = validParameter.validFile(parameters, "iters", false);                    if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, nIters); 
-                       
-                       temp = validParameter.validFile(parameters, "jumble", false);                   if (temp == "not found") { temp = "T"; }
-                       if (m->isTrue(temp)) { jumble = true; }
-                       else { jumble = false; }
-                       m->jumble = jumble;
-                               
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "RareFactSharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RareFactSharedCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-       
-               string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(sharedfile));
-               
-               ValidCalculators validCalculator;
-                       
-               for (int i=0; i<Estimators.size(); i++) {
-                       if (validCalculator.isValidCalculator("sharedrarefaction", Estimators[i]) == true) { 
-                               if (Estimators[i] == "sharedobserved") { 
-                                       rDisplays.push_back(new RareDisplay(new SharedSobs(), new SharedThreeColumnFile(fileNameRoot+"shared.rarefaction", "")));
-                                       outputNames.push_back(fileNameRoot+"shared.rarefaction"); outputTypes["sharedrarefaction"].push_back(fileNameRoot+"shared.rarefaction");
-                               }else if (Estimators[i] == "sharednseqs") { 
-                                       rDisplays.push_back(new RareDisplay(new SharedNSeqs(), new SharedThreeColumnFile(fileNameRoot+"shared.r_nseqs", "")));
-                                       outputNames.push_back(fileNameRoot+"shared.r_nseqs"); outputTypes["sharedr_nseqs"].push_back(fileNameRoot+"shared.r_nseqs");
-                               }
-                       }
-               }
-               
-               //if the users entered no valid calculators don't execute command
-               if (rDisplays.size() == 0) { return 0; }
-                       
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               if (m->control_pressed) { 
-                       m->clearGroups(); 
-                       delete input;
-                       for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       return 0;
-               }
-
-
-               if (lookup.size() < 2) { 
-                       m->mothurOut("I cannot run the command without at least 2 valid groups."); 
-                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
-                       return 0;
-               }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-       
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) { 
-                               m->clearGroups(); 
-                               delete input;
-                               for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               return 0;
-                       }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               rCurve = new Rarefact(lookup, rDisplays);
-                               rCurve->getSharedCurve(freq, nIters);
-                               delete rCurve;
-                       
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookup[0]->getLabel();
-                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       rCurve = new Rarefact(lookup, rDisplays);
-                                       rCurve->getSharedCurve(freq, nIters);
-                                       delete rCurve;
-
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookup[0]->setLabel(saveLabel);
-                       }
-                               
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       
-                       //get next line to process
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               if (m->control_pressed) { 
-                       m->clearGroups(); 
-                       delete input;
-                       for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }
-                       return 0;
-               }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) { 
-                       m->clearGroups(); 
-                       delete input; 
-                       for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);        }
-                       return 0;
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i]; }  } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       rCurve = new Rarefact(lookup, rDisplays);
-                       rCurve->getSharedCurve(freq, nIters);
-                       delete rCurve;
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               }
-               
-               for(int i=0;i<rDisplays.size();i++){    delete rDisplays[i];    }       
-               m->clearGroups(); 
-               delete input;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RareFactSharedCommand", "execute");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
diff --git a/rarefactsharedcommand.h b/rarefactsharedcommand.h
deleted file mode 100644 (file)
index 2112e8d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#ifndef RAREFACTSHAREDCOMMAND_H
-#define RAREFACTSHAREDCOMMAND_H
-/*
- *  rarefactsharedcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "rarefact.h"
-#include "display.h"
-#include "validcalculator.h"
-
-class RareFactSharedCommand : public Command {
-       
-public:
-       RareFactSharedCommand(string);
-       RareFactSharedCommand();
-       ~RareFactSharedCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "rarefaction.shared";          }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "Magurran AE (2004). Measuring biological diversity. Blackwell Pub.: Malden, Ma. \nhttp://www.mothur.org/wiki/Rarefaction.shared"; }
-       string getDescription()         { return "generate inter-sample rarefaction curves using a re-sampling without replacement approach"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       
-       vector<SharedRAbundVector*> lookup;
-       InputData* input;
-       Rarefact* rCurve;
-       vector<Display*> rDisplays;
-       int nIters;
-       string format;
-       float freq;
-       
-       bool abort, allLines, jumble;
-       set<string> labels; //holds labels to be used
-       string label, calc, groups, outputDir, sharedfile;
-       vector<string>  Estimators, Groups, outputNames;
-
-};
-
-#endif
diff --git a/readblast.cpp b/readblast.cpp
deleted file mode 100644 (file)
index 2d49477..0000000
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- *  readblast.cpp
- *  Mothur
- *
- *  Created by westcott on 12/10/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "readblast.h"
-#include "progress.hpp"
-
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareOverlap(seqDist left, seqDist right){
-       return (left.dist < right.dist);        
-} 
-/*********************************************************************************************/
-ReadBlast::ReadBlast(string file, float c, float p, int l, bool ms, bool h) : blastfile(file), cutoff(c), penalty(p), length(l), minWanted(ms), hclusterWanted(h) {
-       try {
-               m = MothurOut::getInstance();
-               matrix = NULL;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadBlast", "ReadBlast");
-               exit(1);
-       }
-} 
-/*********************************************************************************************/
-//assumptions about the blast file: 
-//1. if duplicate lines occur the first line is always best and is chosen
-//2. blast scores are grouped together, ie. a a .... score, a b .... score, a c ....score...
-int ReadBlast::read(NameAssignment* nameMap) {
-       try {
-       
-               //if the user has not given a names file read names from blastfile
-               if (nameMap->size() == 0) { readNames(nameMap);  }
-               int nseqs = nameMap->size();
-               
-               if (m->control_pressed) { return 0; }
-
-               ifstream fileHandle;
-               m->openInputFile(blastfile, fileHandle);
-               
-               string firstName, secondName, eScore, currentRow;
-               string repeatName = "";
-               int count = 1;
-               float distance, thisoverlap, refScore;
-               float percentId; 
-               float numBases, mismatch, gap, startQuery, endQuery, startRef, endRef, score, lengthThisSeq;
-               
-               ofstream outDist;
-               ofstream outOverlap;
-               
-               //create objects needed for read
-               if (!hclusterWanted) {
-                       matrix = new SparseMatrix();
-               }else{
-                       overlapFile = m->getRootName(blastfile) + "overlap.dist";
-                       distFile = m->getRootName(blastfile) + "hclusterDists.dist";
-                       
-                       m->openOutputFile(overlapFile, outOverlap);
-                       m->openOutputFile(distFile, outDist);
-               }
-               
-               if (m->control_pressed) { 
-                       fileHandle.close();
-                       if (!hclusterWanted) {  delete matrix; }
-                       else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile);  }
-                       return 0;
-               }
-               
-               Progress* reading = new Progress("Reading blast:     ", nseqs * nseqs);
-               
-               //this is used to quickly find if we already have a distance for this combo
-               vector< map<int,float> > dists;  dists.resize(nseqs);  //dists[0][1] = distance from seq0 to seq1
-               map<int, float> thisRowsBlastScores;
-               
-               if (!fileHandle.eof()) {
-                       //read in line from file
-                       fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
-                       m->gobble(fileHandle);
-                       
-                       currentRow = firstName;
-                       lengthThisSeq = numBases;
-                       repeatName = firstName + secondName;
-                       
-                       if (firstName == secondName) {   refScore = score;  }
-                       else{
-                               //convert name to number
-                               map<string,int>::iterator itA = nameMap->find(firstName);
-                               map<string,int>::iterator itB = nameMap->find(secondName);
-                               if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                               if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-                               
-                               thisRowsBlastScores[itB->second] = score;
-                               
-                               //calc overlap score
-                               thisoverlap = 1.0 - (percentId * (lengthThisSeq - startQuery) / endRef / 100.0 - penalty);
-                               
-                               //if there is a valid overlap, add it
-                               if ((startRef <= length) && ((endQuery+length) >= lengthThisSeq) && (thisoverlap < cutoff)) {
-                                       if (!hclusterWanted) {
-                                               seqDist overlapValue(itA->second, itB->second, thisoverlap);
-                                               overlap.push_back(overlapValue);
-                                       }else {
-                                               outOverlap << itA->first << '\t' << itB->first << '\t' << thisoverlap << endl;
-                                       }
-                               }
-                       }
-               }else { m->mothurOut("Error in your blast file, cannot read."); m->mothurOutEndLine(); exit(1); }
-
-                               
-               //read file
-               while(!fileHandle.eof()){  
-               
-                       if (m->control_pressed) { 
-                               fileHandle.close();
-                               if (!hclusterWanted) {  delete matrix; }
-                               else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile);  }
-                               delete reading;
-                               return 0;
-                       }
-                       
-                       //read in line from file
-                       fileHandle >> firstName >> secondName >> percentId >> numBases >> mismatch >> gap >> startQuery >> endQuery >> startRef >> endRef >> eScore >> score;
-                       //cout << firstName << '\t' << secondName << '\t' << percentId << '\t' << numBases << '\t' << mismatch << '\t' << gap << '\t' << startQuery << '\t' << endQuery << '\t' << startRef << '\t' << endRef << '\t' << eScore << '\t' << score << endl;       
-                       m->gobble(fileHandle);
-                       
-                       string temp = firstName + secondName; //to check if this file has repeat lines, ie. is this a blast instead of a blscreen file
-                       
-                       //if this is a new pairing
-                       if (temp != repeatName) {
-                               repeatName = temp; 
-                               
-                               if (currentRow == firstName) {
-                                       //cout << "first = " << firstName << " second = " << secondName << endl;        
-                                       if (firstName == secondName) { 
-                                               refScore = score;  
-                                               reading->update((count + nseqs));  
-                                               count++; 
-                                       }else{
-                                               //convert name to number
-                                               map<string,int>::iterator itA = nameMap->find(firstName);
-                                               map<string,int>::iterator itB = nameMap->find(secondName);
-                                               if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                                               if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-                                               
-                                               //save score
-                                               thisRowsBlastScores[itB->second] = score;
-                                                       
-                                               //calc overlap score
-                                               thisoverlap = 1.0 - (percentId * (lengthThisSeq - startQuery) / endRef / 100.0 - penalty);
-                                               
-                                               //if there is a valid overlap, add it
-                                               if ((startRef <= length) && ((endQuery+length) >= lengthThisSeq) && (thisoverlap < cutoff)) {
-                                                       if (!hclusterWanted) {
-                                                               seqDist overlapValue(itA->second, itB->second, thisoverlap);
-                                                               //cout << "overlap = " << itA->second << '\t' << itB->second << '\t' << thisoverlap << endl;
-                                                               overlap.push_back(overlapValue);
-                                                       }else {
-                                                               outOverlap << itA->first << '\t' << itB->first << '\t' << thisoverlap << endl;
-                                                       }
-                                               }
-                                       } //end else
-                               }else { //end row
-                                       //convert blast scores to distance and add cell to sparse matrix if we can
-                                       map<int, float>::iterator it;
-                                       map<int, float>::iterator itDist;
-                                       for(it=thisRowsBlastScores.begin(); it!=thisRowsBlastScores.end(); it++) {  
-                                               distance = 1.0 - (it->second / refScore);
-               
-                                               
-                                               //do we already have the distance calculated for b->a
-                                               map<string,int>::iterator itA = nameMap->find(currentRow);
-                                               itDist = dists[it->first].find(itA->second);
-                                               
-                                               //if we have it then compare
-                                               if (itDist != dists[it->first].end()) {
-       
-                                                       //if you want the minimum blast score ratio, then pick max distance
-                                                       if(minWanted) {  distance = max(itDist->second, distance);  }
-                                                       else{   distance = min(itDist->second, distance);  }
-
-                                                       //is this distance below cutoff
-                                                       if (distance < cutoff) {
-                                                               if (!hclusterWanted) {
-                                                                       PCell value(itA->second, it->first, distance);
-                                                                       matrix->addCell(value);
-                                                               }else{
-                                                                       outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl;
-                                                               }
-                                                       }
-                                                       //not going to need this again
-                                                       dists[it->first].erase(itDist);
-                                               }else { //save this value until we get the other ratio
-                                                       dists[itA->second][it->first] = distance;
-                                               }
-                                       }
-                                       //clear out last rows info
-                                       thisRowsBlastScores.clear();
-                                       
-                                       currentRow = firstName;
-                                       lengthThisSeq = numBases;
-                                       
-                                       //add this row to thisRowsBlastScores
-                                       if (firstName == secondName) {   refScore = score;  }
-                                       else{ //add this row to thisRowsBlastScores
-                                               
-                                               //convert name to number
-                                               map<string,int>::iterator itA = nameMap->find(firstName);
-                                               map<string,int>::iterator itB = nameMap->find(secondName);
-                                               if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                                               if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-                                               
-                                               thisRowsBlastScores[itB->second] = score;
-                                               
-                                               //calc overlap score
-                                               thisoverlap = 1.0 - (percentId * (lengthThisSeq - startQuery) / endRef / 100.0 - penalty);
-                                               
-                                               //if there is a valid overlap, add it
-                                               if ((startRef <= length) && ((endQuery+length) >= lengthThisSeq) && (thisoverlap < cutoff)) {
-                                                       if (!hclusterWanted) {
-                                                               seqDist overlapValue(itA->second, itB->second, thisoverlap);
-                                                               overlap.push_back(overlapValue);
-                                                       }else {
-                                                               outOverlap << itA->first << '\t' << itB->first << '\t' << thisoverlap << endl;
-                                                       }
-                                               }
-                                       }
-                               }//end if current row
-                       }//end if repeat
-               }//end while
-               
-               //get last rows info stored
-               //convert blast scores to distance and add cell to sparse matrix if we can
-               map<int, float>::iterator it;
-               map<int, float>::iterator itDist;
-               for(it=thisRowsBlastScores.begin(); it!=thisRowsBlastScores.end(); it++) {  
-                       distance = 1.0 - (it->second / refScore);
-                       
-                       //do we already have the distance calculated for b->a
-                       map<string,int>::iterator itA = nameMap->find(currentRow);
-                       itDist = dists[it->first].find(itA->second);
-                       
-                       //if we have it then compare
-                       if (itDist != dists[it->first].end()) {
-                               //if you want the minimum blast score ratio, then pick max distance
-                               if(minWanted) {  distance = max(itDist->second, distance);  }
-                               else{   distance = min(itDist->second, distance);  }
-                               
-                               //is this distance below cutoff
-                               if (distance < cutoff) {
-                                       if (!hclusterWanted) {
-                                               PCell value(itA->second, it->first, distance);
-                                               matrix->addCell(value);
-                                       }else{
-                                               outDist << itA->first << '\t' << nameMap->get(it->first) << '\t' << distance << endl;
-                                       }
-                               }
-                               //not going to need this again
-                               dists[it->first].erase(itDist);
-                       }else { //save this value until we get the other ratio
-                               dists[itA->second][it->first] = distance;
-                       }
-               }
-               //clear out info
-               thisRowsBlastScores.clear();
-               dists.clear();
-               
-               if (m->control_pressed) { 
-                               fileHandle.close();
-                               if (!hclusterWanted) {  delete matrix; }
-                               else { outOverlap.close(); m->mothurRemove(overlapFile); outDist.close(); m->mothurRemove(distFile);  }
-                               delete reading;
-                               return 0;
-               }
-               
-               if (!hclusterWanted) {
-                       sort(overlap.begin(), overlap.end(), compareOverlap);
-               }else {
-                       outDist.close();
-                       outOverlap.close();
-               }
-               
-               if (m->control_pressed) { 
-                               fileHandle.close();
-                               if (!hclusterWanted) {  delete matrix; }
-                               else {  m->mothurRemove(overlapFile);  m->mothurRemove(distFile);  }
-                               delete reading;
-                               return 0;
-               }
-               
-               reading->finish();
-               delete reading;
-               fileHandle.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadBlast", "read");
-               exit(1);
-       }
-} 
-/*********************************************************************************************/
-int ReadBlast::readNames(NameAssignment* nameMap) {
-       try {
-               m->mothurOut("Reading names... "); cout.flush();
-               
-               string name, hold, prevName;
-               int num = 1;
-               
-               ifstream in;
-               m->openInputFile(blastfile, in);
-               
-               //ofstream outName;
-               //m->openOutputFile((blastfile + ".tempOutNames"), outName);
-               
-               //read first line
-               in >> prevName;
-       
-               for (int i = 0; i < 11; i++) {  in >> hold;  }
-               m->gobble(in);
-                               
-               //save name in nameMap
-               nameMap->push_back(prevName);
-               
-               while (!in.eof()) {
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       //read line
-                       in >> name;
-       
-                       for (int i = 0; i < 11; i++) {  in >> hold;  }
-                       m->gobble(in);
-                       
-                       //is this a new name?
-                       if (name != prevName) {
-                               prevName = name;
-                               nameMap->push_back(name);
-                               num++;
-                       }
-               }
-       
-               in.close();
-               
-               //write out names file
-               //string outNames = m->getRootName(blastfile) + "names";
-               //ofstream out;
-               //m->openOutputFile(outNames, out);
-               //nameMap->print(out);
-               //out.close();
-               
-               if (m->control_pressed) { return 0; }
-               
-               m->mothurOut(toString(num) + " names read."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadBlast", "readNames");
-               exit(1);
-       }
-} 
-/*********************************************************************************************/
-
-
-
diff --git a/readblast.h b/readblast.h
deleted file mode 100644 (file)
index fd32380..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef READBLAST_H
-#define READBLAST_H
-/*
- *  readblast.h
- *  Mothur
- *
- *  Created by westcott on 12/10/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "sparsematrix.hpp"
-#include "nameassignment.hpp"
-
-/****************************************************************************************/
-
-//Note: this class creates a sparsematrix and list if the read is executed, but does not delete them on deconstruction.
-//the user of this object is responsible for deleting the matrix and list if they call the read or there will be a memory leak
-//it is done this way so the read can be deleted and the information still used.
-
-class ReadBlast {
-       
-public:
-       ReadBlast(string, float, float, int, bool, bool); //blastfile, cutoff, penalty, length of overlap, min or max bsr, hclusterWanted
-       ~ReadBlast() {}
-       
-       int read(NameAssignment*);
-       SparseMatrix* getDistMatrix()           {       return matrix;          }
-       vector<seqDist> getOverlapMatrix()      {       return overlap;         }
-       string getOverlapFile()                         {       return overlapFile;     }
-       string getDistFile()                            {       return distFile;        }
-       
-private:
-       string blastfile, overlapFile, distFile;
-       int length;     //number of amino acids overlapped
-       float penalty, cutoff;  //penalty is used to adjust error rate
-       bool minWanted;  //if true choose min bsr, if false choose max bsr
-       bool hclusterWanted;
-       
-       SparseMatrix* matrix;
-       vector<seqDist> overlap;
-       MothurOut* m;
-       
-       int readNames(NameAssignment*);
-};
-
-/*******************************************************************************************/
-
-#endif
-
diff --git a/readcluster.cpp b/readcluster.cpp
deleted file mode 100644 (file)
index b6cb71d..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- *  readcluster.cpp
- *  Mothur
- *
- *  Created by westcott on 10/28/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "readcluster.h"
-
-/***********************************************************************/
-
-ReadCluster::ReadCluster(string distfile, float c, string o, bool s){
-               m = MothurOut::getInstance();
-        distFile = distfile;
-               cutoff = c;
-               outputDir = o;
-               sortWanted = s;
-               list = NULL;
-}
-
-/***********************************************************************/
-
-int ReadCluster::read(NameAssignment*& nameMap){
-       try {
-        
-               if (format == "phylip") { convertPhylip2Column(nameMap); }
-               else { list = new ListVector(nameMap->getListVector());  }
-               
-               if (m->control_pressed) { return 0; }
-               
-               if (sortWanted) {  OutPutFile = m->sortFile(distFile, outputDir);  }
-               else {  OutPutFile = distFile;   } //for use by clusters splitMatrix to convert a phylip matrix to column
-               
-               return 0;
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadCluster", "read");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int ReadCluster::convertPhylip2Column(NameAssignment*& nameMap){
-       try {   
-               //convert phylip file to column file
-               map<int, string> rowToName;
-               map<int, string>::iterator it;
-               
-               ifstream in;
-               ofstream out;
-               string tempFile = distFile + ".column.temp";
-               
-               m->openInputFile(distFile, in);  m->gobble(in);
-               m->openOutputFile(tempFile, out);
-               
-               float distance;
-               int square, nseqs;
-               string name;
-               vector<string> matrixNames;
-               
-               string numTest;
-               in >> numTest >> name;
-               
-               if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ", quitting."); m->mothurOutEndLine(); exit(1); }
-               else { convert(numTest, nseqs); }
-               
-               rowToName[0] = name;
-               matrixNames.push_back(name);
-               
-               if(nameMap == NULL){
-                       list = new ListVector(nseqs);
-                       list->set(0, name);
-               }
-               else{
-                       list = new ListVector(nameMap->getListVector());
-                       if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-               }
-        
-               char d;
-               while((d=in.get()) != EOF){
-                       
-                       if(isalnum(d)){
-                               square = 1;
-                               in.putback(d);
-                               for(int i=0;i<nseqs;i++){
-                                       in >> distance;
-                               }
-                               break;
-                       }
-                       if(d == '\n'){
-                               square = 0;
-                               break;
-                       }
-               }
-        
-               if(square == 0){
-                                       
-                       for(int i=1;i<nseqs;i++){
-                               in >> name;
-                               rowToName[i] = name;
-                               matrixNames.push_back(name);
-                               
-                               //there's A LOT of repeated code throughout this method...
-                               if(nameMap == NULL){
-                                       list->set(i, name);
-                                       
-                                       for(int j=0;j<i;j++){
-                                       
-                                               if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; }
-                                               
-                                               in >> distance;
-                                               
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if(distance < cutoff){
-                                                       out << i << '\t' << j << '\t' << distance << endl;
-                                               }
-                                       }
-                                       
-                               }
-                               else{
-                                       if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                                       
-                                       for(int j=0;j<i;j++){
-                                               
-                                               if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; }
-                                               
-                                               in >> distance;
-                                               
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if(distance < cutoff){
-                                                       out << i << '\t' << j << '\t' << distance << endl;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               else{
-                       for(int i=1;i<nseqs;i++){
-                               in >> name;                
-                               rowToName[i] = name;
-                               matrixNames.push_back(name);
-               
-                               if(nameMap == NULL){
-                                       list->set(i, name);
-                                       for(int j=0;j<nseqs;j++){
-                                               if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; }
-                                               
-                                               in >> distance;
-                                       
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if(distance < cutoff && j < i){
-                                                       out << i << '\t' << j << '\t' << distance << endl;
-                                               }
-                                       }
-                               }
-                               else{
-                                       if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                                       
-                                       for(int j=0;j<nseqs;j++){
-                                               if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(tempFile); return 0; }
-                                               
-                                               in >> distance;
-                        
-                                               if (distance == -1) { distance = 1000000; }
-                                               
-                                               if(distance < cutoff && j < i){
-                                                       out << i << '\t' << j << '\t' << distance << endl;
-                                               }
-                                               
-                                       }
-                               }
-                       }
-               }
-               
-               list->setLabel("0");
-               in.close();
-               out.close();
-       
-               if(nameMap == NULL){
-                       nameMap = new NameAssignment();
-                       for(int i=0;i<matrixNames.size();i++){
-                               nameMap->push_back(matrixNames[i]);
-                       }
-               }
-               
-       
-               ifstream in2;
-               ofstream out2;
-               
-               string outputFile = m->getRootName(distFile) + "column.dist";
-               m->openInputFile(tempFile, in2);
-               m->openOutputFile(outputFile, out2);
-               
-               int first, second;
-               float dist;
-               
-               while (in2) {
-                       if (m->control_pressed) { in2.close(); out2.close(); m->mothurRemove(tempFile); m->mothurRemove(outputFile); return 0; }
-                       
-                       in2 >> first >> second >> dist;
-                       out2 << rowToName[first] << '\t' << rowToName[second] << '\t' << dist << endl;
-                       m->gobble(in2);
-               }
-               in2.close();
-               out2.close();
-               
-               m->mothurRemove(tempFile);
-               distFile = outputFile;
-       
-               if (m->control_pressed) {  m->mothurRemove(outputFile);  }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadCluster", "convertPhylip2Column");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-ReadCluster::~ReadCluster(){}
-/***********************************************************************/
-
diff --git a/readcluster.h b/readcluster.h
deleted file mode 100644 (file)
index a838dac..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef READCLUSTER_H
-#define READCLUSTER_H
-/*
- *  readcluster.h
- *  Mothur
- *
- *  Created by westcott on 10/28/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "nameassignment.hpp"
-#include "listvector.hpp"
-
-
-/******************************************************/
-
-class ReadCluster {
-       
-public:
-       ReadCluster(string, float, string, bool);
-       ~ReadCluster();
-       int read(NameAssignment*&);
-       string getOutputFile() { return OutPutFile; }
-       void setFormat(string f) { format = f;  }
-       ListVector* getListVector()             {       return list;    }
-       
-private:
-       string distFile, outputDir;
-       string OutPutFile, format;
-       ListVector* list;
-       float cutoff;
-       MothurOut* m;
-       bool sortWanted;
-       
-       int convertPhylip2Column(NameAssignment*&);
-};
-
-/******************************************************/
-
-#endif
-
diff --git a/readcolumn.cpp b/readcolumn.cpp
deleted file mode 100644 (file)
index 53a8c42..0000000
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- *  readcolumn.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readcolumn.h"
-#include "progress.hpp"
-
-/***********************************************************************/
-
-ReadColumnMatrix::ReadColumnMatrix(string df) : distFile(df){
-       
-       successOpen = m->openInputFile(distFile, fileHandle);
-       sim = false;
-       
-}
-/***********************************************************************/
-
-ReadColumnMatrix::ReadColumnMatrix(string df, bool s) : distFile(df){
-       
-       successOpen = m->openInputFile(distFile, fileHandle);
-       sim = s;
-}
-
-/***********************************************************************/
-
-int ReadColumnMatrix::read(NameAssignment* nameMap){
-       try {           
-
-               string firstName, secondName;
-               float distance;
-               int nseqs = nameMap->size();
-
-               list = new ListVector(nameMap->getListVector());
-       
-               Progress* reading = new Progress("Reading matrix:     ", nseqs * nseqs);
-
-               int lt = 1;
-               int refRow = 0; //we'll keep track of one cell - Cell(refRow,refCol) - and see if it's transpose
-               int refCol = 0; //shows up later - Cell(refCol,refRow).  If it does, then its a square matrix
-
-               //need to see if this is a square or a triangular matrix...
-       
-               while(fileHandle && lt == 1){  //let's assume it's a triangular matrix...
-
-               
-                       fileHandle >> firstName >> secondName >> distance;      // get the row and column names and distance
-                       
-                       if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-       
-                       map<string,int>::iterator itA = nameMap->find(firstName);
-                       map<string,int>::iterator itB = nameMap->find(secondName);
-                               
-                       if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                       if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-
-                       if (distance == -1) { distance = 1000000; }
-                       else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                       
-                       if(distance < cutoff && itA != itB){
-                               if(itA->second > itB->second){
-                                       PCell value(itA->second, itB->second, distance);
-                       
-                                       if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
-                                               refRow = itA->second;
-                                               refCol = itB->second;
-                                               D->addCell(value);
-                                       }
-                                       else if(refRow == itA->second && refCol == itB->second){
-                                               lt = 0;
-                                       }
-                                       else{
-                                               D->addCell(value);
-                                       }
-                               }
-                               else if(itA->second < itB->second){
-                                       PCell value(itB->second, itA->second, distance);
-                       
-                                       if(refRow == refCol){           // in other words, if we haven't loaded refRow and refCol...
-                                               refRow = itA->second;
-                                               refCol = itB->second;
-                                               D->addCell(value);
-                                       }
-                                       else if(refRow == itB->second && refCol == itA->second){
-                                               lt = 0;
-                                       }
-                                       else{
-                                               D->addCell(value);
-                                       }
-                               }
-                               reading->update(itA->second * nseqs);
-                       }
-                       m->gobble(fileHandle);
-               }
-
-               if(lt == 0){  // oops, it was square
-       
-                       fileHandle.close();  //let's start over
-                       D->clear();  //let's start over
-                  
-                       m->openInputFile(distFile, fileHandle);  //let's start over
-
-                       while(fileHandle){
-                               fileHandle >> firstName >> secondName >> distance;
-                               
-                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-               
-                               map<string,int>::iterator itA = nameMap->find(firstName);
-                               map<string,int>::iterator itB = nameMap->find(secondName);
-                               
-                               if(itA == nameMap->end()){  m->mothurOut("AAError: Sequence '" + firstName + "' was not found in the names file, please correct\n"); exit(1);  }
-                               if(itB == nameMap->end()){  m->mothurOut("ABError: Sequence '" + secondName + "' was not found in the names file, please correct\n"); exit(1);  }
-                               
-                               if (distance == -1) { distance = 1000000; }
-                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                               
-                               if(distance < cutoff && itA->second > itB->second){
-                                       PCell value(itA->second, itB->second, distance);
-                                       D->addCell(value);
-                                       reading->update(itA->second * nseqs);
-                               }
-               
-                               m->gobble(fileHandle);
-                       }
-               }
-               
-               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-               
-               reading->finish();
-               fileHandle.close();
-
-               list->setLabel("0");
-               
-               return 1;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadColumnMatrix", "read");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-ReadColumnMatrix::~ReadColumnMatrix(){
-       //delete D;
-       //delete list;
-}
-
-
diff --git a/readcolumn.h b/readcolumn.h
deleted file mode 100644 (file)
index 415bef2..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef READCOLUMN_H
-#define READCOLUMN_H
-/*
- *  readcolumn.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readmatrix.hpp"
-
-/******************************************************/
-
-class ReadColumnMatrix : public ReadMatrix {
-       
-public:
-       ReadColumnMatrix(string);
-       ReadColumnMatrix(string, bool);
-       ~ReadColumnMatrix();
-       int read(NameAssignment*);
-private:
-       ifstream fileHandle;
-       string distFile;
-       
-};
-
-/******************************************************/
-
-#endif
diff --git a/readdistcommand.cpp b/readdistcommand.cpp
deleted file mode 100644 (file)
index 8bf6996..0000000
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- *  readdistcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readdistcommand.h"
-#include "readphylip.h"
-#include "readcolumn.h"
-#include "readmatrix.hpp"
-
-//**********************************************************************************************************************
-ReadDistCommand::ReadDistCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*//valid paramters for this command
-                       string Array[] =  {"phylip", "column", "name", "cutoff", "precision", "group","outputdir","inputdir","sim"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  globaldata->setPhylipFile(phylipfile);  globaldata->setFormat("phylip");        }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { abort = true; } 
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  globaldata->setColumnFile(columnfile); globaldata->setFormat("column"); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else {  
-                               globaldata->setGroupFile(groupfile); 
-                               //groupMap = new GroupMap(groupfile);
-                               //groupMap->readMap();
-                       }
-
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else {  globaldata->setNameFile(namefile);      }
-                       
-                       //you are doing a list and group shared
-                       if ((phylipfile != "") && (groupfile != "")) { 
-                       globaldata->setFormat("matrix"); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { m->mothurOut("When executing a read.dist command you must enter a phylip or a column."); m->mothurOutEndLine(); abort = true; }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a read.dist command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-               
-                       if (columnfile != "") {
-                               if (namefile == "") {  cout << "You need to provide a namefile if you are going to use the column format." << endl; abort = true; }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       //get user cutoff and precision or use defaults
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);                if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "sim", false);                              if (temp == "not found") { temp = "F"; }
-                       sim = m->isTrue(temp); 
-                       globaldata->sim = sim;
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "10"; }
-                       convert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0)); 
-                       
-                       if (abort == false) {
-                               distFileName = globaldata->inputFileName;
-                               format = globaldata->getFormat();       
-               
-                               if (format == "column") { read = new ReadColumnMatrix(distFileName); }  
-                               else if (format == "phylip") { read = new ReadPhylipMatrix(distFileName); }
-                               else if (format == "matrix") { 
-                                       groupMap = new GroupMap(groupfile);
-                                       int error = groupMap->readMap();
-                                       if (error == 1) { delete groupMap; abort = true; }
-                                       else {
-                                               if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap;  }
-                                               globaldata->gGroupmap = groupMap;
-                                       }
-                               }
-               
-                               if (format != "matrix" ) {
-                                       read->setCutoff(cutoff);
-       
-                                       if(namefile != ""){     
-                                               nameMap = new NameAssignment(namefile);
-                                               nameMap->readMap();
-                                       }else{
-                                               nameMap = NULL;
-                                       }
-                               }
-                       }
-*/
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadDistCommand", "ReadDistCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ReadDistCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-/*
-               time_t start = time(NULL);
-               size_t numDists = 0;
-               
-               if (format == "matrix") {
-                       ifstream in;
-                       m->openInputFile(distFileName, in);
-                       matrix = new FullMatrix(in); //reads the matrix file
-                       in.close();
-                       
-                       if (m->control_pressed) { delete groupMap; delete matrix; return 0; }
-                       
-                       //if files don't match...
-                       if (matrix->getNumSeqs() < groupMap->getNumSeqs()) {  
-                               m->mothurOut("Your distance file contains " + toString(matrix->getNumSeqs()) + " sequences, and your group file contains " + toString(groupMap->getNumSeqs()) + " sequences.");  m->mothurOutEndLine();                         
-                               //create new group file
-                               if(outputDir == "") { outputDir += m->hasPath(groupfile); }
-                               
-                               string newGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "editted.groups";
-                               outputNames.push_back(newGroupFile);
-                               ofstream outGroups;
-                               m->openOutputFile(newGroupFile, outGroups);
-                               
-                               for (int i = 0; i < matrix->getNumSeqs(); i++) {
-                                       if (m->control_pressed) { delete groupMap; delete matrix; outGroups.close(); m->mothurRemove(newGroupFile); return 0; }
-                                       
-                                       Names temp = matrix->getRowInfo(i);
-                                       outGroups << temp.seqName << '\t' << temp.groupName << endl;
-                               }
-                               outGroups.close();
-                               
-                               m->mothurOut(newGroupFile + " is a new group file containing only the sequence that are in your distance file. I will read this file instead."); m->mothurOutEndLine();
-                               
-                               //read new groupfile
-                               delete groupMap; groupMap = NULL;
-                               groupfile = newGroupFile;
-                               globaldata->setGroupFile(groupfile); 
-                               
-                               groupMap = new GroupMap(groupfile);
-                               groupMap->readMap();
-                               
-                               if (m->control_pressed) { delete groupMap; delete matrix; m->mothurRemove(newGroupFile); return 0; }
-       
-                               globaldata->gGroupmap = groupMap;
-                       }
-                       
-                       //memory leak prevention
-                       if (globaldata->gMatrix != NULL) { delete globaldata->gMatrix;  }
-                       globaldata->gMatrix = matrix; //save matrix for coverage commands
-                       numDists = matrix->getSizes()[1];
-               } else {
-                       read->read(nameMap);
-                       //to prevent memory leak
-                       
-                       if (m->control_pressed) {  return 0; }
-               
-                       if (globaldata->gListVector != NULL) {  delete globaldata->gListVector;  }
-                       globaldata->gListVector = read->getListVector();
-
-                       if (globaldata->gSparseMatrix != NULL) { delete globaldata->gSparseMatrix;  }
-                       globaldata->gSparseMatrix = read->getMatrix();
-                       numDists = globaldata->gSparseMatrix->getNNodes();
-               }
-               
-               if (m->control_pressed) {  return 0; }
-
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-               }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to read "); m->mothurOutEndLine();
- */
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadDistCommand", "execute");
-               exit(1);
-       }
-}
diff --git a/readdistcommand.h b/readdistcommand.h
deleted file mode 100644 (file)
index afe077d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef READDISTCOMMAND_H
-#define READDISTCOMMAND_H
-/*
- *  readdistcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readmatrix.hpp"
-#include "fullmatrix.h"
-#include "groupmap.h"
-
-/* The read.dist command is used to read a distance matrix file.  
-The read.dist command parameter options are phylipfile, columnfile, namefile, cutoff and precision. 
-The read.dist command should be in the following format: read.dist(phylipfile=yourDistFile, 
-namefile=yourNameFile, cutoff=yourCutoff, precision=yourPrecision). The phylipfile or columnfile are required and if you use a columnfile the namefile is required.  
-If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.  */
-
-class NameAssignment;
-
-class ReadDistCommand : public Command {
-public:
-       ReadDistCommand(string);
-       ReadDistCommand() { abort = true; calledHelp = true; }
-       ~ReadDistCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.dist";   }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your distance files directly to the downstream commands like cluster."; } 
-       string getCitation() { return "http://www.mothur.org/wiki/Read.dist"; }
-       string getDescription()         { return "read.dist"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       double cutoff;
-       int precision;
-       ReadMatrix* read;
-       FullMatrix* matrix;
-       GroupMap* groupMap;
-       string distFileName, format, method;
-       string phylipfile, columnfile, namefile, groupfile, outputDir;
-       NameAssignment* nameMap;
-       vector<string> outputNames;
-
-       bool abort, sim;
-
-};
-
-#endif
diff --git a/readmatrix.hpp b/readmatrix.hpp
deleted file mode 100644 (file)
index 49ae294..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef READMATRIX_HPP
-#define READMATRIX_HPP
-
-/*
- *  readmatrix.hpp
- *  
- *
- *  Created by Pat Schloss on 8/13/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "listvector.hpp"
-#include "sparsematrix.hpp"
-#include "nameassignment.hpp"
-
-class SparseMatrix;
-
-class ReadMatrix {
-
-public:
-       ReadMatrix(){   D = new SparseMatrix();  m = MothurOut::getInstance();  }
-       virtual ~ReadMatrix() {}
-       virtual int read(NameAssignment*){ return 1; }
-       
-       void setCutoff(float c)                 {       cutoff = c;             }
-       SparseMatrix* getMatrix()               {       return D;               }
-       ListVector* getListVector()             {       return list;    }
-//     OrderVector* getOrderVector()   {       return order;   }
-
-       int successOpen;
-       
-protected:
-       SparseMatrix* D;
-       ListVector* list;
-       float cutoff;
-       MothurOut* m;
-       bool sim;
-};
-
-
-
-#endif
diff --git a/readotucommand.cpp b/readotucommand.cpp
deleted file mode 100644 (file)
index f39e8df..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- *  readotu.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS AMherst. All rights reserved.
- *
- */
-
-#include "readotucommand.h"
-
-
-//**********************************************************************************************************************
-ReadOtuCommand::ReadOtuCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ReadOtuCommand::ReadOtuCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*
-                       //valid paramters for this command
-                       string Array[] =  {"list","order","shared","relabund","label","group","sabund", "rabund","groups","ordergroup","outputdir","inputdir"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("order");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["order"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("ordergroup");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["ordergroup"] = inputDir + it->second;               }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }    
-                       else {  globaldata->setListFile(listfile);  globaldata->setFormat("list");      }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { abort = true; } 
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  globaldata->setSabundFile(sabundfile); globaldata->setFormat("sabund"); }
-
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { abort = true; } 
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  globaldata->setRabundFile(rabundfile);  globaldata->setFormat("rabund");}
-                       
-                       ordergroupfile = validParameter.validFile(parameters, "ordergroup", true);
-                       if (ordergroupfile == "not open") { abort = true; }     
-                       else if (ordergroupfile == "not found") { ordergroupfile = ""; }
-                       else {  globaldata->setOrderGroupFile(ordergroupfile);  }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { abort = true; } 
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  globaldata->setSharedFile(sharedfile); globaldata->setFormat("sharedfile");     }
-                       
-                       relAbundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relAbundfile == "not open") { abort = true; }       
-                       else if (relAbundfile == "not found") { relAbundfile = ""; }
-                       else {  globaldata->setRelAbundFile(relAbundfile); globaldata->setFormat("relabund");   }
-
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else {  
-                               globaldata->setGroupFile(groupfile); 
-                               groupMap = new GroupMap(groupfile);
-                               
-                               int error = groupMap->readMap();
-                               if (error == 1) { abort = true; }
-                               
-                               globaldata->gGroupmap = groupMap;
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               globaldata->Groups = Groups;
-                       }
-
-                       //you are doing a list and group shared
-                       if ((listfile != "") && (groupfile != "")) { globaldata->setFormat("shared"); }
-                       
-                       //you have not given a file
-                       if ((listfile == "") && (sharedfile == "") && (rabundfile == "") && (sabundfile == "") && (relAbundfile == "")) {
-                               m->mothurOut("You must enter either a listfile, rabundfile, sabundfile, relabund or a sharedfile with the read.otu command. "); m->mothurOutEndLine(); abort = true; 
-                       }
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                               globaldata->labels = labels;
-                       }
-                       
-                       globaldata->allLines = allLines;
-               
-                       orderfile = validParameter.validFile(parameters, "order", true);
-                       if (orderfile == "not open") { abort = true; }  
-                       else if (orderfile == "not found") { orderfile = ""; }
-                       else {  globaldata->setOrderFile(orderfile);    }
-                       
-                               
-                       if (abort == false) {
-                               //gets whichever one of the above is set
-                               filename = globaldata->inputFileName;
-                       }
-                        */
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "ReadOtuCommand");
-               exit(1);
-       }
-}
-///**********************************************************************************************************************
-
-int ReadOtuCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-       
-               /*
-               if (globaldata->getFormat() == "shared") {
-                       
-                       shared = new SharedCommand(outputDir);
-                       int okay = shared->execute();
-                       
-                       //problem with shared
-                       if (okay == 1) {
-                               globaldata->setListFile("");
-                               globaldata->setGroupFile("");
-                               globaldata->setSharedFile("");
-                       }else { //shared command outputs the filenames
-                               //m->mothurOutEndLine();
-                               //m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-                               //m->mothurOut(globaldata->getSharedFile()); m->mothurOutEndLine();     
-                               //m->mothurOutEndLine();
-                       }
-                       
-                       outputTypes = shared->getOutputFiles();
-                       
-                       //set rabund file as new current rabundfile
-                       string current = "";
-                       itTypes = outputTypes.find("rabund");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("shared");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-                       }                       
-                       
-                       delete shared;
-               }
-               */
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadOtuCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/readotucommand.h b/readotucommand.h
deleted file mode 100644 (file)
index c6d6503..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef READOTUCOMMAND_H
-#define READOTUCOMMAND_H
-/*
- *  readotu.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/20/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "sharedcommand.h"
-
-class ReadOtuCommand : public Command {
-public:
-       ReadOtuCommand(string);
-       ReadOtuCommand();
-       ~ReadOtuCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.otu";    }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your files directly to the downstream commands like collect.shared."; }   
-       string getCitation() { return "http://www.mothur.org/wiki/Read.otu"; }
-       string getDescription()         { return "read.otu"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       InputData* input;
-       Command* shared;
-       GroupMap* groupMap;
-       string filename, listfile, orderfile, sharedfile, label, groupfile, sabundfile, rabundfile, format, groups, outputDir, ordergroupfile, relAbundfile;
-       vector<string> Groups, outputNames;
-       map<string, vector<string> > outputTypes;
-
-       bool abort, allLines;
-       set<string> labels; //holds labels to be used
-
-};
-
-#endif
diff --git a/readphylip.cpp b/readphylip.cpp
deleted file mode 100644 (file)
index 1c529b2..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- *  readphylip.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readphylip.h"
-#include "progress.hpp"
-
-/***********************************************************************/
-
-ReadPhylipMatrix::ReadPhylipMatrix(string distFile){
-        
-        successOpen = m->openInputFile(distFile, fileHandle);
-               sim=false;
-        
-}
-/***********************************************************************/
-
-ReadPhylipMatrix::ReadPhylipMatrix(string distFile, bool s){
-       
-       successOpen = m->openInputFile(distFile, fileHandle);
-       sim=s;
-}
-
-
-/***********************************************************************/
-
-int ReadPhylipMatrix::read(NameAssignment* nameMap){
-        try {
-        
-                        float distance;
-                        int square, nseqs;
-                        string name;
-                        vector<string> matrixNames;
-                                               
-                                               string numTest;
-                                               fileHandle >> numTest >> name;
-                       
-                                               if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ", quitting."); m->mothurOutEndLine(); exit(1); }
-                                               else { convert(numTest, nseqs); }
-                       
-                        matrixNames.push_back(name);
-
-                        if(nameMap == NULL){
-                                list = new ListVector(nseqs);
-                                list->set(0, name);
-                        }
-                        else{
-                                list = new ListVector(nameMap->getListVector());
-                                if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                        }
-        
-                        char d;
-                        while((d=fileHandle.get()) != EOF){
-                
-                                if(isalnum(d)){
-                                        square = 1;
-                                        fileHandle.putback(d);
-                                        for(int i=0;i<nseqs;i++){
-                                                fileHandle >> distance;
-                                        }
-                                        break;
-                                }
-                                if(d == '\n'){
-                                        square = 0;
-                                        break;
-                                }
-                        }
-        
-                        Progress* reading;
-      
-                        if(square == 0){
-
-                                reading = new Progress("Reading matrix:     ", nseqs * (nseqs - 1) / 2);
-                
-                                int        index = 0;
-               
-                                for(int i=1;i<nseqs;i++){
-                                                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                                                               
-                                        fileHandle >> name;
-                                        matrixNames.push_back(name);
-                                               
-        
-                                        //there's A LOT of repeated code throughout this method...
-                                        if(nameMap == NULL){
-                                                list->set(i, name);
-                                        
-                                                for(int j=0;j<i;j++){
-                                                                                               
-                                                                                                               if (m->control_pressed) { delete reading; fileHandle.close(); return 0;  }
-                                                                                                               
-                                                        fileHandle >> distance;
-                                                                                       
-                                                
-                                                        if (distance == -1) { distance = 1000000; }
-                                                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                
-                                                        if(distance < cutoff){
-                                                                PCell value(i, j, distance);
-                                                                D->addCell(value);
-                                                        }
-                                                        index++;
-                                                        reading->update(index);
-                                                }
-                                
-                                        }
-                                        else{
-                                                if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                                
-                                                for(int j=0;j<i;j++){
-                                                        fileHandle >> distance;
-                                                                                                               
-                                                                                                               if (m->control_pressed) { delete reading; fileHandle.close(); return 0;  }
-                                
-                                                        if (distance == -1) { distance = 1000000; }
-                                                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                        
-                                                        if(distance < cutoff){
-                                                                PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
-                                                                D->addCell(value);
-                                                        }
-                                                        index++;
-                                                        reading->update(index);
-                                                }
-                                        }
-                                }
-                        }
-                        else{
-
-                                reading = new Progress("Reading matrix:     ", nseqs * nseqs);
-                        
-                                int index = nseqs;
-                
-                                for(int i=1;i<nseqs;i++){
-                                        fileHandle >> name;                
-                                        matrixNames.push_back(name);
-                                                                               
-                                                                               
-        
-                                        if(nameMap == NULL){
-                                                list->set(i, name);
-                                                for(int j=0;j<nseqs;j++){
-                                                        fileHandle >> distance;
-                                                                                                               
-                                                                                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                                                                                               
-                                                        if (distance == -1) { distance = 1000000; }
-                                                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.
-                                                        
-                                                        if(distance < cutoff && j < i){
-                                                                PCell value(i, j, distance);
-                                                                D->addCell(value);
-                                                        }
-                                                        index++;
-                                                        reading->update(index);
-                                                }
-                                        
-                                        }
-                                        else{
-                                                if(nameMap->count(name)==0){        m->mothurOut("Error: Sequence '" + name + "' was not found in the names file, please correct"); m->mothurOutEndLine(); }
-                                
-                                                for(int j=0;j<nseqs;j++){
-                                                        fileHandle >> distance;
-                                                                                                               
-                                                                                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                                                                                               
-                                                       if (distance == -1) { distance = 1000000; }
-                                                                                                               else if (sim) { distance = 1.0 - distance;  }  //user has entered a sim matrix that we need to convert.                                                        
-                                                        
-                                                                                                               if(distance < cutoff && j < i){
-                                                                PCell value(nameMap->get(matrixNames[i]), nameMap->get(matrixNames[j]), distance);
-                                                                D->addCell(value);
-                                                        }
-                                                        index++;
-                                                        reading->update(index);
-                                                }
-                                        }
-                                }
-                        }
-                                               
-                                               if (m->control_pressed) {  fileHandle.close();  delete reading; return 0; }
-                                               
-                        reading->finish();
-                        delete reading;
-
-                        list->setLabel("0");
-                        fileHandle.close();
-
-                     /*   if(nameMap != NULL){
-                                for(int i=0;i<matrixNames.size();i++){
-                                        nameMap->erase(matrixNames[i]);
-                                }
-                                if(nameMap->size() > 0){
-                                        //should probably tell them what is missing if we missed something
-                                        m->mothurOut("missed something\t" + toString(nameMap->size())); m->mothurOutEndLine();
-                                }
-                        } */
-                                               
-                                               return 1;
-
-                }
-        catch(exception& e) {
-               m->errorOut(e, "ReadPhylipMatrix", "read");
-                exit(1);
-        }
-       }
-
-/***********************************************************************/
-
-ReadPhylipMatrix::~ReadPhylipMatrix(){
-       // delete D;
-       // delete list;
-}
diff --git a/readphylip.h b/readphylip.h
deleted file mode 100644 (file)
index 244cc47..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef READPHYLIP_H
-#define READPHYLIP_H
-/*
- *  readphylip.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/21/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readmatrix.hpp"
-
-/******************************************************/
-
-class ReadPhylipMatrix : public ReadMatrix {
-       
-public:
-       ReadPhylipMatrix(string);
-       ReadPhylipMatrix(string, bool);
-       ~ReadPhylipMatrix();
-       int read(NameAssignment*);
-private:
-       ifstream fileHandle;
-       string distFile;
-};
-
-/******************************************************/
-
-#endif
diff --git a/readphylipvector.cpp b/readphylipvector.cpp
deleted file mode 100644 (file)
index 85f4777..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- *  readphylipvector.cpp
- *  mothur
- *
- *  Created by westcott on 1/11/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "readphylipvector.h"
-
-/***********************************************************************/
-ReadPhylipVector::ReadPhylipVector(string d) {
-       try {
-               m = MothurOut::getInstance();
-               distFile = d;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadPhylipVector", "ReadPhylipVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<string> ReadPhylipVector::read(vector< vector<double> >& matrix) {
-       try {
-               vector<string> names;
-               
-               ifstream in;
-               m->openInputFile(distFile, in);
-               
-               //check whether matrix is square
-               char d;
-               int square = 1;
-               int numSeqs;
-               string name;
-               
-               string numTest;
-               in >> numTest >> name;
-               
-               if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ". I suspect you entered a column formatted file as a phylip file, quitting."); m->mothurOutEndLine(); exit(1); }
-               else { convert(numTest, numSeqs); }
-               
-               while((d=in.get()) != EOF){
-                       
-                       //is d a number meaning its square
-                       if(isalnum(d)){ 
-                               square = 1; 
-                               break; 
-                       }
-                       
-                       //is d a line return meaning its lower triangle
-                       if(d == '\n'){
-                               square = 2;
-                               break;
-                       }
-               }
-               in.close();
-               
-               
-               //reopen and read now that you know whether you are square
-               ifstream f;
-               m->openInputFile(distFile, f);
-               
-               int rank;
-               f >> rank;
-               
-               names.resize(rank);
-               matrix.resize(rank);
-               if(square == 1){
-                       for(int i=0;i<rank;i++)
-                               matrix[i].resize(rank);
-                       for(int i=0;i<rank;i++) {
-                               f >> names[i];
-                               for(int j=0;j<rank;j++) {
-                                       if (m->control_pressed) { return names; }
-                                       
-                                       f >> matrix[i][j];
-                                       if (matrix[i][j] == -0.0000)
-                                               matrix[i][j] = 0.0000;
-                               }
-                       }
-               }
-               else if(square == 2){
-                       for(int i=0;i<rank;i++){
-                               matrix[i].resize(rank);
-                       }
-                       matrix[0][0] = 0.0000;
-                       f >> names[0];
-                       for(int i=1;i<rank;i++){
-                               f >> names[i];
-                               matrix[i][i]=0.0000;
-                               for(int j=0;j<i;j++){
-                                       if (m->control_pressed) { return names; }
-                                       f >> matrix[i][j];
-                                       if (matrix[i][j] == -0.0000)
-                                               matrix[i][j] = 0.0000;
-                                       matrix[j][i]=matrix[i][j];
-                               }
-                       }
-               }
-               f.close();
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadPhylipVector", "read");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<string> ReadPhylipVector::read(vector<seqDist>& matrix) {
-       try {
-               vector<string> names;
-               
-               ifstream in;
-               m->openInputFile(distFile, in);
-               
-               //check whether matrix is square
-               char d;
-               int square = 1;
-               int numSeqs;
-               string name;
-               
-               in >> numSeqs >> name; 
-               
-               while((d=in.get()) != EOF){
-                       
-                       //is d a number meaning its square
-                       if(isalnum(d)){ 
-                               square = 1; 
-                               break; 
-                       }
-                       
-                       //is d a line return meaning its lower triangle
-                       if(d == '\n'){
-                               square = 2;
-                               break;
-                       }
-               }
-               in.close();
-               
-               
-               //reopen and read now that you know whether you are square
-               ifstream f;
-               m->openInputFile(distFile, f);
-               
-               int rank;
-               float temp;
-               f >> rank;
-               
-               names.resize(rank);
-               if(square == 1){
-                       for(int i=0;i<rank;i++) {
-                               f >> names[i];
-                               for(int j=0;j<rank;j++) {
-                                       if (m->control_pressed) { return names; }
-                                       
-                                       f >> temp;
-                                       
-                                       if (j < i) { //only save lt
-                                               seqDist dist(i, j, temp);
-                                               matrix.push_back(dist);
-                                       }
-                               }
-                       }
-               }
-               else if(square == 2){
-                       f >> names[0];
-                       for(int i=1;i<rank;i++){
-                               f >> names[i];
-                               for(int j=0;j<i;j++){
-                                       if (m->control_pressed) { return names; }
-                                       f >> temp;
-                                       seqDist dist(i, j, temp);
-                                       matrix.push_back(dist);
-                               }
-                       }
-               }
-               f.close();
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadPhylipVector", "read");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
diff --git a/readphylipvector.h b/readphylipvector.h
deleted file mode 100644 (file)
index aa056c7..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef READPHYLIPVECTOR_H
-#define READPHYLIPVECTOR_H
-
-/*
- *  readphylipvector.h
- *  mothur
- *
- *  Created by westcott on 1/11/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/******************************************************/
-
-class ReadPhylipVector {
-       
-public:
-       ReadPhylipVector(string); //phylipfile - lt or square
-       ~ReadPhylipVector() {}
-       vector<string> read(vector< vector<double> >&); //pass in matrix to fill with values, returns vector of strings containing names in phylipfile
-       vector<string> read(vector<seqDist>&); //pass in matrix to fill with values, returns vector of strings containing names in phylipfile
-       
-private:
-       string distFile;
-       MothurOut* m;
-};
-
-/******************************************************/
-
-#endif
diff --git a/readtree.cpp b/readtree.cpp
deleted file mode 100644 (file)
index 6fa4c3d..0000000
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- *  readtree.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readtree.h"
-
-/***********************************************************************/
-ReadTree::ReadTree() {
-       try {
-               m = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTree", "ReadTree");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int ReadTree::AssembleTrees(map<string, string> nameMap) {
-        try {
-                //assemble users trees
-                for (int i = 0; i < Trees.size(); i++) {
-                        if (m->control_pressed) { return 0;  }
-                        Trees[i]->assembleTree(nameMap);
-                }
-                return 0;
-        }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTree", "AssembleTrees");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int ReadTree::readSpecialChar(istream& f, char c, string name) {
-    try {
-       
-               m->gobble(f);
-               char d = f.get();
-       
-               if(d == EOF){
-                       m->mothurOut("Error: Input file ends prematurely, expecting a " + name + "\n");
-                       exit(1);
-               }
-               if(d != c){
-                       m->mothurOut("Error: Expected " + name + " in input file.  Found " + toString(d) + ".\n");
-                       exit(1);
-               }
-               if(d == ')' && f.peek() == '\n'){
-                       m->gobble(f);
-               }       
-               return d;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTree", "readSpecialChar");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ReadTree::readNodeChar(istream& f) {
-       try {
-//             while(isspace(d=f.get()))               {;}
-               m->gobble(f);
-               char d = f.get();
-
-               if(d == EOF){
-                       m->mothurOut("Error: Input file ends prematurely, expecting a left parenthesis\n");
-                       exit(1);
-               }
-               return d;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTree", "readNodeChar");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-float ReadTree::readBranchLength(istream& f) {
-    try {
-               float b;
-       
-               if(!(f >> b)){
-                       m->mothurOut("Error: Missing branch length in input tree.\n");
-                       exit(1);
-               }
-               m->gobble(f);
-               return b;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTree", "readBranchLength");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-/***********************************************************************/
-
-//Child Classes Below
-
-/***********************************************************************/
-/***********************************************************************/
-//This class reads a file in Newick form and stores it in a tree.
-
-int ReadNewickTree::read(TreeMap* tmap) {
-       try {
-               holder = "";
-               int c, error;
-               int comment = 0;
-               
-               //if you are not a nexus file 
-               if ((c = filehandle.peek()) != '#') {  
-                       while((c = filehandle.peek()) != EOF) { 
-                               while ((c = filehandle.peek()) != EOF) {
-                                       // get past comments
-                                       if(c == '[') {
-                                               comment = 1;
-                                       }
-                                       if(c == ']'){
-                                               comment = 0;
-                                       }
-                                       if((c == '(') && (comment != 1)){ break; }
-                                       filehandle.get();
-                               }
-
-                               //make new tree
-                               T = new Tree(tmap); 
-
-                               numNodes = T->getNumNodes();
-                               numLeaves = T->getNumLeaves();
-                               
-                               error = readTreeString(tmap); 
-                               
-                               //save trees for later commands
-                               Trees.push_back(T); 
-                               m->gobble(filehandle);
-                       }
-               //if you are a nexus file
-               }else if ((c = filehandle.peek()) == '#') {
-                       //get right number of seqs from nexus file.
-                       Tree* temp = new Tree(tmap);  delete temp;
-                       
-                       nexusTranslation(tmap);  //reads file through the translation and updates treemap
-                       while((c = filehandle.peek()) != EOF) { 
-                               // get past comments
-                               while ((c = filehandle.peek()) != EOF) {        
-                                       if(holder == "[" || holder == "[!"){
-                                               comment = 1;
-                                       }
-                                       if(holder == "]"){
-                                               comment = 0;
-                                       }
-                                       if((holder == "tree" || holder == "end;") && comment != 1){ holder = ""; comment = 0; break;}
-                                       filehandle >> holder;
-                               }
-                       
-                               //pass over the "tree rep.6878900 = "
-                               while (((c = filehandle.get()) != '(') && ((c = filehandle.peek()) != EOF) ) {;}
-                                       
-                               if (c == EOF ) { break; }
-                               filehandle.putback(c);  //put back first ( of tree.
-                               
-                               //make new tree
-                               T = new Tree(tmap); 
-                               numNodes = T->getNumNodes();
-                               numLeaves = T->getNumLeaves();
-                               
-                               //read tree info
-                               error = readTreeString(tmap); 
-                                
-                               //save trees for later commands
-                               Trees.push_back(T); 
-                       }
-               }
-               
-               if (error != 0) { readOk = error; } 
-               
-               filehandle.close();
-
-               return readOk;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadNewickTree", "read");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-//This function read the file through the translation of the sequences names and updates treemap.
-string ReadNewickTree::nexusTranslation(TreeMap* tmap) {
-       try {
-               
-               holder = "";
-               int numSeqs = m->Treenames.size(); //must save this some when we clear old names we can still know how many sequences there were
-               int comment = 0;
-               
-               // get past comments
-               while(holder != "translate" && holder != "Translate"){  
-                       if(holder == "[" || holder == "[!"){
-                               comment = 1;
-                       }
-                       if(holder == "]"){
-                               comment = 0;
-                       }
-                       filehandle >> holder; 
-                       if(holder == "tree" && comment != 1){return holder;}
-               }
-               
-               //update treemap
-               tmap->namesOfSeqs.clear();
-               
-               /*char c;
-               string number, name;
-               while ((c = filehandle.peek()) != EOF) {        
-                       
-                       filehandle >> number; 
-                       
-                       if ((number == "tree") || (number == ";") ) {  name = number; break;  }
-                       
-                       filehandle >> name; 
-                       
-                       char lastChar;
-                       if (name.length() != 0) { lastChar = name[name.length()-1]; }
-                       
-                       if ((name == "tree") || (name == ";") ) {  break;  }
-                       
-                       if (lastChar == ',') {  name.erase(name.end()-1); } //erase the comma
-                       */      
-               
-               string number, name;
-               for(int i=0;i<numSeqs;i++){
-                       
-                       filehandle >> number;
-                       filehandle >> name;
-                       name.erase(name.end()-1);  //erase the comma
-                       
-                       //insert new one with new name
-                       string group = tmap->getGroup(name);
-                       tmap->treemap[toString(number)].groupname = group;
-                       tmap->treemap[toString(number)].vectorIndex = tmap->getIndex(name);
-                       //erase old one.  so treemap[sarah].groupnumber is now treemap[1].groupnumber. if number is 1 and name is sarah.
-                       tmap->treemap.erase(name);
-                       tmap->namesOfSeqs.push_back(number);
-               }
-               
-               return name;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadNewickTree", "nexusTranslation");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int ReadNewickTree::readTreeString(TreeMap* tmap) {
-       try {
-               
-               int n = 0;
-               int lc, rc; 
-               
-               int rooted = 0;
-       
-               int ch = filehandle.peek();     
-               
-               if(ch == '('){
-                       n = numLeaves;  //number of leaves / sequences, we want node 1 to start where the leaves left off
-
-                       lc = readNewickInt(filehandle, n, T, tmap);
-                       if (lc == -1) { m->mothurOut("error with lc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
-       
-                       if(filehandle.peek()==','){                                                     
-                               readSpecialChar(filehandle,',',"comma");
-                       }
-                       // ';' means end of tree.                                                                                               
-                       else if((ch=filehandle.peek())==';' || ch=='['){                
-                               rooted = 1;                                                                     
-                       }       
-               
-                       if(rooted != 1){                                                                
-                               rc = readNewickInt(filehandle, n, T, tmap);
-                               if (rc == -1) { m->mothurOut("error with rc"); m->mothurOutEndLine(); return -1; } //reports an error in reading
-                               if(filehandle.peek() == ')'){                                   
-                                       readSpecialChar(filehandle,')',"right parenthesis");
-                               }                                                                                       
-                       }       
-               }
-               //note: treeclimber had the code below added - not sure why?
-               else{
-                       filehandle.putback(ch);
-                       char name[MAX_LINE];
-                       filehandle.get(name, MAX_LINE,'\n');
-                       SKIPLINE(filehandle, ch);
-               
-                       n = T->getIndex(name);
-
-                       if(n!=0){
-                               m->mothurOut("Internal error: The only taxon is not taxon 0.\n");
-                               //exit(1);
-                               readOk = -1; return -1;
-                       }
-                       lc = rc = -1;
-               } 
-               
-               while(((ch=filehandle.get())!=';') && (filehandle.eof() != true)){;}    
-                                                       
-               if(rooted != 1){                                                                        
-                       T->tree[n].setChildren(lc,rc);
-                       T->tree[n].setBranchLength(0);
-                       T->tree[n].setParent(-1);
-                       if(lc!=-1){             T->tree[lc].setParent(n);               }
-                       if(rc!=-1){             T->tree[rc].setParent(n);               }
-               }
-               
-               //T->printTree(); cout << endl;
-               return 0;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadNewickTree", "readTreeString");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ReadNewickTree::readNewickInt(istream& f, int& n, Tree* T, TreeMap* tmap) {
-       try {
-               
-               if (m->control_pressed) { return -1; } 
-               
-               int c = readNodeChar(f);
-
-               if(c == '('){
-               
-                       //to account for multifurcating trees generated by fasttree, we are forcing them to be bifurcating
-                       //read all children
-                       vector<int> childrenNodes;
-                       while(f.peek() != ')'){
-                               int child = readNewickInt(f, n, T, tmap);
-                               if (child == -1) { return -1; } //reports an error in reading
-               //cout << "child = " << child << endl;          
-                               childrenNodes.push_back(child);
-                               
-                               //after a child you either have , or ), check for both
-                               if(f.peek()==')'){  break;  }
-                               else if (f.peek()==',') {   readSpecialChar(f,',',"comma");  }
-                               else {;}
-                       }
-       //cout << childrenNodes.size() << endl;         
-                       if (childrenNodes.size() < 2) {  m->mothurOut("Error in tree, please correct."); m->mothurOutEndLine(); return -1; }
-                       
-                       //then force into 2 node structure
-                       for (int i = 1; i < childrenNodes.size(); i++) {
-                       
-                               int lc, rc;
-                               if (i == 1) { lc = childrenNodes[i-1]; rc = childrenNodes[i]; }
-                               else { lc = n-1; rc = childrenNodes[i]; }
-                       //cout << i << '\t' << lc << '\t' << rc << endl;        
-                               T->tree[n].setChildren(lc,rc);
-                               T->tree[lc].setParent(n);
-                               T->tree[rc].setParent(n);
-                               
-                               //T->printTree(); cout << endl;
-                               n++;
-                       }
-                       
-                       //to account for extra ++ in looping
-                       n--;
-                       
-                       if(f.peek()==')'){      
-                               readSpecialChar(f,')',"right parenthesis");     
-                               //to pass over labels in trees
-                               c=filehandle.get();
-                               while((c!=',') && (c != -1) && (c!= ':') && (c!=';')&& (c!=')')){ c=filehandle.get(); }
-                               filehandle.putback(c);
-                       }                       
-               
-                       if(f.peek() == ':'){                                                                          
-                               readSpecialChar(f,':',"colon"); 
-                                                                               
-                               if(n >= numNodes){ m->mothurOut("Error: Too many nodes in input tree\n");  readOk = -1; return -1; }
-                               
-                               T->tree[n].setBranchLength(readBranchLength(f));
-                       }else{
-                               T->tree[n].setBranchLength(0.0); 
-                       }                                               
-                       
-                       //T->tree[n].setChildren(lc,rc);
-                       //T->tree[lc].setParent(n);
-                       //T->tree[rc].setParent(n);
-                       //T->printTree();  cout << endl;
-                       
-                       return n++;
-               
-               }else{
-                       f.putback(c);
-                       string name = "";
-                       char d=f.get();
-                       while(d != ':' && d != ',' && d!=')' && d!='\n'){                                       
-                               name += d;
-                               d=f.get();
-                       }
-//cout << name << endl;
-                       int blen = 0;
-                       if(d == ':')    {               blen = 1;       }               
-               
-                       f.putback(d);
-               
-                       //set group info
-                       string group = tmap->getGroup(name);
-                       
-                       //find index in tree of name
-                       int n1 = T->getIndex(name);
-                       
-                       //adds sequence names that are not in group file to the "xxx" group
-                       if(group == "not found") {
-                               m->mothurOut("Name: " + name + " is not in your groupfile, and will be disregarded. \n");  //readOk = -1; return n1;
-                               
-                               tmap->namesOfSeqs.push_back(name);
-                               tmap->treemap[name].groupname = "xxx";
-                               
-                               map<string, int>::iterator it;
-                               it = tmap->seqsPerGroup.find("xxx");
-                               if (it == tmap->seqsPerGroup.end()) { //its a new group
-                                       tmap->addGroup("xxx");
-                                       tmap->seqsPerGroup["xxx"] = 1;
-                               }else {
-                                       tmap->seqsPerGroup["xxx"]++;
-                               }
-                               
-                               group = "xxx";
-                       }
-                       
-                       vector<string> tempGroup; tempGroup.push_back(group);
-                       
-                       T->tree[n1].setGroup(tempGroup);
-                       T->tree[n1].setChildren(-1,-1);
-               
-                       if(blen == 1){  
-                               f.get();
-                               T->tree[n1].setBranchLength(readBranchLength(f));
-                       }else{
-                               T->tree[n1].setBranchLength(0.0);
-                       }
-               
-                       while((c=f.get())!=0 && (c != ':' && c != ',' && c!=')') )              {;}             
-       
-                       f.putback(c);
-               
-                       return n1;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadNewickTree", "readNewickInt");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-/**************************************************************************************************/
-
diff --git a/readtree.h b/readtree.h
deleted file mode 100644 (file)
index 6b074de..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef READTREE_H
-#define READTREE_H
-/*
- *  readtree.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "tree.h"
-
-#define MAX_LINE               513
-#define SKIPLINE(f,c)  {while((c=f.get())!=EOF && ((c) != '\n')){}}
-
-class Tree;
-
-/****************************************************************************/
-
-class ReadTree {
-       public:
-               ReadTree(); 
-               virtual ~ReadTree() {};
-               
-               virtual int read(TreeMap*) = 0;
-               int readSpecialChar(istream&, char, string);
-               int readNodeChar(istream& f);
-               float readBranchLength(istream& f);
-       
-               vector<Tree*> getTrees() { return Trees; }
-               int AssembleTrees(map<string, string>);
-               
-       protected:
-               vector<Tree*> Trees;
-               TreeMap* treeMap;
-               int numNodes, numLeaves;
-               MothurOut* m;
-               
-               
-};
-
-/****************************************************************************/
-
-class ReadNewickTree : public ReadTree {
-       
-public:
-       ReadNewickTree(string file) : treeFile(file) { m->openInputFile(file, filehandle); readOk = 0; } 
-       ~ReadNewickTree() {};
-       int read(TreeMap*);
-       
-private:
-       Tree* T;
-       int readNewickInt(istream&, int&, Tree*, TreeMap*);
-       int readTreeString(TreeMap*);
-       string nexusTranslation(TreeMap*);
-       ifstream filehandle;
-       string treeFile;
-       string holder;
-       int readOk;  // readOk = 0 means success, readOk = 1 means errors.
-       
-};
-
-/****************************************************************************/
-
-#endif
diff --git a/readtreecommand.cpp b/readtreecommand.cpp
deleted file mode 100644 (file)
index 7660643..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- *  readtreecommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "readtreecommand.h"
-
-
-//**********************************************************************************************************************
-ReadTreeCommand::ReadTreeCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       /*
-                       //valid paramters for this command
-                       string Array[] =  {"tree","group","name","outputdir","inputdir"};
-                       vector<string> myArray (Array, Array+(sizeof(Array)/sizeof(string)));
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       globaldata->newRead();
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                       }
-
-                       
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { abort = true; }
-                       else if (treefile == "not found") { treefile = ""; m->mothurOut("tree is a required parameter for the read.tree command."); m->mothurOutEndLine(); abort = true;  }     
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { 
-                               groupfile = ""; 
-                               
-                               m->mothurOut("You have not provided a group file. I am assumming all sequence are from the same group."); m->mothurOutEndLine();        
-                               
-                               if (treefile != "") {  Tree* tree = new Tree(treefile); delete tree;  } //extracts names from tree to make faked out groupmap
-                               
-                               //read in group map info.
-                               treeMap = new TreeMap();
-                               for (int i = 0; i < m->Treenames.size(); i++) { treeMap->addSeq(m->Treenames[i], "Group1"); }
-                                       
-                       }else {  
-                               //read in group map info.
-                               treeMap = new TreeMap(groupfile);
-                               treeMap->readMap();
-                       }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { readNamesFile(); }       
-                       
-                       if (abort == false) {
-                               filename = treefile;
-                               read = new ReadNewickTree(filename);
-                       }
-                       */                      
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "ReadTreeCommand");           
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ReadTreeCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               m->mothurOut(getHelpString()); m->mothurOutEndLine();
-               /*
-               int readOk;
-               
-               readOk = read->read(treeMap); 
-               
-               if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine(); globaldata->gTree.clear(); delete globaldata->gTreemap; return 0; }
-               
-               vector<Tree*> T = read->gTree;
-
-               //assemble users trees
-               for (int i = 0; i < T.size(); i++) {
-                       if (m->control_pressed) {  
-                               for (int i = 0; i < T.size(); i++) {  delete T[i];  }
-                               globaldata->gTree.clear();
-                               delete globaldata->gTreemap;
-                               return 0;
-                       }
-       
-                       T[i]->assembleTree();
-               }
-
-               
-               //if you provide a namefile we will use the numNames in the namefile as long as the number of unique match the tree names size.
-               int numNamesInTree;
-               if (namefile != "")  {  
-                       if (numUniquesInName == globaldata->Treenames.size()) {  numNamesInTree = nameMap.size();  }
-                       else {   numNamesInTree = globaldata->Treenames.size();  }
-               }else {  numNamesInTree = globaldata->Treenames.size();  }
-               
-               
-               //output any names that are in group file but not in tree
-               if (numNamesInTree < treeMap->getNumSeqs()) {
-                       for (int i = 0; i < treeMap->namesOfSeqs.size(); i++) {
-                               //is that name in the tree?
-                               int count = 0;
-                               for (int j = 0; j < globaldata->Treenames.size(); j++) {
-                                       if (treeMap->namesOfSeqs[i] == globaldata->Treenames[j]) { break; } //found it
-                                       count++;
-                               }
-                               
-                               if (m->control_pressed) {  
-                                       for (int i = 0; i < T.size(); i++) {  delete T[i];  }
-                                       globaldata->gTree.clear();
-                                       delete globaldata->gTreemap;
-                                       return 0;
-                               }
-                               
-                               //then you did not find it so report it 
-                               if (count == globaldata->Treenames.size()) { 
-                                       //if it is in your namefile then don't remove
-                                       map<string, string>::iterator it = nameMap.find(treeMap->namesOfSeqs[i]);
-                                       
-                                       if (it == nameMap.end()) {
-                                               m->mothurOut(treeMap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); m->mothurOutEndLine();
-                                               treeMap->removeSeq(treeMap->namesOfSeqs[i]);
-                                               i--; //need this because removeSeq removes name from namesOfSeqs
-                                       }
-                               }
-                       }
-                       
-                       globaldata->gTreemap = treeMap;
-               }
-                */
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "execute");   
-               exit(1);
-       }
-}
-/*****************************************************************/
-int ReadTreeCommand::readNamesFile() {
-       try {
-               /*
-               m->names.clear();
-               numUniquesInName = 0;
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               string first, second;
-               map<string, string>::iterator itNames;
-               
-               while(!in.eof()) {
-                       in >> first >> second; m->gobble(in);
-                       
-                       numUniquesInName++;
-
-                       itNames = m->names.find(first);
-                       if (itNames == globaldata->names.end()) {  
-                               globaldata->names[first] = second; 
-                               
-                               //we need a list of names in your namefile to use above when removing extra seqs above so we don't remove them
-                               vector<string> dupNames;
-                               m->splitAtComma(second, dupNames);
-                               
-                               for (int i = 0; i < dupNames.size(); i++) {     nameMap[dupNames[i]] = dupNames[i];  if ((groupfile == "") && (i != 0)) { globaldata->gTreemap->addSeq(dupNames[i], "Group1"); }  }
-                       }else {  m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); globaldata->names.clear(); namefile = ""; return 1; }                 
-               }
-               in.close();
-               */
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReadTreeCommand", "readNamesFile");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/readtreecommand.h b/readtreecommand.h
deleted file mode 100644 (file)
index cbf3769..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef READTREECOMMAND_H
-#define READTREECOMMAND_H
-
-/*
- *  readtreecommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "readtree.h"
-#include "treemap.h"
-
-
-class ReadTreeCommand : public Command {
-public:
-       ReadTreeCommand(string);
-       ReadTreeCommand() { abort = true; calledHelp = true; }
-       ~ReadTreeCommand() {}
-       
-       vector<string> setParameters() {  return outputNames; } //dummy doesn't really do anything
-       string getCommandName()                 { return "read.tree";   }
-       string getCommandCategory()             { return "Hidden";      }
-       string getHelpString() { return "This command is no longer available. You can provide your files directly to the downstream commands like unifrac.unweighted."; }       
-       string getCitation() { return "http://www.mothur.org/wiki/Read.tree"; }
-       string getDescription()         { return "read.tree"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       ReadTree* read;
-       TreeMap* treeMap;
-       string filename, treefile, groupfile, namefile;
-       bool abort;
-       map<string, string> nameMap;
-       vector<string> outputNames;
-       
-       int readNamesFile();
-       int numUniquesInName;
-
-};
-
-
-#endif
diff --git a/refchimeratest.cpp b/refchimeratest.cpp
deleted file mode 100644 (file)
index 2f397e8..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- *  refchimeratest.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 1/31/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "refchimeratest.h"
-#include "mothur.h"
-
-int MAXINT = numeric_limits<int>::max();
-
-//***************************************************************************************************************
-
-RefChimeraTest::RefChimeraTest(vector<Sequence>& refs){
-
-       m = MothurOut::getInstance();
-
-       numRefSeqs = refs.size();
-
-       referenceSeqs.resize(numRefSeqs);
-       referenceNames.resize(numRefSeqs);
-       for(int i=0;i<numRefSeqs;i++){
-               referenceSeqs[i] = refs[i].getAligned();
-               referenceNames[i] = refs[i].getName();
-       }
-       
-       alignLength = referenceSeqs[0].length();
-
-
-}
-//***************************************************************************************************************
-
-int RefChimeraTest::printHeader(ofstream& chimeraReportFile){
-       try {
-               chimeraReportFile << "queryName\tbestRef\tbestSequenceMismatch\tleftParentChi,rightParentChi\tbreakPointChi\tminMismatchToChimera\tdistToBestMera\tnumParents" << endl;
-               return 0; 
-       }catch(exception& e) {
-               m->errorOut(e, "RefChimeraTest", "execute");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int RefChimeraTest::analyzeQuery(string queryName, string querySeq, ofstream& chimeraReportFile){
-       
-       vector<vector<int> > left(numRefSeqs);
-       vector<int> singleLeft, bestLeft;
-       vector<int> singleRight, bestRight;
-       
-       vector<vector<int> > right(numRefSeqs);
-       for(int i=0;i<numRefSeqs;i++){
-               left[i].assign(alignLength, 0);
-       }
-       right = left;
-       
-       int bestSequenceMismatch = getMismatches(querySeq, left, right, bestMatch);
-       
-       int leftParentBi, rightParentBi, breakPointBi;
-       int minMismatchToChimera = getChimera(left, right, leftParentBi, rightParentBi, breakPointBi, singleLeft, bestLeft, singleRight, bestRight);
-       
-//     int minMismatchToTrimera = MAXINT;
-//     int leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB;
-       
-       int nMera = 0;
-       string chimeraRefSeq = "";
-       
-       if(bestSequenceMismatch - minMismatchToChimera >= 3){// || (minMismatchToChimera == 0 && bestSequenceMismatch != 0)){
-       
-               nMera = 2;
-               chimeraRefSeq = stitchBimera(leftParentBi, rightParentBi, breakPointBi);
-               
-//             minMismatchToTrimera = getTrimera(left, right, leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB, singleLeft, bestLeft, singleRight, bestRight);
-//
-//             if(minMismatchToChimera - minMismatchToTrimera <= 3){
-//                     nMera = 2;
-//                     chimeraRefSeq = stitchBimera(leftParentBi, rightParentBi, breakPointBi);
-//             }
-//             else{                   
-//                     nMera = 3;
-//                     chimeraRefSeq = stitchTrimera(leftParentTri, middleParentTri, rightParentTri, breakPointTriA, breakPointTriB);
-//             }
-               
-       }
-       else{
-               nMera = 1;
-               chimeraRefSeq = referenceSeqs[bestMatch];
-       }
-       
-       
-       double distToChimera = calcDistToChimera(querySeq, chimeraRefSeq);
-       
-//     double loonIndex = calcLoonIndex(querySeq, referenceSeqs[leftParentBi], referenceSeqs[rightParentBi], breakPointBi, binMatrix);         
-       
-       chimeraReportFile << queryName << '\t' << referenceNames[bestMatch] << '\t' << bestSequenceMismatch << '\t';
-       chimeraReportFile << referenceNames[leftParentBi] << ',' << referenceNames[rightParentBi] << '\t' << breakPointBi << '\t';
-       chimeraReportFile << minMismatchToChimera << '\t';
-       
-//     if(nMera == 1){
-//             chimeraReportFile << "NA" << '\t' << "NA" << '\t' << "NA";
-//     }
-//     else{
-//             chimeraReportFile << referenceNames[leftParentTri] << ',' << referenceNames[middleParentTri] << ',' << referenceNames[rightParentTri] << '\t' << breakPointTriA << ',' << breakPointTriB << '\t' << minMismatchToTrimera;       
-//     }
-       
-       chimeraReportFile << '\t' << distToChimera << '\t' << nMera << endl;
-               
-       return nMera;
-}
-
-/**************************************************************************************************/
-
-int RefChimeraTest::getMismatches(string& querySeq, vector<vector<int> >& left, vector<vector<int> >& right, int& bestRefSeq){
-       
-       int bestSequenceMismatch = MAXINT;
-       
-       for(int i=0;i<numRefSeqs;i++){
-               
-               int lDiffs = 0;
-               
-               for(int l=0;l<alignLength;l++){
-//                     if(querySeq[l] != '.' && querySeq[l] != referenceSeqs[i][l]){
-                                               
-                       if(querySeq[l] != '.' && referenceSeqs[i][l] != '.' && querySeq[l] != referenceSeqs[i][l] && referenceSeqs[i][l] != 'N'){
-                               lDiffs++;
-                       }
-                       left[i][l] = lDiffs;
-               }
-               
-               int rDiffs = 0;
-               int index = 0;
-               for(int l=alignLength-1;l>=0;l--){
-//                     if(querySeq[l] != '.' && querySeq[l] != referenceSeqs[i][l]){
-                       if(querySeq[l] != '.' && referenceSeqs[i][l] != '.' && querySeq[l] != referenceSeqs[i][l] && referenceSeqs[i][l] != 'N'){
-                               rDiffs++;
-                       }                       
-                       right[i][index++] = rDiffs;
-               }
-               
-               if(lDiffs < bestSequenceMismatch){
-                       bestSequenceMismatch = lDiffs;
-                       bestRefSeq = i;
-               }
-       }
-       return bestSequenceMismatch;
-}
-
-/**************************************************************************************************/
-
-int RefChimeraTest::getChimera(vector<vector<int> >& left, vector<vector<int> >& right, int& leftParent, int& rightParent, int& breakPoint, vector<int>& singleLeft, vector<int>& bestLeft, vector<int>& singleRight, vector<int>& bestRight){
-       
-       singleLeft.resize(alignLength, MAXINT);
-       bestLeft.resize(alignLength, -1);
-       
-       for(int l=0;l<alignLength;l++){
-               for(int i=0;i<numRefSeqs;i++){
-                       if(left[i][l] <= singleLeft[l]){
-                               singleLeft[l] = left[i][l];
-                               bestLeft[l] = i;
-                       }
-               }
-       }
-       
-       singleRight.resize(alignLength, MAXINT);
-       bestRight.resize(alignLength, -1);
-       
-       for(int l=0;l<alignLength;l++){
-               for(int i=0;i<numRefSeqs;i++){
-                       if(right[i][l] <= singleRight[l]){
-                               singleRight[l] = right[i][l];
-                               bestRight[l] = i;
-                       }
-               }
-       }
-       
-       int bestChimeraMismatches = MAXINT;
-       leftParent = -1;
-       rightParent = -1;
-       breakPoint = -1;
-       
-       for(int l=0;l<alignLength;l++){
-               int chimera = singleLeft[l] + singleRight[alignLength - l - 1];
-               if(chimera < bestChimeraMismatches){
-                       bestChimeraMismatches = chimera;
-                       breakPoint = l;
-                       leftParent = bestLeft[l];
-                       rightParent = bestRight[alignLength - l - 1];
-               }
-       }
-       
-       return bestChimeraMismatches;
-}
-
-/**************************************************************************************************/
-
-int RefChimeraTest::getTrimera(vector<vector<int> >& left, vector<vector<int> >& right, int& leftParent, int& middleParent, int& rightParent, int& breakPointA, int& breakPointB, vector<int>& singleLeft, vector<int>& bestLeft, vector<int>& singleRight, vector<int>& bestRight){
-       
-       int bestTrimeraMismatches = MAXINT;
-       
-       leftParent = -1;
-       middleParent = -1;
-       rightParent = -1;
-       
-       breakPointA = -1;
-       breakPointB = -1;
-       
-       vector<vector<int> > minDelta(alignLength);
-       vector<vector<int> > minDeltaSeq(alignLength);
-       
-       for(int i=0;i<alignLength;i++){
-               minDelta[i].assign(alignLength, MAXINT);
-               minDeltaSeq[i].assign(alignLength, -1);
-       }
-       
-       for(int x=0;x<alignLength;x++){
-               for(int y=x;y<alignLength-1;y++){
-                       
-                       for(int i=0;i<numRefSeqs;i++){
-                               int delta = left[i][y] - left[i][x];
-                               
-                               if(delta <= minDelta[x][y]){
-                                       minDelta[x][y] = delta;
-                                       minDeltaSeq[x][y] = i;                                  
-                               }                               
-                       }
-                       minDelta[x][y] += singleLeft[x] + singleRight[alignLength - y - 2];
-                       
-                       if(minDelta[x][y] < bestTrimeraMismatches){
-                               bestTrimeraMismatches = minDelta[x][y];
-                               
-                               breakPointA = x;
-                               breakPointB = y;
-                               
-                               leftParent = bestLeft[x];
-                               middleParent = minDeltaSeq[x][y];
-                               rightParent = bestRight[alignLength - y - 2];                           
-                       }
-               }               
-       }
-       return bestTrimeraMismatches;
-}
-
-/**************************************************************************************************/
-
-string RefChimeraTest::stitchBimera(int leftParent, int rightParent, int breakPoint){
-       
-       string chimeraRefSeq = referenceSeqs[leftParent].substr(0, breakPoint) + referenceSeqs[rightParent].substr(breakPoint);
-       return chimeraRefSeq;
-       
-}
-
-/**************************************************************************************************/
-
-string RefChimeraTest::stitchTrimera(int leftParent, int middleParent, int rightParent, int breakPointA, int breakPointB){
-       
-       string chimeraRefSeq = referenceSeqs[leftParent].substr(0, breakPointA) + referenceSeqs[middleParent].substr(breakPointA, breakPointB-breakPointA) + referenceSeqs[rightParent].substr(breakPointB);
-       
-       return chimeraRefSeq;
-}
-
-/**************************************************************************************************/
-
-double RefChimeraTest::calcDistToChimera(string& querySeq, string& chimeraRefSeq){
-       
-       int match = 0;
-       int mismatch = 0;
-       
-       for(int i=0;i<alignLength;i++){
-//             if(querySeq[i] != '.' && chimeraRefSeq[i] != '.'){
-               if(chimeraRefSeq[i] != '.' && querySeq[i] != '.'){
-                       if(querySeq[i] == '-' && chimeraRefSeq[i] == '-' && chimeraRefSeq[i] != 'N'){   /*      do nothing      */      }
-                       else if(querySeq[i] == chimeraRefSeq[i]){
-                               match++;
-                       }
-                       else{
-                               mismatch++;
-                       }                       
-               }
-       }
-       
-       return (double)mismatch / (double)(mismatch + match);   
-}
-
-//***************************************************************************************************************
-
-int RefChimeraTest::getClosestRefIndex(){
-
-       return bestMatch;
-       
-}
-
-//***************************************************************************************************************
diff --git a/refchimeratest.h b/refchimeratest.h
deleted file mode 100644 (file)
index d4983e0..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef REFCHIMERATEST
-#define REFCHIMERATEST
-
-/*
- *  refchimeratest.h
- *  Mothur
- *
- *  Created by Pat Schloss on 1/31/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sequence.hpp"
-
-
-class RefChimeraTest {
-       
-public:
-       RefChimeraTest(vector<Sequence>&);
-       int printHeader(ofstream&);
-       int analyzeQuery(string, string, ofstream&);
-       int getClosestRefIndex();
-private:
-       int getMismatches(string&, vector<vector<int> >&, vector<vector<int> >&, int&);
-       int getChimera(vector<vector<int> >&, vector<vector<int> >&, int&, int&, int&, vector<int>&, vector<int>&, vector<int>&, vector<int>&);
-       int getTrimera(vector<vector<int> >&, vector<vector<int> >&, int&, int&, int&, int&, int&, vector<int>&, vector<int>&, vector<int>&, vector<int>&);
-       string stitchBimera(int, int, int);
-       string stitchTrimera(int, int, int, int, int);
-       double calcDistToChimera(string&, string&);
-
-       vector<string> referenceSeqs;
-       vector<string> referenceNames;
-       int numRefSeqs;
-       int alignLength;
-       int bestMatch;
-       //ofstream chimeraReportFile;
-       
-       MothurOut* m;
-};
-
-#endif
diff --git a/referencedb.cpp b/referencedb.cpp
deleted file mode 100644 (file)
index d91490e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  referencedb.cpp
- *  Mothur
- *
- *  Created by westcott on 6/29/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "referencedb.h"
-
-/******************************************************/
-ReferenceDB* ReferenceDB::getInstance()  {
-        if(myInstance == NULL) {
-               myInstance = new ReferenceDB();
-        }
-        return myInstance;
- }
-/******************************************************/
-void ReferenceDB::clearMemory()  {
-       referenceSeqs.clear();  
-       setSavedReference("");
-       for(int i = 0; i < wordGenusProb.size(); i++) { wordGenusProb[i].clear(); }
-       wordGenusProb.clear();
-       WordPairDiffArr.clear();
-       setSavedTaxonomy("");
-}
-/*******************************************************
-ReferenceDB::~ReferenceDB() { myInstance = NULL; }
-*******************************************************/
-
diff --git a/referencedb.h b/referencedb.h
deleted file mode 100644 (file)
index 5262e80..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef MYREFERENCEDB_H
-#define MYREFERENCEDB_H
-
-/*
- *  referencedb.h
- *  Mothur
- *
- *  Created by westcott on 6/29/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "sequence.hpp"
-
-/***********************************************/
-
-class ReferenceDB {
-       
-       public:
-       
-               static ReferenceDB* getInstance();
-               void clearMemory();
-       
-               bool save;
-               vector<Sequence> referenceSeqs;
-               vector< vector<float> > wordGenusProb;
-               vector<diffPair> WordPairDiffArr;
-       
-               string getSavedReference()                      { return referencefile;         }
-               void setSavedReference(string p)        { referencefile = p;            }
-               string getSavedTaxonomy()                       { return taxonomyfile;          }
-               void setSavedTaxonomy(string p)         { taxonomyfile = p;                     }
-       
-       private:
-       
-               static ReferenceDB* myInstance;
-               ReferenceDB() { referencefile = ""; taxonomyfile = ""; save = false; }
-               ReferenceDB(const ReferenceDB&){}// Disable copy constructor
-               void operator=(const ReferenceDB&){} // Disable assignment operator
-               ~ReferenceDB(){ myInstance = 0; }
-       
-               string referencefile, taxonomyfile;     
-};
-/***********************************************/
-
-#endif
-
diff --git a/removegroupscommand.cpp b/removegroupscommand.cpp
deleted file mode 100644 (file)
index 801029c..0000000
+++ /dev/null
@@ -1,892 +0,0 @@
-/*
- *  removegroupscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "removegroupscommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-#include "sharedutilities.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> RemoveGroupsCommand::setParameters(){   
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(pfasta);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "sharedGroup", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pgroup);
-        CommandParameter pdesign("design", "InputTypes", "", "", "none", "sharedGroup", "FNGLT",false,false); parameters.push_back(pdesign);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FNGLT",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RemoveGroupsCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The remove.groups command removes sequences from a specfic group or set of groups from the following file types: fasta, name, group, list, taxonomy, design or sharedfile.\n";
-               helpString += "It outputs a file containing the sequences NOT in the those specified groups, or with a sharedfile eliminates the groups you selected.\n";
-               helpString += "The remove.groups command parameters are accnos, fasta, name, group, list, taxonomy, shared, design and groups. The group parameter is required, unless you have a current group file or are using a sharedfile.\n";
-               helpString += "You must also provide an accnos containing the list of groups to remove or set the groups parameter to the groups you wish to remove.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like removed.  You can separate group names with dashes.\n";
-               helpString += "The remove.groups command should be in the following format: remove.groups(accnos=yourAccnos, fasta=yourFasta, group=yourGroupFile).\n";
-               helpString += "Example remove.groups(accnos=amazon.accnos, fasta=amazon.fasta, group=amazon.groups).\n";
-               helpString += "or remove.groups(groups=pasture, fasta=amazon.fasta, amazon.groups).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-RemoveGroupsCommand::RemoveGroupsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-        outputTypes["design"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RemoveGroupsCommand::RemoveGroupsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-            outputTypes["design"] = tempOutNames;
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                
-                it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { accnosfile = ""; abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = ""; }       
-                       else { m->setAccnosFile(accnosfile); }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }        
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = "";  abort = true; }
-                       else if (groupfile == "not found") {    groupfile = "";         }
-                       else { m->setGroupFile(groupfile); }    
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { taxfile = ""; abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-            
-            designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { designfile = ""; abort = true; }
-                       else if (designfile == "not found") {  designfile = "";  }
-                       else { m->setDesignFile(designfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }
-                       else if (sharedfile == "not found") {  sharedfile = "";  }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") {    groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }    
-                       
-                       if ((sharedfile == "") && (groupfile == "") && (designfile == "")) { 
-                               //is there are current file available for any of these?
-                               if ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != "")) {
-                                       //give priority to group, then shared
-                                       groupfile = m->getGroupFile(); 
-                                       if (groupfile != "") {  m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               sharedfile = m->getSharedFile(); 
-                                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("You have no current groupfile or sharedfile and one is required."); m->mothurOutEndLine(); abort = true;
-                                               }
-                                       }
-                               }else {
-                                       //give priority to shared, then group
-                                       sharedfile = m->getSharedFile(); 
-                                       if (sharedfile != "") {  m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               groupfile = m->getGroupFile(); 
-                                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       designfile = m->getDesignFile(); 
-                            if (designfile != "") { m->mothurOut("Using " + designfile + " as input file for the design parameter."); m->mothurOutEndLine(); }
-                            else { 
-                                m->mothurOut("You have no current groupfile or sharedfile or designfile and one is required."); m->mothurOutEndLine(); abort = true;
-                            }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file containing group names or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "")  && (sharedfile == "") && (designfile == "") && (listfile == "") && (taxfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, taxonomy, group, shared, design or list."); m->mothurOutEndLine(); abort = true; }
-                       if ((groupfile == "") && ((namefile != "") || (fastafile != "") || (listfile != "") || (taxfile != "")))  { m->mothurOut("If using a fasta, name, taxonomy, group or list, then you must provide a group file."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
-                               vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-               
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "RemoveGroupsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RemoveGroupsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
-               
-               if (groupfile != "") {
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-                       
-                       //make sure groups are valid
-                       //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
-                       vector<string> namesGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, namesGroups);
-                       delete util;
-                       
-                       //fill names with names of sequences that are from the groups we want to remove 
-                       fillNames();
-                       
-                       delete groupMap;
-               }
-                               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (namefile != "")                     {               readName();             }
-               if (fastafile != "")            {               readFasta();    }
-               if (groupfile != "")            {               readGroup();    }
-               if (listfile != "")                     {               readList();             }
-               if (taxfile != "")                      {               readTax();              }
-               if (sharedfile != "")           {               readShared();   }
-        if (designfile != "")          {               readDesign();   }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-                               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("shared");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-                       }
-            
-            itTypes = outputTypes.find("design");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setDesignFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) == 0) {
-                                       wroteSomething = true;
-                                       currSeq.printSequence(out); 
-                               }else { 
-                                       //if you are not in the accnos file check if you are a name that needs to be changed
-                                       map<string, string>::iterator it = uniqueToRedundant.find(name);
-                                       if (it != uniqueToRedundant.end()) {
-                                               wroteSomething = true;
-                                               currSeq.setName(it->second);
-                                               currSeq.printSequence(out);
-                                       }else { removedCount++; }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your fasta file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readShared(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               
-               //get group names from sharedfile so we can set Groups to the groupNames we want to keep
-               //that way we can take advantage of the reads in inputdata and sharedRabundVector
-               InputData* tempInput = new InputData(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = tempInput->getSharedRAbundVectors();
-       
-               //save m->Groups
-               vector<string> allGroupsNames = m->getAllGroups();
-               vector<string> mothurOutGroups = m->getGroups();
-               
-               vector<string> groupsToKeep;
-               for (int i = 0; i < allGroupsNames.size(); i++) {
-                       if (!m->inUsersGroups(allGroupsNames[i], m->getGroups())) {
-                               groupsToKeep.push_back(allGroupsNames[i]);
-                       }
-               }
-               
-               if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->setGroups(mothurOutGroups); delete tempInput; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  return 0; }
-               
-               //reset read 
-               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               delete tempInput;
-               m->setGroups(groupsToKeep);
-               m->clearAllGroups();
-               m->saveNextLabel = "";
-               m->printedHeaders = false;
-               m->currentBinLabels.clear();
-               m->binLabelsInFile.clear();
-               
-               InputData input(sharedfile, "sharedfile");
-               lookup = input.getSharedRAbundVectors();
-
-               bool wroteSomething = false;
-               
-               while(lookup[0] != NULL) {
-                       
-                       string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + lookup[0]->getLabel() + ".pick" + m->getExtension(sharedfile);
-                       ofstream out;
-                       m->openOutputFile(outputFileName, out);
-                       outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-                       
-                       if (m->control_pressed) { out.close();  m->mothurRemove(outputFileName);  for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
-                       
-                       lookup[0]->printHeaders(out); 
-                       
-                       for (int i = 0; i < lookup.size(); i++) {
-                               out << lookup[i]->getLabel() << '\t' << lookup[i]->getGroup() << '\t';
-                               lookup[i]->print(out);
-                               wroteSomething = true;
-                               
-                       }                       
-                       
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input.getSharedRAbundVectors();
-                       
-                       out.close();
-               }
-               
-               
-               m->setGroups(mothurOutGroups);
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine();  }
-               
-               string groupsString = "";
-               for (int i = 0; i < Groups.size()-1; i++) {     groupsString += Groups[i] + ", "; }
-               groupsString += Groups[Groups.size()-1];
-               
-               m->mothurOut("Removed groups: " + groupsString + " from your shared file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       
-                       removedCount = 0;
-                       
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                               if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                               
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) == 0) {  newNames += name + ",";  }
-                                       else {
-                                               //if you are not in the accnos file check if you are a name that needs to be changed
-                                               map<string, string>::iterator it = uniqueToRedundant.find(name);
-                                               if (it != uniqueToRedundant.end()) {
-                                                       newNames += it->second + ",";
-                                               }else { removedCount++; }
-                                       }
-                               }
-                               
-                               //get last name
-                               if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
-                               else { //if you are not in the accnos file check if you are a name that needs to be changed
-                                       map<string, string>::iterator it = uniqueToRedundant.find(binnames);
-                                       if (it != uniqueToRedundant.end()) {
-                                               newNames += it->second + ",";
-                                       }else { removedCount++; }
-                               }
-                               
-                               //if there are names in this bin add to new list
-                               if (newNames != "") {  
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                       
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> firstCol;         m->gobble(in);          
-                       in >> secondCol;                        
-                       
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                                               
-                       vector<string> validSecond;  validSecond.clear();
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) == 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-                       
-                       removedCount += parsedNames.size()-validSecond.size();
-                       
-                       //if the name in the first column is in the set then print it and any other names in second column also in set
-                       if (names.count(firstCol) == 0) {
-                               
-                               wroteSomething = true;
-                               
-                               out << firstCol << '\t';
-                               
-                               //you know you have at least one valid second since first column is valid
-                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                               out << validSecond[validSecond.size()-1] << endl;
-                               
-                               //make first name in set you come to first column and then add the remaining names to second column
-                       }else {
-                               
-                               //you want part of this row
-                               if (validSecond.size() != 0) {
-                                       
-                                       wroteSomething = true;
-                                       
-                                       out << validSecond[0] << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       uniqueToRedundant[firstCol] = validSecond[0];
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your name file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                       }else {  removedCount++;  }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your group file."); m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readDesign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(designfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(designfile)) + "pick" + m->getExtension(designfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(designfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (!(m->inUsersGroups(name, Groups))) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                       }else {  removedCount++;  }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only groups from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["design"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " groups from your design file."); m->mothurOutEndLine();
-        
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readDesign");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveGroupsCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << tax << endl;
-                       }else {  //if you are not in the accnos file check if you are a name that needs to be changed
-                               map<string, string>::iterator it = uniqueToRedundant.find(name);
-                               if (it != uniqueToRedundant.end()) {
-                                       wroteSomething = true;
-                                       out << it->second << '\t' << tax << endl;
-                               }else { removedCount++; }  }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void RemoveGroupsCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               m->setGroups(Groups);
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveGroupsCommand::fillNames(){
-       try {
-               vector<string> seqs = groupMap->getNamesSeqs();
-               
-               for (int i = 0; i < seqs.size(); i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       string group = groupMap->getGroup(seqs[i]);
-                       
-                       if (m->inUsersGroups(group, Groups)) {
-                               names.insert(seqs[i]);
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveGroupsCommand", "fillNames");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
diff --git a/removegroupscommand.h b/removegroupscommand.h
deleted file mode 100644 (file)
index 24062ba..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef REMOVEGROUPSCOMMAND_H
-#define REMOVEGROUPSCOMMAND_H
-
-/*
- *  removegroupscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/10/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "groupmap.h"
-
-class RemoveGroupsCommand : public Command {
-       
-public:
-       
-       RemoveGroupsCommand(string);    
-       RemoveGroupsCommand();
-       ~RemoveGroupsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "remove.groups";                       }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Remove.groups"; }
-       string getDescription()         { return "removes sequences from a list, fasta, name, group, shared, design or taxonomy file from a given group or set of groups"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       set<string> names;
-       string accnosfile, fastafile, namefile, groupfile, designfile, listfile, taxfile, outputDir, groups, sharedfile;
-       bool abort;
-       vector<string> outputNames, Groups;
-       GroupMap* groupMap;
-       map<string, string> uniqueToRedundant; //if a namefile is given and the first column name is not selected
-       //then the other files need to change the unique name in their file to match.
-       //only add the names that need to be changed to keep the map search quick
-       
-       
-       int readFasta();
-       int readShared();
-       int readName();
-       int readGroup();
-       void readAccnos();
-       int readList();
-       int readTax();
-       int fillNames();
-    int readDesign();
-       
-};
-
-#endif
-
-
diff --git a/removelineagecommand.cpp b/removelineagecommand.cpp
deleted file mode 100644 (file)
index 9fec249..0000000
+++ /dev/null
@@ -1,805 +0,0 @@
-/*
- *  removelineagecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "removelineagecommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-
-//**********************************************************************************************************************
-vector<string> RemoveLineageCommand::setParameters(){  
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptaxon("taxon", "String", "", "", "", "", "",false,true); parameters.push_back(ptaxon);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RemoveLineageCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               helpString += "The remove.lineage command reads a taxonomy file and any of the following file types: fasta, name, group, list or alignreport file.\n";
-               helpString += "It outputs a file containing only the sequences from the taxonomy file that are not from the taxon you requested to be removed.\n";
-               helpString += "The remove.lineage command parameters are taxon, fasta, name, group, list, taxonomy, alignreport and dups.  You must provide taxonomy unless you have a valid current taxonomy file.\n";
-               helpString += "The dups parameter allows you to add the entire line from a name file if you add any name from the line. default=false. \n";
-               helpString += "The taxon parameter allows you to select the taxons you would like to remove, and is required.\n";
-               helpString += "You may enter your taxons with confidence scores, doing so will remove only those sequences that belong to the taxonomy and whose cofidence scores fall below the scores you give.\n";
-               helpString += "If they belong to the taxonomy and have confidences above those you provide the sequence will not be removed.\n";
-               helpString += "The remove.lineage command should be in the following format: remove.lineage(taxonomy=yourTaxonomyFile, taxon=yourTaxons).\n";
-               helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon=Bacteria;Firmicutes;Bacilli;Lactobacillales;).\n";
-               helpString += "Note: If you are running mothur in script mode you must wrap the taxon in ' characters so mothur will ignore the ; in the taxon.\n";
-               helpString += "Example remove.lineage(taxonomy=amazon.silva.taxonomy, taxon='Bacteria;Firmicutes;Bacilli;Lactobacillales;').\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-RemoveLineageCommand::RemoveLineageCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RemoveLineageCommand::RemoveLineageCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();       
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       
-                       //check for required parameters                 
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }        
-                       else { m->setFastaFile(fastafile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       alignfile = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignfile == "not open") { abort = true; }
-                       else if (alignfile == "not found") {  alignfile = "";  }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { taxfile = ""; abort = true; }
-                       else if (taxfile == "not found") {              
-                               taxfile = m->getTaxonomyFile(); 
-                               if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setTaxonomyFile(taxfile); }
-                       
-                       string usedDups = "true";
-                       string temp = validParameter.validFile(parameters, "dups", false);      
-                       if (temp == "not found") { 
-                               if (namefile != "") {  temp = "true";                                   }
-                               else                            {  temp = "false"; usedDups = "";       }
-                       }
-                       dups = m->isTrue(temp);
-                       
-                       taxons = validParameter.validFile(parameters, "taxon", false);  
-                       if (taxons == "not found") { taxons = "";  m->mothurOut("No taxons given, please correct."); m->mothurOutEndLine();  abort = true;  }
-                       else { 
-                               //rip off quotes
-                               if (taxons[0] == '\'') {  taxons = taxons.substr(1); }
-                               if (taxons[(taxons.length()-1)] == '\'') {  taxons = taxons.substr(0, (taxons.length()-1)); }
-                       }
-                       m->splitAtChar(taxons, listOfTaxons, '-');
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == ""))  { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy or listfile."); m->mothurOutEndLine(); abort = true; }
-               
-                       if ((usedDups != "") && (namefile == "")) {  m->mothurOut("You may only use dups with the name option."); m->mothurOutEndLine();  abort = true; }                       
-                       
-                       if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){
-                               vector<string> files; files.push_back(fastafile); files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "RemoveLineageCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RemoveLineageCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (taxfile != "")                      {               readTax();              }  //fills the set of names to remove
-               if (namefile != "")                     {               readName();             }
-               if (fastafile != "")            {               readFasta();    }
-               if (groupfile != "")            {               readGroup();    }
-               if (alignfile != "")            {               readAlign();    }
-               if (listfile != "")                     {               readList();             }
-               
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveLineageCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) == 0) {
-                                       wroteSomething = true;
-                                       
-                                       currSeq.printSequence(out);
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your fasta file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName); 
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveLineageCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                               if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) == 0) {  newNames += name + ",";  }
-                               }
-                       
-                               //get last name
-                               if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
-
-                               //if there are names in this bin add to new list
-                               if (newNames != "") {  
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                               
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your list file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["list"].push_back(outputFileName); 
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveLineageCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> firstCol;                         
-                       in >> secondCol;                        
-
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;  validSecond.clear();
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) == 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-                       
-                       if ((dups) && (validSecond.size() != parsedNames.size())) {  //if dups is true and we want to get rid of anyone, get rid of everyone
-                               for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
-                       }else {
-                                       //if the name in the first column is in the set then print it and any other names in second column also in set
-                               if (names.count(firstCol) == 0) {
-                                       
-                                       wroteSomething = true;
-                                       
-                                       out << firstCol << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       
-                                       //make first name in set you come to first column and then add the remaining names to second column
-                               }else {
-                                       
-                                       //you want part of this row
-                                       if (validSecond.size() != 0) {
-                                               
-                                               wroteSomething = true;
-                                               
-                                               out << validSecond[0] << '\t';
-                                               
-                                               //you know you have at least one valid second since first column is valid
-                                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                               out << validSecond[validSecond.size()-1] << endl;
-                                       }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-
-               if (wroteSomething == false) {  m->mothurOut("Your name file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["name"].push_back(outputFileName);
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveLineageCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                       }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your group file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["group"].push_back(outputFileName);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveLineageCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               
-               vector<bool> taxonsHasConfidence; taxonsHasConfidence.resize(listOfTaxons.size(), false);
-               vector< vector< map<string, float> > > searchTaxons; searchTaxons.resize(listOfTaxons.size());
-               vector<string> noConfidenceTaxons; noConfidenceTaxons.resize(listOfTaxons.size(), "");
-               
-               for (int i = 0; i < listOfTaxons.size(); i++) {
-                       noConfidenceTaxons[i] = listOfTaxons[i];
-                       int hasConPos = listOfTaxons[i].find_first_of('(');
-                       if (hasConPos != string::npos) {  
-                               taxonsHasConfidence[i] = true; 
-                               searchTaxons[i] = getTaxons(listOfTaxons[i]); 
-                               noConfidenceTaxons[i] = listOfTaxons[i];
-                               m->removeConfidences(noConfidenceTaxons[i]);
-                       }
-               }
-               
-               
-               while(!in.eof()){
-
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName);  return 0; }
-
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       bool remove = false;
-                       
-                       for (int j = 0; j < listOfTaxons.size(); j++) {
-                               string newtax = tax;
-                               
-                               //if the users file contains confidence scores we want to ignore them when searching for the taxons, unless the taxon has them
-                               if (!taxonsHasConfidence[j]) {
-                                       
-                                       int hasConfidences = tax.find_first_of('(');
-                                       if (hasConfidences != string::npos) { 
-                                               newtax = tax;
-                                               m->removeConfidences(newtax);
-                                       }
-                                       
-                                       int pos = newtax.find(noConfidenceTaxons[j]);
-                                       
-                                       if (pos == string::npos) { 
-                                               //wroteSomething = true;
-                                               //out << name << '\t' << tax << endl;
-                                       }else{ //this sequence contains the taxon the user wants to remove
-                                               names.insert(name);
-                                               remove=true; break;
-                                       }
-                                       
-                               }else{//if taxons has them and you don't them remove taxons
-                                       int hasConfidences = tax.find_first_of('(');
-                                       if (hasConfidences == string::npos) { 
-                                               
-                                               int pos = newtax.find(noConfidenceTaxons[j]);
-                                               
-                                               if (pos == string::npos) { 
-                                                       //wroteSomething = true;
-                                                       //out << name << '\t' << tax << endl;
-                                               }else{ //this sequence contains the taxon the user wants to remove
-                                                       names.insert(name);
-                                                       remove=true; break;
-                                               }
-                                       }else { //both have confidences so we want to make sure the users confidences are greater then or equal to the taxons
-                                               //first remove confidences from both and see if the taxonomy exists
-                                               
-                                               string noNewTax = tax;
-                                               int hasConfidences = tax.find_first_of('(');
-                                               if (hasConfidences != string::npos) { 
-                                                       noNewTax = tax;
-                                                       m->removeConfidences(noNewTax);
-                                               }
-                                               
-                                               int pos = noNewTax.find(noConfidenceTaxons[j]);
-                                               
-                                               if (pos != string::npos) { //if yes, then are the confidences okay
-                                                       
-                                                       vector< map<string, float> > usersTaxon = getTaxons(newtax);
-                                                       
-                                                       //the usersTaxon is most likely longer than the searchTaxons, and searchTaxon[0] may relate to userTaxon[4]
-                                                       //we want to "line them up", so we will find the the index where the searchstring starts
-                                                       int index = 0;
-                                                       for (int i = 0; i < usersTaxon.size(); i++) {
-                                                               
-                                                               if (usersTaxon[i].begin()->first == searchTaxons[j][0].begin()->first) { 
-                                                                       index = i;  
-                                                                       int spot = 0;
-                                                                       bool goodspot = true;
-                                                                       //is this really the start, or are we dealing with a taxon of the same name?
-                                                                       while ((spot < searchTaxons[j].size()) && ((i+spot) < usersTaxon.size())) {
-                                                                               if (usersTaxon[i+spot].begin()->first != searchTaxons[j][spot].begin()->first) { goodspot = false; break; }
-                                                                               else { spot++; }
-                                                                       }
-                                                                       
-                                                                       if (goodspot) { break; }
-                                                               }
-                                                       }
-                                                       
-                                                       for (int i = 0; i < searchTaxons[j].size(); i++) {
-                                                               
-                                                               if ((i+index) < usersTaxon.size()) { //just in case, should never be false
-                                                                       if (usersTaxon[i+index].begin()->second < searchTaxons[j][i].begin()->second) { //is the users cutoff less than the search taxons
-                                                                               remove = true;
-                                                                               break;
-                                                                       }
-                                                               }else {
-                                                                       remove = true;
-                                                                       break;
-                                                               }
-                                                       }
-                                                       
-                                                       //passed the test so remove you
-                                                       if (remove) {
-                                                               names.insert(name);
-                                                               remove=true; break;
-                                                       }else {
-                                                               //wroteSomething = true;
-                                                               //out << name << '\t' << tax << endl;
-                                                       }
-                                               }else {
-                                                       //wroteSomething = true;
-                                                       //out << name << '\t' << tax << endl;
-                                               }
-                                       }
-                               }
-                               
-                       }
-                       
-                       if (!remove) {  wroteSomething = true; out << name << '\t' << tax << endl; }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (!wroteSomething) { m->mothurOut("Your taxonomy file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["taxonomy"].push_back(outputFileName);
-                       
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readTax");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector< map<string, float> > RemoveLineageCommand::getTaxons(string tax) {
-       try {
-               
-               vector< map<string, float> > t;
-               string taxon = "";
-               int taxLength = tax.length();
-               for(int i=0;i<taxLength;i++){
-                       if(tax[i] == ';'){
-                               
-                               int openParen = taxon.find_first_of('(');
-                               int closeParen = taxon.find_last_of(')');
-                               
-                               string newtaxon, confidence;
-                               if ((openParen != string::npos) && (closeParen != string::npos)) {
-                                       newtaxon = taxon.substr(0, openParen); //rip off confidence
-                                       confidence = taxon.substr((openParen+1), (closeParen-openParen-1));  
-                               }else{
-                                       newtaxon = taxon;
-                                       confidence = "0";
-                               }
-                               float con = 0;
-                               convert(confidence, con);
-                               
-                               map<string, float> temp;
-                               temp[newtaxon] = con;
-                               t.push_back(temp);
-                               
-                               taxon = "";
-                       }
-                       else{
-                               taxon += tax[i];
-                       }
-               }
-               
-               return t;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "getTaxons");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//alignreport file has a column header line then all other lines contain 16 columns.  we just want the first column since that contains the name
-int RemoveLineageCommand::readAlign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(alignfile, in);
-               string name, junk;
-               
-               bool wroteSomething = false;
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                       else                    {       break;                  }
-               }
-               out << endl;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t';
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                                       else                    {       break;                  }
-                               }
-                               out << endl;
-                               
-                       }else {//still read just don't do anything with it
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;             }
-                                       else                    {       break;                  }
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your align file contains only sequences from " + taxons + "."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName); outputTypes["alignreport"].push_back(outputFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveLineageCommand", "readAlign");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
diff --git a/removelineagecommand.h b/removelineagecommand.h
deleted file mode 100644 (file)
index a4ffea9..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef REMOVELINEAGECOMMAND_H
-#define REMOVELINEAGECOMMAND_H
-
-/*
- *  removelineagecommand.h
- *  Mothur
- *
- *  Created by westcott on 9/24/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-
-class RemoveLineageCommand : public Command {
-       
-       public:
-       
-               RemoveLineageCommand(string);
-               RemoveLineageCommand();
-               ~RemoveLineageCommand(){};
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "remove.lineage";                      }
-               string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Remove.lineage"; }
-               string getDescription()         { return "removes sequences from a list, fasta, name, group, alignreport or taxonomy file from a given taxonomy or set of taxonomies"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       private:
-               set<string> names;
-               vector<string> outputNames, listOfTaxons;
-               string fastafile, namefile, groupfile, alignfile, listfile, taxfile, outputDir, taxons;
-               bool abort, dups;
-               
-               int readFasta();
-               int readName();
-               int readGroup();
-               int readAlign();
-               int readList();
-               int readTax();  
-               vector< map<string, float> > getTaxons(string);
-};
-
-#endif
-
diff --git a/removeotuscommand.cpp b/removeotuscommand.cpp
deleted file mode 100644 (file)
index 25ed99e..0000000
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- *  removeotuscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "removeotuscommand.h"
-#include "inputdata.h"
-#include "sharedutilities.h"
-
-//**********************************************************************************************************************
-vector<string> RemoveOtusCommand::setParameters(){     
-       try {
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RemoveOtusCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The remove.otus command removes otus containing sequences from a specfic group or set of groups.\n";
-               helpString += "It outputs a new list file containing the otus containing sequences NOT from in the those specified groups.\n";
-               helpString += "The remove.otus command parameters are accnos, group, list, label and groups. The group and list parameters are required, unless you have valid current files.\n";
-               helpString += "You must also provide an accnos containing the list of groups to get or set the groups parameter to the groups you wish to select.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like.  You can separate group names with dashes.\n";
-               helpString += "The label parameter allows you to specify which distance you want to process.\n";
-               helpString += "The remove.otus command should be in the following format: remove.otus(accnos=yourAccnos, list=yourListFile, group=yourGroupFile, label=yourLabel).\n";
-               helpString += "Example remove.otus(accnos=amazon.accnos, list=amazon.fn.list, group=amazon.groups, label=0.03).\n";
-               helpString += "or remove.otus(groups=pasture, list=amazon.fn.list, amazon.groups, label=0.03).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-///**********************************************************************************************************************
-RemoveOtusCommand::RemoveOtusCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "RemoveOtusCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-RemoveOtusCommand::RemoveOtusCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = ""; }
-                       else { m->setAccnosFile(accnosfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {                            
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current group file and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setGroupFile(groupfile); }   
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {                             
-                               listfile = m->getListFile(); 
-                               if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setListFile(listfile); }     
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                       }
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }  
-                       
-                       if ((accnosfile == "") && (Groups.size() == 0)) { m->mothurOut("You must provide an accnos file or specify groups using the groups parameter."); m->mothurOutEndLine(); abort = true; }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "RemoveOtusCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RemoveOtusCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               groupMap = new GroupMap(groupfile);
-               groupMap->readMap();
-               
-               //get groups you want to remove
-               if (accnosfile != "") { readAccnos(); }
-               
-               //make sure groups are valid
-               //takes care of user setting groupNames that are invalid or setting groups=all
-               SharedUtil* util = new SharedUtil();
-               vector<string> allGroups = groupMap->getNamesOfGroups();
-               util->setGroups(Groups, allGroups);
-               delete util;
-               
-               if (m->control_pressed) { delete groupMap; return 0; }
-               
-               //read through the list file keeping any otus that contain any sequence from the groups selected
-               readListGroup();
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-               
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveOtusCommand::readListGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick." + label +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               string GroupOutputDir = outputDir;
-               if (outputDir == "") {  GroupOutputDir += m->hasPath(groupfile);  }
-               string outputGroupFileName = GroupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick." + label  + m->getExtension(groupfile);
-               
-               ofstream outGroup;
-               m->openOutputFile(outputGroupFileName, outGroup);
-               
-               InputData* input = new InputData(listfile, "list");
-               ListVector* list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               //using first label seen if none is provided
-               if (label == "") { label = lastLabel; }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> labels; labels.insert(label);
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               bool wroteSomething = false;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((list != NULL) && (userLabels.size() != 0)) {
-                       
-                       if (m->control_pressed) {  delete list; delete input; out.close();  outGroup.close(); m->mothurRemove(outputFileName);  m->mothurRemove(outputGroupFileName);return 0;  }
-                       
-                       if(labels.count(list->getLabel()) == 1){
-                               processList(list, groupMap, out, outGroup, wroteSomething);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list; 
-                               
-                               list = input->getListVector(lastLabel);
-                               
-                               processList(list, groupMap, out, outGroup, wroteSomething);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();
-                       
-                       delete list; list = NULL;
-                       
-                       //get next line to process
-                       list = input->getListVector();                          
-               }
-               
-               
-               if (m->control_pressed) {  if (list != NULL) { delete list; } delete input; out.close(); outGroup.close(); m->mothurRemove(outputFileName);  m->mothurRemove(outputGroupFileName); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) { delete list; }
-                       
-                       list = input->getListVector(lastLabel);
-                       
-                       processList(list, groupMap, out, outGroup, wroteSomething);
-                       
-                       delete list; list = NULL;
-               }
-               
-               out.close();
-               outGroup.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("At distance " + label + " your file ONLY contains otus containing sequences from the groups you wish to remove."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               outputTypes["group"].push_back(outputGroupFileName); outputNames.push_back(outputGroupFileName);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveOtusCommand::processList(ListVector*& list, GroupMap*& groupMap, ofstream& out, ofstream& outGroup, bool& wroteSomething){
-       try {
-               
-               //make a new list vector
-               ListVector newList;
-               newList.setLabel(list->getLabel());
-               
-               int numOtus = 0;
-               //for each bin
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       //parse out names that are in accnos file
-                       string binnames = list->get(i);
-                       
-                       bool removeBin = false;
-                       string groupFileOutput = "";
-                       
-                       //parse names
-                       string individual = "";
-                       int length = binnames.length();
-                       for(int j=0;j<length;j++){
-                               if(binnames[j] == ','){
-                                       string group = groupMap->getGroup(individual);
-                                       if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                                       
-                                       if (m->inUsersGroups(group, Groups)) {  removeBin = true; break; }
-                                       groupFileOutput += individual + "\t" + group + "\n";
-                                       individual = "";        
-                                       
-                               }
-                               else{  individual += binnames[j];  }
-                       }
-                       
-                       if (!removeBin) { 
-                               //get last name
-                               string group = groupMap->getGroup(individual);
-                               if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                               
-                               if (m->inUsersGroups(group, Groups)) {  removeBin = true; }
-                               groupFileOutput += individual + "\t" + group + "\n";                            
-                               
-                               if (!removeBin) {
-                                       //if there are no sequences from the groups we want to remove in this bin add to new list, output to groupfile
-                                       newList.push_back(binnames);    
-                                       outGroup << groupFileOutput;
-                               }else {
-                                       numOtus++;
-                               }
-                       }else {
-                               numOtus++;
-                       }
-                       
-               }
-               
-               //print new listvector
-               if (newList.getNumBins() != 0) {
-                       wroteSomething = true;
-                       newList.print(out);
-               }
-               
-               m->mothurOut(newList.getLabel() + " - removed " + toString(numOtus) + " of the " + toString(list->getNumBins()) + " OTUs."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "processList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void RemoveOtusCommand::readAccnos(){
-       try {
-               Groups.clear();
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                       
-                       Groups.push_back(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveOtusCommand", "readAccnos");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/removeotuscommand.h b/removeotuscommand.h
deleted file mode 100644 (file)
index 6a7cf8a..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef REMOVEOTUSCOMMAND_H
-#define REMOVEOTUSCOMMAND_H
-
-/*
- *  removeotuscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "groupmap.h"
-#include "listvector.hpp"
-
-class RemoveOtusCommand : public Command {
-       
-public:
-       
-       RemoveOtusCommand(string);      
-       RemoveOtusCommand();
-       ~RemoveOtusCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "remove.otus";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Remove.otus"; }
-       string getDescription()         { return "outputs a new list file containing the otus NOT containing sequences from the groups specified"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string accnosfile, groupfile, listfile, outputDir, groups, label;
-       bool abort;
-       vector<string> outputNames, Groups;
-       GroupMap* groupMap;
-       
-       void readAccnos();
-       int readListGroup();
-       int processList(ListVector*&, GroupMap*&, ofstream&, ofstream&, bool&);
-       
-};
-
-#endif
-
-
-
-
diff --git a/removerarecommand.cpp b/removerarecommand.cpp
deleted file mode 100644 (file)
index 24b6165..0000000
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
- *  removerarecommand.cpp
- *  mothur
- *
- *  Created by westcott on 1/21/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "removerarecommand.h"
-#include "sequence.hpp"
-#include "groupmap.h"
-#include "sharedutilities.h"
-#include "inputdata.h"
-
-//**********************************************************************************************************************
-vector<string> RemoveRareCommand::setParameters(){     
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pnseqs("nseqs", "Number", "", "0", "", "", "",false,true); parameters.push_back(pnseqs);
-               CommandParameter pbygroup("bygroup", "Boolean", "", "f", "", "", "",false,true); parameters.push_back(pbygroup);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RemoveRareCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The remove.rare command parameters are list, rabund, sabund, shared, group, label, groups, bygroup and nseqs.\n";
-               helpString += "The remove.rare command reads one of the following file types: list, rabund, sabund or shared file. It outputs a new file after removing the rare otus.\n";
-               helpString += "The groups parameter allows you to specify which of the groups you would like analyzed.  Default=all. You may separate group names with dashes.\n";
-               helpString += "The label parameter is used to analyze specific labels in your input. default=all. You may separate label names with dashes.\n";
-               helpString += "The bygroup parameter is only valid with the shared file. default=f, meaning remove any OTU that has nseqs or fewer sequences across all groups.\n";
-               helpString += "bygroups=T means remove any OTU that has nseqs or fewer sequences in each group (if groupA has 1 sequence and group B has 100 sequences in OTUZ and nseqs=1, then set the groupA count for OTUZ to 0 and keep groupB's count at 100.) \n";
-               helpString += "The nseqs parameter allows you to set the cutoff for an otu to be deemed rare. It is required.\n";
-               helpString += "The remove.rare command should be in the following format: remove.rare(shared=yourSharedFile, nseqs=yourRareCutoff).\n";
-               helpString += "Example remove.rare(shared=amazon.fn.shared, nseqs=2).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. shared), '=' and parameters (i.e.yourSharedFile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RemoveRareCommand::RemoveRareCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "RemoveRareCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RemoveRareCommand::RemoveRareCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["shared"] = tempOutNames;   
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       
-                       //check for file parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { abort = true; }
-                       else if (sabundfile == "not found") {  sabundfile = "";  }      
-                       else { m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { abort = true; }
-                       else if (rabundfile == "not found") {  rabundfile = "";  }                              
-                       else { m->setRabundFile(rabundfile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }        
-                       else { m->setGroupFile(groupfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = "";  abort = true; }
-                       else if (sharedfile == "not found") {  sharedfile = "";  }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") {  m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") {  m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               rabundfile = m->getRabundFile(); 
-                                               if (rabundfile != "") {  m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       sabundfile = m->getSabundFile(); 
-                                                       if (sabundfile != "") {  m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                                       else { 
-                                                               m->mothurOut("No valid current files. You must provide a list, sabund, rabund or shared file."); m->mothurOutEndLine(); 
-                                                               abort = true;
-                                                       }
-                                               }
-                                       }
-                               }
-                       } 
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = "all"; }
-                       m->splitAtDash(groups, Groups);
-                       
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "nseqs", false);      
-                       if (temp == "not found") { m->mothurOut("nseqs is a required parameter."); m->mothurOutEndLine(); abort = true; }
-                       else { m->mothurConvert(temp, nseqs); }
-                       
-                       temp = validParameter.validFile(parameters, "bygroup", false);   if (temp == "not found") { temp = "f"; }
-                       byGroup = m->isTrue(temp);
-                       
-                       if (byGroup && (sharedfile == "")) { m->mothurOut("The byGroup parameter is only valid with a shared file."); m->mothurOutEndLine(); }
-                       
-                       if ((groupfile != "") && (listfile == "")) { m->mothurOut("A groupfile is only valid with a list file."); m->mothurOutEndLine(); groupfile = ""; }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "RemoveRareCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RemoveRareCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (sabundfile != "")           {               processSabund();        }
-               if (rabundfile != "")           {               processRabund();        }
-               if (listfile != "")                     {               processList();          }
-               if (sharedfile != "")           {               processShared();        }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-                       
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set rabund file as new current rabundfile
-                       string current = "";
-                       itTypes = outputTypes.find("rabund");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("sabund");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("shared");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-                       }
-               }
-               
-               return 0;               
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveRareCommand::processList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               string outputGroupFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" +  m->getExtension(groupfile);
-               
-               ofstream out, outGroup;
-               m->openOutputFile(outputFileName, out);
-               
-               bool wroteSomething = false;
-               
-               //you must provide a label because the names in the listfile need to be consistent
-               string thisLabel = "";
-               if (allLines) { m->mothurOut("For the listfile you must select one label, using first label in your listfile."); m->mothurOutEndLine(); }
-               else if (labels.size() > 1) { m->mothurOut("For the listfile you must select one label, using " + (*labels.begin()) + "."); m->mothurOutEndLine(); thisLabel = *labels.begin(); }
-               else { thisLabel = *labels.begin(); }
-               
-               InputData input(listfile, "list");
-               ListVector* list = input.getListVector();
-               
-               //get first one or the one we want
-               if (thisLabel != "") {  
-                       //use smart distancing
-                       set<string> userLabels; userLabels.insert(thisLabel);
-                       set<string> processedLabels;
-                       string lastLabel = list->getLabel();
-                       while((list != NULL) && (userLabels.size() != 0)) {
-                               if(userLabels.count(list->getLabel()) == 1){
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       break;
-                               }
-                               
-                               if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       processedLabels.insert(list->getLabel());
-                                       userLabels.erase(list->getLabel());
-                                       delete list;
-                                       list = input.getListVector(lastLabel);
-                                       break;
-                               }
-                               lastLabel = list->getLabel();
-                               delete list;
-                               list = input.getListVector();
-                       }
-                       if (userLabels.size() != 0) { 
-                               m->mothurOut("Your file does not include the label " + thisLabel + ". I will use " + lastLabel + ".");  m->mothurOutEndLine();
-                               list = input.getListVector(lastLabel); 
-                       }
-               }
-               
-               //if groupfile is given then use it
-               GroupMap* groupMap;
-               if (groupfile != "") { 
-                       groupMap = new GroupMap(groupfile); groupMap->readMap(); 
-                       SharedUtil util;
-                       vector<string> namesGroups = groupMap->getNamesOfGroups();
-                       util.setGroups(Groups, namesGroups);
-                       m->openOutputFile(outputGroupFileName, outGroup);
-               }
-               
-               
-               if (list != NULL) {     
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list->getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list->getNumBins(); i++) {
-                               if (m->control_pressed) {  if (groupfile != "") { delete groupMap; outGroup.close(); m->mothurRemove(outputGroupFileName); } out.close();  m->mothurRemove(outputFileName);  return 0; }
-                               
-                               //parse out names that are in accnos file
-                               string binnames = list->get(i);
-                               vector<string> names;
-                               string saveBinNames = binnames;
-                               m->splitAtComma(binnames, names);
-                               
-                               vector<string> newGroupFile;
-                               if (groupfile != "") {
-                                       vector<string> newNames;
-                                       saveBinNames = "";
-                                       for(int k = 0; k < names.size(); k++) {
-                                               string group = groupMap->getGroup(names[k]);
-                                               
-                                               if (m->inUsersGroups(group, Groups)) {
-                                                       newGroupFile.push_back(names[k] + "\t" + group); 
-                                                               
-                                                       newNames.push_back(names[k]);   
-                                                       saveBinNames += names[k] + ",";
-                                               }
-                                       }
-                                       names = newNames;
-                                       saveBinNames = saveBinNames.substr(0, saveBinNames.length()-1);
-                               }
-
-                               if (names.size() > nseqs) { //keep bin
-                                       newList.push_back(saveBinNames);
-                                       for(int k = 0; k < newGroupFile.size(); k++) { outGroup << newGroupFile[k] << endl; }
-                               }
-                       }
-                       
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-               }       
-               
-               out.close();
-               if (groupfile != "") { outGroup.close(); outputTypes["group"].push_back(outputGroupFileName); outputNames.push_back(outputGroupFileName); }
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only rare sequences."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "processList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveRareCommand::processSabund(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + "pick" +  m->getExtension(sabundfile);
-               outputTypes["sabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
-
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               InputData input(sabundfile, "sabund");
-               SAbundVector* sabund = input.getSAbundVector();
-               string lastLabel = sabund->getLabel();
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { delete sabund; out.close(); return 0; }
-                       
-                       if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
-                               
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(sabund->getLabel());
-                               userLabels.erase(sabund->getLabel());
-                               
-                               if (sabund->getMaxRank() > nseqs) {
-                                       for(int i = 1; i <=nseqs; i++) {  sabund->set(i, 0); }
-                               }else { sabund->clear(); }
-                               
-                               if (sabund->getNumBins() > 0) { sabund->print(out); }
-                       }
-                       
-                       if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = sabund->getLabel();
-                               
-                               delete sabund;
-                               sabund = input.getSAbundVector(lastLabel);
-                               
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(sabund->getLabel());
-                               userLabels.erase(sabund->getLabel());
-                               
-                               if (sabund->getMaxRank() > nseqs) {
-                                       for(int i = 1; i <=nseqs; i++) {  sabund->set(i, 0); }
-                               }else { sabund->clear(); }
-                               
-                               if (sabund->getNumBins() > 0) { sabund->print(out); }
-                                                               
-                               //restore real lastlabel to save below
-                               sabund->setLabel(saveLabel);
-                       }               
-                       
-                       lastLabel = sabund->getLabel();                 
-                       
-                       delete sabund;
-                       sabund = input.getSAbundVector();
-               }
-               
-               if (m->control_pressed) {  out.close(); return 0; }     
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (sabund != NULL) {   delete sabund;  }
-                       sabund = input.getSAbundVector(lastLabel);
-                       
-                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                       
-                       if (sabund->getMaxRank() > nseqs) {
-                               for(int i = 1; i <=nseqs; i++) {  sabund->set(i, 0); }
-                       }else { sabund->clear(); }
-                       
-                       if (sabund->getNumBins() > 0) { sabund->print(out); }
-                       
-                       delete sabund;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "processSabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveRareCommand::processRabund(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + "pick" +  m->getExtension(rabundfile);
-               outputTypes["rabund"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               InputData input(rabundfile, "rabund");
-               RAbundVector* rabund = input.getRAbundVector();
-               string lastLabel = rabund->getLabel();
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { delete rabund; out.close(); return 0; }
-                       
-                       if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
-                               
-                               m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(rabund->getLabel());
-                               userLabels.erase(rabund->getLabel());
-                               
-                               RAbundVector newRabund; newRabund.setLabel(rabund->getLabel());
-                               for (int i = 0; i < rabund->getNumBins(); i++) {
-                                       if (rabund->get(i) > nseqs) {
-                                               newRabund.push_back(rabund->get(i));
-                                       }
-                               }
-                               if (newRabund.getNumBins() > 0) { newRabund.print(out); }
-                       }
-                       
-                       if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = rabund->getLabel();
-                               
-                               delete rabund;
-                               rabund = input.getRAbundVector(lastLabel);
-                               
-                               m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(rabund->getLabel());
-                               userLabels.erase(rabund->getLabel());
-                               
-                               RAbundVector newRabund; newRabund.setLabel(rabund->getLabel());
-                               for (int i = 0; i < rabund->getNumBins(); i++) {
-                                       if (rabund->get(i) > nseqs) {
-                                               newRabund.push_back(rabund->get(i));
-                                       }
-                               }
-                               if (newRabund.getNumBins() > 0) { newRabund.print(out); }                               
-                               
-                               //restore real lastlabel to save below
-                               rabund->setLabel(saveLabel);
-                       }               
-                       
-                       lastLabel = rabund->getLabel();                 
-                       
-                       delete rabund;
-                       rabund = input.getRAbundVector();
-               }
-               
-               if (m->control_pressed) {  out.close(); return 0; }     
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (rabund != NULL) {   delete rabund;  }
-                       rabund = input.getRAbundVector(lastLabel);
-                       
-                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                       
-                       RAbundVector newRabund; newRabund.setLabel(rabund->getLabel());
-                       for (int i = 0; i < rabund->getNumBins(); i++) {
-                               if (rabund->get(i) > nseqs) {
-                                       newRabund.push_back(rabund->get(i));
-                               }
-                       }
-                       if (newRabund.getNumBins() > 0) { newRabund.print(out); }       
-                       
-                       delete rabund;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "processRabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveRareCommand::processShared(){
-       try {
-               m->setGroups(Groups);
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + "pick" +  m->getExtension(sharedfile);
-               outputTypes["shared"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               InputData input(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input.getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  out.close(); return 0; }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               processLookup(lookup, out);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input.getSharedRAbundVectors(lastLabel);
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                               processLookup(lookup, out);                     
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }               
-                       
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input.getSharedRAbundVectors();
-               }
-               
-               if (m->control_pressed) {  out.close(); return 0; }     
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i];       }  }
-                       lookup = input.getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       
-                       if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                       processLookup(lookup, out);     
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "processSabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveRareCommand::processLookup(vector<SharedRAbundVector*>& lookup, ofstream& out){
-       try {
-               
-               vector<SharedRAbundVector> newRabunds;  newRabunds.resize(lookup.size());
-               for (int i = 0; i < lookup.size(); i++) {  
-                       newRabunds[i].setGroup(lookup[i]->getGroup());
-                       newRabunds[i].setLabel(lookup[i]->getLabel());
-               }
-               
-               if (byGroup) {
-                       
-                       //for each otu
-                       for (int i = 0; i < lookup[0]->getNumBins(); i++) {
-                               bool allZero = true;
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               //for each group
-                               for (int j = 0; j < lookup.size(); j++) {
-                                       
-                                       //are you rare?
-                                       if (lookup[j]->getAbundance(i) > nseqs) {
-                                               newRabunds[j].push_back(lookup[j]->getAbundance(i), newRabunds[j].getGroup());
-                                               allZero = false;
-                                       }else {
-                                               newRabunds[j].push_back(0, newRabunds[j].getGroup());
-                                       }
-                               }
-                               
-                               //eliminates zero otus
-                               if (allZero) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
-                       }
-               }else {
-                       //for each otu
-                       for (int i = 0; i < lookup[0]->getNumBins(); i++) {
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               int totalAbund = 0;
-                               //get total otu abundance
-                               for (int j = 0; j < lookup.size(); j++) {
-                                       newRabunds[j].push_back(lookup[j]->getAbundance(i), newRabunds[j].getGroup());
-                                       totalAbund += lookup[j]->getAbundance(i);
-                               }
-                               
-                               //eliminates otus below rare cutoff
-                               if (totalAbund <= nseqs) { for (int j = 0; j < newRabunds.size(); j++) {  newRabunds[j].pop_back(); } }
-                       }
-               }
-               
-               //do we have any otus above the rare cutoff
-               if (newRabunds[0].getNumBins() != 0) { 
-                       for (int j = 0; j < newRabunds.size(); j++) { 
-                               out << newRabunds[j].getLabel() << '\t' << newRabunds[j].getGroup() << '\t';
-                               newRabunds[j].print(out); 
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveRareCommand", "processLookup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
-
diff --git a/removerarecommand.h b/removerarecommand.h
deleted file mode 100644 (file)
index 9e58c06..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef REMOVERARECOMMAND_H
-#define REMOVERARECOMMAND_H
-
-/*
- *  removerarecommand.h
- *  mothur
- *
- *  Created by westcott on 1/21/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "listvector.hpp"
-
-
-class RemoveRareCommand : public Command {
-       
-public:
-       
-       RemoveRareCommand(string);      
-       RemoveRareCommand();
-       ~RemoveRareCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "remove.rare";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Remove.rare"; }
-       string getDescription()         { return "removes rare sequences from a sabund, rabund, shared or list and group file"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string sabundfile, rabundfile, sharedfile, groupfile, listfile, outputDir, groups, label;
-       int nseqs, allLines;
-       bool abort, byGroup;
-       vector<string> outputNames, Groups;
-       set<string> labels;
-       
-       int processSabund();
-       int processRabund();
-       int processList();
-       int processShared();
-       int processLookup(vector<SharedRAbundVector*>&, ofstream&);
-       
-};
-
-#endif
-
-
-
-
diff --git a/removeseqscommand.cpp b/removeseqscommand.cpp
deleted file mode 100644 (file)
index 2abe9ef..0000000
+++ /dev/null
@@ -1,792 +0,0 @@
-/*
- *  removeseqscommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "removeseqscommand.h"
-#include "sequence.hpp"
-#include "listvector.hpp"
-
-//**********************************************************************************************************************
-vector<string> RemoveSeqsCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(paccnos);
-               CommandParameter pdups("dups", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pdups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string RemoveSeqsCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The remove.seqs command reads an .accnos file and at least one of the following file types: fasta, name, group, list, taxonomy, quality or alignreport file.\n";
-               helpString += "It outputs a file containing the sequences NOT in the .accnos file.\n";
-               helpString += "The remove.seqs command parameters are accnos, fasta, name, group, list, taxonomy, qfile, alignreport and dups.  You must provide accnos and at least one of the file parameters.\n";
-               helpString += "The dups parameter allows you to remove the entire line from a name file if you remove any name from the line. default=true. \n";
-               helpString += "The remove.seqs command should be in the following format: remove.seqs(accnos=yourAccnos, fasta=yourFasta).\n";
-               helpString += "Example remove.seqs(accnos=amazon.accnos, fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-RemoveSeqsCommand::RemoveSeqsCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "RemoveSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-RemoveSeqsCommand::RemoveSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       
-                       //check for required parameters
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { abort = true; }
-                       else if (accnosfile == "not found") {  
-                               accnosfile = m->getAccnosFile(); 
-                               if (accnosfile != "") {  m->mothurOut("Using " + accnosfile + " as input file for the accnos parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("You have no valid accnos file and accnos is required."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               }  
-                       }else { m->setAccnosFile(accnosfile); } 
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }        
-                       else { m->setFastaFile(fastafile); }
-                                                                  
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); } 
-                                                                  
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       alignfile = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignfile == "not open") { abort = true; }
-                       else if (alignfile == "not found") {  alignfile = "";  }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") {  listfile = "";  }
-                       else { m->setListFile(listfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { abort = true; }
-                       else if (qualfile == "not found") {  qualfile = "";  }                  
-                       else { m->setQualFile(qualfile); }
-                       
-                       string usedDups = "true";
-                       string temp = validParameter.validFile(parameters, "dups", false);      
-                       if (temp == "not found") { 
-                               if (namefile != "") {  temp = "true";                                   }
-                               else                            {  temp = "false"; usedDups = "";       }
-                       }
-                       dups = m->isTrue(temp);
-                       
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "") && (qualfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, group, taxonomy, quality, alignreport or list."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile != "") && (namefile == "")) {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "RemoveSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int RemoveSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get names you want to keep
-               readAccnos();
-               
-               if (m->control_pressed) { return 0; }
-               
-               //read through the correct file and output lines you want to keep
-               if (namefile != "")                     {               readName();             }
-               if (fastafile != "")            {               readFasta();    }
-               if (groupfile != "")            {               readGroup();    }
-               if (alignfile != "")            {               readAlign();    }
-               if (listfile != "")                     {               readList();             }
-               if (taxfile != "")                      {               readTax();              }
-               if (qualfile != "")                     {               readQual();             }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-       
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("list");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("qfile");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-                       }                       
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "pick" + m->getExtension(fastafile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       Sequence currSeq(in);
-                       name = currSeq.getName();
-                       
-                       if (name != "") {
-                               //if this name is in the accnos file
-                               if (names.count(name) == 0) {
-                                       wroteSomething = true;
-                                       
-                                       currSeq.printSequence(out);
-                               }else {  removedCount++;  }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your fasta file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readQual(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "pick" +  m->getExtension(qualfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               
-               ifstream in;
-               m->openInputFile(qualfile, in);
-               string name;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               
-               while(!in.eof()){       
-                       string saveName = "";
-                       string name = "";
-                       string scores = "";
-                       
-                       in >> name; 
-                       
-                       if (name.length() != 0) { 
-                               saveName = name.substr(1);
-                               while (!in.eof())       {       
-                                       char c = in.get(); 
-                                       if (c == 10 || c == 13){        break;  }
-                                       else { name += c; }     
-                               } 
-                               m->gobble(in);
-                       }
-                       
-                       while(in){
-                               char letter= in.get();
-                               if(letter == '>'){      in.putback(letter);     break;  }
-                               else{ scores += letter; }
-                       }
-                       
-                       m->gobble(in);
-                       
-                       if (names.count(saveName) == 0) {
-                               wroteSomething = true;
-                               
-                               out << name << endl << scores;
-                       }else {  removedCount++;  }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               
-               if (wroteSomething == false) { m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputNames.push_back(outputFileName);  outputTypes["qfile"].push_back(outputFileName); 
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your quality file."); m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readQual");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readList(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "pick" +  m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(listfile, in);
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       
-                       removedCount = 0;
-                       
-                       //read in list vector
-                       ListVector list(in);
-                       
-                       //make a new list vector
-                       ListVector newList;
-                       newList.setLabel(list.getLabel());
-                       
-                       //for each bin
-                       for (int i = 0; i < list.getNumBins(); i++) {
-                               if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                               //parse out names that are in accnos file
-                               string binnames = list.get(i);
-                               
-                               string newNames = "";
-                               while (binnames.find_first_of(',') != -1) { 
-                                       string name = binnames.substr(0,binnames.find_first_of(','));
-                                       binnames = binnames.substr(binnames.find_first_of(',')+1, binnames.length());
-                                       
-                                       //if that name is in the .accnos file, add it
-                                       if (names.count(name) == 0) {  newNames += name + ",";  }
-                                       else {  removedCount++;  }
-                               }
-                       
-                               //get last name
-                               if (names.count(binnames) == 0) {  newNames += binnames + ",";  }
-                               else {  removedCount++;  }
-
-                               //if there are names in this bin add to new list
-                               if (newNames != "") {  
-                                       newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                                       newList.push_back(newNames);    
-                               }
-                       }
-                               
-                       //print new listvector
-                       if (newList.getNumBins() != 0) {
-                               wroteSomething = true;
-                               newList.print(out);
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["list"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your list file."); m->mothurOutEndLine();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "pick" + m->getExtension(namefile);
-
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> firstCol;         m->gobble(in);          
-                       in >> secondCol;                        
-                       
-                       vector<string> parsedNames;
-                       m->splitAtComma(secondCol, parsedNames);
-                       
-                       vector<string> validSecond;  validSecond.clear();
-                       for (int i = 0; i < parsedNames.size(); i++) {
-                               if (names.count(parsedNames[i]) == 0) {
-                                       validSecond.push_back(parsedNames[i]);
-                               }
-                       }
-                       
-                       if ((dups) && (validSecond.size() != parsedNames.size())) {  //if dups is true and we want to get rid of anyone, get rid of everyone
-                               for (int i = 0; i < parsedNames.size(); i++) {  names.insert(parsedNames[i]);  }
-                               removedCount += parsedNames.size();
-                       }else {
-                               removedCount += parsedNames.size()-validSecond.size();
-                               //if the name in the first column is in the set then print it and any other names in second column also in set
-                               if (names.count(firstCol) == 0) {
-                                       
-                                       wroteSomething = true;
-                                       
-                                       out << firstCol << '\t';
-                                       
-                                       //you know you have at least one valid second since first column is valid
-                                       for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                       out << validSecond[validSecond.size()-1] << endl;
-                                       
-                                       //make first name in set you come to first column and then add the remaining names to second column
-                               }else {
-                                       
-                                       //you want part of this row
-                                       if (validSecond.size() != 0) {
-                                               
-                                               wroteSomething = true;
-                                               
-                                               out << validSecond[0] << '\t';
-                                               
-                                               //you know you have at least one valid second since first column is valid
-                                               for (int i = 0; i < validSecond.size()-1; i++) {  out << validSecond[i] << ',';  }
-                                               out << validSecond[validSecond.size()-1] << endl;
-                                       }
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["name"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your name file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> group;                    //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << group << endl;
-                       }else {  removedCount++;  }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["group"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your group file."); m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int RemoveSeqsCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       in >> tax;                      //read from second column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               out << name << '\t' << tax << endl;
-                       }else {  removedCount++;  }
-                                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["taxonomy"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your taxonomy file."); m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//alignreport file has a column header line then all other lines contain 16 columns.  we just want the first column since that contains the name
-int RemoveSeqsCommand::readAlign(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(alignfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(alignfile)) + "pick.align.report";
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-
-               ifstream in;
-               m->openInputFile(alignfile, in);
-               string name, junk;
-               
-               bool wroteSomething = false;
-               int removedCount = 0;
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                       else                    {       break;                  }
-               }
-               out << endl;
-               
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                       
-                       in >> name;                             //read from first column
-                       
-                       //if this name is in the accnos file
-                       if (names.count(name) == 0) {
-                               wroteSomething = true;
-                               
-                               out << name << '\t';
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;      out << junk << '\t';   }
-                                       else                    {       break;                  }
-                               }
-                               out << endl;
-                               
-                       }else {//still read just don't do anything with it
-                               removedCount++;  
-                               
-                               //read rest
-                               for (int i = 0; i < 15; i++) {  
-                                       if (!in.eof())  {       in >> junk;             }
-                                       else                    {       break;                  }
-                               }
-                       }
-                       
-                       m->gobble(in);
-               }
-               in.close();
-               out.close();
-               
-               if (wroteSomething == false) {  m->mothurOut("Your file contains only sequences from the .accnos file."); m->mothurOutEndLine();  }
-               outputTypes["alignreport"].push_back(outputFileName); outputNames.push_back(outputFileName);
-               
-               m->mothurOut("Removed " + toString(removedCount) + " sequences from your alignreport file."); m->mothurOutEndLine();
-
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readAlign");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void RemoveSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name;
-                                               
-                       names.insert(name);
-                       
-                       m->gobble(in);
-               }
-               in.close();             
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "RemoveSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
diff --git a/removeseqscommand.h b/removeseqscommand.h
deleted file mode 100644 (file)
index df96e45..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef REMOVESEQSCOMMAND_H
-#define REMOVESEQSCOMMAND_H
-
-/*
- *  removeseqscommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "command.hpp"
-
-class RemoveSeqsCommand : public Command {
-       
-       public:
-       
-               RemoveSeqsCommand(string);      
-               RemoveSeqsCommand();
-               ~RemoveSeqsCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "remove.seqs";                         }
-               string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Remove.seqs"; }
-               string getDescription()         { return "removes sequences from a list, fasta, name, group, alignreport, quality or taxonomy file"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       
-       private:
-               set<string> names;
-               string accnosfile, fastafile, namefile, groupfile, alignfile, listfile, taxfile, qualfile, outputDir;
-               bool abort, dups;
-               vector<string> outputNames;
-               
-               int readFasta();
-               int readName();
-               int readGroup();
-               int readAlign();
-               void readAccnos();
-               int readList();
-               int readTax();
-               int readQual();
-               
-};
-
-#endif
-
diff --git a/reportfile.cpp b/reportfile.cpp
deleted file mode 100644 (file)
index 8e3b746..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- *  reportfile.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 12/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "reportfile.h"
-
-/**************************************************************************************************/
-
-ReportFile::ReportFile(){
-       try {
-               m = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReportFile", "ReportFile");
-               exit(1);
-       }                                                       
-}
-
-/**************************************************************************************************/
-
-ReportFile::ReportFile(ifstream& repFile, string repFileName){
-       try {           
-               m = MothurOut::getInstance();
-               
-               m->openInputFile(repFileName, repFile);
-               m->getline(repFile);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReportFile", "ReportFile");
-               exit(1);
-       }                                                       
-}
-
-
-/**************************************************************************************************/
-
-ReportFile::ReportFile(ifstream& repFile){
-       try {
-               
-               m = MothurOut::getInstance();
-               
-               repFile >> queryName;
-               repFile >> queryLength;
-               repFile >> templateName;
-               repFile >> templateLength;
-               repFile >> searchMethod;
-               repFile >> dummySearchScore;
-               repFile >> alignmentMethod;
-               repFile >> queryStart;
-               repFile >> queryEnd;
-               repFile >> templateStart;
-               repFile >> templateEnd;
-               repFile >> pairwiseAlignmentLength;
-               repFile >> gapsInQuery;
-               repFile >> gapsInTemplate;
-               repFile >> longestInsert;
-               repFile >> simBtwnQueryAndTemplate;
-
-               if(dummySearchScore != "nan"){
-                       istringstream stream(dummySearchScore);
-                       stream >> searchScore;
-               }
-               else{
-                       searchScore = 0;
-               }
-               
-               m->gobble(repFile);             
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReportFile", "ReportFile");
-               exit(1);
-       }                                                       
-       
-}
-
-/**************************************************************************************************/
diff --git a/reportfile.h b/reportfile.h
deleted file mode 100644 (file)
index 067dd14..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef REPORTFILE
-#define REPORTFILE
-
-/*
- *  reportfile.h
- *  Mothur
- *
- *  Created by Pat Schloss on 7/12/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-/**************************************************************************************************/
-
-class ReportFile {
-public:
-       ReportFile();
-       ReportFile(ifstream&);
-       ReportFile(ifstream&, string);
-       
-       string getQueryName()                           {       return queryName;                               }
-       string getTemplateName()                        {       return templateName;                    }
-       string getSearchMethod()                        {       return searchMethod;                    }
-       string getAlignmentMethod()                     {       return alignmentMethod;                 }
-       
-       int getQueryLength()                            {       return queryLength;                             }
-       int getTemplateLength()                         {       return templateLength;                  }
-       int getQueryStart()                                     {       return queryStart;                              }
-       int getQueryEnd()                                       {       return queryEnd;                                }
-       int getTemplateStart()                          {       return templateStart;                   }
-       int getTemplateEnd()                            {       return templateEnd;                             }
-       int getPairwiseAlignmentLength()        {       return pairwiseAlignmentLength; }
-       int getGapsInQuery()                            {       return gapsInQuery;                             }
-       int getGapsInTemplate()                         {       return gapsInTemplate;                  }
-       int getLongestInsert()                          {       return longestInsert;                   }
-       
-       float getSearchScore()                          {       return searchScore;                             }
-       float getSimBtwnQueryAndTemplate()      {       return simBtwnQueryAndTemplate; }
-       
-
-private:
-       
-       MothurOut* m;
-               
-       string queryName, templateName, searchMethod, alignmentMethod, dummySearchScore;
-       int queryLength, templateLength, queryStart, queryEnd, templateStart, templateEnd, pairwiseAlignmentLength, gapsInQuery, gapsInTemplate, longestInsert;
-       float searchScore, simBtwnQueryAndTemplate;
-       
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/reversecommand.cpp b/reversecommand.cpp
deleted file mode 100644 (file)
index c664ad7..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- *  reversecommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 6/6/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "reversecommand.h"
-#include "sequence.hpp"
-#include "qualityscores.h"
-
-//**********************************************************************************************************************
-vector<string> ReverseSeqsCommand::setParameters(){    
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "fastaQual", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "fastaQual", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ReverseSeqsCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The reverse.seqs command reads a fastafile and outputs a fasta file containing the reverse compliment.\n";
-               helpString += "The reverse.seqs command parameters fasta or qfile are required.\n";
-               helpString += "The reverse.seqs command should be in the following format: \n";
-               helpString += "reverse.seqs(fasta=yourFastaFile) \n";   
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ReverseSeqsCommand::ReverseSeqsCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-ReverseSeqsCommand::ReverseSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastaFileName = validParameter.validFile(parameters, "fasta", true);
-                       if (fastaFileName == "not open") { abort = true; }
-                       else if (fastaFileName == "not found") { fastaFileName = "";}// m->mothurOut("fasta is a required parameter for the reverse.seqs command."); m->mothurOutEndLine(); abort = true;  }    
-                       else { m->setFastaFile(fastaFileName); }
-                       
-                       qualFileName = validParameter.validFile(parameters, "qfile", true);
-                       if (qualFileName == "not open") { abort = true; }
-                       else if (qualFileName == "not found") { qualFileName = ""; }//m->mothurOut("fasta is a required parameter for the reverse.seqs command."); m->mothurOutEndLine(); abort = true;  }      
-                       else { m->setQualFile(qualFileName); }
-                       
-                       if((fastaFileName == "") && (qualFileName == "")){
-                               fastaFileName = m->getFastaFile(); 
-                               if (fastaFileName != "") {  m->mothurOut("Using " + fastaFileName + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       qualFileName = m->getQualFile(); 
-                                       if (qualFileName != "") {  m->mothurOut("Using " + qualFileName + " as input file for the qfile parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You have no current files for fasta or qfile, and fasta or qfile is a required parameter for the reverse.seqs command."); m->mothurOutEndLine();
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                       }
-
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "ReverseSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-
-int ReverseSeqsCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               string fastaReverseFileName;
-               
-               if(fastaFileName != ""){
-                       ifstream inFASTA;
-                       m->openInputFile(fastaFileName, inFASTA);
-                       
-                       ofstream outFASTA;
-                       string tempOutputDir = outputDir;
-                       if (outputDir == "") { tempOutputDir += m->hasPath(fastaFileName); } //if user entered a file with a path then preserve it
-                       fastaReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(fastaFileName)) + "rc" + m->getExtension(fastaFileName);
-                       m->openOutputFile(fastaReverseFileName, outFASTA);
-                       
-                       while(!inFASTA.eof()){
-                               if (m->control_pressed) {  inFASTA.close();  outFASTA.close(); m->mothurRemove(fastaReverseFileName); return 0; }
-                                
-                               Sequence currSeq(inFASTA);  m->gobble(inFASTA);
-                               if (currSeq.getName() != "") {
-                                       currSeq.reverseComplement();
-                                       currSeq.printSequence(outFASTA);
-                               }
-                       }
-                       inFASTA.close();
-                       outFASTA.close();
-                       outputNames.push_back(fastaReverseFileName); outputTypes["fasta"].push_back(fastaReverseFileName);
-               }
-               
-               string qualReverseFileName;
-
-               if(qualFileName != ""){
-                       QualityScores currQual;
-
-                       ifstream inQual;
-                       m->openInputFile(qualFileName, inQual);
-                       
-                       ofstream outQual;
-                       string tempOutputDir = outputDir;
-                       if (outputDir == "") { tempOutputDir += m->hasPath(qualFileName); } //if user entered a file with a path then preserve it
-                       string qualReverseFileName = tempOutputDir + m->getRootName(m->getSimpleName(qualFileName)) + "rc" + m->getExtension(qualFileName);
-                       m->openOutputFile(qualReverseFileName, outQual);
-
-                       while(!inQual.eof()){
-                               if (m->control_pressed) {  inQual.close();  outQual.close(); m->mothurRemove(qualReverseFileName); return 0; }
-                               currQual = QualityScores(inQual);  m->gobble(inQual);
-                               currQual.flipQScores(); 
-                               currQual.printQScores(outQual);
-                       }
-                       inQual.close();
-                       outQual.close();
-                       outputNames.push_back(qualReverseFileName); outputTypes["qfile"].push_back(qualReverseFileName);
-               }
-               
-               if (m->control_pressed) {  m->mothurRemove(qualReverseFileName); m->mothurRemove(fastaReverseFileName); return 0; }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("qfile");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-               }
-               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               for(int i=0;i<outputNames.size();i++){
-                       m->mothurOut(outputNames[i]);
-                       m->mothurOutEndLine();
-               }
-               
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ReverseSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
diff --git a/reversecommand.h b/reversecommand.h
deleted file mode 100644 (file)
index f0fdfa8..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef REVERSECOMMAND_H
-#define REVERSECOMMAND_H
-
-/*
- *  reversecommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 6/6/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-class ReverseSeqsCommand : public Command {
-public:
-       ReverseSeqsCommand(string);
-       ReverseSeqsCommand();
-       ~ReverseSeqsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "reverse.seqs";                        }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Reverse.seqs"; }
-       string getDescription()         { return "outputs a fasta file containing the reverse-complements"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-
-       bool abort;
-       string fastaFileName, qualFileName, outputDir;
-       vector<string> outputNames;
-       
-};
-
-#endif
diff --git a/sabundvector.cpp b/sabundvector.cpp
deleted file mode 100644 (file)
index 1bceec2..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- *  sabund.cpp
- *  
- *
- *  Created by Pat Schloss on 8/8/08.
- *  Copyright 2008 Patrick D. Schloss. All rights resesaved.
- *
- */
-
-#include "sabundvector.hpp"
-#include "calculator.h"
-
-/***********************************************************************/
-
-SAbundVector::SAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){}
-
-/***********************************************************************/
-
-SAbundVector::SAbundVector(int size) : DataVector(), data(size, 0), maxRank(0), numBins(0), numSeqs(0) {}
-
-/***********************************************************************/
-
-SAbundVector::SAbundVector(string id, vector<int> sav) : DataVector(id), data(sav) {
-       try {
-               for(int i=0;i<sav.size();i++){
-                       if(data[i] != 0){       maxRank = i;    }
-                       numSeqs += i*data[i];
-                       numBins += data[i];
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "SAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SAbundVector::SAbundVector(vector <int> dataVec, int mr, int nb, int ns) {
-       try {
-               data = dataVec;
-               maxRank = mr;
-               numBins = nb;
-               numSeqs = ns;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "SAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-SAbundVector::SAbundVector(ifstream& f): DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               int hold;
-               f >> label >> hold;
-       
-               data.assign(hold+1, 0);
-               int inputData;
-       
-               for(int i=1;i<=hold;i++){
-                       f >> inputData;
-
-                       set(i, inputData);
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "SAbundVector");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-void SAbundVector::set(int sabund, int abundance){
-       try {
-
-               int initSize = data[sabund];
-               data[sabund] = abundance;
-       
-               if(sabund != 0){
-                       numBins += (abundance - initSize);
-               }
-       
-               numSeqs += sabund * (abundance - initSize);
-       
-               if(sabund > maxRank)    {       maxRank = sabund;               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "set");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-int SAbundVector::get(int index){
-       return data[index];
-}
-
-/***********************************************************************/
-
-void SAbundVector::push_back(int abundance){
-       try {
-               data.push_back(abundance);
-       
-               maxRank++;      
-       
-               numBins += abundance;
-       
-               numSeqs += (maxRank * abundance);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "push_back");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void SAbundVector::quicksort(){
-       sort(data.rbegin(), data.rend());
-}
-
-/***********************************************************************/
-
-int SAbundVector::sum(){
-       VecCalc vecCalc;
-       return vecCalc.sumElements(data);
-}
-
-/***********************************************************************/
-
-void SAbundVector::resize(int size){
-       data.resize(size);
-}
-
-/***********************************************************************/
-
-int SAbundVector::size(){
-       return data.size();             
-}
-
-/***********************************************************************/
-void SAbundVector::print(string prefix, ostream& output){
-       
-       output << prefix << '\t' << maxRank << '\t';
-       
-       for(int i=1;i<=maxRank;i++){
-               output << data[i] << '\t';
-       }
-       output << endl;
-}
-/***********************************************************************/
-void SAbundVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();   
-}
-/***********************************************************************/
-void SAbundVector::print(ostream& output){
-       try {
-               output << label << '\t' << maxRank << '\t';
-       
-               for(int i=1;i<=maxRank;i++){
-                       output << data[i] << '\t';
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "print");
-               exit(1);
-       }
-}
-
-/**********************************************************************/
-int SAbundVector::getNumBins(){
-//     if(needToUpdate == 1){  updateStats();  }
-       return numBins;
-}
-
-/***********************************************************************/
-
-int SAbundVector::getNumSeqs(){
-//     if(needToUpdate == 1){  updateStats();  }
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int SAbundVector::getMaxRank(){
-//     if(needToUpdate == 1){  updateStats();  }
-       return maxRank;
-}
-/***********************************************************************/
-RAbundVector SAbundVector::getRAbundVector(){
-       try {
-               RAbundVector rav;
-       
-               for(int i=1;i < data.size();i++){
-                       for(int j=0;j<data[i];j++){
-                               rav.push_back(i);
-                       }
-               }
-               sort(rav.rbegin(), rav.rend());
-
-               rav.setLabel(label);
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "getRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SAbundVector SAbundVector::getSAbundVector(){
-       return *this;                   
-}
-
-/***********************************************************************/
-
-OrderVector SAbundVector::getOrderVector(map<string,int>* hold = NULL){
-       try {
-               OrderVector ov;
-       
-               int binIndex = 0;
-       
-               for(int i=1;i<data.size();i++){
-                       for(int j=0;j<data[i];j++){
-                               for(int k=0;k<i;k++){
-                                       ov.push_back(binIndex);
-                               }
-                               binIndex++;
-                       }
-               }
-       
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);
-               ov.getNumBins();
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SAbundVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sabundvector.hpp b/sabundvector.hpp
deleted file mode 100644 (file)
index 666e94f..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef SABUND_H
-#define SABUND_H
-
-#include "datavector.hpp"
-#include "rabundvector.hpp"
-#include "ordervector.hpp"
-#include "calculator.h"
-
-
-/*  Data Structure for a sabund file.
-    This class is a child to datavector.  It represents OTU information at a certain distance. 
-       A sabundvector can be converted into and ordervector, listvector or rabundvector.
-       Each member of the internal container "data" represents the number of OTU's with that many members, but staring at 1.
-       So data[1] = 2, because there are two OTUs with 1 member.
-       example: listvector             =       a,b,c,d,e,f             g,h,i           j,k             l               m  
-                        rabundvector   =       6                               3                       2               1               1
-                        sabundvector   =       2               1               1               0               0               1
-                        ordervector    =       1       1       1       1       1       1       2       2       2       3       3       4       5 */
-
-
-class SAbundVector : public DataVector {
-       
-public:
-       SAbundVector();
-       SAbundVector(int);
-//     SAbundVector(const SAbundVector&);
-       SAbundVector(vector<int>, int, int, int);
-       SAbundVector(string, vector<int>);
-       SAbundVector(const SAbundVector& rv) : DataVector(rv.label), data(rv.data), maxRank(rv.maxRank), numBins(rv.numBins), numSeqs(rv.numSeqs){};
-       SAbundVector(ifstream&);
-       ~SAbundVector(){};
-
-       int getNumBins();       
-       int getNumSeqs();       
-       int getMaxRank();       
-       
-       void set(int, int);
-       int get(int);
-       void push_back(int);
-       void quicksort();
-       int sum();
-       void resize(int);
-       int size();
-       void clear();
-
-       void print(ostream&);
-       void print(string, ostream&);
-               
-       RAbundVector getRAbundVector();         
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       
-private:
-       vector<int> data;
-//     bool needToUpdate;
-//     void updateStats();
-       
-       int maxRank;
-       int numBins;
-       int numSeqs;
-
-};
-
-#endif
diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp
deleted file mode 100644 (file)
index 7ac910d..0000000
+++ /dev/null
@@ -1,1404 +0,0 @@
-/*
- *  screenseqscommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 6/3/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "screenseqscommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> ScreenSeqsCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter palignreport("alignreport", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(palignreport);
-               CommandParameter ptax("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptax);
-               CommandParameter pstart("start", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pstart);
-               CommandParameter pend("end", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pend);
-               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxambig);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pminlength("minlength", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pminlength);
-               CommandParameter pmaxlength("maxlength", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxlength);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pcriteria("criteria", "Number", "", "90", "", "", "",false,false); parameters.push_back(pcriteria);
-               CommandParameter poptimize("optimize", "Multiple", "none-start-end-maxambig-maxhomop-minlength-maxlength", "none", "", "", "",true,false); parameters.push_back(poptimize);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ScreenSeqsCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The screen.seqs command reads a fastafile and creates .....\n";
-               helpString += "The screen.seqs command parameters are fasta, start, end, maxambig, maxhomop, minlength, maxlength, name, group, qfile, alignreport, taxonomy, optimize, criteria and processors.\n";
-               helpString += "The fasta parameter is required.\n";
-               helpString += "The alignreport and taxonomy parameters allow you to remove bad seqs from taxonomy and alignreport files.\n";
-               helpString += "The start parameter .... The default is -1.\n";
-               helpString += "The end parameter .... The default is -1.\n";
-               helpString += "The maxambig parameter allows you to set the maximum number of ambigious bases allowed. The default is -1.\n";
-               helpString += "The maxhomop parameter allows you to set a maximum homopolymer length. \n";
-               helpString += "The minlength parameter allows you to set and minimum sequence length. \n";
-               helpString += "The maxlength parameter allows you to set and maximum sequence length. \n";
-               helpString += "The processors parameter allows you to specify the number of processors to use while running the command. The default is 1.\n";
-               helpString += "The optimize and criteria parameters allow you set the start, end, maxabig, maxhomop, minlength and maxlength parameters relative to your set of sequences .\n";
-               helpString += "For example optimize=start-end, criteria=90, would set the start and end values to the position 90% of your sequences started and ended.\n";
-               helpString += "The name parameter allows you to provide a namesfile, and the group parameter allows you to provide a groupfile.\n";
-               helpString += "The screen.seqs command should be in the following format: \n";
-               helpString += "screen.seqs(fasta=yourFastaFile, name=youNameFile, group=yourGroupFIle, start=yourStart, end=yourEnd, maxambig=yourMaxambig,  \n";
-               helpString += "maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength)  \n";    
-               helpString += "Example screen.seqs(fasta=abrecovery.fasta, name=abrecovery.names, group=abrecovery.groups, start=..., end=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-ScreenSeqsCommand::ScreenSeqsCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["alignreport"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-ScreenSeqsCommand::ScreenSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("screen.seqs");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["alignreport"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("alignreport");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["alignreport"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                       }
-
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                         
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (fastafile == "not open") { abort = true; }
-                       else { m->setFastaFile(fastafile); }
-       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { abort = true; }   
-                       else if (qualfile == "not found") { qualfile = ""; }
-                       else { m->setQualFile(qualfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }    
-                       else { m->setNameFile(namefile); }
-                       
-                       alignreport = validParameter.validFile(parameters, "alignreport", true);
-                       if (alignreport == "not open") { abort = true; }
-                       else if (alignreport == "not found") { alignreport = ""; }
-                       
-                       taxonomy = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxonomy == "not open") { abort = true; }
-                       else if (taxonomy == "not found") { taxonomy = ""; }    
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "start", false);            if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, startPos); 
-               
-                       temp = validParameter.validFile(parameters, "end", false);                      if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, endPos);  
-
-                       temp = validParameter.validFile(parameters, "maxambig", false);         if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, maxAmbig);  
-
-                       temp = validParameter.validFile(parameters, "maxhomop", false);         if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, maxHomoP);  
-
-                       temp = validParameter.validFile(parameters, "minlength", false);        if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, minLength); 
-                       
-                       temp = validParameter.validFile(parameters, "maxlength", false);        if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, maxLength); 
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       temp = validParameter.validFile(parameters, "optimize", false); //optimizing trumps the optimized values original value
-                       if (temp == "not found"){       temp = "none";          }
-                       m->splitAtDash(temp, optimize);         
-                       
-                       //check for invalid optimize options
-                       set<string> validOptimizers;
-                       validOptimizers.insert("none"); validOptimizers.insert("start"); validOptimizers.insert("end"); validOptimizers.insert("maxambig"); validOptimizers.insert("maxhomop"); validOptimizers.insert("minlength"); validOptimizers.insert("maxlength");
-                       for (int i = 0; i < optimize.size(); i++) { 
-                               if (validOptimizers.count(optimize[i]) == 0) { 
-                                       m->mothurOut(optimize[i] + " is not a valid optimizer. Valid options are start, end, maxambig, maxhomop, minlength and maxlength."); m->mothurOutEndLine();
-                                       optimize.erase(optimize.begin()+i);
-                                       i--;
-                               }
-                       }
-                       
-                       if (optimize.size() == 1) { if (optimize[0] == "none") { optimize.clear(); } }
-                       
-                       temp = validParameter.validFile(parameters, "criteria", false); if (temp == "not found"){       temp = "90";                            }
-                       m->mothurConvert(temp, criteria); 
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "ScreenSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //if the user want to optimize we need to know the 90% mark
-               vector<unsigned long long> positions;
-               if (optimize.size() != 0) {  //get summary is paralellized so we need to divideFile, no need to do this step twice so I moved it here
-                       //use the namefile to optimize correctly
-                       if (namefile != "") { nameMap = m->readNames(namefile); }
-                       getSummary(positions); 
-               } 
-               else { 
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                positions = m->divideFile(fastafile, processors);
-                for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); }
-                       #else 
-                if(processors == 1){ lines.push_back(linePair(0, 1000));  }
-                else {
-                    int numFastaSeqs = 0;
-                    positions = m->setFilePosFasta(fastafile, numFastaSeqs); 
-                    if (positions.size() < processors) { processors = positions.size(); }
-                
-                    //figure out how many sequences you have to process
-                    int numSeqsPerProcessor = numFastaSeqs / processors;
-                    for (int i = 0; i < processors; i++) {
-                        int startIndex =  i * numSeqsPerProcessor;
-                        if(i == (processors - 1)){     numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                        lines.push_back(linePair(positions[startIndex], numSeqsPerProcessor));
-                    }
-                }
-                       #endif
-               }
-                                       
-               string goodSeqFile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "good" + m->getExtension(fastafile);
-               string badAccnosFile =  outputDir + m->getRootName(m->getSimpleName(fastafile)) + "bad.accnos";
-               
-               int numFastaSeqs = 0;
-               set<string> badSeqNames;
-               int start = time(NULL);
-       
-#ifdef USE_MPI 
-                       int pid, numSeqsPerProcessor; 
-                       int tag = 2001;
-                       vector<unsigned long long> MPIPos;
-                       
-                       MPI_Status status; 
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                       MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-       
-                       MPI_File inMPI;
-                       MPI_File outMPIGood;
-                       MPI_File outMPIBadAccnos;
-                       
-                       int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                       int inMode=MPI_MODE_RDONLY; 
-                       
-                       char outGoodFilename[1024];
-                       strcpy(outGoodFilename, goodSeqFile.c_str());
-
-                       char outBadAccnosFilename[1024];
-                       strcpy(outBadAccnosFilename, badAccnosFile.c_str());
-
-                       char inFileName[1024];
-                       strcpy(inFileName, fastafile.c_str());
-                       
-                       MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                       MPI_File_open(MPI_COMM_WORLD, outGoodFilename, outMode, MPI_INFO_NULL, &outMPIGood);
-                       MPI_File_open(MPI_COMM_WORLD, outBadAccnosFilename, outMode, MPI_INFO_NULL, &outMPIBadAccnos);
-                       
-                       if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIGood); MPI_File_close(&outMPIBadAccnos); return 0; }
-                       
-                       if (pid == 0) { //you are the root process 
-                               
-                               MPIPos = m->setFilePosFasta(fastafile, numFastaSeqs); //fills MPIPos, returns numSeqs
-                               
-                               //send file positions to all processes
-                               for(int i = 1; i < processors; i++) { 
-                                       MPI_Send(&numFastaSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                               }
-                               
-                               //figure out how many sequences you have to align
-                               numSeqsPerProcessor = numFastaSeqs / processors;
-                               int startIndex =  pid * numSeqsPerProcessor;
-                               if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-
-                               //align your part
-                               driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBadAccnos, MPIPos, badSeqNames);
-
-                               if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIGood);  MPI_File_close(&outMPIBadAccnos);  return 0; }
-
-                               for (int i = 1; i < processors; i++) {
-                                       //get bad lists
-                                       int badSize;
-                                       MPI_Recv(&badSize, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                               }
-                       }else{ //you are a child process
-                               MPI_Recv(&numFastaSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPIPos.resize(numFastaSeqs+1);
-                               MPI_Recv(&MPIPos[0], (numFastaSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-
-                               //figure out how many sequences you have to align
-                               numSeqsPerProcessor = numFastaSeqs / processors;
-                               int startIndex =  pid * numSeqsPerProcessor;
-                               if(pid == (processors - 1)){    numSeqsPerProcessor = numFastaSeqs - pid * numSeqsPerProcessor;         }
-
-                               //align your part
-                               driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPIGood, outMPIBadAccnos, MPIPos, badSeqNames);
-
-                               if (m->control_pressed) { MPI_File_close(&inMPI);  MPI_File_close(&outMPIGood);  MPI_File_close(&outMPIBadAccnos); return 0; }
-                               
-                               //send bad list 
-                               int badSize = badSeqNames.size();
-                               MPI_Send(&badSize, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                       }
-                       
-                       //close files 
-                       MPI_File_close(&inMPI);
-                       MPI_File_close(&outMPIGood);
-                       MPI_File_close(&outMPIBadAccnos);
-                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                                       
-#else
-        if(processors == 1){ numFastaSeqs = driver(lines[0], goodSeqFile, badAccnosFile, fastafile, badSeqNames);      }       
-        else{ numFastaSeqs = createProcesses(goodSeqFile, badAccnosFile, fastafile, badSeqNames); }
-        
-        if (m->control_pressed) { m->mothurRemove(goodSeqFile); return 0; }
-#endif         
-
-               #ifdef USE_MPI
-                       MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                       
-                       if (pid == 0) { //only one process should fix files
-                       
-                               //read accnos file with all names in it, process 0 just has its names
-                               MPI_File inMPIAccnos;
-                               MPI_Offset size;
-                       
-                               char inFileName[1024];
-                               strcpy(inFileName, badAccnosFile.c_str());
-                       
-                               MPI_File_open(MPI_COMM_SELF, inFileName, inMode, MPI_INFO_NULL, &inMPIAccnos);  //comm, filename, mode, info, filepointer
-                               MPI_File_get_size(inMPIAccnos, &size);
-                       
-                               char* buffer = new char[size];
-                               MPI_File_read(inMPIAccnos, buffer, size, MPI_CHAR, &status);
-                       
-                               string tempBuf = buffer;
-                               if (tempBuf.length() > size) { tempBuf = tempBuf.substr(0, size);  }
-                               istringstream iss (tempBuf,istringstream::in);
-
-                               delete buffer;
-                               MPI_File_close(&inMPIAccnos);
-                               
-                               badSeqNames.clear();
-                               string tempName;
-                               while (!iss.eof()) {
-                                       iss >> tempName; m->gobble(iss);
-                                       badSeqNames.insert(tempName);
-                               }
-               #endif
-                                                                                                                                                                       
-               if(namefile != "" && groupfile != "")   {       
-                       screenNameGroupFile(badSeqNames);       
-                       if (m->control_pressed) {  m->mothurRemove(goodSeqFile); return 0; }
-               }else if(namefile != "")        {       
-                       screenNameGroupFile(badSeqNames);
-                       if (m->control_pressed) {  m->mothurRemove(goodSeqFile);  return 0; }   
-               }else if(groupfile != "")                               {       screenGroupFile(badSeqNames);           }       // this screens just the group
-               
-               if (m->control_pressed) { m->mothurRemove(goodSeqFile);  return 0; }
-
-               if(alignreport != "")                                   {       screenAlignReport(badSeqNames);         }
-               if(qualfile != "")                                              {       screenQual(badSeqNames);                        }
-               if(taxonomy != "")                                              {       screenTaxonomy(badSeqNames);            }
-               
-               if (m->control_pressed) { m->mothurRemove(goodSeqFile);  return 0; }
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(goodSeqFile); m->mothurOutEndLine();       outputTypes["fasta"].push_back(goodSeqFile);
-               m->mothurOut(badAccnosFile); m->mothurOutEndLine();      outputTypes["accnos"].push_back(badAccnosFile);
-               for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
-               m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               itTypes = outputTypes.find("qfile");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-               }
-               
-               itTypes = outputTypes.find("taxonomy");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-               }
-
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to screen " + toString(numFastaSeqs) + " sequences.");
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::screenNameGroupFile(set<string> badSeqNames){
-       try {
-               ifstream inputNames;
-               m->openInputFile(namefile, inputNames);
-               set<string> badSeqGroups;
-               string seqName, seqList, group;
-               set<string>::iterator it;
-
-               string goodNameFile = outputDir + m->getRootName(m->getSimpleName(namefile)) + "good" + m->getExtension(namefile);
-               outputNames.push_back(goodNameFile);  outputTypes["name"].push_back(goodNameFile);
-               
-               ofstream goodNameOut;   m->openOutputFile(goodNameFile, goodNameOut);
-               
-               while(!inputNames.eof()){
-                       if (m->control_pressed) { goodNameOut.close();  inputNames.close(); m->mothurRemove(goodNameFile);  return 0; }
-
-                       inputNames >> seqName >> seqList;
-                       it = badSeqNames.find(seqName);
-                               
-                       if(it != badSeqNames.end()){
-                               badSeqNames.erase(it);
-                               
-                               if(namefile != ""){
-                                       int start = 0;
-                                       for(int i=0;i<seqList.length();i++){
-                                               if(seqList[i] == ','){
-                                                       badSeqGroups.insert(seqList.substr(start,i-start));
-                                                       start = i+1;
-                                               }                                       
-                                       }
-                                       badSeqGroups.insert(seqList.substr(start,seqList.length()-start));
-                               }
-                       }
-                       else{
-                               goodNameOut << seqName << '\t' << seqList << endl;
-                       }
-                       m->gobble(inputNames);
-               }
-               inputNames.close();
-               goodNameOut.close();
-       
-               //we were unable to remove some of the bad sequences
-               if (badSeqNames.size() != 0) {
-                       for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
-                               m->mothurOut("Your namefile does not include the sequence " + *it + " please correct."); 
-                               m->mothurOutEndLine();
-                       }
-               }
-
-               if(groupfile != ""){
-                       
-                       ifstream inputGroups;
-                       m->openInputFile(groupfile, inputGroups);
-
-                       string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
-                       outputNames.push_back(goodGroupFile);   outputTypes["group"].push_back(goodGroupFile);
-                       
-                       ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
-                       
-                       while(!inputGroups.eof()){
-                               if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); m->mothurRemove(goodNameFile);  m->mothurRemove(goodGroupFile); return 0; }
-
-                               inputGroups >> seqName >> group;
-                               
-                               it = badSeqGroups.find(seqName);
-                               
-                               if(it != badSeqGroups.end()){
-                                       badSeqGroups.erase(it);
-                               }
-                               else{
-                                       goodGroupOut << seqName << '\t' << group << endl;
-                               }
-                               m->gobble(inputGroups);
-                       }
-                       inputGroups.close();
-                       goodGroupOut.close();
-                       
-                       //we were unable to remove some of the bad sequences
-                       if (badSeqGroups.size() != 0) {
-                               for (it = badSeqGroups.begin(); it != badSeqGroups.end(); it++) {  
-                                       m->mothurOut("Your groupfile does not include the sequence " + *it + " please correct."); 
-                                       m->mothurOutEndLine();
-                               }
-                       }
-               }
-               
-               
-               return 0;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "screenNameGroupFile");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int ScreenSeqsCommand::getSummary(vector<unsigned long long>& positions){
-       try {
-               
-               vector<int> startPosition;
-               vector<int> endPosition;
-               vector<int> seqLength;
-               vector<int> ambigBases;
-               vector<int> longHomoPolymer;
-               
-        vector<unsigned long long> positions;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               positions = m->divideFile(fastafile, processors);
-               for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); }   
-#else
-               if(processors == 1){ lines.push_back(linePair(0, 1000));  }
-        else {
-            int numFastaSeqs = 0;
-            positions = m->setFilePosFasta(fastafile, numFastaSeqs); 
-            if (positions.size() < processors) { processors = positions.size(); }
-            
-            //figure out how many sequences you have to process
-            int numSeqsPerProcessor = numFastaSeqs / processors;
-            for (int i = 0; i < processors; i++) {
-                int startIndex =  i * numSeqsPerProcessor;
-                if(i == (processors - 1)){     numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                lines.push_back(linePair(positions[startIndex], numSeqsPerProcessor));
-            }
-        }
-#endif
-               
-#ifdef USE_MPI
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-               
-               if (pid == 0) { 
-                       driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
-#else
-               int numSeqs = 0;
-               //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(processors == 1){
-                               numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
-                       }else{
-                               numSeqs = createProcessesCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile); 
-                       }
-                               
-                       if (m->control_pressed) {  return 0; }
-               //#else
-               //      numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
-               //      if (m->control_pressed) {  return 0; }
-               //#endif
-#endif
-               sort(startPosition.begin(), startPosition.end());
-               sort(endPosition.begin(), endPosition.end());
-               sort(seqLength.begin(), seqLength.end());
-               sort(ambigBases.begin(), ambigBases.end());
-               sort(longHomoPolymer.begin(), longHomoPolymer.end());
-               
-               //numSeqs is the number of unique seqs, startPosition.size() is the total number of seqs, we want to optimize using all seqs
-               int criteriaPercentile  = int(startPosition.size() * (criteria / (float) 100));
-               
-               for (int i = 0; i < optimize.size(); i++) {
-                       if (optimize[i] == "start") { startPos = startPosition[criteriaPercentile]; m->mothurOut("Optimizing start to " + toString(startPos) + "."); m->mothurOutEndLine(); }
-                       else if (optimize[i] == "end") { int endcriteriaPercentile = int(endPosition.size() * ((100 - criteria) / (float) 100));  endPos = endPosition[endcriteriaPercentile]; m->mothurOut("Optimizing end to " + toString(endPos) + "."); m->mothurOutEndLine();}
-                       else if (optimize[i] == "maxambig") { maxAmbig = ambigBases[criteriaPercentile]; m->mothurOut("Optimizing maxambig to " + toString(maxAmbig) + "."); m->mothurOutEndLine(); }
-                       else if (optimize[i] == "maxhomop") { maxHomoP = longHomoPolymer[criteriaPercentile]; m->mothurOut("Optimizing maxhomop to " + toString(maxHomoP) + "."); m->mothurOutEndLine(); }
-                       else if (optimize[i] == "minlength") { int mincriteriaPercentile = int(seqLength.size() * ((100 - criteria) / (float) 100)); minLength = seqLength[mincriteriaPercentile]; m->mothurOut("Optimizing minlength to " + toString(minLength) + "."); m->mothurOutEndLine(); }
-                       else if (optimize[i] == "maxlength") { maxLength = seqLength[criteriaPercentile]; m->mothurOut("Optimizing maxlength to " + toString(maxLength) + "."); m->mothurOutEndLine(); }
-               }
-
-#ifdef USE_MPI
-               }
-               
-               MPI_Status status; 
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-               MPI_Comm_size(MPI_COMM_WORLD, &processors); 
-                       
-               if (pid == 0) { 
-                       //send file positions to all processes
-                       for(int i = 1; i < processors; i++) { 
-                               MPI_Send(&startPos, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                               MPI_Send(&endPos, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                               MPI_Send(&maxAmbig, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                               MPI_Send(&maxHomoP, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                               MPI_Send(&minLength, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                               MPI_Send(&maxLength, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                       }
-               }else {
-                       MPI_Recv(&startPos, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                       MPI_Recv(&endPos, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                       MPI_Recv(&maxAmbig, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                       MPI_Recv(&maxHomoP, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                       MPI_Recv(&minLength, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                       MPI_Recv(&maxLength, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-               }
-               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#endif
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "getSummary");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int ScreenSeqsCommand::driverCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename, linePair filePos) {   
-       try {
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-                               
-               in.seekg(filePos.start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-                               
-                       if (m->control_pressed) { in.close(); return 1; }
-                                       
-                       Sequence current(in); m->gobble(in);
-       
-                       if (current.getName() != "") {
-                               int num = 1;
-                               if (namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = nameMap.find(current.getName());
-                                       
-                                       if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       startPosition.push_back(current.getStartPos());
-                                       endPosition.push_back(current.getEndPos());
-                                       seqLength.push_back(current.getNumBases());
-                                       ambigBases.push_back(current.getAmbigBases());
-                                       longHomoPolymer.push_back(current.getLongHomoPolymer());
-                               }
-                               
-                               count++;
-                       }
-                       //if((count) % 100 == 0){       m->mothurOut("Optimizing sequence: " + toString(count)); m->mothurOutEndLine();         }
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = in.tellg();
-                               if ((pos == -1) || (pos >= filePos.end)) { break; }
-                       #else
-                               if (in.eof()) { break; }
-                       #endif
-                       
-               }
-               
-               in.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "driverCreateSummary");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int ScreenSeqsCommand::createProcessesCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename) {
-       try {
-        
-        int process = 1;
-               int num = 0;
-               vector<int> processIDS;
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[process]);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = fastafile + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               
-                               out << num << endl;
-                               out << startPosition.size() << endl;
-                               for (int k = 0; k < startPosition.size(); k++)          {               out << startPosition[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < endPosition.size(); k++)            {               out << endPosition[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < seqLength.size(); k++)                      {               out << seqLength[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < ambigBases.size(); k++)                     {               out << ambigBases[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < longHomoPolymer.size(); k++)        {               out << longHomoPolymer[k] << '\t'; }  out << endl;
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //parent reads in and combine Filter info
-               for (int i = 0; i < processIDS.size(); i++) {
-                       string tempFilename = fastafile + toString(processIDS[i]) + ".num.temp";
-                       ifstream in;
-                       m->openInputFile(tempFilename, in);
-                       
-                       int temp, tempNum;
-                       in >> tempNum; m->gobble(in); num += tempNum;
-                       in >> tempNum; m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; startPosition.push_back(temp);              }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; endPosition.push_back(temp);                }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; seqLength.push_back(temp);                  }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; ambigBases.push_back(temp);                 }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; longHomoPolymer.push_back(temp);    }               m->gobble(in);
-                               
-                       in.close();
-                       m->mothurRemove(tempFilename);
-               }
-               
-               
-#else 
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the seqSumData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to vectors.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<sumData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-            
-                       // Allocate memory for thread data.
-                       sumData* tempSum = new sumData(filename, m, lines[i].start, lines[i].end, namefile, nameMap);
-                       pDataArray.push_back(tempSum);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MySumThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-        //do your part
-               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[processors-1]);
-         
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            for (int k = 0; k < pDataArray[i]->startPosition.size(); k++) {    startPosition.push_back(pDataArray[i]->startPosition[k]);       }
-                       for (int k = 0; k < pDataArray[i]->endPosition.size(); k++) {   endPosition.push_back(pDataArray[i]->endPosition[k]);       }
-            for (int k = 0; k < pDataArray[i]->seqLength.size(); k++) {        seqLength.push_back(pDataArray[i]->seqLength[k]);       }
-            for (int k = 0; k < pDataArray[i]->ambigBases.size(); k++) {       ambigBases.push_back(pDataArray[i]->ambigBases[k]);       }
-            for (int k = 0; k < pDataArray[i]->longHomoPolymer.size(); k++) {  longHomoPolymer.push_back(pDataArray[i]->longHomoPolymer[k]);       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-
-#endif         
-        return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "createProcessesCreateSummary");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::screenGroupFile(set<string> badSeqNames){
-       try {
-               ifstream inputGroups;
-               m->openInputFile(groupfile, inputGroups);
-               string seqName, group;
-               set<string>::iterator it;
-               
-               string goodGroupFile = outputDir + m->getRootName(m->getSimpleName(groupfile)) + "good" + m->getExtension(groupfile);
-               outputNames.push_back(goodGroupFile);  outputTypes["group"].push_back(goodGroupFile);
-               ofstream goodGroupOut;  m->openOutputFile(goodGroupFile, goodGroupOut);
-               
-               while(!inputGroups.eof()){
-                       if (m->control_pressed) { goodGroupOut.close(); inputGroups.close(); m->mothurRemove(goodGroupFile); return 0; }
-
-                       inputGroups >> seqName >> group;
-                       it = badSeqNames.find(seqName);
-                       
-                       if(it != badSeqNames.end()){
-                               badSeqNames.erase(it);
-                       }
-                       else{
-                               goodGroupOut << seqName << '\t' << group << endl;
-                       }
-                       m->gobble(inputGroups);
-               }
-               
-               if (m->control_pressed) { goodGroupOut.close();  inputGroups.close(); m->mothurRemove(goodGroupFile);  return 0; }
-
-               //we were unable to remove some of the bad sequences
-               if (badSeqNames.size() != 0) {
-                       for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
-                               m->mothurOut("Your groupfile does not include the sequence " + *it + " please correct."); 
-                               m->mothurOutEndLine();
-                       }
-               }
-               
-               inputGroups.close();
-               goodGroupOut.close();
-               
-               if (m->control_pressed) { m->mothurRemove(goodGroupFile);   }
-               
-               return 0;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "screenGroupFile");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::screenAlignReport(set<string> badSeqNames){
-       try {
-               ifstream inputAlignReport;
-               m->openInputFile(alignreport, inputAlignReport);
-               string seqName, group;
-               set<string>::iterator it;
-               
-               string goodAlignReportFile = outputDir + m->getRootName(m->getSimpleName(alignreport)) + "good" + m->getExtension(alignreport);
-               outputNames.push_back(goodAlignReportFile);  outputTypes["alignreport"].push_back(goodAlignReportFile);
-               ofstream goodAlignReportOut;    m->openOutputFile(goodAlignReportFile, goodAlignReportOut);
-
-               while (!inputAlignReport.eof()) {               //      need to copy header
-                       char c = inputAlignReport.get();
-                       goodAlignReportOut << c;
-                       if (c == 10 || c == 13){        break;  }       
-               }
-
-               while(!inputAlignReport.eof()){
-                       if (m->control_pressed) { goodAlignReportOut.close(); inputAlignReport.close(); m->mothurRemove(goodAlignReportFile); return 0; }
-
-                       inputAlignReport >> seqName;
-                       it = badSeqNames.find(seqName);
-                       string line;            
-                       while (!inputAlignReport.eof()) {               //      need to copy header
-                               char c = inputAlignReport.get();
-                               line += c;
-                               if (c == 10 || c == 13){        break;  }       
-                       }
-                       
-                       if(it != badSeqNames.end()){
-                               badSeqNames.erase(it);
-                       }
-                       else{
-                               goodAlignReportOut << seqName << '\t' << line;
-                       }
-                       m->gobble(inputAlignReport);
-               }
-               
-               if (m->control_pressed) { goodAlignReportOut.close();  inputAlignReport.close(); m->mothurRemove(goodAlignReportFile);  return 0; }
-
-               //we were unable to remove some of the bad sequences
-               if (badSeqNames.size() != 0) {
-                       for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
-                               m->mothurOut("Your alignreport file does not include the sequence " + *it + " please correct."); 
-                               m->mothurOutEndLine();
-                       }
-               }
-
-               inputAlignReport.close();
-               goodAlignReportOut.close();
-                               
-               if (m->control_pressed) {  m->mothurRemove(goodAlignReportFile);  return 0; }
-               
-               return 0;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "screenAlignReport");
-               exit(1);
-       }
-       
-}
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::screenTaxonomy(set<string> badSeqNames){
-       try {
-               ifstream input;
-               m->openInputFile(taxonomy, input);
-               string seqName, tax;
-               set<string>::iterator it;
-               
-               string goodTaxFile = outputDir + m->getRootName(m->getSimpleName(taxonomy)) + "good" + m->getExtension(taxonomy);
-               outputNames.push_back(goodTaxFile);  outputTypes["taxonomy"].push_back(goodTaxFile);
-               ofstream goodTaxOut;    m->openOutputFile(goodTaxFile, goodTaxOut);
-                               
-               while(!input.eof()){
-                       if (m->control_pressed) { goodTaxOut.close(); input.close(); m->mothurRemove(goodTaxFile); return 0; }
-                       
-                       input >> seqName >> tax;
-                       it = badSeqNames.find(seqName);
-                       
-                       if(it != badSeqNames.end()){ badSeqNames.erase(it); }
-                       else{
-                               goodTaxOut << seqName << '\t' << tax << endl;
-                       }
-                       m->gobble(input);
-               }
-               
-               if (m->control_pressed) { goodTaxOut.close(); input.close(); m->mothurRemove(goodTaxFile); return 0; }
-               
-               //we were unable to remove some of the bad sequences
-               if (badSeqNames.size() != 0) {
-                       for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
-                               m->mothurOut("Your taxonomy file does not include the sequence " + *it + " please correct."); 
-                               m->mothurOutEndLine();
-                       }
-               }
-               
-               input.close();
-               goodTaxOut.close();
-               
-               if (m->control_pressed) {  m->mothurRemove(goodTaxFile);  return 0; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "screenTaxonomy");
-               exit(1);
-       }
-       
-}
-//***************************************************************************************************************
-
-int ScreenSeqsCommand::screenQual(set<string> badSeqNames){
-       try {
-               ifstream in;
-               m->openInputFile(qualfile, in);
-               set<string>::iterator it;
-               
-               string goodQualFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + "good" + m->getExtension(qualfile);
-               outputNames.push_back(goodQualFile);  outputTypes["qfile"].push_back(goodQualFile);
-               ofstream goodQual;      m->openOutputFile(goodQualFile, goodQual);
-               
-               while(!in.eof()){       
-                       
-                       if (m->control_pressed) { goodQual.close(); in.close(); m->mothurRemove(goodQualFile); return 0; }
-
-                       string saveName = "";
-                       string name = "";
-                       string scores = "";
-                       
-                       in >> name; 
-                       
-                       if (name.length() != 0) { 
-                               saveName = name.substr(1);
-                               while (!in.eof())       {       
-                                       char c = in.get(); 
-                                       if (c == 10 || c == 13){        break;  }
-                                       else { name += c; }     
-                               } 
-                               m->gobble(in);
-                       }
-                       
-                       while(in){
-                               char letter= in.get();
-                               if(letter == '>'){      in.putback(letter);     break;  }
-                               else{ scores += letter; }
-                       }
-                       
-                       m->gobble(in);
-                       
-                       it = badSeqNames.find(saveName);
-                       
-                       if(it != badSeqNames.end()){
-                               badSeqNames.erase(it);
-                       }else{                          
-                               goodQual << name << endl << scores;
-                       }
-                       
-                       m->gobble(in);
-               }
-               
-               in.close();
-               goodQual.close();
-               
-               //we were unable to remove some of the bad sequences
-               if (badSeqNames.size() != 0) {
-                       for (it = badSeqNames.begin(); it != badSeqNames.end(); it++) {  
-                               m->mothurOut("Your qual file does not include the sequence " + *it + " please correct."); 
-                               m->mothurOutEndLine();
-                       }
-               }
-               
-               if (m->control_pressed) {  m->mothurRemove(goodQualFile);  return 0; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "screenQual");
-               exit(1);
-       }
-       
-}
-//**********************************************************************************************************************
-
-int ScreenSeqsCommand::driver(linePair filePos, string goodFName, string badAccnosFName, string filename, set<string>& badSeqNames){
-       try {
-               ofstream goodFile;
-               m->openOutputFile(goodFName, goodFile);
-               
-               ofstream badAccnosFile;
-               m->openOutputFile(badAccnosFName, badAccnosFile);
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-
-               inFASTA.seekg(filePos.start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-               
-                       if (m->control_pressed) {  return 0; }
-                       
-                       Sequence currSeq(inFASTA); m->gobble(inFASTA);
-                       if (currSeq.getName() != "") {
-                               bool goodSeq = 1;               //      innocent until proven guilty
-                               if(goodSeq == 1 && startPos != -1 && startPos < currSeq.getStartPos())                  {       goodSeq = 0;    }
-                               if(goodSeq == 1 && endPos != -1 && endPos > currSeq.getEndPos())                                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxAmbig != -1 && maxAmbig < currSeq.getAmbigBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxHomoP != -1 && maxHomoP < currSeq.getLongHomoPolymer())   {       goodSeq = 0;    }
-                               if(goodSeq == 1 && minLength != -1 && minLength > currSeq.getNumBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxLength != -1 && maxLength < currSeq.getNumBases())                {       goodSeq = 0;    }
-                               
-                               if(goodSeq == 1){
-                                       currSeq.printSequence(goodFile);        
-                               }
-                               else{
-                                       badAccnosFile << currSeq.getName() << endl;
-                                       badSeqNames.insert(currSeq.getName());
-                               }
-                       count++;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= filePos.end)) { break; }
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 100 == 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               }
-               //report progress
-               if((count) % 100 != 0){ m->mothurOut("Processing sequence: " + toString(count)); m->mothurOutEndLine();         }
-               
-                       
-               goodFile.close();
-               inFASTA.close();
-               badAccnosFile.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "driver");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ScreenSeqsCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& goodFile, MPI_File& badAccnosFile, vector<unsigned long long>& MPIPos, set<string>& badSeqNames){
-       try {
-               string outputString = "";
-               MPI_Status statusGood; 
-               MPI_Status statusBadAccnos; 
-               MPI_Status status; 
-               int pid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-
-               for(int i=0;i<num;i++){
-               
-                       if (m->control_pressed) {  return 0; }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-
-                       char* buf4 = new char[length];
-                       memcpy(buf4, outputString.c_str(), length);
-
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;  delete buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       
-                       Sequence currSeq(iss);                  
-                       
-                       //process seq
-                       if (currSeq.getName() != "") {
-                               bool goodSeq = 1;               //      innocent until proven guilty
-                               if(goodSeq == 1 && startPos != -1 && startPos < currSeq.getStartPos())                  {       goodSeq = 0;    }
-                               if(goodSeq == 1 && endPos != -1 && endPos > currSeq.getEndPos())                                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxAmbig != -1 && maxAmbig < currSeq.getAmbigBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxHomoP != -1 && maxHomoP < currSeq.getLongHomoPolymer())   {       goodSeq = 0;    }
-                               if(goodSeq == 1 && minLength != -1 && minLength > currSeq.getNumBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && maxLength != -1 && maxLength < currSeq.getNumBases())                {       goodSeq = 0;    }
-                               
-                               if(goodSeq == 1){
-                                       outputString =  ">" + currSeq.getName() + "\n" + currSeq.getAligned() + "\n";
-                               
-                                       //print good seq
-                                       length = outputString.length();
-                                       char* buf2 = new char[length];
-                                       memcpy(buf2, outputString.c_str(), length);
-                                       
-                                       MPI_File_write_shared(goodFile, buf2, length, MPI_CHAR, &statusGood);
-                                       delete buf2;
-                               }
-                               else{
-
-                                       badSeqNames.insert(currSeq.getName());
-                                       
-                                       //write to bad accnos file
-                                       outputString = currSeq.getName() + "\n";
-                               
-                                       length = outputString.length();
-                                       char* buf3 = new char[length];
-                                       memcpy(buf3, outputString.c_str(), length);
-                                       
-                                       MPI_File_write_shared(badAccnosFile, buf3, length, MPI_CHAR, &statusBadAccnos);
-                                       delete buf3;
-                               }
-                       }
-                       
-                       //report progress
-                       if((i) % 100 == 0){     m->mothurOut("Processing sequence: " + toString(i)); m->mothurOutEndLine();             }
-               }
-                               
-               return 1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "driverMPI");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-
-int ScreenSeqsCommand::createProcesses(string goodFileName, string badAccnos, string filename, set<string>& badSeqNames) {
-       try {
-        
-        vector<int> processIDS;   
-        int process = 1;
-               int num = 0;
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(lines[process], goodFileName + toString(getpid()) + ".temp", badAccnos + toString(getpid()) + ".temp", filename, badSeqNames);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = filename + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << num << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-        num = driver(lines[0], goodFileName, badAccnos, filename, badSeqNames);
-        
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               for (int i = 0; i < processIDS.size(); i++) {
-                       ifstream in;
-                       string tempFile =  filename + toString(processIDS[i]) + ".num.temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { int tempNum = 0; in >> tempNum; num += tempNum; }
-                       in.close(); m->mothurRemove(tempFile);
-            
-            m->appendFiles((goodFileName + toString(processIDS[i]) + ".temp"), goodFileName);
-            m->mothurRemove((goodFileName + toString(processIDS[i]) + ".temp"));
-                       
-            m->appendFiles((badAccnos + toString(processIDS[i]) + ".temp"), badAccnos);
-            m->mothurRemove((badAccnos + toString(processIDS[i]) + ".temp"));
-               }
-               
-        //read badSeqs in because root process doesnt know what other "bad" seqs the children found
-        ifstream inBad;
-        int ableToOpen = m->openInputFile(badAccnos, inBad, "no error");
-        
-        if (ableToOpen == 0) {
-            badSeqNames.clear();
-            string tempName;
-            while (!inBad.eof()) {
-                inBad >> tempName; m->gobble(inBad);
-                badSeqNames.insert(tempName);
-            }
-            inBad.close();
-        }
-#else
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the sumScreenData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to badSeqNames.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<sumScreenData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-            
-            string extension = "";
-            if (i!=0) {extension += toString(i) + ".temp"; processIDS.push_back(i); }
-            
-                       // Allocate memory for thread data.
-                       sumScreenData* tempSum = new sumScreenData(startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength, filename, m, lines[i].start, lines[i].end,goodFileName+extension, badAccnos+extension);
-                       pDataArray.push_back(tempSum);
-                       
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MySumScreenThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-        //do your part
-        num = driver(lines[processors-1], (goodFileName+toString(processors-1)+".temp"), (badAccnos+toString(processors-1)+".temp"), filename, badSeqNames);
-        processIDS.push_back(processors-1);
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            for (set<string>::iterator it = pDataArray[i]->badSeqNames.begin(); it != pDataArray[i]->badSeqNames.end(); it++) {        badSeqNames.insert(*it);       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-        
-        for (int i = 0; i < processIDS.size(); i++) {
-            m->appendFiles((goodFileName + toString(processIDS[i]) + ".temp"), goodFileName);
-            m->mothurRemove((goodFileName + toString(processIDS[i]) + ".temp"));
-                       
-            m->appendFiles((badAccnos + toString(processIDS[i]) + ".temp"), badAccnos);
-            m->mothurRemove((badAccnos + toString(processIDS[i]) + ".temp"));
-               }
-
-#endif 
-        
-        return num;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ScreenSeqsCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-
diff --git a/screenseqscommand.h b/screenseqscommand.h
deleted file mode 100644 (file)
index 291d8e6..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-#ifndef SCREENSEQSCOMMAND_H
-#define SCREENSEQSCOMMAND_H
-
-/*
- *  screenseqscommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 6/3/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-#include "mothur.h"
-#include "command.hpp"
-#include "sequence.hpp"
-
-class ScreenSeqsCommand : public Command {
-       
-public:
-       ScreenSeqsCommand(string);
-       ScreenSeqsCommand();
-       ~ScreenSeqsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "screen.seqs";                         }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Screen.seqs"; }
-       string getDescription()         { return "enables you to keep sequences that fulfill certain user defined criteria"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<linePair> lines;
-
-       int screenNameGroupFile(set<string>);
-       int screenGroupFile(set<string>);
-       int screenAlignReport(set<string>);
-       int screenQual(set<string>);
-       int screenTaxonomy(set<string>);
-       
-       int driver(linePair, string, string, string, set<string>&);
-       int createProcesses(string, string, string, set<string>&);
-       
-       #ifdef USE_MPI
-       int driverMPI(int, int, MPI_File&, MPI_File&, MPI_File&, vector<unsigned long long>&, set<string>&);
-       #endif
-
-       bool abort;
-       string fastafile, namefile, groupfile, alignreport, outputDir, qualfile, taxonomy;
-       int startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength, processors, criteria;
-       vector<string> outputNames;
-       vector<string> optimize;
-       map<string, int> nameMap;
-       int readNames();
-       
-       int getSummary(vector<unsigned long long>&);
-       int createProcessesCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string);
-       int driverCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string, linePair);        
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct sumData {
-       vector<int> startPosition;
-       vector<int> endPosition;
-       vector<int> seqLength; 
-       vector<int> ambigBases; 
-       vector<int> longHomoPolymer; 
-       string filename, namefile; 
-       unsigned long long start;
-       unsigned long long end;
-       int count;
-       MothurOut* m;
-       map<string, int> nameMap;
-       
-       
-       sumData(){}
-       sumData(string f, MothurOut* mout, unsigned long long st, unsigned long long en, string nf, map<string, int> nam) {
-               filename = f;
-        namefile = nf;
-               m = mout;
-               start = st;
-               end = en;
-               nameMap = nam;
-               count = 0;
-       }
-};
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct sumScreenData {
-    int startPos, endPos, maxAmbig, maxHomoP, minLength, maxLength;
-       unsigned long long start;
-       unsigned long long end;
-       int count;
-       MothurOut* m;
-       string goodFName, badAccnosFName, filename;
-    set<string> badSeqNames;
-       
-       
-       sumScreenData(){}
-       sumScreenData(int s, int e, int a, int h, int minl, int maxl, string f, MothurOut* mout, unsigned long long st, unsigned long long en, string gf, string bf) {
-               startPos = s;
-               endPos = e;
-               minLength = minl;
-        maxLength = maxl;
-               maxAmbig = a;
-               maxHomoP = h;
-               filename = f;
-        goodFName = gf;
-        badAccnosFName = bf;
-               m = mout;
-               start = st;
-               end = en;
-               count = 0;
-       }
-};
-
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MySumThreadFunction(LPVOID lpParam){ 
-       sumData* pDataArray;
-       pDataArray = (sumData*)lpParam;
-       
-       try {
-               ifstream in;
-               pDataArray->m->openInputFile(pDataArray->filename, in);
-        
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       in.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) { in.close();  pDataArray->count = 1; return 1; }
-                       
-                       Sequence current(in); pDataArray->m->gobble(in); 
-                       
-                       if (current.getName() != "") {
-                               
-                               int num = 1;
-                               if (pDataArray->namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = pDataArray->nameMap.find(current.getName());
-                                       
-                                       if (it == pDataArray->nameMap.end()) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       pDataArray->startPosition.push_back(current.getStartPos());
-                                       pDataArray->endPosition.push_back(current.getEndPos());
-                                       pDataArray->seqLength.push_back(current.getNumBases());
-                                       pDataArray->ambigBases.push_back(current.getAmbigBases());
-                                       pDataArray->longHomoPolymer.push_back(current.getLongHomoPolymer());
-                               }
-            }
-               }
-               
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ScreenSeqsCommand", "MySumThreadFunction");
-               exit(1);
-       }
-} 
-
-/**************************************************************************************************/
-
-static DWORD WINAPI MySumScreenThreadFunction(LPVOID lpParam){ 
-       sumScreenData* pDataArray;
-       pDataArray = (sumScreenData*)lpParam;
-       
-       try {
-        
-        ofstream goodFile;
-               pDataArray->m->openOutputFile(pDataArray->goodFName, goodFile);
-               
-               ofstream badAccnosFile;
-               pDataArray->m->openOutputFile(pDataArray->badAccnosFName, badAccnosFile);
-               
-               ifstream in;
-               pDataArray->m->openInputFile(pDataArray->filename, in);
-        
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       in.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) { in.close(); badAccnosFile.close(); goodFile.close(); pDataArray->count = 1; return 1; }
-                       
-                       Sequence currSeq(in); pDataArray->m->gobble(in); 
-                       
-                       if (currSeq.getName() != "") {
-                               bool goodSeq = 1;               //      innocent until proven guilty
-                               if(goodSeq == 1 && pDataArray->startPos != -1 && pDataArray->startPos < currSeq.getStartPos())                  {       goodSeq = 0;    }
-                               if(goodSeq == 1 && pDataArray->endPos != -1 && pDataArray->endPos > currSeq.getEndPos())                                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && pDataArray->maxAmbig != -1 && pDataArray->maxAmbig < currSeq.getAmbigBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && pDataArray->maxHomoP != -1 && pDataArray->maxHomoP < currSeq.getLongHomoPolymer())   {       goodSeq = 0;    }
-                               if(goodSeq == 1 && pDataArray->minLength != -1 && pDataArray->minLength > currSeq.getNumBases())                {       goodSeq = 0;    }
-                               if(goodSeq == 1 && pDataArray->maxLength != -1 && pDataArray->maxLength < currSeq.getNumBases())                {       goodSeq = 0;    }
-                               
-                               if(goodSeq == 1){
-                                       currSeq.printSequence(goodFile);        
-                               }
-                               else{
-                                       badAccnosFile << currSeq.getName() << endl;
-                                       pDataArray->badSeqNames.insert(currSeq.getName());
-                               }
-    
-                       }               
-            //report progress
-                       if((i+1) % 100 == 0){   pDataArray->m->mothurOut("Processing sequence: " + toString(i+1)); pDataArray->m->mothurOutEndLine();           }
-               }
-               //report progress
-               if((pDataArray->count) % 100 != 0){     pDataArray->m->mothurOut("Processing sequence: " + toString(pDataArray->count)); pDataArray->m->mothurOutEndLine();             }
-               
-
-               
-               in.close();
-        goodFile.close();
-        badAccnosFile.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ScreenSeqsCommand", "MySumScreenThreadFunction");
-               exit(1);
-       }
-} 
-
-#endif
-
-/**************************************************************************************************/
-
-
-
-#endif
diff --git a/secondarystructurecommand.cpp b/secondarystructurecommand.cpp
deleted file mode 100644 (file)
index 24142e0..0000000
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- *  secondarystructurecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/18/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "secondarystructurecommand.h"
-#include "sequence.hpp"
-
-//**********************************************************************************************************************
-vector<string> AlignCheckCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pmap("map", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pmap);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string AlignCheckCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The align.check command reads a fasta file and map file.\n";
-               helpString += "It outputs a file containing the secondary structure matches in the .align.check file.\n";
-               helpString += "The align.check command parameters are fasta and map, both are required.\n";
-               helpString += "The align.check command should be in the following format: align.check(fasta=yourFasta, map=yourMap).\n";
-               helpString += "Example align.check(map=silva.ss.map, fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-AlignCheckCommand::AlignCheckCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["aligncheck"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "AlignCheckCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-AlignCheckCommand::AlignCheckCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               haderror = 0;
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["aligncheck"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("map");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["map"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-
-                       //check for required parameters
-                       mapfile = validParameter.validFile(parameters, "map", true);
-                       if (mapfile == "not open") { abort = true; }
-                       else if (mapfile == "not found") {  mapfile = "";  m->mothurOut("You must provide an map file."); m->mothurOutEndLine(); abort = true; }        
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {                            
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = "";  }   
-                       else { m->setNameFile(namefile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-                       
-                       if ((namefile == "") && (fastafile != "")){
-                               vector<string> files; files.push_back(fastafile); 
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "AlignCheckCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int AlignCheckCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //get secondary structure info.
-               readMap();
-               
-               if (namefile != "") { nameMap = m->readNames(namefile); }
-               
-               if (m->control_pressed) { return 0; }
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               ofstream out;
-               string outfile = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "align.check";
-               m->openOutputFile(outfile, out);
-               
-                               
-               out << "name" << '\t' << "pound" << '\t' << "dash" << '\t' << "plus" << '\t' << "equal" << '\t';
-               out << "loop" << '\t' << "tilde" << '\t' << "total"  << '\t' << "numseqs" << endl;
-
-               vector<int> pound;
-               vector<int> dash;
-               vector<int> plus;
-               vector<int> equal;
-               vector<int> loop;
-               vector<int> tilde;
-               vector<int> total;
-               
-               int count = 0;
-               while(!in.eof()){
-                       if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outfile); return 0; }
-                       
-                       Sequence seq(in);  m->gobble(in);
-                       if (seq.getName() != "") {
-                               statData data = getStats(seq.getAligned());
-                               
-                               if (haderror == 1) { m->control_pressed = true; break; }
-                               
-                               int num = 1;
-                               if (namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = nameMap.find(seq.getName());
-                                       
-                                       if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + seq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       pound.push_back(data.pound);
-                                       dash.push_back(data.dash);
-                                       plus.push_back(data.plus);
-                                       equal.push_back(data.equal);
-                                       loop.push_back(data.loop);
-                                       tilde.push_back(data.tilde);
-                                       total.push_back(data.total);
-                               }       
-                               count++;
-                               
-                               out << seq.getName() << '\t' << data.pound << '\t' << data.dash << '\t' << data.plus << '\t' << data.equal << '\t';
-                               out << data.loop << '\t' << data.tilde << '\t' << data.total << '\t' << num << endl;
-                       }
-               }
-
-               in.close();
-               out.close();
-               
-               if (m->control_pressed) {  m->mothurRemove(outfile); return 0; }
-               
-               sort(pound.begin(), pound.end());
-               sort(dash.begin(), dash.end());
-               sort(plus.begin(), plus.end());
-               sort(equal.begin(), equal.end());
-               sort(loop.begin(), loop.end());
-               sort(tilde.begin(), tilde.end());
-               sort(total.begin(), total.end());
-               int size = pound.size();
-               
-               int ptile0_25   = int(size * 0.025);
-               int ptile25             = int(size * 0.250);
-               int ptile50             = int(size * 0.500);
-               int ptile75             = int(size * 0.750);
-               int ptile97_5   = int(size * 0.975);
-               int ptile100    = size - 1;
-               
-               if (m->control_pressed) {  m->mothurRemove(outfile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("\t\tPound\tDash\tPlus\tEqual\tLoop\tTilde\tTotal"); m->mothurOutEndLine();
-               m->mothurOut("Minimum:\t" + toString(pound[0]) + "\t" + toString(dash[0]) + "\t" + toString(plus[0]) + "\t" + toString(equal[0]) + "\t" + toString(loop[0]) + "\t" + toString(tilde[0]) + "\t" + toString(total[0])); m->mothurOutEndLine();
-               m->mothurOut("2.5%-tile:\t" + toString(pound[ptile0_25]) + "\t" + toString(dash[ptile0_25]) + "\t" + toString(plus[ptile0_25]) + "\t" + toString(equal[ptile0_25]) + "\t"+ toString(loop[ptile0_25]) + "\t"+ toString(tilde[ptile0_25]) + "\t"+ toString(total[ptile0_25])); m->mothurOutEndLine();
-               m->mothurOut("25%-tile:\t" + toString(pound[ptile25]) + "\t" + toString(dash[ptile25]) + "\t" + toString(plus[ptile25]) + "\t" + toString(equal[ptile25]) + "\t" + toString(loop[ptile25]) + "\t" + toString(tilde[ptile25]) + "\t" + toString(total[ptile25])); m->mothurOutEndLine();
-               m->mothurOut("Median: \t" + toString(pound[ptile50]) + "\t" + toString(dash[ptile50]) + "\t" + toString(plus[ptile50]) + "\t" + toString(equal[ptile50]) + "\t" + toString(loop[ptile50]) + "\t" + toString(tilde[ptile50]) + "\t" + toString(total[ptile50])); m->mothurOutEndLine();
-               m->mothurOut("75%-tile:\t" + toString(pound[ptile75]) + "\t" + toString(dash[ptile75]) + "\t" + toString(plus[ptile75]) + "\t" + toString(equal[ptile75]) + "\t" + toString(loop[ptile75]) + "\t" + toString(tilde[ptile75]) + "\t" + toString(total[ptile75])); m->mothurOutEndLine();
-               m->mothurOut("97.5%-tile:\t" + toString(pound[ptile97_5]) + "\t" + toString(dash[ptile97_5]) + "\t" + toString(plus[ptile97_5]) + "\t" + toString(equal[ptile97_5]) + "\t" + toString(loop[ptile97_5]) + "\t" + toString(tilde[ptile97_5]) + "\t" + toString(total[ptile97_5])); m->mothurOutEndLine();
-               m->mothurOut("Maximum:\t" + toString(pound[ptile100]) + "\t" + toString(dash[ptile100]) + "\t" + toString(plus[ptile100]) + "\t" + toString(equal[ptile100]) + "\t" + toString(loop[ptile100]) + "\t" + toString(tilde[ptile100]) + "\t" + toString(total[ptile100])); m->mothurOutEndLine();
-               if (namefile == "") {  m->mothurOut("# of Seqs:\t" + toString(count)); m->mothurOutEndLine(); }
-               else { m->mothurOut("# of unique seqs:\t" + toString(count)); m->mothurOutEndLine(); m->mothurOut("total # of seqs:\t" + toString(size)); m->mothurOutEndLine(); }
-               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(outfile); m->mothurOutEndLine();   outputNames.push_back(outfile); outputTypes["aligncheck"].push_back(outfile);
-               m->mothurOutEndLine();
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void AlignCheckCommand::readMap(){
-       try {
-                       
-               structMap.resize(1, 0);
-               ifstream in;
-               
-               m->openInputFile(mapfile, in);
-               
-               while(!in.eof()){
-                       int position;
-                       in >> position;
-                       structMap.push_back(position);  
-                       m->gobble(in);
-               }
-               in.close();
-
-               seqLength = structMap.size();
-               
-               
-               //check you make sure is structMap[10] = 380 then structMap[380] = 10.
-               for(int i=0;i<seqLength;i++){
-                       if(structMap[i] != 0){
-                               if(structMap[structMap[i]] != i){
-                                       m->mothurOut("Your map file contains an error:  line " + toString(i) + " does not match line " + toString(structMap[i]) + "."); m->mothurOutEndLine();
-                               }
-                       }
-               }
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "readMap");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-statData AlignCheckCommand::getStats(string sequence){
-       try {
-       
-               statData data;
-               sequence = "*" + sequence; // need to pad the sequence so we can index it by 1
-               
-               int length = sequence.length();
-               
-               if (length != seqLength) { m->mothurOut("your sequences are " + toString(length) + " long, but your map file only contains " + toString(seqLength) + " entries. please correct."); m->mothurOutEndLine(); haderror = 1; return data;  }
-               
-               for(int i=1;i<length;i++){
-                       if(structMap[i] != 0){
-                               if(sequence[i] == 'A'){
-                                       if(sequence[structMap[i]] == 'T')               {       data.tilde++;   }
-                                       else if(sequence[structMap[i]] == 'A')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == 'G')  {       data.equal++;   }
-                                       else if(sequence[structMap[i]] == 'C')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == '-')  {       data.pound++;   }
-                                       data.total++;
-                               }
-                               else if(sequence[i] == 'T'){
-                                       if(sequence[structMap[i]] == 'T')               {       data.plus++;    }
-                                       else if(sequence[structMap[i]] == 'A')  {       data.tilde++;   }
-                                       else if(sequence[structMap[i]] == 'G')  {       data.dash++;    }
-                                       else if(sequence[structMap[i]] == 'C')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == '-')  {       data.pound++;   }
-                                       data.total++;
-                               }
-                               else if(sequence[i] == 'G'){
-                                       if(sequence[structMap[i]] == 'T')               {       data.dash++;    }
-                                       else if(sequence[structMap[i]] == 'A')  {       data.equal++;   }
-                                       else if(sequence[structMap[i]] == 'G')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == 'C')  {       data.tilde++;   }
-                                       else if(sequence[structMap[i]] == '-')  {       data.pound++;   }
-                                       data.total++;
-                               }
-                               else if(sequence[i] == 'C'){
-                                       if(sequence[structMap[i]] == 'T')               {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == 'A')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == 'G')  {       data.tilde++;   }
-                                       else if(sequence[structMap[i]] == 'C')  {       data.pound++;   }
-                                       else if(sequence[structMap[i]] == '-')  {       data.pound++;   }
-                                       data.total++;
-                               }
-                               else if(sequence[i] == '-'){
-                                       if(sequence[structMap[i]] == 'T')               {       data.pound++;   data.total++;   }
-                                       else if(sequence[structMap[i]] == 'A')  {       data.pound++;   data.total++;   }
-                                       else if(sequence[structMap[i]] == 'G')  {       data.pound++;   data.total++;   }
-                                       else if(sequence[structMap[i]] == 'C')  {       data.pound++;   data.total++;   }
-                                       else if(sequence[structMap[i]] == '-')  {               /*donothing*/                           }
-                               }                       
-                       }
-                       else if(isalnum(sequence[i])){
-                               data.loop++;
-                               data.total++;
-                       }
-               }
-               return data;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "AlignCheckCommand", "getStats");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/secondarystructurecommand.h b/secondarystructurecommand.h
deleted file mode 100644 (file)
index 4e7bdea..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef SECONDARYSTRUCTURECHECKERCOMMAND_H
-#define SECONDARYSTRUCTURECHECKERCOMMAND_H
-
-/*
- *  secondarystructurecommand.h
- *  Mothur
- *
- *  Created by westcott on 9/18/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-
-/**************************************************************************************************/
-
-struct statData {
-       int pound;
-       int tilde;
-       int dash;
-       int plus;
-       int equal;
-       int loop;
-       int total;
-       statData() : pound(0), loop(0), tilde(0), dash(0), plus(0), equal(0), total(0) {};      
-};
-
-/**************************************************************************************************/
-
-
-class AlignCheckCommand : public Command {
-       
-       public:
-       
-               AlignCheckCommand(string);      
-               AlignCheckCommand();
-               ~AlignCheckCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "align.check";                         }
-               string getCommandCategory()             { return "Sequence Processing";         }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Align.check"; }
-               string getDescription()         { return "calculate the number of potentially misaligned bases in a 16S rRNA gene sequence alignment"; }
-
-       
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       private:
-               vector<int> structMap;
-               string mapfile, fastafile, outputDir, namefile;
-               bool abort;
-               int seqLength, haderror;
-               vector<string> outputNames;
-               map<string, int> nameMap;
-               
-               void readMap();
-               statData getStats(string sequence);
-};
-
-/**************************************************************************************************/
-#endif
-
diff --git a/sensspeccommand.cpp b/sensspeccommand.cpp
deleted file mode 100644 (file)
index 82922ed..0000000
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- *  sensspeccommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 7/6/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sensspeccommand.h"
-
-//**********************************************************************************************************************
-vector<string> SensSpecCommand::setParameters(){       
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pphylip);
-               //CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumn", "PhylipColumn", "none",false,false); parameters.push_back(pcolumn);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "-1.00", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);
-               CommandParameter phard("hard", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(phard);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SensSpecCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The sens.spec command....\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SensSpecCommand::SensSpecCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["sensspec"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-SensSpecCommand::SensSpecCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;  
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       string temp;
-                       
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["sensspec"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               //it = parameters.find("name");
-                               //user has given a template file
-                               //if(it != parameters.end()){ 
-                                       //path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       //if (path == "") {     parameters["name"] = inputDir + it->second;             }
-                               //}
-                               
-                       }
-                       //check for required parameters
-                       listFile = validParameter.validFile(parameters, "list", true);
-                       if (listFile == "not found") {          
-                               listFile = m->getListFile(); 
-                               if (listFile != "") { m->mothurOut("Using " + listFile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current list file and the list parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (listFile == "not open") { abort = true; }      
-                       else { m->setListFile(listFile); }
-                       
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not found") { phylipfile = "";  }
-                       else if (phylipfile == "not open") { abort = true; }    
-                       else { distFile = phylipfile; format = "phylip"; m->setPhylipFile(phylipfile);  }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not found") { columnfile = ""; }
-                       else if (columnfile == "not open") { abort = true; }    
-                       else { distFile = columnfile; format = "column";   m->setColumnFile(columnfile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "")) { //is there are current file available for either of these?
-                               //give priority to column, then phylip
-                               columnfile = m->getColumnFile(); 
-                               if (columnfile != "") {  distFile = columnfile; format = "column";  m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       phylipfile = m->getPhylipFile(); 
-                                       if (phylipfile != "") {  distFile = phylipfile; format = "phylip"; m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a phylip or column file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When executing a sens.spec command you must enter ONLY ONE of the following: phylip or column."); m->mothurOutEndLine(); abort = true; }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);
-                       if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(listFile); //if user entered a file with a path then preserve it        
-                       }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       temp = validParameter.validFile(parameters, "hard", false);
-                       if (temp == "not found"){       hard = 0;       }
-                       else if(!m->isTrue(temp))       {       hard = 0;       }
-                       else if(m->isTrue(temp))        {       hard = 1;       }
-                       
-//                     temp = validParameter.validFile(parameters, "name", true);
-//                     if (temp == "not found")        {       nameFile = "";          }
-//                     else if(temp == "not open")     {       abort = true;           }
-//                     else                                            {       nameFile = temp;        }
-//                     cout << "name:\t" << nameFile << endl;
-
-                       temp = validParameter.validFile(parameters, "cutoff", false);           if (temp == "not found") { temp = "-1.00"; }
-                       m->mothurConvert(temp, cutoff);  
-//                     cout << cutoff << endl;
-                       
-                       temp = validParameter.validFile(parameters, "precision", false);        if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, precision);  
-//                     cout << precision << endl;
-                       
-                       string label = validParameter.validFile(parameters, "label", false);                    
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       sensSpecFileName = outputDir + m->getRootName(m->getSimpleName(listFile)) + "sensspec";
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "SensSpecCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int SensSpecCommand::execute(){
-       try{
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               setUpOutput();
-               outputNames.push_back(sensSpecFileName); outputTypes["sensspec"].push_back(sensSpecFileName);
-               if(format == "phylip")          {       processPhylip();        }
-               else if(format == "column")     {       processColumn();        }
-               
-               if (m->control_pressed) { m->mothurRemove(sensSpecFileName); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(sensSpecFileName); m->mothurOutEndLine();  
-               m->mothurOutEndLine();
-               
-               
-               return 0;       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "execute");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int SensSpecCommand::processPhylip(){
-       try{
-               //probably need some checking to confirm that the names in the distance matrix are the same as those in the list file
-               string origCutoff = "";
-               bool getCutoff = 0;
-               if(cutoff == -1.00)     {       getCutoff = 1;                                                                                                                  }
-               else                            {       origCutoff = toString(cutoff);  cutoff += (0.49 / double(precision));   }               
-               
-               map<string, int> seqMap;
-               string seqList;
-               
-               InputData input(listFile, "list");
-               ListVector* list = input.getListVector();
-               string lastLabel = list->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }  delete list;  return 0;  }
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //process
-                               fillSeqMap(seqMap, list);
-                               process(seqMap, list->getLabel(), getCutoff, origCutoff);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list;
-                               list = input.getListVector(lastLabel);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //process
-                               fillSeqMap(seqMap, list);
-                               process(seqMap, list->getLabel(), getCutoff, origCutoff);
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }               
-                       
-                       lastLabel = list->getLabel();                   
-                       
-                       delete list;
-                       list = input.getListVector();
-               }
-               
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       list = input.getListVector(lastLabel);
-                       
-                       //process
-                       fillSeqMap(seqMap, list);
-                       process(seqMap, list->getLabel(), getCutoff, origCutoff);
-                       
-                       delete list;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "processPhylip");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int SensSpecCommand::fillSeqMap(map<string, int>& seqMap, ListVector*& list){
-       try {
-               //for each otu
-               for(int i=0;i<list->getNumBins();i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       string seqList = list->get(i);
-                       int seqListLength = seqList.length();
-                       string seqName = "";
-                       
-                       //parse bin by name, mapping each name to its otu number
-                       for(int j=0;j<seqListLength;j++){
-                               
-                               if(seqList[j] == ','){
-                                       seqMap[seqName] = i;
-                                       seqName = "";
-                               }
-                               else{
-                                       seqName += seqList[j];
-                               }
-                               
-                       }
-                       seqMap[seqName] = i;
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "fillSeqMap");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int SensSpecCommand::fillSeqPairSet(set<string>& seqPairSet, ListVector*& list){
-       try {
-               int numSeqs = 0;
-               
-               //for each otu
-               for(int i=0;i<list->getNumBins();i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       vector<string> seqNameVector;
-                       string bin = list->get(i);
-                       m->splitAtComma(bin, seqNameVector);
-                       
-                       numSeqs += seqNameVector.size();
-                       
-                       for(int j=0;j<seqNameVector.size();j++){
-                               string seqPairString = "";                              
-                               for(int k=0;k<j;k++){
-                                       if(seqNameVector[j] < seqNameVector[k]) {       seqPairString = seqNameVector[j] + '\t' + seqNameVector[k];     }
-                                       else                                                                    {       seqPairString = seqNameVector[k] + '\t' + seqNameVector[j];     }
-                                       seqPairSet.insert(seqPairString);
-                               }
-                       }
-               }
-               
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "fillSeqMap");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int SensSpecCommand::process(map<string, int>& seqMap, string label, bool& getCutoff, string& origCutoff){
-       try {
-                                               
-               int lNumSeqs = seqMap.size();
-               int pNumSeqs = 0;
-               
-               ifstream phylipFile;
-               m->openInputFile(distFile, phylipFile);
-               phylipFile >> pNumSeqs;
-               if(pNumSeqs != lNumSeqs){       m->mothurOut("numSeq mismatch!\n"); m->control_pressed = true; }
-               
-               string seqName;
-               double distance;
-               vector<int> otuIndices(lNumSeqs, -1);
-               
-               truePositives = 0;
-               falsePositives = 0;
-               trueNegatives = 0;
-               falseNegatives = 0;
-               
-               if(getCutoff == 1){
-                       if(label != "unique"){
-                               origCutoff = label;
-                               convert(label, cutoff);
-                               if(hard == 0){  cutoff += (0.49 / double(precision));   }               
-                       }
-                       else{
-                               origCutoff = "unique";
-                               cutoff = 0.0000;
-                       }
-               }
-               
-               m->mothurOut(label); m->mothurOutEndLine();
-               
-               for(int i=0;i<lNumSeqs;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       phylipFile >> seqName;
-                       otuIndices[i] = seqMap[seqName];
-                       
-                       for(int j=0;j<i;j++){
-                               phylipFile >> distance;
-                               
-                               if(distance <= cutoff){
-                                       if(otuIndices[i] == otuIndices[j])      {       truePositives++;        }
-                                       else                                                            {       falseNegatives++;       }
-                               }
-                               else{
-                                       if(otuIndices[i] == otuIndices[j])      {       falsePositives++;       }
-                                       else                                                            {       trueNegatives++;        }
-                               }
-                       }
-               }
-               phylipFile.close();
-               
-               outputStatistics(label, origCutoff);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "process");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int SensSpecCommand::process(set<string>& seqPairSet, string label, bool& getCutoff, string& origCutoff, int numSeqs){
-       try {
-               int numDists = (numSeqs * (numSeqs-1) / 2);
-               
-               ifstream columnFile;
-               m->openInputFile(distFile, columnFile);
-               string seqNameA, seqNameB, seqPairString;
-               double distance;
-               
-               truePositives = 0;
-               falsePositives = 0;
-               trueNegatives = numDists;
-               falseNegatives = 0;
-               
-               if(getCutoff == 1){
-                       if(label != "unique"){
-                               origCutoff = label;
-                               convert(label, cutoff);
-                               if(hard == 0){  cutoff += (0.49 / double(precision));   }               
-                       }
-                       else{
-                               origCutoff = "unique";
-                               cutoff = 0.0000;
-                       }
-               }
-               
-               m->mothurOut(label); m->mothurOutEndLine();
-               
-               while(columnFile){
-                       columnFile >> seqNameA >> seqNameB >> distance;
-                       if(seqNameA < seqNameB) {       seqPairString = seqNameA + '\t' + seqNameB;     }
-                       else                                    {       seqPairString = seqNameB + '\t' + seqNameA;     }
-                       
-                       set<string>::iterator it = seqPairSet.find(seqPairString);
-                       
-                       if(distance <= cutoff){
-                               if(it != seqPairSet.end()){
-                                       truePositives++;
-                                       seqPairSet.erase(it);   
-                               }
-                               else{
-                                       falseNegatives++;
-                               }
-                               trueNegatives--;
-                       }
-                       else if(it != seqPairSet.end()){        
-                               falsePositives++;
-                               trueNegatives--;
-                               seqPairSet.erase(it);   
-                       }
-                       
-                       m->gobble(columnFile);
-               }
-               falsePositives += seqPairSet.size();
-               
-               outputStatistics(label, origCutoff);
-               
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "process");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int SensSpecCommand::processColumn(){
-       try{            
-               string origCutoff = "";
-               bool getCutoff = 0;
-               if(cutoff == -1.00)     {       getCutoff = 1;                                                                                                                  }
-               else                            {       origCutoff = toString(cutoff);  cutoff += (0.49 / double(precision));   }
-               
-               set<string> seqPairSet;
-               int numSeqs = 0;
-               
-               InputData input(listFile, "list");
-               ListVector* list = input.getListVector();
-               string lastLabel = list->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }  delete list;  return 0;  }
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //process
-                               numSeqs = fillSeqPairSet(seqPairSet, list);
-                               process(seqPairSet, list->getLabel(), getCutoff, origCutoff, numSeqs);
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list;
-                               list = input.getListVector(lastLabel);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //process
-                               numSeqs = fillSeqPairSet(seqPairSet, list);
-                               process(seqPairSet, list->getLabel(), getCutoff, origCutoff, numSeqs);
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }               
-                       
-                       lastLabel = list->getLabel();                   
-                       
-                       delete list;
-                       list = input.getListVector();
-               }
-               
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) {     delete list;    }
-                       list = input.getListVector(lastLabel);
-                       
-                       //process
-                       numSeqs = fillSeqPairSet(seqPairSet, list);
-                       delete list;
-                       process(seqPairSet, list->getLabel(), getCutoff, origCutoff, numSeqs);
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "processColumn");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void SensSpecCommand::setUpOutput(){
-       try{            
-               ofstream sensSpecFile;
-               m->openOutputFile(sensSpecFileName, sensSpecFile);
-               
-               sensSpecFile << "label\tcutoff\ttp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n";
-
-               sensSpecFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "setUpOutput");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void SensSpecCommand::outputStatistics(string label, string cutoff){
-       try{            
-               double tp = (double) truePositives;
-               double fp = (double) falsePositives;
-               double tn = (double) trueNegatives;
-               double fn = (double) falseNegatives;
-               
-               double p = tp + fn;
-               double n = fp + tn;
-               double pPrime = tp + fp;
-               double nPrime = tn + fn;
-               
-               double sensitivity = tp / p;    
-               double specificity = tn / n;
-               double positivePredictiveValue = tp / pPrime;
-               double negativePredictiveValue = tn / nPrime;
-               double falseDiscoveryRate = fp / pPrime;
-               
-               double accuracy = (tp + tn) / (p + n);
-               double matthewsCorrCoef = (tp * tn - fp * fn) / sqrt(p * n * pPrime * nPrime);  if(p == 0 || n == 0){   matthewsCorrCoef = 0;   }
-               double f1Score = 2.0 * tp / (p + pPrime);
-               
-               
-               if(p == 0)                      {       sensitivity = 0;        matthewsCorrCoef = 0;   }
-               if(n == 0)                      {       specificity = 0;        matthewsCorrCoef = 0;   }
-               if(p + n == 0)          {       accuracy = 0;                                                           }
-               if(p + pPrime == 0)     {       f1Score = 0;                                                            }
-               if(pPrime == 0)         {       positivePredictiveValue = 0;    falseDiscoveryRate = 0; matthewsCorrCoef = 0;   }
-               if(nPrime == 0)         {       negativePredictiveValue = 0;    matthewsCorrCoef = 0;                                                   }
-               
-               ofstream sensSpecFile;
-               m->openOutputFileAppend(sensSpecFileName, sensSpecFile);
-               
-               sensSpecFile << label << '\t' << cutoff << '\t';
-               sensSpecFile << truePositives << '\t' << trueNegatives << '\t' << falsePositives << '\t' << falseNegatives << '\t';
-               sensSpecFile << setprecision(4);
-               sensSpecFile << sensitivity << '\t' << specificity << '\t' << positivePredictiveValue << '\t' << negativePredictiveValue << '\t';
-               sensSpecFile << falseDiscoveryRate << '\t' << accuracy << '\t' << matthewsCorrCoef << '\t' << f1Score << endl;
-               
-               sensSpecFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SensSpecCommand", "outputStatistics");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-
-
diff --git a/sensspeccommand.h b/sensspeccommand.h
deleted file mode 100644 (file)
index 02e84c0..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef SENSSPECCOMMAND_H
-#define SENSSPECCOMMAND_H
-
-
-/*
- *  sensspeccommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 7/6/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "listvector.hpp"
-#include "inputdata.h"
-
-class SensSpecCommand : public Command {
-       
-public:
-       SensSpecCommand(string);
-       SensSpecCommand();
-       ~SensSpecCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "sens.spec";                           }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "Schloss PD, Westcott SL (2011). Assessing and improving methods used in OTU-based approaches for 16S rRNA gene sequence analysis. Appl Environ Microbiol. \nhttp://www.mothur.org/wiki/Sens.spec"; }
-       string getDescription()         { return "sens.spec"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       int processPhylip();
-       int processColumn();
-       void setUpOutput();
-       void outputStatistics(string, string);
-       
-       string listFile, distFile, nameFile, sensSpecFileName, phylipfile, columnfile;
-       string outputDir;
-       string format;
-       vector<string> outputNames;
-       set<string> labels; //holds labels to be used
-
-       long int truePositives, falsePositives, trueNegatives, falseNegatives;
-       bool abort, allLines;
-       bool hard;
-       //string lineLabel;
-       double cutoff;
-       int precision;
-       
-       int fillSeqMap(map<string, int>&, ListVector*&);
-       int fillSeqPairSet(set<string>&, ListVector*&);
-       int process(map<string, int>&, string, bool&, string&);
-       int process(set<string>&, string, bool&, string&, int);
-
-};
-
-#endif
-
-
-
diff --git a/seqerrorcommand.cpp b/seqerrorcommand.cpp
deleted file mode 100644 (file)
index 0dc15f5..0000000
+++ /dev/null
@@ -1,1394 +0,0 @@
-/*
- *  seqerrorcommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 7/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "seqerrorcommand.h"
-#include "reportfile.h"
-#include "qualityscores.h"
-#include "refchimeratest.h"
-#include "filterseqscommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> SeqErrorCommand::setParameters(){       
-       try {
-               CommandParameter pquery("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pquery);
-               CommandParameter preference("reference", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(preference);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "QualReport",false,false); parameters.push_back(pqfile);
-               CommandParameter preport("report", "InputTypes", "", "", "none", "none", "QualReport",false,false); parameters.push_back(preport);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pignorechimeras("ignorechimeras", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pignorechimeras);
-               CommandParameter pthreshold("threshold", "Number", "", "1.0", "", "", "",false,false); parameters.push_back(pthreshold);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter psave("save", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(psave);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SeqErrorCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The seq.error command reads a query alignment file and a reference alignment file and creates .....\n";
-               helpString += "The fasta parameter...\n";
-               helpString += "The reference parameter...\n";
-               helpString += "The qfile parameter...\n";
-               helpString += "The report parameter...\n";
-               helpString += "The name parameter...\n";
-               helpString += "The ignorechimeras parameter...\n";
-               helpString += "The threshold parameter...\n";
-               helpString += "The processors parameter...\n";
-               helpString += "If the save parameter is set to true the reference sequences will be saved in memory, to clear them later you can use the clear.memory command. Default=f.";
-               helpString += "Example seq.error(...).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/seq.error .\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SeqErrorCommand::SeqErrorCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["error.summary"] = tempOutNames;
-               outputTypes["error.seq"] = tempOutNames;
-               outputTypes["error.quality"] = tempOutNames;
-               outputTypes["error.qual.forward"] = tempOutNames;
-               outputTypes["error.qual.reverse"] = tempOutNames;
-               outputTypes["error.forward"] = tempOutNames;
-               outputTypes["error.reverse"] = tempOutNames;
-               outputTypes["error.count"] = tempOutNames;
-               outputTypes["error.matrix"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "SeqErrorCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-SeqErrorCommand::SeqErrorCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;   
-               rdb = ReferenceDB::getInstance();
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       string temp;
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["error.summary"] = tempOutNames;
-                       outputTypes["error.seq"] = tempOutNames;
-                       outputTypes["error.quality"] = tempOutNames;
-                       outputTypes["error.qual.forward"] = tempOutNames;
-                       outputTypes["error.qual.reverse"] = tempOutNames;
-                       outputTypes["error.forward"] = tempOutNames;
-                       outputTypes["error.reverse"] = tempOutNames;
-                       outputTypes["error.count"] = tempOutNames;
-                       outputTypes["error.matrix"] = tempOutNames;
-
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("reference");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reference"] = inputDir + it->second;                }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a names file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                               it = parameters.find("qfile");
-                               //user has given a quality score file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("report");
-                               //user has given a alignment report file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["report"] = inputDir + it->second;           }
-                               }
-                               
-                       }
-                       //check for required parameters
-                       queryFileName = validParameter.validFile(parameters, "fasta", true);
-                       if (queryFileName == "not found") { 
-                               queryFileName = m->getFastaFile(); 
-                               if (queryFileName != "") { m->mothurOut("Using " + queryFileName + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fasta file and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (queryFileName == "not open") { queryFileName = ""; abort = true; }     
-                       else { m->setFastaFile(queryFileName); }
-                       
-                       referenceFileName = validParameter.validFile(parameters, "reference", true);
-                       if (referenceFileName == "not found") { m->mothurOut("reference is a required parameter for the seq.error command."); m->mothurOutEndLine(); abort = true; }
-                       else if (referenceFileName == "not open") { abort = true; }     
-                       
-                       //check for optional parameters
-                       namesFileName = validParameter.validFile(parameters, "name", true);
-                       if(namesFileName == "not found"){       namesFileName = "";     }
-                       else if (namesFileName == "not open") { namesFileName = ""; abort = true; }     
-                       else { m->setNameFile(namesFileName); }
-                       
-                       qualFileName = validParameter.validFile(parameters, "qfile", true);
-                       if(qualFileName == "not found"){        qualFileName = "";      }
-                       else if (qualFileName == "not open") { qualFileName = ""; abort = true; }       
-                       else { m->setQualFile(qualFileName); }
-                       
-                       reportFileName = validParameter.validFile(parameters, "report", true);
-                       if(reportFileName == "not found"){      reportFileName = "";    }
-                       else if (reportFileName == "not open") { reportFileName = ""; abort = true; }   
-                       
-                       if((reportFileName != "" && qualFileName == "") || (reportFileName == "" && qualFileName != "")){
-                               m->mothurOut("if you use either a qual file or a report file, you have to have both.");
-                               m->mothurOutEndLine();
-                               abort = true; 
-                       }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);
-                       if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(queryFileName); //if user entered a file with a path then preserve it   
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       temp = validParameter.validFile(parameters, "threshold", false);        if (temp == "not found") { temp = "1.00"; }
-                       m->mothurConvert(temp, threshold);  
-                       
-                       temp = validParameter.validFile(parameters, "save", false);                     if (temp == "not found"){       temp = "f";                             }
-                       save = m->isTrue(temp); 
-                       rdb->save = save; 
-                       if (save) { //clear out old references
-                               rdb->clearMemory();     
-                       }
-                       
-                       //this has to go after save so that if the user sets save=t and provides no reference we abort
-                       referenceFileName = validParameter.validFile(parameters, "reference", true);
-                       if (referenceFileName == "not found") { 
-                               //check for saved reference sequences
-                               if (rdb->referenceSeqs.size() != 0) {
-                                       referenceFileName = "saved";
-                               }else {
-                                       m->mothurOut("[ERROR]: You don't have any saved reference sequences and the reference parameter is a required."); 
-                                       m->mothurOutEndLine();
-                                       abort = true; 
-                               }
-                       }else if (referenceFileName == "not open") { abort = true; }    
-                       else {  if (save) {     rdb->setSavedReference(referenceFileName);      }       }
-                       
-                       
-                       temp = validParameter.validFile(parameters, "ignorechimeras", false);   if (temp == "not found") { temp = "T"; }
-                       ignoreChimeras = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-
-                       substitutionMatrix.resize(6);
-                       for(int i=0;i<6;i++){   substitutionMatrix[i].resize(6,0);      }
-                       
-                       if ((namesFileName == "") && (queryFileName != "")){
-                               vector<string> files; files.push_back(queryFileName); 
-                               parser.getNameFile(files);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "SeqErrorCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int SeqErrorCommand::execute(){
-       try{
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int start = time(NULL);
-               maxLength = 2000;
-               totalBases = 0;
-               totalMatches = 0;
-               
-               string errorSummaryFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.summary";
-               outputNames.push_back(errorSummaryFileName); outputTypes["error.summary"].push_back(errorSummaryFileName);
-                       
-               string errorSeqFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq";
-               outputNames.push_back(errorSeqFileName); outputTypes["error.seq"].push_back(errorSeqFileName);
-               
-               string errorChimeraFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.chimera";
-               outputNames.push_back(errorChimeraFileName); outputTypes["error.chimera"].push_back(errorChimeraFileName);
-               
-               getReferences();        //read in reference sequences - make sure there's no ambiguous bases
-
-               if(namesFileName != ""){        weights = getWeights(); }
-               
-               vector<unsigned long long> fastaFilePos;
-               vector<unsigned long long> qFilePos;
-               vector<unsigned long long> reportFilePos;
-               
-               setLines(queryFileName, qualFileName, reportFileName, fastaFilePos, qFilePos, reportFilePos);
-               
-               if (m->control_pressed) { return 0; }
-               
-               for (int i = 0; i < (fastaFilePos.size()-1); i++) {
-                       lines.push_back(linePair(fastaFilePos[i], fastaFilePos[(i+1)]));
-                       if (qualFileName != "") {  qLines.push_back(linePair(qFilePos[i], qFilePos[(i+1)]));  }
-                       if (reportFileName != "") {  rLines.push_back(linePair(reportFilePos[i], reportFilePos[(i+1)]));  }
-               }       
-               if(qualFileName == "")  {       qLines = lines; rLines = lines; } //fills with duds
-               
-               int numSeqs = 0;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               if(processors == 1){
-                       numSeqs = driver(queryFileName, qualFileName, reportFileName, errorSummaryFileName, errorSeqFileName, errorChimeraFileName, lines[0], qLines[0], rLines[0]);
-               }else{
-                       numSeqs = createProcesses(queryFileName, qualFileName, reportFileName, errorSummaryFileName, errorSeqFileName, errorChimeraFileName);
-               }       
-#else
-               numSeqs = driver(queryFileName, qualFileName, reportFileName, errorSummaryFileName, errorSeqFileName, errorChimeraFileName, lines[0], qLines[0], rLines[0]);
-#endif
-               
-               if(qualFileName != "" && reportFileName != ""){         
-                       printErrorQuality(qScoreErrorMap);
-                       printQualityFR(qualForwardMap, qualReverseMap);
-               }
-               
-               printErrorFRFile(errorForward, errorReverse);
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-
-               string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.count";
-               ofstream errorCountFile;
-               m->openOutputFile(errorCountFileName, errorCountFile);
-               outputNames.push_back(errorCountFileName);  outputTypes["error.count"].push_back(errorCountFileName);
-               m->mothurOut("Overall error rate:\t" + toString((double)(totalBases - totalMatches) / (double)totalBases) + "\n");
-               m->mothurOut("Errors\tSequences\n");
-               errorCountFile << "Errors\tSequences\n";                
-               for(int i=0;i<misMatchCounts.size();i++){
-                       m->mothurOut(toString(i) + '\t' + toString(misMatchCounts[i]) + '\n');
-                       errorCountFile << i << '\t' << misMatchCounts[i] << endl;
-               }
-               errorCountFile.close();
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-
-               printSubMatrix();
-                               
-               string megAlignmentFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.ref-query";
-               ofstream megAlignmentFile;
-               m->openOutputFile(megAlignmentFileName, megAlignmentFile);
-               outputNames.push_back(megAlignmentFileName);  outputTypes["error.ref-query"].push_back(megAlignmentFileName);
-               
-               for(int i=0;i<numRefs;i++){
-                       megAlignmentFile << referenceSeqs[i].getInlineSeq() << endl;
-                       megAlignmentFile << megaAlignVector[i] << endl;
-               }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to check " + toString(numSeqs) + " sequences.");
-               m->mothurOutEndLine();
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); }
-               m->mothurOutEndLine();
-               
-               return 0;       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SeqErrorCommand::createProcesses(string filename, string qFileName, string rFileName, string summaryFileName, string errorOutputFileName, string chimeraOutputFileName) {  
-       try {
-               int process = 1;
-               processIDS.clear();
-               map<char, vector<int> >::iterator it;
-               int num = 0;
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               
-                               num = driver(filename, qFileName, rFileName, summaryFileName + toString(getpid()) + ".temp", errorOutputFileName+ toString(getpid()) + ".temp", chimeraOutputFileName + toString(getpid()) + ".temp", lines[process], qLines[process], rLines[process]);
-                               
-                               //pass groupCounts to parent
-                               ofstream out;
-                               string tempFile = filename + toString(getpid()) + ".info.temp";
-                               m->openOutputFile(tempFile, out);
-                               
-                               //output totalBases and totalMatches
-                               out << num << '\t' << totalBases << '\t' << totalMatches << endl << endl;
-                               
-                               //output substitutionMatrix
-                               for(int i = 0; i < substitutionMatrix.size(); i++) {
-                                       for (int j = 0; j < substitutionMatrix[i].size(); j++) {
-                                               out << substitutionMatrix[i][j] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               //output qScoreErrorMap
-                               for (it = qScoreErrorMap.begin(); it != qScoreErrorMap.end(); it++) {
-                                       vector<int> thisScoreErrorMap = it->second;
-                                       out << it->first << '\t';
-                                       for (int i = 0; i < thisScoreErrorMap.size(); i++) {
-                                               out << thisScoreErrorMap[i] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               //output qualForwardMap
-                               for(int i = 0; i < qualForwardMap.size(); i++) {
-                                       for (int j = 0; j < qualForwardMap[i].size(); j++) {
-                                               out << qualForwardMap[i][j] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               //output qualReverseMap
-                               for(int i = 0; i < qualReverseMap.size(); i++) {
-                                       for (int j = 0; j < qualReverseMap[i].size(); j++) {
-                                               out << qualReverseMap[i][j] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               
-                               //output errorForward
-                               for (it = errorForward.begin(); it != errorForward.end(); it++) {
-                                       vector<int> thisErrorForward = it->second;
-                                       out << it->first << '\t';
-                                       for (int i = 0; i < thisErrorForward.size(); i++) {
-                                               out << thisErrorForward[i] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               //output errorReverse
-                               for (it = errorReverse.begin(); it != errorReverse.end(); it++) {
-                                       vector<int> thisErrorReverse = it->second;
-                                       out << it->first << '\t';
-                                       for (int i = 0; i < thisErrorReverse.size(); i++) {
-                                               out << thisErrorReverse[i] << '\t';
-                                       }
-                                       out << endl;
-                               }
-                               out << endl;
-                               
-                               //output misMatchCounts
-                               out << misMatchCounts.size() << endl;
-                               for (int j = 0; j < misMatchCounts.size(); j++) {
-                                       out << misMatchCounts[j] << '\t';
-                               }
-                               out << endl;
-                               
-                               
-                               //output megaAlignVector
-                               for (int j = 0; j < megaAlignVector.size(); j++) {
-                                       out << megaAlignVector[j] << endl;
-                               }
-                               out << endl;
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               num = driver(filename, qFileName, rFileName, summaryFileName, errorOutputFileName, chimeraOutputFileName, lines[0], qLines[0], rLines[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //append files
-               for(int i=0;i<processIDS.size();i++){
-                       
-                       m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine();
-                       
-                       m->appendFiles((summaryFileName + toString(processIDS[i]) + ".temp"), summaryFileName);
-                       m->mothurRemove((summaryFileName + toString(processIDS[i]) + ".temp"));
-                       m->appendFiles((errorOutputFileName + toString(processIDS[i]) + ".temp"), errorOutputFileName);
-                       m->mothurRemove((errorOutputFileName + toString(processIDS[i]) + ".temp"));
-                       m->appendFiles((chimeraOutputFileName + toString(processIDS[i]) + ".temp"), chimeraOutputFileName);
-                       m->mothurRemove((chimeraOutputFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       ifstream in;
-                       string tempFile =  filename + toString(processIDS[i]) + ".info.temp";
-                       m->openInputFile(tempFile, in);
-                       
-                       //input totalBases and totalMatches
-                       int tempBases, tempMatches, tempNumSeqs;
-                       in >> tempNumSeqs >> tempBases >> tempMatches; m->gobble(in);
-                       totalBases += tempBases; totalMatches += tempMatches; num += tempNumSeqs;
-                       
-                       //input substitutionMatrix
-                       int tempNum;
-                       for(int i = 0; i < substitutionMatrix.size(); i++) {
-                               for (int j = 0; j < substitutionMatrix[i].size(); j++) {
-                                       in >> tempNum; substitutionMatrix[i][j] += tempNum;
-                               }
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input qScoreErrorMap
-                       char first;
-                       for (int i = 0; i < qScoreErrorMap.size(); i++) {
-                               in >> first;
-                               vector<int> thisScoreErrorMap = qScoreErrorMap[first];
-                               
-                               for (int i = 0; i < thisScoreErrorMap.size(); i++) {
-                                       in >> tempNum; thisScoreErrorMap[i] += tempNum;
-                               }
-                               qScoreErrorMap[first] = thisScoreErrorMap;
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input qualForwardMap
-                       for(int i = 0; i < qualForwardMap.size(); i++) {
-                               for (int j = 0; j < qualForwardMap[i].size(); j++) {
-                                       in >> tempNum; qualForwardMap[i][j] += tempNum;
-                               }
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input qualReverseMap
-                       for(int i = 0; i < qualReverseMap.size(); i++) {
-                               for (int j = 0; j < qualReverseMap[i].size(); j++) {
-                                       in >> tempNum; qualReverseMap[i][j] += tempNum;
-                               }
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input errorForward
-                       for (int i = 0; i < errorForward.size(); i++) {
-                               in >> first;
-                               vector<int> thisErrorForward = errorForward[first];
-                               
-                               for (int i = 0; i < thisErrorForward.size(); i++) {
-                                       in >> tempNum; thisErrorForward[i] += tempNum;
-                               }
-                               errorForward[first] = thisErrorForward;
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input errorReverse
-                       for (int i = 0; i < errorReverse.size(); i++) {
-                               in >> first;
-                               vector<int> thisErrorReverse = errorReverse[first];
-                               
-                               for (int i = 0; i < thisErrorReverse.size(); i++) {
-                                       in >> tempNum; thisErrorReverse[i] += tempNum;
-                               }
-                               errorReverse[first] = thisErrorReverse;
-                               m->gobble(in);
-                       }
-                       m->gobble(in);
-                       
-                       //input misMatchCounts
-                       int misMatchSize;
-                       in >> misMatchSize; m->gobble(in);
-                       if (misMatchSize > misMatchCounts.size()) {     misMatchCounts.resize(misMatchSize, 0); }
-                       for (int j = 0; j < misMatchCounts.size(); j++) {
-                               in >> tempNum; misMatchCounts[j] += tempNum;
-                       }
-                       m->gobble(in);
-                       
-                       //input megaAlignVector
-                       string thisLine;
-                       for (int j = 0; j < megaAlignVector.size(); j++) {
-                               thisLine = m->getline(in); m->gobble(in); megaAlignVector[j] += thisLine + '\n';
-                       }
-                       m->gobble(in);
-                       
-                       in.close(); m->mothurRemove(tempFile);
-                       
-               }
-#endif         
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "createProcesses");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SeqErrorCommand::driver(string filename, string qFileName, string rFileName, string summaryFileName, string errorOutputFileName, string chimeraOutputFileName, linePair line, linePair qline, linePair rline) {    
-       
-       try {
-               ReportFile report;
-               QualityScores quality;
-               
-               misMatchCounts.resize(11, 0);
-               int maxMismatch = 0;
-               int numSeqs = 0;
-               
-               map<string, int>::iterator it;
-               qScoreErrorMap['m'].assign(41, 0);
-               qScoreErrorMap['s'].assign(41, 0);
-               qScoreErrorMap['i'].assign(41, 0);
-               qScoreErrorMap['a'].assign(41, 0);
-               
-               errorForward['m'].assign(maxLength,0);
-               errorForward['s'].assign(maxLength,0);
-               errorForward['i'].assign(maxLength,0);
-               errorForward['d'].assign(maxLength,0);
-               errorForward['a'].assign(maxLength,0);
-               
-               errorReverse['m'].assign(maxLength,0);
-               errorReverse['s'].assign(maxLength,0);
-               errorReverse['i'].assign(maxLength,0);
-               errorReverse['d'].assign(maxLength,0);
-               errorReverse['a'].assign(maxLength,0);  
-               
-               //open inputfiles and go to beginning place for this processor
-               ifstream queryFile;
-               m->openInputFile(filename, queryFile);
-               queryFile.seekg(line.start);
-               
-               ifstream reportFile;
-               ifstream qualFile;
-               if(qFileName != "" && rFileName != ""){
-                       m->openInputFile(qFileName, qualFile);
-                       qualFile.seekg(qline.start);  
-                       
-                       //gobble headers
-                       if (rline.start == 0) {  report = ReportFile(reportFile, rFileName); } 
-                       else{
-                               m->openInputFile(rFileName, reportFile);
-                               reportFile.seekg(rline.start); 
-                       }
-                       
-                       qualForwardMap.resize(maxLength);
-                       qualReverseMap.resize(maxLength);
-                       for(int i=0;i<maxLength;i++){
-                               qualForwardMap[i].assign(41,0);
-                               qualReverseMap[i].assign(41,0);
-                       }       
-               }
-               
-               ofstream outChimeraReport;
-               m->openOutputFile(chimeraOutputFileName, outChimeraReport);
-               RefChimeraTest chimeraTest(referenceSeqs);
-               if (line.start == 0) { chimeraTest.printHeader(outChimeraReport); }
-               
-               ofstream errorSummaryFile;
-               m->openOutputFile(summaryFileName, errorSummaryFile);
-               if (line.start == 0) { printErrorHeader(errorSummaryFile); }
-               
-               ofstream errorSeqFile;
-               m->openOutputFile(errorOutputFileName, errorSeqFile);
-               
-               megaAlignVector.resize(numRefs, "");
-               
-               int index = 0;
-               bool ignoreSeq = 0;
-               
-               bool moreSeqs = 1;
-               while (moreSeqs) {
-                       
-                       if (m->control_pressed) { queryFile.close(); if(qFileName != "" && rFileName != ""){  reportFile.close(); qualFile.close(); } outChimeraReport.close(); errorSummaryFile.close();errorSeqFile.close(); return 0; }
-                       
-                       Sequence query(queryFile);
-                       
-                       int numParentSeqs = chimeraTest.analyzeQuery(query.getName(), query.getAligned(), outChimeraReport);
-                       int closestRefIndex = chimeraTest.getClosestRefIndex();
-                       
-                       if(numParentSeqs > 1 && ignoreChimeras == 1)    {       ignoreSeq = 1;  }
-                       else                                                                                    {       ignoreSeq = 0;  }
-                       
-                       Compare minCompare;
-            getErrors(query, referenceSeqs[closestRefIndex], minCompare);
-                       
-                       if(namesFileName != ""){
-                               it = weights.find(query.getName());
-                               minCompare.weight = it->second;
-                       }
-                       else{   minCompare.weight = 1;  }
-                       
-                       printErrorData(minCompare, numParentSeqs, errorSummaryFile, errorSeqFile);
-                       
-                       if(!ignoreSeq){
-                               
-                               for(int i=0;i<minCompare.sequence.length();i++){
-                                       char letter = minCompare.sequence[i];
-                                       
-                                       if(letter != 'r'){
-                                               errorForward[letter][i] += minCompare.weight;
-                                               errorReverse[letter][minCompare.total-i-1] += minCompare.weight;                                
-                                       }
-                               }
-                       }
-                       
-                       if(qualFileName != "" && reportFileName != ""){
-                               report = ReportFile(reportFile);
-                               
-                               //                              int origLength = report.getQueryLength();
-                               int startBase = report.getQueryStart();
-                               int endBase = report.getQueryEnd();
-                               
-                               quality = QualityScores(qualFile);
-                               
-                               if(!ignoreSeq){
-//                                     cout << query.getName() << '\t';
-                                       
-                                       quality.updateQScoreErrorMap(qScoreErrorMap, minCompare.sequence, startBase, endBase, minCompare.weight);
-                                       quality.updateForwardMap(qualForwardMap, startBase, endBase, minCompare.weight);
-                                       quality.updateReverseMap(qualReverseMap, startBase, endBase, minCompare.weight);
-
-//                                     cout << endl;
-                               }
-                       }                       
-                       
-                       if(minCompare.errorRate < threshold && !ignoreSeq){
-                               totalBases += (minCompare.total * minCompare.weight);
-                               totalMatches += minCompare.matches * minCompare.weight;
-                               if(minCompare.mismatches > maxMismatch){
-                                       maxMismatch = minCompare.mismatches;
-                                       misMatchCounts.resize(maxMismatch + 1, 0);
-                               }                               
-                               misMatchCounts[minCompare.mismatches] += minCompare.weight;
-                               numSeqs++;
-                               
-                               megaAlignVector[closestRefIndex] += query.getInlineSeq() + '\n';
-                       }
-                       
-                       index++;
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = queryFile.tellg();
-                               if ((pos == -1) || (pos >= line.end)) { break; }
-                       #else
-                               if (queryFile.eof()) { break; }
-                       #endif
-                       
-                       if(index % 100 == 0){   m->mothurOut(toString(index) + '\n');   }
-               }
-               queryFile.close();
-               if(qFileName != "" && rFileName != ""){  reportFile.close(); qualFile.close(); }
-               errorSummaryFile.close();       
-               errorSeqFile.close();
-               
-               //report progress
-               if(index % 100 != 0){   m->mothurOut(toString(index) + '\n');   }
-               
-               return index;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "driver");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-void SeqErrorCommand::getReferences(){
-       try {
-               int numAmbigSeqs = 0;
-               
-               int maxStartPos = 0;
-               int minEndPos = 100000;
-               
-               if (referenceFileName == "saved") {
-                       int start = time(NULL);
-                       m->mothurOutEndLine();  m->mothurOut("Using sequences from " + rdb->getSavedReference() + " that are saved in memory.");        m->mothurOutEndLine();
-                       
-                       for (int i = 0; i < rdb->referenceSeqs.size(); i++) {
-                               int numAmbigs = rdb->referenceSeqs[i].getAmbigBases();
-                               if(numAmbigs > 0){      numAmbigSeqs++; }
-                               
-                               //                      int startPos = rdb->referenceSeqs[i].getStartPos();
-                               //                      if(startPos > maxStartPos)      {       maxStartPos = startPos; }
-                               //
-                               //                      int endPos = rdb->referenceSeqs[i].getEndPos();
-                               //                      if(endPos < minEndPos)          {       minEndPos = endPos;             }                               
-                               
-                               referenceSeqs.push_back(rdb->referenceSeqs[i]);
-                       }
-                       referenceFileName = rdb->getSavedReference();
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " to load " + toString(rdb->referenceSeqs.size()) + " sequences.");m->mothurOutEndLine();  
-               
-               }else {
-                       int start = time(NULL);
-
-                       ifstream referenceFile;
-                       m->openInputFile(referenceFileName, referenceFile);
-                       
-                       while(referenceFile){
-                               Sequence currentSeq(referenceFile);
-                               int numAmbigs = currentSeq.getAmbigBases();
-                               if(numAmbigs > 0){      numAmbigSeqs++; }
-                               
-       //                      int startPos = currentSeq.getStartPos();
-       //                      if(startPos > maxStartPos)      {       maxStartPos = startPos; }
-       //
-       //                      int endPos = currentSeq.getEndPos();
-       //                      if(endPos < minEndPos)          {       minEndPos = endPos;             }
-                               referenceSeqs.push_back(currentSeq);
-                               
-                               if (rdb->save) { rdb->referenceSeqs.push_back(currentSeq); }
-                                       
-                               m->gobble(referenceFile);
-                       }
-                       referenceFile.close();
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " to read " + toString(referenceSeqs.size()) + " sequences.");m->mothurOutEndLine();  
-               }
-               
-               numRefs = referenceSeqs.size();
-               
-               for(int i=0;i<numRefs;i++){
-                       referenceSeqs[i].padToPos(maxStartPos);
-                       referenceSeqs[i].padFromPos(minEndPos);
-               }
-               
-               if(numAmbigSeqs != 0){
-                       m->mothurOut("Warning: " + toString(numAmbigSeqs) + " reference sequences have ambiguous bases, these bases will be ignored\n");
-               }       
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "getReferences");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int SeqErrorCommand::getErrors(Sequence query, Sequence reference, Compare& errors){
-       try {
-               if(query.getAlignLength() != reference.getAlignLength()){
-                       m->mothurOut("Warning: " + toString(query.getName()) + " and " + toString(reference.getName()) + " are different lengths\n");
-               }
-               int alignLength = query.getAlignLength();
-       
-               string q = query.getAligned();
-               string r = reference.getAligned();
-
-               int started = 0;
-               //Compare errors;
-
-               for(int i=0;i<alignLength;i++){
-//                     cout << r[i] << '\t' << q[i] << '\t';
-                       if(q[i] != '.' && r[i] != '.' && (q[i] != '-' || r[i] != '-')){                 //      no missing data and no double gaps
-                               if(r[i] != 'N'){
-                                       started = 1;
-                                       
-                                       if(q[i] == 'A'){
-                                               if(r[i] == 'A'){        errors.AA++;    errors.matches++;       errors.sequence += 'm'; }
-                                               if(r[i] == 'T'){        errors.AT++;    errors.sequence += 's'; }
-                                               if(r[i] == 'G'){        errors.AG++;    errors.sequence += 's'; }
-                                               if(r[i] == 'C'){        errors.AC++;    errors.sequence += 's'; }
-                                               if(r[i] == '-'){        errors.Ai++;    errors.sequence += 'i'; }
-                                       }
-                                       else if(q[i] == 'T'){
-                                               if(r[i] == 'A'){        errors.TA++;    errors.sequence += 's'; }
-                                               if(r[i] == 'T'){        errors.TT++;    errors.matches++;       errors.sequence += 'm'; }
-                                               if(r[i] == 'G'){        errors.TG++;    errors.sequence += 's'; }
-                                               if(r[i] == 'C'){        errors.TC++;    errors.sequence += 's'; }
-                                               if(r[i] == '-'){        errors.Ti++;    errors.sequence += 'i'; }
-                                       }
-                                       else if(q[i] == 'G'){
-                                               if(r[i] == 'A'){        errors.GA++;    errors.sequence += 's'; }
-                                               if(r[i] == 'T'){        errors.GT++;    errors.sequence += 's'; }
-                                               if(r[i] == 'G'){        errors.GG++;    errors.matches++;       errors.sequence += 'm'; }
-                                               if(r[i] == 'C'){        errors.GC++;    errors.sequence += 's'; }
-                                               if(r[i] == '-'){        errors.Gi++;    errors.sequence += 'i'; }
-                                       }
-                                       else if(q[i] == 'C'){
-                                               if(r[i] == 'A'){        errors.CA++;    errors.sequence += 's'; }
-                                               if(r[i] == 'T'){        errors.CT++;    errors.sequence += 's'; }
-                                               if(r[i] == 'G'){        errors.CG++;    errors.sequence += 's'; }
-                                               if(r[i] == 'C'){        errors.CC++;    errors.matches++;       errors.sequence += 'm'; }
-                                               if(r[i] == '-'){        errors.Ci++;    errors.sequence += 'i'; }
-                                       }
-                                       else if(q[i] == 'N'){
-                                               if(r[i] == 'A'){        errors.NA++;    errors.sequence += 'a'; }
-                                               if(r[i] == 'T'){        errors.NT++;    errors.sequence += 'a'; }
-                                               if(r[i] == 'G'){        errors.NG++;    errors.sequence += 'a'; }
-                                               if(r[i] == 'C'){        errors.NC++;    errors.sequence += 'a'; }
-                                               if(r[i] == '-'){        errors.Ni++;    errors.sequence += 'a'; }
-                                       }
-                                       else if(q[i] == '-' && r[i] != '-'){
-                                               if(r[i] == 'A'){        errors.dA++;    errors.sequence += 'd'; }
-                                               if(r[i] == 'T'){        errors.dT++;    errors.sequence += 'd'; }
-                                               if(r[i] == 'G'){        errors.dG++;    errors.sequence += 'd'; }
-                                               if(r[i] == 'C'){        errors.dC++;    errors.sequence += 'd'; }
-                                       }
-                                       errors.total++; 
-                               }
-                               else{
-                                       
-                                       if(q[i] == '-'){
-                                               errors.sequence += 'd'; errors.total++;
-                                       }                                               
-                                       else{
-                                               errors.sequence += 'r';
-                                       }
-                               }
-                       }
-                               
-                       else if(q[i] == '.' && r[i] != '.'){            //      reference extends beyond query
-                               if(started == 1){       break;  }
-                       }
-                       else if(q[i] != '.' && r[i] == '.'){            //      query extends beyond reference
-                               if(started == 1){       break;  }
-                       }
-                       else if(q[i] == '.' && r[i] == '.'){            //      both are missing data
-                               if(started == 1){       break;  }                       
-                       }
-//                     cout << errors.sequence[errors.sequence.length()-1] << endl;
-               }
-//             cout << errors.sequence << endl;
-               errors.mismatches = errors.total-errors.matches;
-               errors.errorRate = (double)(errors.total-errors.matches) / (double)errors.total;
-               errors.queryName = query.getName();
-               errors.refName = reference.getName();
-               
-               //return errors;
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "getErrors");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-map<string, int> SeqErrorCommand::getWeights(){
-       ifstream nameFile;
-       m->openInputFile(namesFileName, nameFile);
-       
-       string seqName;
-       string redundantSeqs;
-       map<string, int> nameCountMap;
-       
-       while(nameFile){
-               nameFile >> seqName >> redundantSeqs;
-               nameCountMap[seqName] = m->getNumNames(redundantSeqs); 
-               m->gobble(nameFile);
-       }
-       return nameCountMap;
-}
-
-
-//***************************************************************************************************************
-
-void SeqErrorCommand::printErrorHeader(ofstream& errorSummaryFile){
-       try {
-               errorSummaryFile << "query\treference\tweight\t";
-               errorSummaryFile << "AA\tAT\tAG\tAC\tTA\tTT\tTG\tTC\tGA\tGT\tGG\tGC\tCA\tCT\tCG\tCC\tNA\tNT\tNG\tNC\tAi\tTi\tGi\tCi\tNi\tdA\tdT\tdG\tdC\t";
-               errorSummaryFile << "insertions\tdeletions\tsubstitutions\tambig\tmatches\tmismatches\ttotal\terror\tnumparents\n";
-               
-               errorSummaryFile << setprecision(6);
-               errorSummaryFile.setf(ios::fixed);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printErrorHeader");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void SeqErrorCommand::printErrorData(Compare error, int numParentSeqs, ofstream& errorSummaryFile, ofstream& errorSeqFile){
-       try {
-
-               errorSummaryFile << error.queryName << '\t' << error.refName << '\t' << error.weight << '\t';
-               errorSummaryFile << error.AA << '\t' << error.AT << '\t' << error.AG << '\t' << error.AC << '\t';
-               errorSummaryFile << error.TA << '\t' << error.TT << '\t' << error.TG << '\t' << error.TC << '\t';
-               errorSummaryFile << error.GA << '\t' << error.GT << '\t' << error.GG << '\t' << error.GC << '\t';
-               errorSummaryFile << error.CA << '\t' << error.CT << '\t' << error.CG << '\t' << error.CC << '\t';
-               errorSummaryFile << error.NA << '\t' << error.NT << '\t' << error.NG << '\t' << error.NC << '\t';
-               errorSummaryFile << error.Ai << '\t' << error.Ti << '\t' << error.Gi << '\t' << error.Ci << '\t' << error.Ni << '\t';
-               errorSummaryFile << error.dA << '\t' << error.dT << '\t' << error.dG << '\t' << error.dC << '\t';
-               
-               errorSummaryFile << error.Ai + error.Ti + error.Gi + error.Ci << '\t';                  //insertions
-               errorSummaryFile << error.dA + error.dT + error.dG + error.dC << '\t';                  //deletions
-               errorSummaryFile << error.mismatches - (error.Ai + error.Ti + error.Gi + error.Ci) - (error.dA + error.dT + error.dG + error.dC) - (error.NA + error.NT + error.NG + error.NC + error.Ni) << '\t';      //substitutions
-               errorSummaryFile << error.NA + error.NT + error.NG + error.NC + error.Ni << '\t';       //ambiguities
-               errorSummaryFile << error.matches << '\t' << error.mismatches << '\t' << error.total << '\t' << error.errorRate << '\t' << numParentSeqs << endl;
-
-               errorSeqFile << '>' << error.queryName << "\tref:" << error.refName << '\n' << error.sequence << endl;
-               
-               int a=0;                int t=1;                int g=2;                int c=3;
-               int gap=4;              int n=5;
-
-               if(numParentSeqs == 1 || ignoreChimeras == 0){
-                       substitutionMatrix[a][a] += error.weight * error.AA;
-                       substitutionMatrix[a][t] += error.weight * error.TA;
-                       substitutionMatrix[a][g] += error.weight * error.GA;
-                       substitutionMatrix[a][c] += error.weight * error.CA;
-                       substitutionMatrix[a][gap] += error.weight * error.dA;
-                       substitutionMatrix[a][n] += error.weight * error.NA;
-                       
-                       substitutionMatrix[t][a] += error.weight * error.AT;
-                       substitutionMatrix[t][t] += error.weight * error.TT;
-                       substitutionMatrix[t][g] += error.weight * error.GT;
-                       substitutionMatrix[t][c] += error.weight * error.CT;
-                       substitutionMatrix[t][gap] += error.weight * error.dT;
-                       substitutionMatrix[t][n] += error.weight * error.NT;
-
-                       substitutionMatrix[g][a] += error.weight * error.AG;
-                       substitutionMatrix[g][t] += error.weight * error.TG;
-                       substitutionMatrix[g][g] += error.weight * error.GG;
-                       substitutionMatrix[g][c] += error.weight * error.CG;
-                       substitutionMatrix[g][gap] += error.weight * error.dG;
-                       substitutionMatrix[g][n] += error.weight * error.NG;
-
-                       substitutionMatrix[c][a] += error.weight * error.AC;
-                       substitutionMatrix[c][t] += error.weight * error.TC;
-                       substitutionMatrix[c][g] += error.weight * error.GC;
-                       substitutionMatrix[c][c] += error.weight * error.CC;
-                       substitutionMatrix[c][gap] += error.weight * error.dC;
-                       substitutionMatrix[c][n] += error.weight * error.NC;
-
-                       substitutionMatrix[gap][a] += error.weight * error.Ai;
-                       substitutionMatrix[gap][t] += error.weight * error.Ti;
-                       substitutionMatrix[gap][g] += error.weight * error.Gi;
-                       substitutionMatrix[gap][c] += error.weight * error.Ci;
-                       substitutionMatrix[gap][n] += error.weight * error.Ni;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printErrorData");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void SeqErrorCommand::printSubMatrix(){
-       try {
-               string subMatrixFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.matrix";
-               ofstream subMatrixFile;
-               m->openOutputFile(subMatrixFileName, subMatrixFile);
-               outputNames.push_back(subMatrixFileName);  outputTypes["error.matrix"].push_back(subMatrixFileName);
-               vector<string> bases(6);
-               bases[0] = "A";
-               bases[1] = "T";
-               bases[2] = "G";
-               bases[3] = "C";
-               bases[4] = "Gap";
-               bases[5] = "N";
-               vector<int> refSums(5,1);
-
-               for(int i=0;i<5;i++){
-                       subMatrixFile << "\tr" << bases[i];
-                       
-                       for(int j=0;j<6;j++){
-                               refSums[i] += substitutionMatrix[i][j];                         
-                       }
-               }
-               subMatrixFile << endl;
-               
-               for(int i=0;i<6;i++){
-                       subMatrixFile << 'q' << bases[i];
-                       for(int j=0;j<5;j++){
-                               subMatrixFile << '\t' << substitutionMatrix[j][i];                              
-                       }
-                       subMatrixFile << endl;
-               }
-
-               subMatrixFile << "total";
-               for(int i=0;i<5;i++){
-                       subMatrixFile << '\t' << refSums[i];
-               }
-               subMatrixFile << endl;
-               subMatrixFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printSubMatrix");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-void SeqErrorCommand::printErrorFRFile(map<char, vector<int> > errorForward, map<char, vector<int> > errorReverse){
-       try{
-               string errorForwardFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq.forward";
-               ofstream errorForwardFile;
-               m->openOutputFile(errorForwardFileName, errorForwardFile);
-               outputNames.push_back(errorForwardFileName);  outputTypes["error.forward"].push_back(errorForwardFileName);
-
-               errorForwardFile << "position\ttotalseqs\tmatch\tsubstitution\tinsertion\tdeletion\tambiguous" << endl;
-               for(int i=0;i<maxLength;i++){
-                       float match = (float)errorForward['m'][i];
-                       float subst = (float)errorForward['s'][i];
-                       float insert = (float)errorForward['i'][i];
-                       float del = (float)errorForward['d'][i];
-                       float amb = (float)errorForward['a'][i];
-                       float total = match + subst + insert + del + amb;
-                       if(total == 0){ break;  }
-                       errorForwardFile << i+1 << '\t' << total << '\t' << match/total  << '\t' << subst/total  << '\t' << insert/total  << '\t' << del/total  << '\t' << amb/total << endl;
-               }
-               errorForwardFile.close();
-
-               string errorReverseFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.seq.reverse";
-               ofstream errorReverseFile;
-               m->openOutputFile(errorReverseFileName, errorReverseFile);
-               outputNames.push_back(errorReverseFileName);  outputTypes["error.reverse"].push_back(errorReverseFileName);
-
-               errorReverseFile << "position\ttotalseqs\tmatch\tsubstitution\tinsertion\tdeletion\tambiguous" << endl;
-               for(int i=0;i<maxLength;i++){
-                       float match = (float)errorReverse['m'][i];
-                       float subst = (float)errorReverse['s'][i];
-                       float insert = (float)errorReverse['i'][i];
-                       float del = (float)errorReverse['d'][i];
-                       float amb = (float)errorReverse['a'][i];
-                       float total = match + subst + insert + del + amb;
-                       if(total == 0){ break;  }
-                       errorReverseFile << i+1 << '\t' << total << '\t' << match/total  << '\t' << subst/total  << '\t' << insert/total  << '\t' << del/total  << '\t' << amb/total << endl;
-               }
-               errorReverseFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printErrorFRFile");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void SeqErrorCommand::printErrorQuality(map<char, vector<int> > qScoreErrorMap){
-       try{
-
-               string errorQualityFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.quality";
-               ofstream errorQualityFile;
-               m->openOutputFile(errorQualityFileName, errorQualityFile);
-               outputNames.push_back(errorQualityFileName);  outputTypes["error.quality"].push_back(errorQualityFileName);
-
-               errorQualityFile << "qscore\tmatches\tsubstitutions\tinsertions\tambiguous" << endl;
-               for(int i=0;i<41;i++){
-                       errorQualityFile << i << '\t' << qScoreErrorMap['m'][i] << '\t' << qScoreErrorMap['s'][i] << '\t' << qScoreErrorMap['i'][i] << '\t'<< qScoreErrorMap['a'][i] << endl;
-               }
-               errorQualityFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printErrorFRFile");
-               exit(1);
-       }
-}
-
-
-//***************************************************************************************************************
-
-void SeqErrorCommand::printQualityFR(vector<vector<int> > qualForwardMap, vector<vector<int> > qualReverseMap){
-
-       try{
-               int numRows = 0;
-               int numColumns = qualForwardMap[0].size();
-
-               for(int i=0;i<qualForwardMap.size();i++){
-                       for(int j=0;j<numColumns;j++){
-                               if(qualForwardMap[i][j] != 0){
-                                       if(numRows < i)         {       numRows = i+20;         }
-                               }
-                       }
-               }
-
-               string qualityForwardFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.qual.forward";
-               ofstream qualityForwardFile;
-               m->openOutputFile(qualityForwardFileName, qualityForwardFile);
-               outputNames.push_back(qualityForwardFileName);  outputTypes["error.qual.forward"].push_back(qualityForwardFileName);
-
-               for(int i=0;i<numColumns;i++){  qualityForwardFile << '\t' << i;        }       qualityForwardFile << endl;
-
-               for(int i=0;i<numRows;i++){
-                       qualityForwardFile << i+1;
-                       for(int j=0;j<numColumns;j++){
-                               qualityForwardFile << '\t' << qualForwardMap[i][j];
-                       }
-
-                       qualityForwardFile << endl;
-               }
-               qualityForwardFile.close();
-
-               
-               string qualityReverseFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.qual.reverse";
-               ofstream qualityReverseFile;
-               m->openOutputFile(qualityReverseFileName, qualityReverseFile);
-               outputNames.push_back(qualityReverseFileName);  outputTypes["error.qual.reverse"].push_back(qualityReverseFileName);
-               
-               for(int i=0;i<numColumns;i++){  qualityReverseFile << '\t' << i;        }       qualityReverseFile << endl;
-               for(int i=0;i<numRows;i++){
-                       
-                       qualityReverseFile << i+1;
-                       for(int j=0;j<numColumns;j++){
-                               qualityReverseFile << '\t' << qualReverseMap[i][j];
-                       }
-                       qualityReverseFile << endl;
-               }
-               qualityReverseFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "printErrorFRFile");
-               exit(1);
-       }
-       
-}
-/**************************************************************************************************/
-
-int SeqErrorCommand::setLines(string filename, string qfilename, string rfilename, vector<unsigned long long>& fastaFilePos, vector<unsigned long long>& qfileFilePos, vector<unsigned long long>& rfileFilePos) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               //set file positions for fasta file
-               fastaFilePos = m->divideFile(filename, processors);
-               
-               if (qfilename == "") { return processors; }
-               
-               //get name of first sequence in each chunk
-               map<string, int> firstSeqNames;
-               for (int i = 0; i < (fastaFilePos.size()-1); i++) {
-                       ifstream in;
-                       m->openInputFile(filename, in);
-                       in.seekg(fastaFilePos[i]);
-                       
-                       Sequence temp(in); 
-                       firstSeqNames[temp.getName()] = i;
-                       
-                       in.close();
-               }
-               
-               //make copy to use below
-               map<string, int> firstSeqNamesReport = firstSeqNames;
-               
-               //seach for filePos of each first name in the qfile and save in qfileFilePos
-               ifstream inQual;
-               m->openInputFile(qfilename, inQual);
-               
-               string input;
-               while(!inQual.eof()){   
-                       input = m->getline(inQual);
-                       
-                       if (input.length() != 0) {
-                               if(input[0] == '>'){ //this is a sequence name line
-                                       istringstream nameStream(input);
-                                       
-                                       string sname = "";  nameStream >> sname;
-                                       sname = sname.substr(1);
-                                       
-                                       map<string, int>::iterator it = firstSeqNames.find(sname);
-                                       
-                                       if(it != firstSeqNames.end()) { //this is the start of a new chunk
-                                               unsigned long long pos = inQual.tellg(); 
-                                               qfileFilePos.push_back(pos - input.length() - 1);       
-                                               firstSeqNames.erase(it);
-                                       }
-                               }
-                       }
-                       
-                       if (firstSeqNames.size() == 0) { break; }
-               }
-               inQual.close();
-               
-               if (firstSeqNames.size() != 0) { 
-                       for (map<string, int>::iterator it = firstSeqNames.begin(); it != firstSeqNames.end(); it++) {
-                               m->mothurOut(it->first + " is in your fasta file and not in your quality file, aborting."); m->mothurOutEndLine();
-                       }
-                       m->control_pressed = true;
-                       return processors;
-               }
-               
-               //get last file position of qfile
-               FILE * pFile;
-               unsigned long long size;
-               
-               //get num bytes in file
-               pFile = fopen (qfilename.c_str(),"rb");
-               if (pFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (pFile, 0, SEEK_END);
-                       size=ftell (pFile);
-                       fclose (pFile);
-               }
-               
-               qfileFilePos.push_back(size);
-               
-               //seach for filePos of each first name in the rfile and save in rfileFilePos
-               string junk;
-               ifstream inR;
-               m->openInputFile(rfilename, inR);
-               
-               //read column headers
-               for (int i = 0; i < 16; i++) {  
-                       if (!inR.eof()) {       inR >> junk;    }
-                       else                    {       break;                  }
-               }
-               
-               while(!inR.eof()){
-                       
-                       if (m->control_pressed) { inR.close();  return processors; }
-                       
-                       input = m->getline(inR);        
-                       
-                       if (input.length() != 0) {
-                               
-                               istringstream nameStream(input);
-                               string sname = "";  nameStream >> sname;
-                               
-                               map<string, int>::iterator it = firstSeqNamesReport.find(sname);
-                       
-                               if(it != firstSeqNamesReport.end()) { //this is the start of a new chunk
-                                       unsigned long long pos = inR.tellg(); 
-                                       rfileFilePos.push_back(pos - input.length() - 1);       
-                                       firstSeqNamesReport.erase(it);
-                               }
-                       }
-                       
-                       if (firstSeqNamesReport.size() == 0) { break; }
-                       m->gobble(inR);
-               }
-               inR.close();
-               
-               if (firstSeqNamesReport.size() != 0) { 
-                       for (map<string, int>::iterator it = firstSeqNamesReport.begin(); it != firstSeqNamesReport.end(); it++) {
-                               m->mothurOut(it->first + " is in your fasta file and not in your report file, aborting."); m->mothurOutEndLine();
-                       }
-                       m->control_pressed = true;
-                       return processors;
-               }
-               
-               //get last file position of qfile
-               FILE * rFile;
-               unsigned long long sizeR;
-               
-               //get num bytes in file
-               rFile = fopen (rfilename.c_str(),"rb");
-               if (rFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (rFile, 0, SEEK_END);
-                       sizeR=ftell (rFile);
-                       fclose (rFile);
-               }
-               
-               rfileFilePos.push_back(sizeR);
-               
-               return processors;
-               
-#else
-               
-               fastaFilePos.push_back(0); qfileFilePos.push_back(0);
-               //get last file position of fastafile
-               FILE * pFile;
-               unsigned long long size;
-               
-               //get num bytes in file
-               pFile = fopen (filename.c_str(),"rb");
-               if (pFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (pFile, 0, SEEK_END);
-                       size=ftell (pFile);
-                       fclose (pFile);
-               }
-               fastaFilePos.push_back(size);
-               
-               //get last file position of fastafile
-               FILE * qFile;
-               
-               //get num bytes in file
-               qFile = fopen (qfilename.c_str(),"rb");
-               if (qFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (qFile, 0, SEEK_END);
-                       size=ftell (qFile);
-                       fclose (qFile);
-               }
-               qfileFilePos.push_back(size);
-               
-               return 1;
-               
-#endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqErrorCommand", "setLines");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
diff --git a/seqerrorcommand.h b/seqerrorcommand.h
deleted file mode 100644 (file)
index e7c97e1..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef SEQERRORCOMMAND
-#define SEQERRORCOMMAND
-
-/*
- *  seqerrorcommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 7/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "sequence.hpp"
-#include "referencedb.h"
-
-
-class SeqErrorCommand : public Command {
-public:
-       SeqErrorCommand(string);
-       SeqErrorCommand();
-       ~SeqErrorCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "seq.error";                           }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Seq.error"; }
-       string getDescription()         { return "seq.error"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort;
-       ReferenceDB* rdb;
-       
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-        ~linePair(){}
-       };
-       
-    struct Compare {
-        int AA, AT, AG, AC,    TA, TT, TG, TC, GA, GT, GG, GC, CA, CT, CG, CC, NA, NT, NG, NC, Ai, Ti, Gi, Ci, Ni, dA, dT, dG, dC;
-        string refName, queryName, sequence;
-        double errorRate;
-        int weight, matches, mismatches, total;
-        
-        Compare(){
-            AA=0; AT=0; AG=0; AC=0;
-            TA=0; TT=0; TG=0; TC=0;
-            GA=0; GT=0; GG=0; GC=0;
-            CA=0; CT=0; CG=0; CC=0;
-            NA=0; NT=0; NG=0; NC=0;
-            Ai=0; Ti=0; Gi=0; Ci=0; Ni=0;
-            dA=0; dT=0; dG=0; dC=0;
-            refName = "";
-            queryName = "";
-            weight = 1;
-            matches = 0;
-            mismatches = 0;
-            total = 0;
-            errorRate = 1.0000;
-            sequence = "";
-        }
-        ~Compare(){};
-    };
-
-       vector<int> processIDS;   //processid
-       vector<linePair> lines;
-       vector<linePair> qLines;
-       vector<linePair> rLines;
-
-       void getReferences();
-       map<string,int> getWeights();
-       int getErrors(Sequence, Sequence, Compare&);
-       void printErrorHeader(ofstream&);
-       void printErrorData(Compare, int, ofstream&, ofstream&);
-       void printSubMatrix();
-       void printErrorFRFile(map<char, vector<int> >, map<char, vector<int> >);
-       void printErrorQuality(map<char, vector<int> >);
-       void printQualityFR(vector<vector<int> >, vector<vector<int> >);
-       
-       int setLines(string, string, string, vector<unsigned long long>&, vector<unsigned long long>&, vector<unsigned long long>&);
-       int driver(string, string, string, string, string, string, linePair, linePair, linePair);
-       int createProcesses(string, string, string, string, string, string);
-
-       string queryFileName, referenceFileName, qualFileName, reportFileName, namesFileName, outputDir;
-       double threshold;
-       bool ignoreChimeras, save;
-       int numRefs, processors;
-       int maxLength, totalBases, totalMatches;
-       //ofstream errorSummaryFile, errorSeqFile;
-       vector<string> outputNames;
-       
-       vector<Sequence> referenceSeqs;
-       vector<vector<int> > substitutionMatrix;
-       vector<vector<int> > qualForwardMap;
-       vector<vector<int> > qualReverseMap;
-       vector<int> misMatchCounts;
-       map<char, vector<int> > qScoreErrorMap;
-       map<char, vector<int> > errorForward;
-       map<char, vector<int> > errorReverse;
-       map<string, int> weights;
-       vector<string> megaAlignVector;
-
-};
-
-#endif
diff --git a/seqnoise.cpp b/seqnoise.cpp
deleted file mode 100644 (file)
index 8e7a439..0000000
+++ /dev/null
@@ -1,1019 +0,0 @@
-/*
- *  mySeqNoise.cpp
- *  
- *
- *  Created by Pat Schloss on 8/31/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "seqnoise.h"
-#include "sequence.hpp"
-
-#define MIN_DELTA 1.0e-6
-#define MIN_ITER 20
-#define MAX_ITER 1000
-#define MIN_COUNT 0.1
-#define MIN_TAU   1.0e-4
-#define MIN_WEIGHT 0.1
-
-
-/**************************************************************************************************/
-int seqNoise::getSequenceData(string sequenceFileName, vector<string>& sequences){
-       try {
-               
-               ifstream sequenceFile;
-               m->openInputFile(sequenceFileName, sequenceFile);
-               
-               while(!sequenceFile.eof()){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence temp(sequenceFile); m->gobble(sequenceFile);
-                       
-                       if (temp.getName() != "") {
-                               sequences.push_back(temp.getAligned());
-                       }
-               }
-               sequenceFile.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "getSequenceData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int seqNoise::addSeq(string seq, vector<string>& sequences){ 
-       try {
-               sequences.push_back(seq);
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "addSeq");
-               exit(1);
-       }
-}      
-/**************************************************************************************************/
-//no checks for file mismatches
-int seqNoise::getRedundantNames(string namesFileName, vector<string>& uniqueNames, vector<string>& redundantNames, vector<int>& seqFreq){
-       try {
-               string unique, redundant;
-               ifstream namesFile;
-               m->openInputFile(namesFileName, namesFile);
-               
-               for(int i=0;i<redundantNames.size();i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       namesFile >> uniqueNames[i]; m->gobble(namesFile);
-                       namesFile >> redundantNames[i]; m->gobble(namesFile);
-                       
-                       seqFreq[i] = m->getNumNames(redundantNames[i]);
-               }
-               namesFile.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "getRedundantNames");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int seqNoise::addRedundantName(string uniqueName, string redundantName, vector<string>& uniqueNames, vector<string>& redundantNames, vector<int>& seqFreq){ 
-       try {
-               
-               uniqueNames.push_back(uniqueName);
-               redundantNames.push_back(redundantName);
-               seqFreq.push_back(m->getNumNames(redundantName));
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "addRedundantName");
-               exit(1);
-       }
-}      
-/**************************************************************************************************/
-int seqNoise::getDistanceData(string distFileName, vector<double>& distances){
-       try {
-               
-               ifstream distFile;
-               m->openInputFile(distFileName, distFile);
-               
-               int numSeqs = 0;
-               string name = "";
-               
-               distFile >> numSeqs;
-               
-               for(int i=0;i<numSeqs;i++){
-                       
-                       if (m->control_pressed) {  break; }
-                       
-                       distances[i * numSeqs + i] = 0.0000;
-                       
-                       distFile >> name;
-                       
-                       for(int j=0;j<i;j++){
-                               distFile >> distances[i * numSeqs + j];
-                               distances[j * numSeqs + i] = distances[i * numSeqs + j];
-                       }
-               }
-               
-               distFile.close();       
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "getDistanceData");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int seqNoise::getListData(string listFileName, double cutOff, vector<int>& otuData, vector<int>& otuFreq, vector<vector<int> >& otuBySeqLookUp){
-       try {
-               
-               ifstream listFile;
-               m->openInputFile(listFileName, listFile);
-               double threshold;
-               int numOTUs;
-               string line = "";
-               bool adjustCutoff = true;
-               
-               if(listFile.peek() == 'u'){     m->getline(listFile);   }
-               
-               while(listFile){
-                       listFile >> threshold;
-                       
-                       if(threshold < cutOff){
-                               line = m->getline(listFile); m->gobble(listFile);
-                       }
-                       else{
-                               adjustCutoff = false;
-                               listFile >> numOTUs;
-                               otuFreq.resize(numOTUs, 0);
-                               
-                               for(int i=0;i<numOTUs;i++){
-                                       
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       string otu;
-                                       listFile >> otu;
-                                       
-                                       int count = 0;
-                                       
-                                       string number = "";
-                                       
-                                       for(int j=0;j<otu.size();j++){
-                                               if(otu[j] != ','){
-                                                       number += otu[j];
-                                               }
-                                               else{
-                                                       int index = atoi(number.c_str());
-                                                       otuData[index] = i;
-                                                       count++;
-                                                       number = "";
-                                               }
-                                       }
-                                       
-                                       int index = atoi(number.c_str());
-                                       otuData[index] = i;
-                                       count++;
-                                       
-                                       otuFreq[i] = count;
-                               }
-                               
-                               otuBySeqLookUp.resize(numOTUs);
-                               
-                               int numSeqs = otuData.size();
-                               
-                               for(int i=0;i<numSeqs;i++){
-                                       if (m->control_pressed) { return 0; }
-                                       otuBySeqLookUp[otuData[i]].push_back(i);
-                               }
-                               for(int i=0;i<numOTUs;i++){
-                                       if (m->control_pressed) { return 0; }
-                                       for(int j=otuBySeqLookUp[i].size();j<numSeqs;j++){
-                                               otuBySeqLookUp[i].push_back(0);
-                                       }
-                               }
-                               
-                               break;
-                       }
-               }
-               
-               listFile.close();
-               
-               //the listfile does not contain a threshold greater than the cutoff so use highest value
-               if (adjustCutoff) {
-                       istringstream iss (line,istringstream::in);
-                       
-                       iss >> numOTUs;
-                       otuFreq.resize(numOTUs, 0);
-                       
-                       for(int i=0;i<numOTUs;i++){
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               string otu;
-                               iss >> otu;
-                               
-                               int count = 0;
-                               
-                               string number = "";
-                               
-                               for(int j=0;j<otu.size();j++){
-                                       if(otu[j] != ','){
-                                               number += otu[j];
-                                       }
-                                       else{
-                                               int index = atoi(number.c_str());
-                                               otuData[index] = i;
-                                               count++;
-                                               number = "";
-                                       }
-                               }
-                               
-                               int index = atoi(number.c_str());
-                               otuData[index] = i;
-                               count++;
-                               
-                               otuFreq[i] = count;
-                       }
-                       
-                       otuBySeqLookUp.resize(numOTUs);
-                       
-                       int numSeqs = otuData.size();
-                       
-                       for(int i=0;i<numSeqs;i++){
-                               if (m->control_pressed) { return 0; }
-                               otuBySeqLookUp[otuData[i]].push_back(i);
-                       }
-                       for(int i=0;i<numOTUs;i++){
-                               if (m->control_pressed) { return 0; }
-                               for(int j=otuBySeqLookUp[i].size();j<numSeqs;j++){
-                                       otuBySeqLookUp[i].push_back(0);
-                               }
-                       }
-                       
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "getListData");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int seqNoise::updateOTUCountData(vector<int> otuFreq,
-                                                                vector<vector<int> > otuBySeqLookUp,
-                                                                vector<vector<int> > aanI,
-                                                                vector<int>& anP,
-                                                                vector<int>& anI,
-                                                                vector<int>& cumCount
-                                                                ){
-       try {
-               int numOTUs = otuFreq.size();
-               
-               int count = 0;
-               
-               for(int i=0;i<numOTUs;i++){
-                       cumCount[i] = count;
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       for(int j=0;j<otuFreq[i];j++){
-                               anP[count] = otuBySeqLookUp[i][j];
-                               anI[count] = aanI[i][j];
-                               
-                               count++;
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "updateOTUCountData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-double seqNoise::calcNewWeights(
-                                         vector<double>& weights,      //
-                                         vector<int> seqFreq,          //
-                                         vector<int> anI,                      //
-                                         vector<int> cumCount,         //
-                                         vector<int> anP,                      //
-                                         vector<int> otuFreq,          //
-                                         vector<double> tau            //
-                                         ){
-       try {
-               
-               int numOTUs = weights.size();
-               double maxChange = -1;
-               
-               cout.flush();
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       double change = weights[i];
-                       
-                       weights[i] = 0.0000;
-                       
-                       for(int j=0;j<otuFreq[i];j++){
-                               
-                               int index1 = cumCount[i] + j;
-                               int index2 = anI[index1];
-                               
-                               double currentTau = tau[anP[index1]];
-                               double freq = double(seqFreq[index2]);
-                               
-                               weights[i] += currentTau * freq;
-                       }
-                       change = fabs(weights[i] - change);
-                       
-                       if(change > maxChange){ maxChange = change;     }
-                       cout.flush();
-               }
-               return maxChange;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "calcNewWeights");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::calcCentroids(
-                                  vector<int> anI,
-                                  vector<int> anP,
-                                  vector<int>& change, 
-                                  vector<int>& centroids, 
-                                  vector<int> cumCount,
-                                  vector<double> distances,///
-                                  vector<int> seqFreq, 
-                                  vector<int> otuFreq, 
-                                  vector<double> tau 
-                                  ){
-       try {
-               int numOTUs = change.size();
-               int numSeqs = seqFreq.size();
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       int minFIndex = -1;
-                       double minFValue = 1e10;
-                       
-                       change[i] = 0;
-                       double count = 0.00000;
-                       
-                       int freqOfOTU = otuFreq[i];
-                       
-                       for(int j=0;j<freqOfOTU;j++){
-                               int index = cumCount[i] + j;
-                               count += seqFreq[anI[index]]*tau[anP[index]];
-                       }
-                       
-                       if(freqOfOTU > 0 && count > MIN_COUNT){
-                               
-                               vector<double> adF(freqOfOTU);
-                               vector<int> anL(freqOfOTU);
-                               
-                               for(int j=0;j<freqOfOTU;j++){
-                                       anL[j] = anI[cumCount[i] + j];
-                                       adF[j] = 0.0000;
-                               }
-                               
-                               for(int j=0;j<freqOfOTU;j++){           
-                                       int index = cumCount[i] + j;
-                                       double curTau = tau[anP[index]];
-                                       
-                                       for(int k=0;k<freqOfOTU;k++){
-                                               double dist = distances[anL[j]*numSeqs + anL[k]];
-                                               
-                                               adF[k] += dist * curTau * seqFreq[anL[j]];
-                                       }
-                               }
-                               
-                               for(int j=0;j<freqOfOTU;j++){
-                                       if(adF[j] < minFValue){
-                                               minFIndex = j;
-                                               minFValue = adF[j];
-                                       }
-                               }
-                               
-                               if(centroids[i] != anL[minFIndex]){
-                                       change[i] = 1;
-                                       centroids[i] = anL[minFIndex];
-                               }
-                       }
-                       else if(centroids[i] != -1){
-                               change[i] = 1;
-                               centroids[i] = -1;                      
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "calcCentroids");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::checkCentroids(vector<double>& weights, vector<int> centroids){
-       try {
-               int numOTUs = centroids.size();
-               vector<int> unique(numOTUs, 1);
-               
-               double minWeight = MIN_WEIGHT;
-               for(int i=0;i<numOTUs;i++){
-                       if (m->control_pressed) { return 0; }
-                       if(weights[i] < minWeight){     unique[i] = -1; }
-               }
-               
-               for(int i=0;i<numOTUs;i++){
-                       if (m->control_pressed) { return 0; }
-                       if(unique[i] == 1){
-                               for(int j=i+1; j<numOTUs;j++){
-                                       if(unique[j] == 1){
-                                               if(centroids[i] == centroids[j]){
-                                                       unique[j] = 0;
-                                                       weights[i] += weights[j];
-                                                       weights[j] = 0;
-                                               }
-                                       }
-                               }
-                       }               
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "checkCentroids");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::setUpOTUData(vector<int>& otuData, vector<double>& percentage, vector<int> cumCount, vector<double> tau, vector<int> otuFreq, vector<int> anP, vector<int> anI){
-       try {
-
-               int numOTUs = cumCount.size();
-               int numSeqs = otuData.size();
-               
-               vector<double> bestTau(numSeqs, 0);
-               vector<double> bestIndex(numSeqs, -1);
-               
-               for(int i=0;i<numOTUs;i++){
-                       if (m->control_pressed) { return 0; }
-                       for(int j=0;j<otuFreq[i];j++){
-                               
-                               int index1 = cumCount[i] + j;
-                               double thisTau = tau[anP[index1]];
-                               int index2 = anI[index1];
-                               
-                               if(thisTau > bestTau[index2]){
-                                       bestTau[index2] = thisTau;
-                                       bestIndex[index2] = i;
-                               }
-                       }               
-               }
-               
-               for(int i=0;i<numSeqs;i++){
-                       if (m->control_pressed) { return 0; }
-                       otuData[i] = bestIndex[i];
-                       percentage[i] = 1 - bestTau[i];
-               }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "setUpOTUData");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::finishOTUData(vector<int> otuData, vector<int>& otuFreq, vector<int>& anP, vector<int>& anI, vector<int>& cumCount, vector<vector<int> >& otuBySeqLookUp, vector<vector<int> >& aanI, vector<double>& tau){
-       try {
-               int numSeqs = otuData.size();
-               int numOTUs = otuFreq.size();
-               int total = numSeqs;
-               
-               otuFreq.assign(numOTUs, 0);
-               tau.assign(numSeqs, 1);
-               anP.assign(numSeqs, 0);
-               anI.assign(numSeqs, 0);
-               
-               for(int i=0;i<numSeqs;i++){
-                       if (m->control_pressed) { return 0; }
-                       int otu = otuData[i];
-                       total++;
-                       
-                       otuBySeqLookUp[otu][otuFreq[otu]] = i;
-                       aanI[otu][otuFreq[otu]] = i;
-                       otuFreq[otu]++;
-               }
-               updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount);
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "finishOTUData");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::getLastMatch(char direction, vector<vector<char> >& alignMoves, int i, int j, vector<int>& seqA, vector<int>& seqB){
-       try{
-               char nullReturn = -1;
-               
-               while(i>=1 && j>=1){
-                       if (m->control_pressed) { return nullReturn; }
-                       if(direction == 'd'){
-                               if(seqA[i-1] == seqB[j-1])      {       return seqA[i-1];       }
-                               else                                            {       return nullReturn;      }
-                       }
-                       
-                       else if(direction == 'l')               {       j--;                            }
-                       else                                                    {       i--;                            }
-                       
-                       direction = alignMoves[i][j];
-               }
-               
-               return nullReturn;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "getLastMatch");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::countDiffs(vector<int> query, vector<int> ref){
-       try {
-               //double MATCH = 5.0;
-               //double MISMATCH = -2.0;
-               //double GAP = -2.0;
-               
-               vector<vector<double> > correctMatrix(4);
-               for(int i=0;i<4;i++){   correctMatrix[i].resize(4);     }
-               
-               correctMatrix[0][0] = 0.000000;         //AA
-               correctMatrix[1][0] = 11.619259;        //CA
-               correctMatrix[2][0] = 11.694004;        //TA
-               correctMatrix[3][0] = 7.748623;         //GA
-               
-               correctMatrix[1][1] = 0.000000;         //CC
-               correctMatrix[2][1] = 7.619657;         //TC
-               correctMatrix[3][1] = 12.852562;        //GC
-               
-               correctMatrix[2][2] = 0.000000;         //TT
-               correctMatrix[3][2] = 10.964048;        //TG
-               
-               correctMatrix[3][3] = 0.000000;         //GG
-               
-               for(int i=0;i<4;i++){
-                       for(int j=0;j<i;j++){
-                               correctMatrix[j][i] = correctMatrix[i][j];
-                       }
-               }
-               
-               int queryLength = query.size();
-               int refLength = ref.size();
-               
-               vector<vector<double> > alignMatrix(queryLength + 1);
-               vector<vector<char> > alignMoves(queryLength + 1);
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i].resize(refLength + 1, 0);
-                       alignMoves[i].resize(refLength + 1, 'x');
-               }
-               
-               for(int i=0;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[i][0] = 15.0 * i;
-                       alignMoves[i][0] = 'u';
-               }
-               
-               for(int i=0;i<=refLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       alignMatrix[0][i] = 15.0 * i;
-                       alignMoves[0][i] = 'l';
-               }
-               
-               for(int i=1;i<=queryLength;i++){
-                       if (m->control_pressed) { return 0; }
-                       for(int j=1;j<=refLength;j++){
-                               
-                               double nogap;           
-                               nogap = alignMatrix[i-1][j-1] + correctMatrix[query[i-1]][ref[j-1]];
-                               
-                               
-                               double gap;
-                               double left;
-                               if(i == queryLength){ //terminal gap
-                                       left = alignMatrix[i][j-1];
-                               }
-                               else{
-                                       if(ref[j-1] == getLastMatch('l', alignMoves, i, j, query, ref)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       left = alignMatrix[i][j-1] + gap;
-                               }
-                               
-                               
-                               double up;
-                               if(j == refLength){ //terminal gap
-                                       up = alignMatrix[i-1][j];
-                               }
-                               else{
-                                       
-                                       if(query[i-1] == getLastMatch('u', alignMoves, i, j, query, ref)){
-                                               gap = 4.0;
-                                       }
-                                       else{
-                                               gap = 15.0;
-                                       }
-                                       
-                                       up = alignMatrix[i-1][j] + gap;
-                               }
-                               
-                               
-                               
-                               if(nogap < left){
-                                       if(nogap < up){
-                                               alignMoves[i][j] = 'd';
-                                               alignMatrix[i][j] = nogap;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                               else{
-                                       if(left < up){
-                                               alignMoves[i][j] = 'l';
-                                               alignMatrix[i][j] = left;
-                                       }
-                                       else{
-                                               alignMoves[i][j] = 'u';
-                                               alignMatrix[i][j] = up;
-                                       }
-                               }
-                       }
-               }
-               
-               int i = queryLength;
-               int j = refLength;
-               int diffs = 0;
-               
-               //      string alignA = "";
-               //      string alignB = "";
-               //      string bases = "ACTG";
-               
-               while(i > 0 && j > 0){
-                       if (m->control_pressed) { return 0; }
-                       if(alignMoves[i][j] == 'd'){
-                               //                      alignA = bases[query[i-1]] + alignA;
-                               //                      alignB = bases[ref[j-1]] + alignB;
-                               
-                               if(query[i-1] != ref[j-1])      {       diffs++;        }
-                               
-                               i--;
-                               j--;
-                       }
-                       else if(alignMoves[i][j] == 'u'){
-                               if(j != refLength){
-                                       //                              alignA = bases[query[i-1]] + alignA;
-                                       //                              alignB = '-' + alignB;
-                                       
-                                       diffs++;
-                               }
-                               
-                               i--;
-                       }
-                       else if(alignMoves[i][j] == 'l'){
-                               if(i != queryLength){
-                                       //                              alignA = '-' + alignA;
-                                       //                              alignB = bases[ref[j-1]] + alignB;
-                                       
-                                       diffs++;
-                               }
-                               
-                               j--;
-                       }
-               }
-               
-               //      cout << diffs << endl;
-               //      cout << alignA << endl;
-               //      cout << alignB << endl;
-               //      cout << endl;
-               
-               return diffs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "countDiffs");
-               exit(1);
-       }
-       
-}
-
-/**************************************************************************************************/
-
-vector<int> seqNoise::convertSeq(string bases){
-       try {
-               vector<int> numbers(bases.length(), -1);
-               
-               for(int i=0;i<bases.length();i++){
-                       if (m->control_pressed) { return numbers; }
-                       
-                       char b = bases[i];
-                       
-                       if(b == 'A')    {       numbers[i] = 0; }
-                       else if(b=='C') {       numbers[i] = 1; }
-                       else if(b=='T') {       numbers[i] = 2; }
-                       else if(b=='G') {       numbers[i] = 3; }
-                       else                    {       numbers[i] = 0; }
-               }
-               
-               return numbers;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "convertSeq");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-string seqNoise::degapSeq(string aligned){
-       try {
-               string unaligned = "";
-               
-               for(int i=0;i<aligned.length();i++){
-                       
-                       if (m->control_pressed) { return ""; }
-                       
-                       if(aligned[i] != '-' && aligned[i] != '.'){
-                               unaligned += aligned[i];
-                       }
-               }
-               
-               return unaligned;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "degapSeq");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int seqNoise::writeOutput(string fastaFileName, string namesFileName, string uMapFileName, vector<int> finalTau, vector<int> centroids, vector<int> otuData, vector<string> sequences, vector<string> uniqueNames, vector<string> redundantNames, vector<int> seqFreq, vector<double>& distances){
-       try {
-               int numOTUs = finalTau.size();
-               int numSeqs = uniqueNames.size();
-               
-               ofstream fastaFile(fastaFileName.c_str());
-               ofstream namesFile(namesFileName.c_str());
-               ofstream uMapFile(uMapFileName.c_str());
-               
-               vector<int> maxSequenceAbund(numOTUs, 0);
-               vector<int> maxSequenceIndex(numOTUs, 0);
-               
-               for(int i=0;i<numSeqs;i++){
-                       if (m->control_pressed) { return 0; }
-                       if(maxSequenceAbund[otuData[i]] < seqFreq[i]){
-                               maxSequenceAbund[otuData[i]] = seqFreq[i];
-                               maxSequenceIndex[otuData[i]] = i;
-                       }
-               }
-               
-               int count = 1;
-               
-               for(int i=0;i<numOTUs;i++){
-                       if (m->control_pressed) { return 0; }
-                       
-                       if(finalTau[i] > 0){
-                               
-                               if(maxSequenceIndex[i] != centroids[i] && distances[maxSequenceIndex[i]*numSeqs + centroids[i]] == 0){
-                                       //                              cout << uniqueNames[centroids[i]] << '\t' << uniqueNames[maxSequenceIndex[i]] << '\t' << count << endl;
-                                       centroids[i] = maxSequenceIndex[i];
-                               }
-                               
-                               int index = centroids[i];
-                               
-                               fastaFile << '>' << uniqueNames[index] << endl << sequences[index] << endl;
-                               namesFile << uniqueNames[index] << '\t';
-                               
-                               string refSeq = sequences[index];
-                               string redundantSeqs = redundantNames[index];;
-                               
-                               
-                               vector<freqData> frequencyData;
-                               
-                               for(int j=0;j<numSeqs;j++){
-                                       if(otuData[j] == i && j != index){
-                                               frequencyData.push_back(freqData(j, seqFreq[j]));
-                                       }
-                               }
-                               sort(frequencyData.rbegin(), frequencyData.rend());
-                               
-                               string refDegap = degapSeq(refSeq);
-                               vector<int> rUnalign = convertSeq(refDegap);
-                               
-                               uMapFile << "ideal_seq_" << count << '\t' << finalTau[i] << endl;
-                               uMapFile << uniqueNames[index] << '\t' << seqFreq[index] << "\t0\t" << refDegap << endl;
-                               
-                               
-                               for(int j=0;j<frequencyData.size();j++){
-                                       if (m->control_pressed) { return 0; }
-                                       redundantSeqs += ',' + redundantNames[frequencyData[j].index];
-                                       
-                                       uMapFile << uniqueNames[frequencyData[j].index] << '\t' << seqFreq[frequencyData[j].index] << '\t';
-                                       
-                                       string querySeq = sequences[frequencyData[j].index];
-                                       
-                                       string queryDegap = degapSeq(querySeq);
-                                       vector<int> qUnalign = convertSeq(queryDegap);
-                                       
-                                       int udiffs = countDiffs(qUnalign, rUnalign);
-                                       uMapFile << udiffs << '\t' << queryDegap << endl;
-                                       
-                               }                                       
-                               
-                               uMapFile << endl;
-                               namesFile << redundantSeqs << endl;
-                               count++;
-                               
-                       }
-               }
-               fastaFile.close();
-               namesFile.close();
-               uMapFile.close();
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "seqNoise", "writeOutput");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************
-
-int main(int argc, char *argv[]){
-       
-       double sigma = 100;
-       sigma = atof(argv[5]);
-       
-       double cutOff = 0.08;
-       int minIter = 10;
-       int maxIter = 1000;
-       double minDelta = 1e-6;
-       
-       string sequenceFileName = argv[1];
-       string fileNameStub = sequenceFileName.substr(0,sequenceFileName.find_last_of('.')) + ".shhh";
-       
-       vector<string> sequences;
-       getSequenceData(sequenceFileName, sequences);
-       
-       int numSeqs = sequences.size();
-       
-       vector<string> uniqueNames(numSeqs);
-       vector<string> redundantNames(numSeqs);
-       vector<int> seqFreq(numSeqs);
-       
-       string namesFileName = argv[4];
-       getRedundantNames(namesFileName, uniqueNames, redundantNames, seqFreq);
-       
-       string distFileName = argv[2];
-       vector<double> distances(numSeqs * numSeqs);
-       getDistanceData(distFileName, distances);
-       
-       string listFileName = argv[3];
-       vector<int> otuData(numSeqs);
-       vector<int> otuFreq;
-       vector<vector<int> > otuBySeqLookUp;
-       
-       getListData(listFileName, cutOff, otuData, otuFreq, otuBySeqLookUp);
-       
-       int numOTUs = otuFreq.size();
-       
-       vector<double> weights(numOTUs, 0);
-       vector<int> change(numOTUs, 1);
-       vector<int> centroids(numOTUs, -1);
-       vector<int> cumCount(numOTUs, 0);
-       
-       vector<double> tau(numSeqs, 1);
-       vector<int> anP(numSeqs, 0);
-       vector<int> anI(numSeqs, 0);
-       vector<int> anN(numSeqs, 0);
-       vector<vector<int> > aanI = otuBySeqLookUp;
-       
-       int numIters = 0;
-       double maxDelta = 1e6;
-       
-       while(numIters < minIter || ((maxDelta > minDelta) && (numIters < maxIter))){
-               
-               updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount);
-               maxDelta = calcNewWeights(weights, seqFreq, anI, cumCount, anP, otuFreq, tau);
-               
-               calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau);
-               checkCentroids(weights, centroids);
-               
-               otuFreq.assign(numOTUs, 0);
-               
-               int total = 0;
-               
-               for(int i=0;i<numSeqs;i++){
-                       double offset = 1e6;
-                       double norm = 0.0000;
-                       double minWeight = MIN_WEIGHT;
-                       vector<double> currentTau(numOTUs);
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               if(weights[j] > minWeight && distances[i * numSeqs+centroids[j]] < offset){
-                                       offset = distances[i * numSeqs+centroids[j]];
-                               }
-                       }
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               if(weights[j] > minWeight){
-                                       currentTau[j] = exp(sigma * (-distances[(i * numSeqs + centroids[j])] + offset)) * weights[j];
-                                       norm += currentTau[j];
-                               }
-                               else{
-                                       currentTau[j] = 0.0000;
-                               }
-                       }                       
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               currentTau[j] /= norm;
-                       }
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               
-                               if(currentTau[j] > MIN_TAU){
-                                       int oldTotal = total;
-                                       total++;
-                                       
-                                       tau.resize(oldTotal+1);
-                                       tau[oldTotal] = currentTau[j];
-                                       otuBySeqLookUp[j][otuFreq[j]] = oldTotal;
-                                       aanI[j][otuFreq[j]] = i;
-                                       otuFreq[j]++;
-                                       
-                               }
-                       }
-                       
-                       anP.resize(total);
-                       anI.resize(total);
-               }
-               
-               numIters++;
-       }
-       
-       updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount);
-       
-       vector<double> percentage(numSeqs);
-       setUpOTUData(otuData, percentage, cumCount, tau, otuFreq, anP, anI);
-       finishOTUData(otuData, otuFreq, anP, anI, cumCount, otuBySeqLookUp, aanI, tau);
-       
-       change.assign(numOTUs, 1);
-       calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau);
-       
-       
-       vector<int> finalTau(numOTUs, 0);
-       for(int i=0;i<numSeqs;i++){
-               finalTau[otuData[i]] += int(seqFreq[i]);
-       }
-       
-       writeOutput(fileNameStub, finalTau, centroids, otuData, sequences, uniqueNames, redundantNames, seqFreq, distances);
-       
-       return 0;
-}
-
-**************************************************************************************************/
diff --git a/seqnoise.h b/seqnoise.h
deleted file mode 100644 (file)
index d6760a3..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef SEQNOISE
-#define SEQNOISE
-
-
-
-/*
- *  mySeqNoise.h
- *  
- *
- *  Created by Pat Schloss on 8/31/11.
- *  Copyright 2011 Patrick D. Schloss. All rights reserved.
- *
- */
-
-/*****************************************************************************************************************************/
-/*****************************************************************************************************************************/
-/* NOTE: Order matters in this class.  If you are going to use it, make sure your files have the sequences in the same order. */
-/*****************************************************************************************************************************/
-/*****************************************************************************************************************************/
-
-
-#include "mothurout.h"
-/**************************************************************************************************/
-
-struct freqData {
-       
-       freqData(int i, int freq) : frequency(freq), index(i){  }
-       
-       bool operator<( freqData const& rhs ) const {
-               return frequency < rhs.frequency; 
-       }
-       
-       int frequency;
-       int index;
-       
-};
-/**************************************************************************************************/
-
-class seqNoise {
-public:
-       seqNoise() { m = MothurOut::getInstance();  }
-       ~seqNoise(){}
-       
-       int getSequenceData(string, vector<string>&);
-       int addSeq(string, vector<string>&); 
-       int getRedundantNames(string, vector<string>&, vector<string>&, vector<int>&);
-       int addRedundantName(string, string, vector<string>&, vector<string>&, vector<int>&);
-    int getDistanceData(string, vector<double>&);
-       int getListData(string, double, vector<int>&, vector<int>&, vector<vector<int> >&);
-       int updateOTUCountData(vector<int>, vector<vector<int> >, vector<vector<int> >, vector<int>&, vector<int>&, vector<int>&);
-       double calcNewWeights(vector<double>&,vector<int>,vector<int>,vector<int>,vector<int>,vector<int>,vector<double>);
-       int calcCentroids(vector<int>,vector<int>,vector<int>&,vector<int>&,vector<int>,vector<double>,vector<int>,vector<int>,vector<double>);
-       int checkCentroids(vector<double>&, vector<int>);
-       int setUpOTUData(vector<int>&, vector<double>&, vector<int>, vector<double>, vector<int>, vector<int>, vector<int>);
-       int finishOTUData(vector<int>, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<vector<int> >&, vector<vector<int> >&, vector<double>&);
-       int writeOutput(string, string, string, vector<int>, vector<int>, vector<int>, vector<string>, vector<string>, vector<string>, vector<int>, vector<double>&);
-
-
-private:
-       MothurOut* m;
-       
-       int getLastMatch(char, vector<vector<char> >&, int, int, vector<int>&, vector<int>&);
-       int countDiffs(vector<int>, vector<int>);
-       vector<int> convertSeq(string);
-       string degapSeq(string);
-       
-};
-
-/**************************************************************************************************/
-#endif
-
diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp
deleted file mode 100644 (file)
index 1ea58c5..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-/*
- *  seqcoordcommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 5/30/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "seqsummarycommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> SeqSummaryCommand::setParameters(){     
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SeqSummaryCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The summary.seqs command reads a fastafile and summarizes the sequences.\n";
-               helpString += "The summary.seqs command parameters are fasta, name and processors, fasta is required, unless you have a valid current fasta file.\n";
-               helpString += "The name parameter allows you to enter a name file associated with your fasta file. \n";
-               helpString += "The summary.seqs command should be in the following format: \n";
-               helpString += "summary.seqs(fasta=yourFastaFile, processors=2) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-SeqSummaryCommand::SeqSummaryCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-SeqSummaryCommand::SeqSummaryCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter("summary.seqs");
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {                            
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = "";  }   
-                       else { m->setNameFile(namefile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastafile); //if user entered a file with a path then preserve it       
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "SeqSummaryCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int SeqSummaryCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //set current fasta to fastafile
-               m->setFastaFile(fastafile);
-               
-               string summaryFile = outputDir + m->getSimpleName(fastafile) + ".summary";
-                               
-               int numSeqs = 0;
-               
-               vector<int> startPosition;
-               vector<int> endPosition;
-               vector<int> seqLength;
-               vector<int> ambigBases;
-               vector<int> longHomoPolymer;
-               
-               if (namefile != "") { nameMap = m->readNames(namefile); }
-               
-               if (m->control_pressed) { return 0; }
-                       
-#ifdef USE_MPI 
-                               int pid, numSeqsPerProcessor; 
-                               int tag = 2001;
-                               int startTag = 1; int endTag = 2; int lengthTag = 3; int baseTag = 4; int lhomoTag = 5;
-                               int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
-                               vector<unsigned long long> MPIPos;
-                               
-                               MPI_Status status; 
-                               MPI_Status statusOut;
-                               MPI_File inMPI; 
-                               MPI_File outMPI; 
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-                                                       
-                               char tempFileName[1024];
-                               strcpy(tempFileName, fastafile.c_str());
-                               
-                               char sumFileName[1024];
-                               strcpy(sumFileName, summaryFile.c_str());
-               
-                               MPI_File_open(MPI_COMM_WORLD, tempFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
-                               MPI_File_open(MPI_COMM_WORLD, sumFileName, outMode, MPI_INFO_NULL, &outMPI);
-                               
-                               if (m->control_pressed) {  MPI_File_close(&inMPI);  MPI_File_close(&outMPI); return 0;  }
-                               
-                               if (pid == 0) { //you are the root process
-                                               //print header
-                                               string outputString = "seqname\tstart\tend\tnbases\tambigs\tpolymer\tnumSeqs\n";        
-                                               int length = outputString.length();
-                                               char* buf2 = new char[length];
-                                               memcpy(buf2, outputString.c_str(), length);
-                                       
-                                               MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &statusOut);
-                                               delete buf2;
-                                               
-                                               MPIPos = m->setFilePosFasta(fastafile, numSeqs); //fills MPIPos, returns numSeqs
-                                       
-                                               for(int i = 1; i < processors; i++) { 
-                                                       MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                                       MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
-                                               }
-                                               
-                                               //figure out how many sequences you have to do
-                                               numSeqsPerProcessor = numSeqs / processors;
-                                               int startIndex =  pid * numSeqsPerProcessor;
-                                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                                               
-                                               //do your part
-                                               MPICreateSummary(startIndex, numSeqsPerProcessor, startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, inMPI, outMPI, MPIPos);
-                                               
-                               }else { //i am the child process
-                       
-                                       MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPIPos.resize(numSeqs+1);
-                                       MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                                       //figure out how many sequences you have to align
-                                       numSeqsPerProcessor = numSeqs / processors;
-                                       int startIndex =  pid * numSeqsPerProcessor;
-                                       if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
-                               
-                                       //do your part
-                                       MPICreateSummary(startIndex, numSeqsPerProcessor, startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, inMPI, outMPI, MPIPos);
-                               }
-                               
-                               MPI_File_close(&inMPI);
-                               MPI_File_close(&outMPI);
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-                               
-                               if (pid == 0) {
-                                       //get the info from the child processes
-                                       for(int i = 1; i < processors; i++) { 
-                                               int size;
-                                               MPI_Recv(&size, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-
-                                               vector<int> temp; temp.resize(size+1);
-                                               
-                                               for(int j = 0; j < 5; j++) { 
-                                               
-                                                       MPI_Recv(&temp[0], (size+1), MPI_INT, i, 2001, MPI_COMM_WORLD, &status); 
-                                                       int receiveTag = temp[temp.size()-1];  //child process added a int to the end to indicate what count this is for
-                                                       
-                                                       if (receiveTag == startTag) { 
-                                                               for (int k = 0; k < size; k++) {                startPosition.push_back(temp[k]);       }
-                                                       }else if (receiveTag == endTag) { 
-                                                               for (int k = 0; k < size; k++) {                endPosition.push_back(temp[k]); }
-                                                       }else if (receiveTag == lengthTag) { 
-                                                               for (int k = 0; k < size; k++) {                seqLength.push_back(temp[k]);   }
-                                                       }else if (receiveTag == baseTag) { 
-                                                               for (int k = 0; k < size; k++) {                ambigBases.push_back(temp[k]);  }
-                                                       }else if (receiveTag == lhomoTag) { 
-                                                               for (int k = 0; k < size; k++) {                longHomoPolymer.push_back(temp[k]);     }
-                                                       }
-                                               } 
-                                       }
-
-                               }else{
-                               
-                                       //send my counts
-                                       int size = startPosition.size();
-                                       MPI_Send(&size, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                                       
-                                       startPosition.push_back(startTag);
-                                       int ierr = MPI_Send(&(startPosition[0]), (size+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                                       endPosition.push_back(endTag);
-                                       ierr = MPI_Send (&(endPosition[0]), (size+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                                       seqLength.push_back(lengthTag);
-                                       ierr = MPI_Send(&(seqLength[0]), (size+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                                       ambigBases.push_back(baseTag);
-                                       ierr = MPI_Send(&(ambigBases[0]), (size+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                                       longHomoPolymer.push_back(lhomoTag);
-                                       ierr = MPI_Send(&(longHomoPolymer[0]), (size+1), MPI_INT, 0, 2001, MPI_COMM_WORLD);
-                               }
-                               
-                               MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
-#else
-                       vector<unsigned long long> positions; 
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               positions = m->divideFile(fastafile, processors);
-                               for (int i = 0; i < (positions.size()-1); i++) {        lines.push_back(new linePair(positions[i], positions[(i+1)]));  }
-                       #else
-                               positions = m->setFilePosFasta(fastafile, numSeqs); 
-                if (positions.size() < processors) { processors = positions.size(); }
-               
-                               //figure out how many sequences you have to process
-                               int numSeqsPerProcessor = numSeqs / processors;
-                               for (int i = 0; i < processors; i++) {
-                                       int startIndex =  i * numSeqsPerProcessor;
-                                       if(i == (processors - 1)){      numSeqsPerProcessor = numSeqs - i * numSeqsPerProcessor;        }
-                                       lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
-                               }
-                       #endif
-                       
-
-                       if(processors == 1){
-                               numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, summaryFile, lines[0]);
-                       }else{
-                               numSeqs = createProcessesCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, summaryFile); 
-                       }
-                       
-                       if (m->control_pressed) {  return 0; }
-#endif
-                       
-               #ifdef USE_MPI
-                       if (pid == 0) { 
-               #endif
-               
-               sort(startPosition.begin(), startPosition.end());
-               sort(endPosition.begin(), endPosition.end());
-               sort(seqLength.begin(), seqLength.end());
-               sort(ambigBases.begin(), ambigBases.end());
-               sort(longHomoPolymer.begin(), longHomoPolymer.end());
-               int size = startPosition.size();
-               
-               //find means
-               float meanStartPosition, meanEndPosition, meanSeqLength, meanAmbigBases, meanLongHomoPolymer;
-               meanStartPosition = 0; meanEndPosition = 0; meanSeqLength = 0; meanAmbigBases = 0; meanLongHomoPolymer = 0;
-               for (int i = 0; i < size; i++) {
-                       meanStartPosition += startPosition[i];
-                       meanEndPosition += endPosition[i];
-                       meanSeqLength += seqLength[i];
-                       meanAmbigBases += ambigBases[i];
-                       meanLongHomoPolymer += longHomoPolymer[i];
-               }
-               //this is an int divide so the remainder is lost
-               meanStartPosition /= (float) size; meanEndPosition /= (float) size; meanLongHomoPolymer /= (float) size; meanSeqLength /= (float) size; meanAmbigBases /= (float) size;
-                               
-               int ptile0_25   = int(size * 0.025);
-               int ptile25             = int(size * 0.250);
-               int ptile50             = int(size * 0.500);
-               int ptile75             = int(size * 0.750);
-               int ptile97_5   = int(size * 0.975);
-               int ptile100    = size - 1;
-               
-               //to compensate for blank sequences that would result in startPosition and endPostion equalling -1
-               if (startPosition[0] == -1) {  startPosition[0] = 0;    }
-               if (endPosition[0] == -1)       {  endPosition[0] = 0;          }
-               
-               if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("\t\tStart\tEnd\tNBases\tAmbigs\tPolymer\tNumSeqs"); m->mothurOutEndLine();
-               m->mothurOut("Minimum:\t" + toString(startPosition[0]) + "\t" + toString(endPosition[0]) + "\t" + toString(seqLength[0]) + "\t" + toString(ambigBases[0]) + "\t" + toString(longHomoPolymer[0]) + "\t" + toString(1)); m->mothurOutEndLine();
-               m->mothurOut("2.5%-tile:\t" + toString(startPosition[ptile0_25]) + "\t" + toString(endPosition[ptile0_25]) + "\t" + toString(seqLength[ptile0_25]) + "\t" + toString(ambigBases[ptile0_25]) + "\t"+ toString(longHomoPolymer[ptile0_25]) + "\t" + toString(ptile0_25+1)); m->mothurOutEndLine();
-               m->mothurOut("25%-tile:\t" + toString(startPosition[ptile25]) + "\t" + toString(endPosition[ptile25]) + "\t" + toString(seqLength[ptile25]) + "\t" + toString(ambigBases[ptile25]) + "\t" + toString(longHomoPolymer[ptile25]) + "\t" + toString(ptile25+1)); m->mothurOutEndLine();
-               m->mothurOut("Median: \t" + toString(startPosition[ptile50]) + "\t" + toString(endPosition[ptile50]) + "\t" + toString(seqLength[ptile50]) + "\t" + toString(ambigBases[ptile50]) + "\t" + toString(longHomoPolymer[ptile50]) + "\t" + toString(ptile50+1)); m->mothurOutEndLine();
-               m->mothurOut("75%-tile:\t" + toString(startPosition[ptile75]) + "\t" + toString(endPosition[ptile75]) + "\t" + toString(seqLength[ptile75]) + "\t" + toString(ambigBases[ptile75]) + "\t" + toString(longHomoPolymer[ptile75]) + "\t" + toString(ptile75+1)); m->mothurOutEndLine();
-               m->mothurOut("97.5%-tile:\t" + toString(startPosition[ptile97_5]) + "\t" + toString(endPosition[ptile97_5]) + "\t" + toString(seqLength[ptile97_5]) + "\t" + toString(ambigBases[ptile97_5]) + "\t" + toString(longHomoPolymer[ptile97_5]) + "\t" + toString(ptile97_5+1)); m->mothurOutEndLine();
-               m->mothurOut("Maximum:\t" + toString(startPosition[ptile100]) + "\t" + toString(endPosition[ptile100]) + "\t" + toString(seqLength[ptile100]) + "\t" + toString(ambigBases[ptile100]) + "\t" + toString(longHomoPolymer[ptile100]) + "\t" + toString(ptile100+1)); m->mothurOutEndLine();
-               m->mothurOut("Mean:\t" + toString(meanStartPosition) + "\t" + toString(meanEndPosition) + "\t" + toString(meanSeqLength) + "\t" + toString(meanAmbigBases) + "\t" + toString(meanLongHomoPolymer)); m->mothurOutEndLine();
-
-               if (namefile == "") {  m->mothurOut("# of Seqs:\t" + toString(numSeqs)); m->mothurOutEndLine(); }
-               else { m->mothurOut("# of unique seqs:\t" + toString(numSeqs)); m->mothurOutEndLine(); m->mothurOut("total # of seqs:\t" + toString(startPosition.size())); m->mothurOutEndLine(); }
-               
-               if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(summaryFile); m->mothurOutEndLine();       outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile);
-               m->mothurOutEndLine();
-               
-               #ifdef USE_MPI
-                       }
-               #endif
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int SeqSummaryCommand::driverCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename, string sumFile, linePair* filePos) {  
-       try {
-               
-               ofstream outSummary;
-               m->openOutputFile(sumFile, outSummary);
-               
-               //print header if you are process 0
-               if (filePos->start == 0) {
-                       outSummary << "seqname\tstart\tend\tnbases\tambigs\tpolymer\tnumSeqs" << endl;  
-               }
-                               
-               ifstream in;
-               m->openInputFile(filename, in);
-                               
-               in.seekg(filePos->start);
-
-               bool done = false;
-               int count = 0;
-       
-               while (!done) {
-                               
-                       if (m->control_pressed) { in.close(); outSummary.close(); return 1; }
-                                       
-                       Sequence current(in); m->gobble(in);
-       
-                       if (current.getName() != "") {
-                               
-                               int num = 1;
-                               if (namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = nameMap.find(current.getName());
-                                       
-                                       if (it == nameMap.end()) { m->mothurOut("[ERROR]: '" + current.getName() + "' is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       startPosition.push_back(current.getStartPos());
-                                       endPosition.push_back(current.getEndPos());
-                                       seqLength.push_back(current.getNumBases());
-                                       ambigBases.push_back(current.getAmbigBases());
-                                       longHomoPolymer.push_back(current.getLongHomoPolymer());
-                               }
-                               
-                               count++;
-                               outSummary << current.getName() << '\t';
-                               outSummary << current.getStartPos() << '\t' << current.getEndPos() << '\t';
-                               outSummary << current.getNumBases() << '\t' << current.getAmbigBases() << '\t';
-                               outSummary << current.getLongHomoPolymer() << '\t' << num << endl;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = in.tellg();
-                               if ((pos == -1) || (pos >= filePos->end)) { break; }
-                       #else
-                               if (in.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       //if((count) % 100 == 0){       m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               }
-               //report progress
-               //if((count) % 100 != 0){       m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               
-               in.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "driverCreateSummary");
-               exit(1);
-       }
-}
-#ifdef USE_MPI
-/**************************************************************************************/
-int SeqSummaryCommand::MPICreateSummary(int start, int num, vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, MPI_File& inMPI, MPI_File& outMPI, vector<unsigned long long>& MPIPos) {      
-       try {
-               
-               int pid;
-               MPI_Status status; 
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); 
-
-               for(int i=0;i<num;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       //read next sequence
-                       int length = MPIPos[start+i+1] - MPIPos[start+i];
-       
-                       char* buf4 = new char[length];
-                       MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status);
-                       
-                       string tempBuf = buf4;
-                       if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length);  }
-                       istringstream iss (tempBuf,istringstream::in);
-                       delete buf4;
-
-                       Sequence current(iss);  
-
-                       if (current.getName() != "") {
-                               
-                               int num = 1;
-                               if (namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = nameMap.find(current.getName());
-                                       
-                                       if (it == nameMap.end()) { cout << "[ERROR]: " << current.getName() << " is not in your namefile, please correct." << endl; m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       startPosition.push_back(current.getStartPos());
-                                       endPosition.push_back(current.getEndPos());
-                                       seqLength.push_back(current.getNumBases());
-                                       ambigBases.push_back(current.getAmbigBases());
-                                       longHomoPolymer.push_back(current.getLongHomoPolymer());
-                               }
-                               
-                               string outputString = current.getName() + "\t" + toString(current.getStartPos()) + "\t" + toString(current.getEndPos()) + "\t";
-                               outputString += toString(current.getNumBases()) + "\t" + toString(current.getAmbigBases()) + "\t" + toString(current.getLongHomoPolymer()) + "\t" + toString(num) + "\n";
-                               
-                               //output to file
-                               length = outputString.length();
-                               char* buf3 = new char[length];
-                               memcpy(buf3, outputString.c_str(), length);
-                                       
-                               MPI_File_write_shared(outMPI, buf3, length, MPI_CHAR, &status);
-                               delete buf3;
-                       }       
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "MPICreateSummary");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-int SeqSummaryCommand::createProcessesCreateSummary(vector<int>& startPosition, vector<int>& endPosition, vector<int>& seqLength, vector<int>& ambigBases, vector<int>& longHomoPolymer, string filename, string sumFile) {
-       try {
-               int process = 1;
-               int num = 0;
-               processIDS.clear();
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, sumFile + toString(getpid()) + ".temp", lines[process]);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = fastafile + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               
-                               out << num << endl;
-                               out << startPosition.size() << endl;
-                               for (int k = 0; k < startPosition.size(); k++)          {               out << startPosition[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < endPosition.size(); k++)            {               out << endPosition[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < seqLength.size(); k++)                      {               out << seqLength[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < ambigBases.size(); k++)                     {               out << ambigBases[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < longHomoPolymer.size(); k++)        {               out << longHomoPolymer[k] << '\t'; }  out << endl;
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do your part
-               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, sumFile, lines[0]);
-
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //parent reads in and combine Filter info
-               for (int i = 0; i < processIDS.size(); i++) {
-                       string tempFilename = fastafile + toString(processIDS[i]) + ".num.temp";
-                       ifstream in;
-                       m->openInputFile(tempFilename, in);
-                       
-                       int temp, tempNum;
-                       in >> tempNum; m->gobble(in); num += tempNum;
-                       in >> tempNum; m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; startPosition.push_back(temp);              }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; endPosition.push_back(temp);                }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; seqLength.push_back(temp);                  }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; ambigBases.push_back(temp);                 }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; longHomoPolymer.push_back(temp);    }               m->gobble(in);
-                               
-                       in.close();
-                       m->mothurRemove(tempFilename);
-                       
-                       m->appendFiles((sumFile + toString(processIDS[i]) + ".temp"), sumFile);
-                       m->mothurRemove((sumFile + toString(processIDS[i]) + ".temp"));
-               }
-               
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the seqSumData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to allow both threads to add info to vectors.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<seqSumData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-            
-            string extension = "";
-            if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
-                       // Allocate memory for thread data.
-                       seqSumData* tempSum = new seqSumData(filename, (sumFile+extension), m, lines[i]->start, lines[i]->end, namefile, nameMap);
-                       pDataArray.push_back(tempSum);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MySeqSumThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-        //do your part
-               num = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, (sumFile+toString(processors-1)+".temp"), lines[processors-1]);
-        processIDS.push_back(processors-1);
-
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-            for (int k = 0; k < pDataArray[i]->startPosition.size(); k++) {    startPosition.push_back(pDataArray[i]->startPosition[k]);       }
-                       for (int k = 0; k < pDataArray[i]->endPosition.size(); k++) {   endPosition.push_back(pDataArray[i]->endPosition[k]);       }
-            for (int k = 0; k < pDataArray[i]->seqLength.size(); k++) {        seqLength.push_back(pDataArray[i]->seqLength[k]);       }
-            for (int k = 0; k < pDataArray[i]->ambigBases.size(); k++) {       ambigBases.push_back(pDataArray[i]->ambigBases[k]);       }
-            for (int k = 0; k < pDataArray[i]->longHomoPolymer.size(); k++) {  longHomoPolymer.push_back(pDataArray[i]->longHomoPolymer[k]);       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-    
-               //append files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((sumFile + toString(processIDS[i]) + ".temp"), sumFile);
-                       m->mothurRemove((sumFile + toString(processIDS[i]) + ".temp"));
-               }
-#endif         
-               return num;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SeqSummaryCommand", "createProcessesCreateSummary");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-
-
-
diff --git a/seqsummarycommand.h b/seqsummarycommand.h
deleted file mode 100644 (file)
index d8837a3..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-#ifndef SEQSUMMARYCOMMAND_H
-#define SEQSUMMARYCOMMAND_H
-
-/*
- *  seqcoordcommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 5/30/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "sequence.hpp"
-
-/**************************************************************************************************/
-
-class SeqSummaryCommand : public Command {
-public:
-       SeqSummaryCommand(string);
-       SeqSummaryCommand();
-       ~SeqSummaryCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "summary.seqs";                        }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Summary.seqs"; }
-       string getDescription()         { return "summarize the quality of sequences in an unaligned or aligned fasta file"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-private:
-       bool abort;
-       string fastafile, outputDir, namefile;
-       int processors;
-       vector<string> outputNames;
-       map<string, int> nameMap;
-       
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-
-       vector<linePair*> lines;
-       vector<int> processIDS;
-       
-       int createProcessesCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string, string);
-       int driverCreateSummary(vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, string, string, linePair*);       
-
-       #ifdef USE_MPI
-       int MPICreateSummary(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, MPI_File&, MPI_File&, vector<unsigned long long>&);        
-       #endif
-
-
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct seqSumData {
-       vector<int> startPosition;
-       vector<int> endPosition;
-       vector<int> seqLength; 
-       vector<int> ambigBases; 
-       vector<int> longHomoPolymer; 
-       string filename; 
-       string sumFile; 
-       unsigned long long start;
-       unsigned long long end;
-       int count;
-       MothurOut* m;
-       string namefile;
-       map<string, int> nameMap;
-       
-       
-       seqSumData(){}
-       seqSumData(string f, string sf, MothurOut* mout, unsigned long long st, unsigned long long en, string na, map<string, int> nam) {
-               filename = f;
-               sumFile = sf;
-               m = mout;
-               start = st;
-               end = en;
-               namefile = na;
-               nameMap = nam;
-               count = 0;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MySeqSumThreadFunction(LPVOID lpParam){ 
-       seqSumData* pDataArray;
-       pDataArray = (seqSumData*)lpParam;
-       
-       try {
-               ofstream outSummary;
-               pDataArray->m->openOutputFile(pDataArray->sumFile, outSummary);
-               
-               ifstream in;
-               pDataArray->m->openInputFile(pDataArray->filename, in);
-
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       outSummary << "seqname\tstart\tend\tnbases\tambigs\tpolymer\tnumSeqs" << endl;  
-                       in.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
-               }
-               
-               pDataArray->count = pDataArray->end;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) { in.close(); outSummary.close(); pDataArray->count = 1; return 1; }
-                       
-                       Sequence current(in); pDataArray->m->gobble(in); 
-                       
-                       if (current.getName() != "") {
-                               
-                               int num = 1;
-                               if (pDataArray->namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = pDataArray->nameMap.find(current.getName());
-                                       
-                                       if (it == pDataArray->nameMap.end()) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               //for each sequence this sequence represents
-                               for (int i = 0; i < num; i++) {
-                                       pDataArray->startPosition.push_back(current.getStartPos());
-                                       pDataArray->endPosition.push_back(current.getEndPos());
-                                       pDataArray->seqLength.push_back(current.getNumBases());
-                                       pDataArray->ambigBases.push_back(current.getAmbigBases());
-                                       pDataArray->longHomoPolymer.push_back(current.getLongHomoPolymer());
-                               }
-                               
-                               outSummary << current.getName() << '\t';
-                               outSummary << current.getStartPos() << '\t' << current.getEndPos() << '\t';
-                               outSummary << current.getNumBases() << '\t' << current.getAmbigBases() << '\t';
-                               outSummary << current.getLongHomoPolymer() << '\t' << num << endl;
-                       }
-               }
-               
-               in.close();
-               outSummary.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "SeqSummaryCommand", "MySeqSumThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-
-
-#endif
-
-/**************************************************************************************************/
-
-
diff --git a/sequence.cpp b/sequence.cpp
deleted file mode 100644 (file)
index d877f4b..0000000
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- *  sequence.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "sequence.hpp"
-
-/***********************************************************************/
-Sequence::Sequence(){
-       m = MothurOut::getInstance();
-       initialize();
-}
-/***********************************************************************/
-Sequence::Sequence(string newName, string sequence) {
-       try {
-               m = MothurOut::getInstance();
-               initialize();   
-               name = newName;
-               
-               //setUnaligned removes any gap characters for us
-               setUnaligned(sequence);
-               setAligned(sequence);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                       
-}
-/***********************************************************************/
-Sequence::Sequence(string newName, string sequence, string justUnAligned) {
-       try {
-               m = MothurOut::getInstance();
-               initialize();   
-               name = newName;
-               
-               //setUnaligned removes any gap characters for us
-               setUnaligned(sequence);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                       
-}
-
-//********************************************************************************************************************
-//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
-Sequence::Sequence(istringstream& fastaString){
-       try {
-               m = MothurOut::getInstance();
-       
-               initialize();
-               fastaString >> name;
-               
-               if (name.length() != 0) { 
-               
-                       name = name.substr(1);
-                       string sequence;
-               
-                       //read comments
-                       while ((name[0] == '#') && fastaString) { 
-                               while (!fastaString.eof())      {       char c = fastaString.get(); if (c == 10 || c == 13){    break;  }       } // get rest of line if there's any crap there
-                               sequence = getCommentString(fastaString);
-                               
-                               if (fastaString) {  
-                                       fastaString >> name;  
-                                       name = name.substr(1);  
-                               }else { 
-                                       name = "";
-                                       break;
-                               }
-                       }
-                       
-                       while (!fastaString.eof())      {       char c = fastaString.get();  if (c == 10 || c == 13){ break;    }       } // get rest of line if there's any crap there
-                       
-                       int numAmbig = 0;
-                       sequence = getSequenceString(fastaString, numAmbig);
-                       
-                       setAligned(sequence);   
-                       //setUnaligned removes any gap characters for us                                                
-                       setUnaligned(sequence); 
-                       
-                       if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
-               
-               }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaString.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                                                               
-}
-//********************************************************************************************************************
-//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
-Sequence::Sequence(istringstream& fastaString, string JustUnaligned){
-       try {
-               m = MothurOut::getInstance();
-       
-               initialize();
-               fastaString >> name;
-               
-               if (name.length() != 0) { 
-               
-                       name = name.substr(1);
-                       string sequence;
-               
-                       //read comments
-                       while ((name[0] == '#') && fastaString) { 
-                               while (!fastaString.eof())      {       char c = fastaString.get(); if (c == 10 || c == 13){    break;  }       } // get rest of line if there's any crap there
-                               sequence = getCommentString(fastaString);
-                               
-                               if (fastaString) {  
-                                       fastaString >> name;  
-                                       name = name.substr(1);  
-                               }else { 
-                                       name = "";
-                                       break;
-                               }
-                       }
-                       
-                       while (!fastaString.eof())      {       char c = fastaString.get();  if (c == 10 || c == 13){ break;    }       } // get rest of line if there's any crap there
-                       
-                       int numAmbig = 0;
-                       sequence = getSequenceString(fastaString, numAmbig);
-                       
-                       //setUnaligned removes any gap characters for us                                                
-                       setUnaligned(sequence); 
-                       
-                       if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
-                       
-               }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaString.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                                                               
-}
-
-
-//********************************************************************************************************************
-//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
-Sequence::Sequence(ifstream& fastaFile){
-       try {
-               m = MothurOut::getInstance();
-               initialize();
-               fastaFile >> name;
-               
-               if (name.length() != 0) { 
-               
-                       name = name.substr(1); 
-                       
-                       string sequence;
-               
-                       //read comments
-                       while ((name[0] == '#') && fastaFile) { 
-                               while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                               sequence = getCommentString(fastaFile);
-                               
-                               if (fastaFile) {  
-                                       fastaFile >> name;  
-                                       name = name.substr(1);  
-                               }else { 
-                                       name = "";
-                                       break;
-                               }
-                       }
-                       
-                       //read real sequence
-                       while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){  break;      }       } // get rest of line if there's any crap there
-                       
-                       int numAmbig = 0;
-                       sequence = getSequenceString(fastaFile, numAmbig);
-                       
-                       setAligned(sequence);   
-                       //setUnaligned removes any gap characters for us                                                
-                       setUnaligned(sequence); 
-                       
-                       if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
-                       
-               }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                                                       
-}
-//********************************************************************************************************************
-//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
-Sequence::Sequence(ifstream& fastaFile, string& extraInfo, bool getInfo){
-       try {
-               m = MothurOut::getInstance();
-               initialize();
-               fastaFile >> name;
-        extraInfo = "";
-               
-               if (name.length() != 0) { 
-            
-                       name = name.substr(1); 
-                       
-                       string sequence;
-            
-                       //read comments
-                       while ((name[0] == '#') && fastaFile) { 
-                               while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                               sequence = getCommentString(fastaFile);
-                               
-                               if (fastaFile) {  
-                                       fastaFile >> name;  
-                                       name = name.substr(1);  
-                               }else { 
-                                       name = "";
-                                       break;
-                               }
-                       }
-                       
-                       //read info after sequence name
-                       while (!fastaFile.eof())        {       
-                char c = fastaFile.get(); 
-                if (c == 10 || c == 13){  break;       }       
-                extraInfo += c;
-            } 
-                       
-                       int numAmbig = 0;
-                       sequence = getSequenceString(fastaFile, numAmbig);
-                       
-                       setAligned(sequence);   
-                       //setUnaligned removes any gap characters for us                                                
-                       setUnaligned(sequence); 
-                       
-                       if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
-                       
-               }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                                                       
-}
-//********************************************************************************************************************
-//this function will jump over commented out sequences, but if the last sequence in a file is commented out it makes a blank seq
-Sequence::Sequence(ifstream& fastaFile, string JustUnaligned){
-       try {
-               m = MothurOut::getInstance();
-               initialize();
-               fastaFile >> name;
-               
-               if (name.length() != 0) { 
-                       name = name.substr(1);
-                       string sequence;
-                       
-                       //read comments
-                       while ((name[0] == '#') && fastaFile) { 
-                               while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                               sequence = getCommentString(fastaFile);
-                               
-                               if (fastaFile) {  
-                                       fastaFile >> name;  
-                                       name = name.substr(1);  
-                               }else { 
-                                       name = "";
-                                       break;
-                               }
-                       }
-                       
-                       //read real sequence
-                       while (!fastaFile.eof())        {       char c = fastaFile.get(); if (c == 10 || c == 13){       break; }       } // get rest of line if there's any crap there
-                       
-                       int numAmbig = 0;
-                       sequence = getSequenceString(fastaFile, numAmbig);
-                       
-                       //setUnaligned removes any gap characters for us                                                
-                       setUnaligned(sequence); 
-                       
-                       if ((numAmbig / (float) numBases) > 0.25) { m->mothurOut("[WARNING]: We found more than 25% of the bases in sequence " + name + " to be ambiguous. Mothur is not setup to process protein sequences."); m->mothurOutEndLine(); }
-                       
-               }else{ m->mothurOut("Error in reading your fastafile, at position " + toString(fastaFile.tellg()) + ". Blank name."); m->mothurOutEndLine(); }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "Sequence");
-               exit(1);
-       }                                                       
-}
-
-//********************************************************************************************************************
-string Sequence::getSequenceString(ifstream& fastaFile, int& numAmbig) {
-       try {
-               char letter;
-               string sequence = "";   
-               numAmbig = 0;
-               
-               while(fastaFile){
-                       letter= fastaFile.get();
-                       if(letter == '>'){
-                               fastaFile.putback(letter);
-                               break;
-                       }
-                       else if(isprint(letter)){
-                               letter = toupper(letter);
-                               if(letter == 'U'){letter = 'T';}
-                               if(letter != '.' && letter != '-' && letter != 'A' && letter != 'T' && letter != 'G'  && letter != 'C' && letter != 'N'){
-                                       letter = 'N';
-                                       numAmbig++;
-                               }
-                               sequence += letter;
-                       }
-               }
-               
-               return sequence;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "getSequenceString");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-//comment can contain '>' so we need to account for that
-string Sequence::getCommentString(ifstream& fastaFile) {
-       try {
-               char letter;
-               string sequence = "";
-               
-               while(fastaFile){
-                       letter=fastaFile.get();
-                       if((letter == '\r') || (letter == '\n')){  
-                               m->gobble(fastaFile);  //in case its a \r\n situation
-                               break;
-                       }
-               }
-               
-               return sequence;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "getCommentString");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-string Sequence::getSequenceString(istringstream& fastaFile, int& numAmbig) {
-       try {
-               char letter;
-               string sequence = "";
-               numAmbig = 0;
-               
-               while(!fastaFile.eof()){
-                       letter= fastaFile.get();
-       
-                       if(letter == '>'){
-                               fastaFile.putback(letter);
-                               break;
-                       }
-                       else if(isprint(letter)){
-                               letter = toupper(letter);
-                               if(letter == 'U'){letter = 'T';}
-                               if(letter != '.' && letter != '-' && letter != 'A' && letter != 'T' && letter != 'G'  && letter != 'C' && letter != 'N'){
-                                       letter = 'N';
-                                       numAmbig++;
-                               }
-                               sequence += letter;
-                       }
-               }
-               
-               return sequence;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "getSequenceString");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-//comment can contain '>' so we need to account for that
-string Sequence::getCommentString(istringstream& fastaFile) {
-       try {
-               char letter;
-               string sequence = "";
-               
-               while(fastaFile){
-                       letter=fastaFile.get();
-                       if((letter == '\r') || (letter == '\n')){  
-                               m->gobble(fastaFile);  //in case its a \r\n situation
-                               break;
-                       }
-               }
-               
-               return sequence;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Sequence", "getCommentString");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-
-void Sequence::initialize(){
-       
-       name = "";
-       unaligned = "";
-       aligned = "";
-       pairwise = "";
-       
-       numBases = 0;
-       alignmentLength = 0;
-       isAligned = 0;
-       startPos = -1;
-       endPos = -1;
-       longHomoPolymer = -1;
-       ambigBases = -1;
-       
-}      
-
-//********************************************************************************************************************
-
-void Sequence::setName(string seqName) {
-       if(seqName[0] == '>')   {       name = seqName.substr(1);       }
-       else                                    {       name = seqName;                         }
-}
-
-//********************************************************************************************************************
-
-void Sequence::setUnaligned(string sequence){
-       
-       if(sequence.find_first_of('.') != string::npos || sequence.find_first_of('-') != string::npos) {
-               string temp = "";
-               for(int j=0;j<sequence.length();j++) {
-                       if(isalpha(sequence[j]))        {       temp += sequence[j];    }
-               }
-               unaligned = temp;
-       }
-       else {
-               unaligned = sequence;
-       }
-       numBases = unaligned.length();
-       
-}
-
-//********************************************************************************************************************
-
-void Sequence::setAligned(string sequence){
-       
-       //if the alignment starts or ends with a gap, replace it with a period to indicate missing data
-       aligned = sequence;
-       alignmentLength = aligned.length();
-       setUnaligned(sequence); 
-
-       if(aligned[0] == '-'){
-               for(int i=0;i<alignmentLength;i++){
-                       if(aligned[i] == '-'){
-                               aligned[i] = '.';
-                       }
-                       else{
-                               break;
-                       }
-               }
-               for(int i=alignmentLength-1;i>=0;i--){
-                       if(aligned[i] == '-'){
-                               aligned[i] = '.';
-                       }
-                       else{
-                               break;
-                       }
-               }
-       }
-       isAligned = 1;  
-}
-
-//********************************************************************************************************************
-
-void Sequence::setPairwise(string sequence){
-       pairwise = sequence;
-}
-
-//********************************************************************************************************************
-
-string Sequence::convert2ints() {
-       
-       if(unaligned == "")     {       /* need to throw an error */    }
-       
-       string processed;
-       
-       for(int i=0;i<unaligned.length();i++) {
-               if(toupper(unaligned[i]) == 'A')                {       processed += '0';       }
-               else if(toupper(unaligned[i]) == 'C')   {       processed += '1';       }
-               else if(toupper(unaligned[i]) == 'G')   {       processed += '2';       }
-               else if(toupper(unaligned[i]) == 'T')   {       processed += '3';       }
-               else if(toupper(unaligned[i]) == 'U')   {       processed += '3';       }
-               else                                                                    {       processed += '4';       }
-       }
-       return processed;
-}
-
-//********************************************************************************************************************
-
-string Sequence::getName(){
-       return name;
-}
-
-//********************************************************************************************************************
-
-string Sequence::getAligned(){
-       if(isAligned == 0)      { return unaligned; }
-       else                            {  return aligned;  }
-}
-
-//********************************************************************************************************************
-
-string Sequence::getInlineSeq(){
-       return name + '\t' + aligned;   
-}
-
-
-//********************************************************************************************************************
-
-string Sequence::getPairwise(){
-       return pairwise;
-}
-
-//********************************************************************************************************************
-
-string Sequence::getUnaligned(){
-       return unaligned;
-}
-
-//********************************************************************************************************************
-
-int Sequence::getNumBases(){
-       return numBases;
-}
-
-//********************************************************************************************************************
-
-void Sequence::printSequence(ostream& out){
-
-       out << ">" << name << endl;
-       if(isAligned){
-               out << aligned << endl;
-       }
-       else{
-               out << unaligned << endl;
-       }
-}
-
-//********************************************************************************************************************
-
-int Sequence::getAlignLength(){
-       return alignmentLength;
-}
-
-//********************************************************************************************************************
-
-int Sequence::getAmbigBases(){
-       if(ambigBases == -1){
-               ambigBases = 0;
-               for(int j=0;j<numBases;j++){
-                       if(unaligned[j] != 'A' && unaligned[j] != 'T' && unaligned[j] != 'G' && unaligned[j] != 'C'){
-                               ambigBases++;
-                       }
-               }
-       }       
-       
-       return ambigBases;
-}
-
-//********************************************************************************************************************
-
-void Sequence::removeAmbigBases(){
-       
-       for(int j=0;j<alignmentLength;j++){
-               if(aligned[j] != 'A' && aligned[j] != 'T' && aligned[j] != 'G' && aligned[j] != 'C'){
-                       aligned[j] = '-';
-               }
-       }
-       setUnaligned(aligned);
-}
-       
-//********************************************************************************************************************
-
-int Sequence::getLongHomoPolymer(){
-       if(longHomoPolymer == -1){
-               longHomoPolymer = 1;
-               int homoPolymer = 1;
-               for(int j=1;j<numBases;j++){
-                       if(unaligned[j] == unaligned[j-1]){
-                               homoPolymer++;
-                       }
-                       else{
-                               if(homoPolymer > longHomoPolymer){      longHomoPolymer = homoPolymer;  }
-                               homoPolymer = 1;
-                       }
-               }
-               if(homoPolymer > longHomoPolymer){      longHomoPolymer = homoPolymer;  }
-       }
-       return longHomoPolymer;
-}
-
-//********************************************************************************************************************
-
-int Sequence::getStartPos(){
-       if(startPos == -1){
-               for(int j = 0; j < alignmentLength; j++) {
-                       if(aligned[j] != '.'){
-                               startPos = j + 1;
-                               break;
-                       }
-               }
-       }
-       if(isAligned == 0){     startPos = 1;   }
-
-       return startPos;
-}
-
-//********************************************************************************************************************
-
-void Sequence::padToPos(int start){
-
-       for(int j = startPos-1; j < start-1; j++) {
-               aligned[j] = '.';
-       }
-       startPos = start;
-
-}
-//********************************************************************************************************************
-
-int Sequence::filterToPos(int start){
-    
-    if (start > aligned.length()) { start = aligned.length(); m->mothurOut("[ERROR]: start to large.\n"); }
-    
-       for(int j = 0; j < start-1; j++) {
-               aligned[j] = '.';
-       }
-       
-    //things like ......----------AT become ................AT
-    for(int j = start-1; j < aligned.length(); j++) {
-        if (isalpha(aligned[j])) { break; }
-        else { aligned[j] = '.'; }
-    }
-    setUnaligned(aligned);
-    
-    return 0;
-    
-}
-//********************************************************************************************************************
-
-int Sequence::filterFromPos(int end){
-    
-    if (end > aligned.length()) { end = aligned.length(); m->mothurOut("[ERROR]: end to large.\n"); }
-    
-       for(int j = end; j < aligned.length(); j++) {
-               aligned[j] = '.';
-       }
-       
-    for(int j = aligned.length()-1; j < 0; j--) {
-        if (isalpha(aligned[j])) { break; }
-        else { aligned[j] = '.'; }
-    }
-    
-    setUnaligned(aligned);
-    
-    return 0;
-}
-//********************************************************************************************************************
-
-int Sequence::getEndPos(){
-       if(endPos == -1){
-               for(int j=alignmentLength-1;j>=0;j--){
-                       if(aligned[j] != '.'){
-                               endPos = j + 1;
-                               break;
-                       }
-               }
-       }
-       if(isAligned == 0){     endPos = numBases;      }
-       
-       return endPos;
-}
-
-//********************************************************************************************************************
-
-void Sequence::padFromPos(int end){
-       cout << end << '\t' << endPos << endl;
-       for(int j = end; j < endPos; j++) {
-               aligned[j] = '.';
-       }
-       endPos = end;
-       
-}
-
-//********************************************************************************************************************
-
-bool Sequence::getIsAligned(){
-       return isAligned;
-}
-//********************************************************************************************************************
-
-void Sequence::reverseComplement(){
-
-       string temp;
-       for(int i=numBases-1;i>=0;i--){
-               if(unaligned[i] == 'A')         {       temp += 'T';    }
-               else if(unaligned[i] == 'T'){   temp += 'A';    }
-               else if(unaligned[i] == 'G'){   temp += 'C';    }
-               else if(unaligned[i] == 'C'){   temp += 'G';    }
-               else                                            {       temp += 'N';    }
-       }
-       unaligned = temp;
-       aligned = temp;
-       
-}
-
-//********************************************************************************************************************
-
-void Sequence::trim(int length){
-       
-       if(numBases > length){
-               unaligned = unaligned.substr(0,length);
-               numBases = length;
-       }
-       
-}
-
-///**************************************************************************************************/
diff --git a/sequence.hpp b/sequence.hpp
deleted file mode 100644 (file)
index db4c4f3..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#ifndef SEQUENCE_H
-#define SEQUENCE_H
-
-/*
- *  sequence.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     A sequence object has three components: i) an accession number / name, ii) the unaligned primary sequence, iii) a
- *     pairwise aligned sequence, and iv) a sequence that is aligned to a reference alignment.  This class has methods
- *     to set and get these values for the other classes where they are needed.  *
- *
- */
-
-
-//Data Structure for a fasta file.
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/**************************************************************************************************/
-
-class Sequence {
-public:
-       Sequence();
-       Sequence(string, string);
-       Sequence(ifstream&);
-    Sequence(ifstream&, string&, bool);
-       Sequence(istringstream&);
-       //these constructors just set the unaligned string to save space
-       Sequence(string, string, string);  
-       Sequence(ifstream&, string);
-       Sequence(istringstream&, string);
-       
-       void setName(string);
-       void setUnaligned(string);
-       void setPairwise(string);
-       void setAligned(string);
-       void setLength();
-       void reverseComplement();
-       void trim(int);
-       
-       string convert2ints();
-       string getName();
-       string getAligned();
-       string getPairwise();
-       string getUnaligned();
-       string getInlineSeq();
-       int getNumBases();
-       int getStartPos();
-       int getEndPos();
-       void padToPos(int);
-       void padFromPos(int);
-    int filterToPos(int); //any character before the pos is changed to . and aligned and unaligned strings changed
-    int filterFromPos(int); //any character after the pos is changed to . and aligned and unaligned strings changed
-       int getAlignLength();
-       int getAmbigBases();
-       void removeAmbigBases();
-       int getLongHomoPolymer();
-       bool getIsAligned();
-       void printSequence(ostream&);
-       
-private:
-       MothurOut* m;
-       void initialize();
-       string getSequenceString(ifstream&, int&);
-       string getCommentString(ifstream&);
-       string getSequenceString(istringstream&, int&);
-       string getCommentString(istringstream&);
-       string name;
-       string unaligned;
-       string aligned;
-       string pairwise;
-       int numBases;
-       int alignmentLength;
-       bool isAligned;
-       int longHomoPolymer;
-       int ambigBases;
-       int startPos, endPos;
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/sequencedb.cpp b/sequencedb.cpp
deleted file mode 100644 (file)
index e798ee1..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- *  sequencedb.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/13/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sequencedb.h"
-#include "sequence.hpp"
-#include "mothur.h"
-#include "calculator.h"
-
-
-/***********************************************************************/
-
-SequenceDB::SequenceDB() {  m = MothurOut::getInstance();  length = 0; samelength = true; }
-/***********************************************************************/
-//the clear function free's the memory
-SequenceDB::~SequenceDB() { clear(); }
-
-/***********************************************************************/
-
-SequenceDB::SequenceDB(int newSize) {
-       data.resize(newSize, Sequence());
-       length = 0; samelength = true;
-}
-
-/***********************************************************************/
-
-SequenceDB::SequenceDB(ifstream& filehandle) {
-       try{
-               length = 0; samelength = true;
-                               
-               //read through file
-               while (!filehandle.eof()) {
-                       //input sequence info into sequencedb
-                       Sequence newSequence(filehandle);
-                       
-                       if (newSequence.getName() != "") {   
-                               if (length == 0) { length = newSequence.getAligned().length(); }
-                               if (length != newSequence.getAligned().length()) { samelength = false; }
-                               data.push_back(newSequence);  
-                       }
-                       
-                       //takes care of white space
-                       m->gobble(filehandle);
-               }
-
-               filehandle.close();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "SequenceDB");
-               exit(1);
-       }
-}
-/*******************************************************************************/
-string SequenceDB::readName(ifstream& in) {
-       try{
-               string name = "";
-               int c;
-               string temp;
-               
-               while ((c = in.get()) != EOF) {
-                       //if c is not a line return
-                       if (c != 10) {
-                               name += c;
-                       }else { break;  }
-               }
-                       
-               return name;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "readName");
-               exit(1);
-       }
-}
-
-/*******************************************************************************/
-string SequenceDB::readSequence(ifstream& in) {
-       try{
-               string sequence = "";
-               string line;
-               int pos, c;
-               
-               while (!in.eof()) {
-                       //save position in file in case next line is a new name.
-                       pos = in.tellg();
-                       line = "";
-                       in >> line;                     
-                       //if you are at a new name
-                       if (line[0] == '>') {
-                               //put file pointer back since you are now at a new name
-                               in.seekg(pos, ios::beg);
-                               c = in.get();  //because you put it back to a newline char
-                               break;
-                       }else {  sequence += line;      }
-               }
-               
-               if (length == 0) { length = sequence.length(); }
-               if (length != sequence.length()) { samelength = false; }
-               
-               return sequence;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "readSequence");
-               exit(1);
-       }
-}
-       
-/***********************************************************************/
-
-int SequenceDB::getNumSeqs() {
-       return data.size();
-}
-
-/***********************************************************************/
-
-void SequenceDB::set(int index, string newUnaligned) {
-       try {
-               if (length == 0) { length = newUnaligned.length(); }
-               if (length != newUnaligned.length()) { samelength = false; }
-               
-               data[index] = Sequence(data[index].getName(), newUnaligned);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SequenceDB::set(int index, Sequence newSeq) {
-       try {
-               if (length == 0) { length = newSeq.getAligned().length(); }
-               if (length != newSeq.getAligned().length()) { samelength = false; }
-
-               data[index] = newSeq;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-Sequence SequenceDB::get(int index) {
-       return data[index];
-}
-
-/***********************************************************************/
-
-void SequenceDB::resize(int newSize) {
-       try {
-               data.resize(newSize);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "resize");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SequenceDB::clear() {
-       try {
-               data.clear();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "clear");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-int SequenceDB::size() {
-       return data.size();
-}
-
-/***********************************************************************/
-
-void SequenceDB::print(ostream& out) {
-       try {
-               for(int i = 0; i < data.size(); i++) {
-                       data[i].printSequence(out);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "print");
-               exit(1);
-       }
-}
-       
-/***********************************************************************/
-
-void SequenceDB::push_back(Sequence newSequence) {
-       try {
-               if (length == 0) { length = newSequence.getAligned().length(); }
-               if (length != newSequence.getAligned().length()) { samelength = false; }
-
-               data.push_back(newSequence);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceDB", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sequencedb.h b/sequencedb.h
deleted file mode 100644 (file)
index 8f7640e..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef SEQUENCEDB_H
-#define SEQUENCEDB_H
-
-/*
- *  sequencedb.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/13/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-/* This class is a container to store the sequences. */
-
-
-#include "sequence.hpp"
-#include "calculator.h"
-
-
-class SequenceDB {
-       
-public:
-       SequenceDB();
-       SequenceDB(int);           //makes data that size
-       SequenceDB(ifstream&);     //reads file to fill data
-       SequenceDB(const SequenceDB& sdb) : data(sdb.data) {};
-       ~SequenceDB();             //loops through data and delete each sequence
-
-       int getNumSeqs();
-       
-       void set(int, string);     //unaligned - should also set length
-       void set(int, Sequence);   //unaligned - should also set length
-       Sequence get(int);         //returns sequence name at that location
-       void push_back(Sequence);        //adds unaligned sequence
-       void resize(int);      //resizes data
-       void clear();              //clears data - remeber to loop through and delete the sequences inside or you will have a memory leak
-       int size();                //returns datas size
-       void print(ostream&);      //loops through data using sequence class print
-       bool sameLength() { return samelength; }
-               
-private:
-       vector<Sequence> data;
-       string readName(ifstream&);
-       string readSequence(ifstream&);
-       MothurOut* m;
-       bool samelength;
-       int length;
-
-};
-
-#endif
diff --git a/sequenceparser.cpp b/sequenceparser.cpp
deleted file mode 100644 (file)
index fd94b24..0000000
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- *  sequenceParser.cpp
- *  Mothur
- *
- *  Created by westcott on 9/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sequenceparser.h"
-
-
-/************************************************************/
-SequenceParser::SequenceParser(string groupFile, string fastaFile, string nameFile) {
-       try {
-               
-               m = MothurOut::getInstance();
-               int error;
-               
-               //read group file
-               groupMap = new GroupMap(groupFile);
-               error = groupMap->readMap();
-               
-               if (error == 1) { m->control_pressed = true; }
-               
-               //initialize maps
-               vector<string> namesOfGroups = groupMap->getNamesOfGroups();
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       vector<Sequence> temp;
-                       map<string, string> tempMap;
-                       seqs[namesOfGroups[i]] = temp;
-                       nameMapPerGroup[namesOfGroups[i]] = tempMap;
-               }
-               
-               //read fasta file making sure each sequence is in the group file
-               ifstream in;
-               m->openInputFile(fastaFile, in);
-               
-               map<string, string> seqName; //stores name -> sequence string so we can make new "unique" sequences when we parse the name file
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       
-                       if (seq.getName() != "") {
-                               
-                                string group = groupMap->getGroup(seq.getName());
-                                if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
-                                else { 
-                                        seqs[group].push_back(seq);    
-                                        seqName[seq.getName()] = seq.getAligned();
-                                }
-                       }
-               }
-               in.close();
-                                
-               if (error == 1) { m->control_pressed = true; }
-                                
-               //read name file
-               ifstream inName;
-               m->openInputFile(nameFile, inName);
-               
-               string first, second;
-               int countName = 0;
-               set<string> thisnames1;
-               
-               while(!inName.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       inName >> first; m->gobble(inName);
-                       inName >> second; m->gobble(inName);
-                       
-                       vector<string> names;
-                       m->splitAtChar(second, names, ',');
-                       
-                       //get aligned string for these seqs from the fasta file
-                       string alignedString = "";
-                       map<string, string>::iterator itAligned = seqName.find(names[0]);
-                       if (itAligned == seqName.end()) {
-                               error = 1; m->mothurOut("[ERROR]: " + names[0] + " is in your name file and not in your fasta file, please correct."); m->mothurOutEndLine();
-                       }else {
-                               alignedString = itAligned->second;
-                       }
-                       
-                       //separate by group - parse one line in name file
-                       map<string, string> splitMap; //group -> name1,name2,...
-                       map<string, string>::iterator it;
-                       for (int i = 0; i < names.size(); i++) {
-                               
-                               string group = groupMap->getGroup(names[i]);
-                               if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + names[i] + " is in your name file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
-                               else {  
-                                       
-                                       it = splitMap.find(group);
-                                       if (it != splitMap.end()) { //adding seqs to this group
-                                               (it->second) += "," + names[i];
-                                               thisnames1.insert(names[i]);
-                                               countName++;
-                                       }else { //first sighting of this group
-                                               splitMap[group] = names[i];
-                                               countName++;
-                                               thisnames1.insert(names[i]);
-                                               
-                                               //is this seq in the fasta file?
-                                               if (i != 0) { //if not then we need to add a duplicate sequence to the seqs for this group so the new "fasta" and "name" files will match
-                                                       Sequence tempSeq(names[i], alignedString); //get the first guys sequence string since he's in the fasta file.
-                                                       seqs[group].push_back(tempSeq);
-                                               }
-                                       }
-                               }
-                               
-                               allSeqsMap[names[i]] = names[0];
-                       }
-                       
-                       
-                       //fill nameMapPerGroup - holds all lines in namefile separated by group
-                       for (it = splitMap.begin(); it != splitMap.end(); it++) {
-                               //grab first name
-                               string firstName = "";
-                               for(int i = 0; i < (it->second).length(); i++) {
-                                       if (((it->second)[i]) != ',') {
-                                               firstName += ((it->second)[i]);
-                                       }else { break; }
-                               }
-                               
-                               //group1 -> seq1 -> seq1,seq2,seq3
-                               nameMapPerGroup[it->first][firstName] = it->second;
-                       }
-               }
-               
-               inName.close();
-               
-               if (error == 1) { m->control_pressed = true; }
-               
-               if (countName != (groupMap->getNumSeqs())) {
-                       vector<string> groupseqsnames = groupMap->getNamesSeqs();
-                       
-                       for (int i = 0; i < groupseqsnames.size(); i++) {
-                               set<string>::iterator itnamesfile = thisnames1.find(groupseqsnames[i]);
-                               if (itnamesfile == thisnames1.end()){
-                                       cout << "missing name " + groupseqsnames[i] << '\t' << allSeqsMap[groupseqsnames[i]] << endl;
-                               }
-                       }
-                       
-                       m->mothurOutEndLine();
-                       m->mothurOut("[ERROR]: Your name file contains " + toString(countName) + " valid sequences, and your groupfile contains " + toString(groupMap->getNumSeqs()) + ", please correct.");
-                       m->mothurOutEndLine();
-                       m->control_pressed = true;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "SequenceParser");
-               exit(1);
-       }
-}
-/************************************************************/
-SequenceParser::SequenceParser(string groupFile, string fastaFile) {
-       try {
-               
-               m = MothurOut::getInstance();
-               int error;
-               
-               //read group file
-               groupMap = new GroupMap(groupFile);
-               error = groupMap->readMap();
-               
-               if (error == 1) { m->control_pressed = true; }
-               
-               //initialize maps
-               vector<string> namesOfGroups = groupMap->getNamesOfGroups();
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       vector<Sequence> temp;
-                       seqs[namesOfGroups[i]] = temp;
-               }
-               
-               //read fasta file making sure each sequence is in the group file
-               ifstream in;
-               m->openInputFile(fastaFile, in);
-               int count = 0;
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       
-                       if (seq.getName() != "") {
-                               
-                               string group = groupMap->getGroup(seq.getName());
-                               if (group == "not found") {  error = 1; m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file and not in your groupfile, please correct."); m->mothurOutEndLine();  }
-                               else {  seqs[group].push_back(seq);     count++; }
-                       }
-               }
-               in.close();
-               
-               if (error == 1) { m->control_pressed = true; }
-               
-               if (count != (groupMap->getNumSeqs())) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("[ERROR]: Your fasta file contains " + toString(count) + " valid sequences, and your groupfile contains " + toString(groupMap->getNumSeqs()) + ", please correct.");
-                       if (count < (groupMap->getNumSeqs())) { m->mothurOut(" Did you forget to include the name file?"); }
-                       m->mothurOutEndLine();
-                       m->control_pressed = true;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "SequenceParser");
-               exit(1);
-       }
-}
-/************************************************************/
-SequenceParser::~SequenceParser(){ delete groupMap; }
-/************************************************************/
-int SequenceParser::getNumGroups(){ return groupMap->getNumGroups(); }
-/************************************************************/
-vector<string> SequenceParser::getNamesOfGroups(){ return groupMap->getNamesOfGroups(); }
-/************************************************************/
-bool SequenceParser::isValidGroup(string g){ return groupMap->isValidGroup(g); }
-/************************************************************/
-string SequenceParser::getGroup(string g){ return groupMap->getGroup(g); }
-/************************************************************/
-int SequenceParser::getNumSeqs(string g){ 
-       try {
-               map<string, vector<Sequence> >::iterator it;
-               int num = 0;
-               
-               it = seqs.find(g);
-               if(it == seqs.end()) {
-                       m->mothurOut("[ERROR]: " + g + " is not a valid group, please correct."); m->mothurOutEndLine();
-               }else {
-                       num = (it->second).size();
-               }
-               
-               return num; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "getNumSeqs");
-               exit(1);
-       }
-}
-/************************************************************/
-vector<Sequence> SequenceParser::getSeqs(string g){ 
-       try {
-               map<string, vector<Sequence> >::iterator it;
-               vector<Sequence> seqForThisGroup;
-               
-               it = seqs.find(g);
-               if(it == seqs.end()) {
-                       m->mothurOut("[ERROR]: No sequences available for group " + g + ", please correct."); m->mothurOutEndLine();
-               }else {
-                       seqForThisGroup = it->second;
-               }
-               
-               return seqForThisGroup; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "getSeqs");
-               exit(1);
-       }
-}
-/************************************************************/
-int SequenceParser::getSeqs(string g, string filename, bool uchimeFormat=false){ 
-       try {
-               map<string, vector<Sequence> >::iterator it;
-               vector<Sequence> seqForThisGroup;
-               vector<seqPriorityNode> nameVector;
-               
-               it = seqs.find(g);
-               if(it == seqs.end()) {
-                       m->mothurOut("[ERROR]: No sequences available for group " + g + ", please correct."); m->mothurOutEndLine();
-               }else {
-                       
-                       ofstream out;
-                       m->openOutputFile(filename, out);
-                       
-                       seqForThisGroup = it->second;
-                       
-                       if (uchimeFormat) {
-                               // format should look like 
-                               //>seqName /ab=numRedundantSeqs/
-                               //sequence
-                               
-                               map<string, string> nameMapForThisGroup = getNameMap(g);
-                               map<string, string>::iterator itNameMap;
-                               int error = 0;
-                               
-                               for (int i = 0; i < seqForThisGroup.size(); i++) {
-                                       itNameMap = nameMapForThisGroup.find(seqForThisGroup[i].getName());
-                                       
-                                       if (itNameMap == nameMapForThisGroup.end()){
-                                               error = 1;
-                                               m->mothurOut("[ERROR]: " + seqForThisGroup[i].getName() + " is in your fastafile, but is not in your namesfile, please correct."); m->mothurOutEndLine();
-                                       }else {
-                                               int num = m->getNumNames(itNameMap->second);
-                                               
-                                               seqPriorityNode temp(num, seqForThisGroup[i].getAligned(), seqForThisGroup[i].getName());
-                                               nameVector.push_back(temp);
-                                       }
-                               }
-                               
-                               if (error == 1) { out.close(); m->mothurRemove(filename); return 1; }
-                               
-                               //sort by num represented
-                               sort(nameVector.begin(), nameVector.end(), compareSeqPriorityNodes);
-
-                               //print new file in order of
-                               for (int i = 0; i < nameVector.size(); i++) {
-                                       
-                                       if(m->control_pressed) { out.close(); m->mothurRemove(filename); return 1; }
-                                       
-                                       out << ">" << nameVector[i].name  << "/ab=" << nameVector[i].numIdentical << "/" << endl << nameVector[i].seq << endl;
-                               }
-                               
-                       }else { 
-                //m->mothurOut("Group " + g +  " contains " + toString(seqForThisGroup.size()) + " unique seqs.\n");
-                               for (int i = 0; i < seqForThisGroup.size(); i++) {
-                                       
-                                       if(m->control_pressed) { out.close(); m->mothurRemove(filename); return 1; }
-                                       
-                                       seqForThisGroup[i].printSequence(out);  
-                               }
-                       }
-                       out.close();
-               }
-               
-               return 0; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "getSeqs");
-               exit(1);
-       }
-}
-
-/************************************************************/
-map<string, string> SequenceParser::getNameMap(string g){ 
-       try {
-               map<string, map<string, string> >::iterator it;
-               map<string, string> nameMapForThisGroup;
-               
-               it = nameMapPerGroup.find(g);
-               if(it == nameMapPerGroup.end()) {
-                       m->mothurOut("[ERROR]: No nameMap available for group " + g + ", please correct."); m->mothurOutEndLine();
-               }else {
-                       nameMapForThisGroup = it->second;
-               }
-               
-               return nameMapForThisGroup; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "getNameMap");
-               exit(1);
-       }
-}
-/************************************************************/
-int SequenceParser::getNameMap(string g, string filename){ 
-       try {
-               map<string, map<string, string> >::iterator it;
-               map<string, string> nameMapForThisGroup;
-               
-               it = nameMapPerGroup.find(g);
-               if(it == nameMapPerGroup.end()) {
-                       m->mothurOut("[ERROR]: No nameMap available for group " + g + ", please correct."); m->mothurOutEndLine();
-               }else {
-                       nameMapForThisGroup = it->second;
-                       
-                       ofstream out;
-                       m->openOutputFile(filename, out);
-                       
-                       for (map<string, string>::iterator itFile = nameMapForThisGroup.begin(); itFile != nameMapForThisGroup.end(); itFile++) {
-                               
-                               if(m->control_pressed) { out.close(); m->mothurRemove(filename); return 1; }
-                               
-                               out << itFile->first << '\t' << itFile->second << endl;
-                       }
-                       
-                       out.close();
-               }
-               
-               return 0; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SequenceParser", "getNameMap");
-               exit(1);
-       }
-}
-/************************************************************/
-
-
-
diff --git a/sequenceparser.h b/sequenceparser.h
deleted file mode 100644 (file)
index 23fcb9e..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef SEQUENCEPARSER_H
-#define SEQUENCEPARSER_H
-
-/*
- *  sequenceParser.h
- *  Mothur
- *
- *  Created by westcott on 9/9/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "sequence.hpp"
-#include "groupmap.h"
-
-/* This class reads a fasta and group file with a namesfile as optional and parses the data by group. 
-       Note: The sum of all the groups unique sequences will be larger than the original number of unique sequences. 
-       This is because when we parse the name file we make a unique for each group instead of 1 unique for all
-       groups. 
- */
-
-class SequenceParser {
-       
-       public:
-       
-               SequenceParser(string, string);                 //group, fasta - file mismatches will set m->control_pressed = true
-               SequenceParser(string, string, string); //group, fasta, name  - file mismatches will set m->control_pressed = true
-               ~SequenceParser();
-               
-               //general operations
-               int getNumGroups();
-               vector<string> getNamesOfGroups();      
-               bool isValidGroup(string);  //return true if string is a valid group
-               string getGroup(string);        //returns group of a specific sequence
-               
-               int getNumSeqs(string);         //returns the number of unique sequences in a specific group
-               vector<Sequence> getSeqs(string); //returns unique sequences in a specific group
-               map<string, string> getNameMap(string); //returns seqName -> namesOfRedundantSeqs separated by commas for a specific group - the name file format, but each line is parsed by group.
-               
-               int getSeqs(string, string, bool); //prints unique sequences in a specific group to a file - group, filename, uchimeFormat=false
-               int getNameMap(string, string); //print seqName -> namesOfRedundantSeqs separated by commas for a specific group - group, filename
-               
-               map<string, string> getAllSeqsMap(){ return allSeqsMap; }  //returns map where the key=sequenceName and the value=representativeSequence - helps us remove duplicates after group by group processing
-       private:
-       
-               GroupMap* groupMap;
-               MothurOut* m;
-       
-               int numSeqs;
-               map<string, string> allSeqsMap;
-               map<string, vector<Sequence> > seqs; //a vector for each group
-               map<string, map<string, string> > nameMapPerGroup; //nameMap for each group
-};
-
-#endif
-
diff --git a/setcurrentcommand.cpp b/setcurrentcommand.cpp
deleted file mode 100644 (file)
index 9673540..0000000
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
- *  setcurrentcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 3/16/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "setcurrentcommand.h"
-
-//**********************************************************************************************************************
-vector<string> SetCurrentCommand::setParameters(){     
-       try {
-               
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pflow);
-        CommandParameter pbiom("biom", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pbiom);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pcolumn);
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plist);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);            
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pdesign("design", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pdesign);
-               CommandParameter porder("order", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(porder);
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(ptree);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
-               CommandParameter prelabund("relabund", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(prelabund);
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psff);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pclear("clear", "String", "", "", "", "", "",false,false); parameters.push_back(pclear);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetCurrentCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SetCurrentCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The set.current command allows you to set the current files saved by mothur.\n";
-               helpString += "The set.current command parameters are: clear, phylip, column, list, rabund, sabund, name, group, design, order, tree, shared, ordergroup, relabund, fasta, qfile, sff, oligos, accnos, biom and taxonomy.\n";
-               helpString += "The clear paramter is used to indicate which file types you would like to clear values for, multiple types can be separated by dashes.\n";
-               helpString += "The set.current command should be in the following format: \n";
-               helpString += "set.current(fasta=yourFastaFile) or set.current(fasta=amazon.fasta, clear=name-accnos)\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetCurrentCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-SetCurrentCommand::SetCurrentCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetCurrentCommand", "SetCurrentCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SetCurrentCommand::SetCurrentCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       //valid paramters for this command
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("design");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["design"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("order");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["order"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("ordergroup");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["ordergroup"] = inputDir + it->second;               }
-                               }
-                               
-                               it = parameters.find("relabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["relabund"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("sff");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sff"] = inputDir + it->second;              }
-                               }
-                               
-                               it = parameters.find("oligos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("flow");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["flow"] = inputDir + it->second;             }
-                               }
-                
-                it = parameters.find("biom");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["biom"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { m->mothurOut("Ignoring: " + parameters["phylip"]); m->mothurOutEndLine(); phylipfile = ""; }
-                       else if (phylipfile == "not found") {  phylipfile = "";  }      
-                       if (phylipfile != "") { m->setPhylipFile(phylipfile); }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { m->mothurOut("Ignoring: " + parameters["column"]); m->mothurOutEndLine(); columnfile = ""; }
-                       else if (columnfile == "not found") {  columnfile = "";  }      
-                       if (columnfile != "") { m->setColumnFile(columnfile); }
-                       
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { m->mothurOut("Ignoring: " + parameters["list"]); m->mothurOutEndLine(); listfile = ""; }
-                       else if (listfile == "not found") {  listfile = "";  }  
-                       if (listfile != "") { m->setListFile(listfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["rabund"]); m->mothurOutEndLine(); rabundfile = ""; }
-                       else if (rabundfile == "not found") {  rabundfile = "";  }      
-                       if (rabundfile != "") { m->setRabundFile(rabundfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["sabund"]); m->mothurOutEndLine(); sabundfile = ""; }
-                       else if (sabundfile == "not found") {  sabundfile = "";  }      
-                       if (sabundfile != "") { m->setSabundFile(sabundfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { m->mothurOut("Ignoring: " + parameters["name"]); m->mothurOutEndLine(); namefile = ""; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       if (namefile != "") { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { m->mothurOut("Ignoring: " + parameters["group"]); m->mothurOutEndLine(); groupfile = ""; }
-                       else if (groupfile == "not found") {  groupfile = "";  }
-                       if (groupfile != "") { m->setGroupFile(groupfile); }
-                       
-                       designfile = validParameter.validFile(parameters, "design", true);
-                       if (designfile == "not open") { m->mothurOut("Ignoring: " + parameters["design"]); m->mothurOutEndLine(); designfile = ""; }
-                       else if (designfile == "not found") {  designfile = "";  }      
-                       if (designfile != "") { m->setDesignFile(designfile); }
-                       
-                       orderfile = validParameter.validFile(parameters, "order", true);
-                       if (orderfile == "not open") { m->mothurOut("Ignoring: " + parameters["order"]); m->mothurOutEndLine(); orderfile = ""; }
-                       else if (orderfile == "not found") {  orderfile = "";  }
-                       if (orderfile != "") { m->setOrderFile(orderfile); }
-                       
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { m->mothurOut("Ignoring: " + parameters["tree"]); m->mothurOutEndLine(); treefile = ""; }
-                       else if (treefile == "not found") {  treefile = "";  }  
-                       if (treefile != "") { m->setTreeFile(treefile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { m->mothurOut("Ignoring: " + parameters["shared"]); m->mothurOutEndLine(); sharedfile = ""; }
-                       else if (sharedfile == "not found") {  sharedfile = "";  }      
-                       if (sharedfile != "") { m->setSharedFile(sharedfile); }
-                       
-                       ordergroupfile = validParameter.validFile(parameters, "ordergroup", true);
-                       if (ordergroupfile == "not open") { m->mothurOut("Ignoring: " + parameters["ordergroup"]); m->mothurOutEndLine(); ordergroupfile = ""; }
-                       else if (ordergroupfile == "not found") {  ordergroupfile = "";  }      
-                       if (ordergroupfile != "") { m->setOrderGroupFile(ordergroupfile); }
-                       
-                       relabundfile = validParameter.validFile(parameters, "relabund", true);
-                       if (relabundfile == "not open") { m->mothurOut("Ignoring: " + parameters["relabund"]); m->mothurOutEndLine(); relabundfile = ""; }
-                       else if (relabundfile == "not found") {  relabundfile = "";  }  
-                       if (relabundfile != "") { m->setRelAbundFile(relabundfile); }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { m->mothurOut("Ignoring: " + parameters["fasta"]); m->mothurOutEndLine(); fastafile = ""; }
-                       else if (fastafile == "not found") {  fastafile = "";  }
-                       if (fastafile != "") { m->setFastaFile(fastafile); }
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { m->mothurOut("Ignoring: " + parameters["qfile"]); m->mothurOutEndLine(); qualfile = ""; }
-                       else if (qualfile == "not found") {  qualfile = "";  }  
-                       if (qualfile != "") { m->setQualFile(qualfile); }
-                       
-                       sfffile = validParameter.validFile(parameters, "sff", true);
-                       if (sfffile == "not open") { m->mothurOut("Ignoring: " + parameters["sff"]); m->mothurOutEndLine(); sfffile = ""; }
-                       else if (sfffile == "not found") {  sfffile = "";  }    
-                       if (sfffile != "") { m->setSFFFile(sfffile); }
-                       
-                       oligosfile = validParameter.validFile(parameters, "oligos", true);
-                       if (oligosfile == "not open") { m->mothurOut("Ignoring: " + parameters["oligos"]); m->mothurOutEndLine(); oligosfile = ""; }
-                       else if (oligosfile == "not found") {  oligosfile = "";  }      
-                       if (oligosfile != "") { m->setOligosFile(oligosfile); }
-                       
-                       accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { m->mothurOut("Ignoring: " + parameters["accnos"]); m->mothurOutEndLine(); accnosfile = ""; }
-                       else if (accnosfile == "not found") {  accnosfile = "";  }      
-                       if (accnosfile != "") { m->setAccnosFile(accnosfile); }
-                       
-                       taxonomyfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxonomyfile == "not open") { m->mothurOut("Ignoring: " + parameters["taxonomy"]); m->mothurOutEndLine(); taxonomyfile = ""; }
-                       else if (taxonomyfile == "not found") {  taxonomyfile = "";  }  
-                       if (taxonomyfile != "") { m->setTaxonomyFile(taxonomyfile); }
-                       
-                       flowfile = validParameter.validFile(parameters, "flow", true);
-                       if (flowfile == "not open") { m->mothurOut("Ignoring: " + parameters["flow"]); m->mothurOutEndLine(); flowfile = ""; }
-                       else if (flowfile == "not found") {  flowfile = "";  }  
-                       if (flowfile != "") { m->setFlowFile(flowfile); }
-            
-            biomfile = validParameter.validFile(parameters, "biom", true);
-                       if (biomfile == "not open") { m->mothurOut("Ignoring: " + parameters["biom"]); m->mothurOutEndLine(); biomfile = ""; }
-                       else if (biomfile == "not found") {  biomfile = "";  }  
-                       if (biomfile != "") { m->setBiomFile(biomfile); }
-                       
-                       processors = validParameter.validFile(parameters, "processors", false);
-                       if (processors == "not found") {  processors = "1";  }  
-                       if (processors != "") { m->setProcessors(processors); }
-                       
-                       clearTypes = validParameter.validFile(parameters, "clear", false);                      
-                       if (clearTypes == "not found") { clearTypes = ""; }
-                       else { m->splitAtDash(clearTypes, types);       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetCurrentCommand", "SetCurrentCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SetCurrentCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //user wants to clear a type
-               if (types.size() != 0) {
-                       for (int i = 0; i < types.size(); i++) {
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               //look for file types
-                               if (types[i] == "fasta") {
-                                       m->setFastaFile("");
-                               }else if (types[i] == "qfile") {
-                                       m->setQualFile("");
-                               }else if (types[i] == "phylip") {
-                                       m->setPhylipFile("");
-                               }else if (types[i] == "column") {
-                                       m->setColumnFile("");
-                               }else if (types[i] == "list") {
-                                       m->setListFile("");
-                               }else if (types[i] == "rabund") {
-                                       m->setRabundFile("");
-                               }else if (types[i] == "sabund") {
-                                       m->setSabundFile("");
-                               }else if (types[i] == "name") {
-                                       m->setNameFile("");
-                               }else if (types[i] == "group") {
-                                       m->setGroupFile("");
-                               }else if (types[i] == "order") {
-                                       m->setOrderFile("");
-                               }else if (types[i] == "ordergroup") {
-                                       m->setOrderGroupFile("");
-                               }else if (types[i] == "tree") {
-                                       m->setTreeFile("");
-                               }else if (types[i] == "shared") {
-                                       m->setSharedFile("");
-                               }else if (types[i] == "relabund") {
-                                       m->setRelAbundFile("");
-                               }else if (types[i] == "design") {
-                                       m->setDesignFile("");
-                               }else if (types[i] == "sff") {
-                                       m->setSFFFile("");
-                               }else if (types[i] == "oligos") {
-                                       m->setOligosFile("");
-                               }else if (types[i] == "accnos") {
-                                       m->setAccnosFile("");
-                               }else if (types[i] == "taxonomy") {
-                                       m->setTaxonomyFile("");
-                               }else if (types[i] == "flow") {
-                                       m->setFlowFile("");
-                }else if (types[i] == "biom") {
-                                       m->setBiomFile("");
-                               }else if (types[i] == "processors") {
-                                       m->setProcessors("1");
-                               }else if (types[i] == "all") {
-                                       m->clearCurrentFiles();
-                               }else {
-                                       m->mothurOut("[ERROR]: mothur does not save a current file for " + types[i]); m->mothurOutEndLine();
-                               }
-                       }
-               }
-               
-               m->mothurOutEndLine(); m->mothurOut("Current files saved by mothur:"); m->mothurOutEndLine();
-               m->printCurrentFiles();
-               
-               return 0;       
-       }
-       
-       catch(exception& e) {
-               m->errorOut(e, "SetCurrentCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
diff --git a/setcurrentcommand.h b/setcurrentcommand.h
deleted file mode 100644 (file)
index 3949519..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef SETCURRENTCOMMAND_H
-#define SETCURRENTCOMMAND_H
-
-/*
- *  setcurrentcommand.h
- *  Mothur
- *
- *  Created by westcott on 3/16/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-
-class SetCurrentCommand : public Command {
-       
-public:
-       SetCurrentCommand(string);
-       SetCurrentCommand();
-       ~SetCurrentCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "set.current"; }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Set.current"; }
-       string getDescription()         { return "set current files for mothur"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       vector<string> outputNames;
-       bool abort;
-       
-       string clearTypes;
-       vector<string> types;
-       
-       string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile, biomfile;
-       string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
-
-       
-};
-
-#endif
-
-
diff --git a/setdircommand.cpp b/setdircommand.cpp
deleted file mode 100644 (file)
index 55b752d..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- *  setoutdircommand.cpp
- *  Mothur
- *
- *  Created by westcott on 1/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "setdircommand.h"
-
-//**********************************************************************************************************************
-vector<string> SetDirectoryCommand::setParameters(){   
-       try {
-               CommandParameter ptempdefault("tempdefault", "String", "", "", "", "", "",false,false); parameters.push_back(ptempdefault);     
-               CommandParameter pinput("input", "String", "", "", "", "", "",false,false); parameters.push_back(pinput);
-               CommandParameter poutput("output", "String", "", "", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetDirectoryCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SetDirectoryCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The set.dir command can be used to direct the output files generated by mothur to a specific place, the directory must exist.\n";
-               helpString += "The set.dir command can also be used to specify the directory where your input files are located, the directory must exist.\n";
-               helpString += "The set.dir command can also be used to override or set the default location mothur will look for files if it is unable to find them, the directory must exist.\n";
-               helpString += "The set.dir command parameters are input, output and tempdefault and one is required.\n";
-               helpString += "To return the output to the same directory as the input files you may enter: output=clear.\n";
-               helpString += "To return the input to the current working directory you may enter: input=clear.\n";
-               helpString += "To set the output to the directory where mothur.exe is located you may enter: output=default.\n";
-               helpString += "To set the input to the directory where mothur.exe is located you may enter: input=default.\n";
-               helpString += "To return the tempdefault to the default you provided at compile time you may enter: tempdefault=clear.\n";
-               helpString += "To set the tempdefault to the directory where mothur.exe is located you may enter: tempdefault=default.\n";
-               helpString += "The set.dir command should be in the following format: set.dir(output=yourOutputDirectory, input=yourInputDirectory, tempdefault=yourTempDefault).\n";
-               helpString += "Example set.outdir(output=/Users/lab/desktop/outputs, input=/Users/lab/desktop/inputs).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. output), '=' and parameters (i.e.yourOutputDirectory).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetDirectoryCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SetDirectoryCommand::SetDirectoryCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-               
-                       output = validParameter.validFile(parameters, "output", false);                 
-                       if (output == "not found") {  output = "";  } 
-                       
-                       input = validParameter.validFile(parameters, "input", false);                   
-                       if (input == "not found") {  input = "";  }
-                       
-                       tempdefault = validParameter.validFile(parameters, "tempdefault", false);                       
-                       if (tempdefault == "not found") {  tempdefault = "";  }
-                               
-                       if ((input == "") && (output == "") && (tempdefault == "")) {   
-                               m->mothurOut("You must provide either an input, output or tempdefault for the set.outdir command."); m->mothurOutEndLine(); abort = true;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetDirectoryCommand", "SetDirectoryCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SetDirectoryCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               commandFactory = CommandFactory::getInstance();
-               
-               m->mothurOut("Mothur's directories:"); m->mothurOutEndLine();
-               
-               //redirect output
-               if ((output == "clear") || (output == "")) {  output = "";  commandFactory->setOutputDirectory(output);  }
-               else if (output == "default") { 
-                       string exepath = m->argv;
-                       output = exepath.substr(0, (exepath.find_last_of('m')));
-                       
-                       m->mothurOut("outputDir=" + output); m->mothurOutEndLine();  
-                       commandFactory->setOutputDirectory(output);
-               }else {
-            if (m->dirCheck(output)) {
-                m->mothurOut("outputDir=" + output); m->mothurOutEndLine();  
-                               commandFactory->setOutputDirectory(output);
-            }
-               }
-               
-               //redirect input
-               if ((input == "clear") || (input == "")) {  input = "";  commandFactory->setInputDirectory(input);  }
-               else if (input == "default") { 
-                       string exepath = m->argv;
-                       input = exepath.substr(0, (exepath.find_last_of('m')));
-                       
-                       m->mothurOut("inputDir=" + input); m->mothurOutEndLine();  
-                       commandFactory->setInputDirectory(input);
-               }else {
-            if (m->dirCheck(input)) {
-                m->mothurOut("inputDir=" + input); m->mothurOutEndLine();  
-                               commandFactory->setInputDirectory(input); 
-            }
-        }
-               
-               //set default
-               if (tempdefault == "clear") {  
-                       #ifdef MOTHUR_FILES
-                               string temp = MOTHUR_FILES; 
-                               m->mothurOut("tempDefault=" + temp); m->mothurOutEndLine();  
-                               m->setDefaultPath(temp);
-                       #else
-                               string temp = ""; 
-                               m->mothurOut("No default directory defined at compile time."); m->mothurOutEndLine();  
-                               m->setDefaultPath(temp);
-                       #endif
-               }else if (tempdefault == "") {  //do nothing
-               }else if (tempdefault == "default") { 
-                       string exepath = m->argv;
-                       tempdefault = exepath.substr(0, (exepath.find_last_of('m')));
-                       
-                       m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();  
-                       m->setDefaultPath(tempdefault);
-               }else {
-            if (m->dirCheck(tempdefault)) {
-                m->mothurOut("tempDefault=" + tempdefault); m->mothurOutEndLine();  
-                               m->setDefaultPath(tempdefault); 
-            }
-        }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetDirectoryCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************/
diff --git a/setdircommand.h b/setdircommand.h
deleted file mode 100644 (file)
index b3b00c4..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef SETDIRCOMMAND_H
-#define SETDIRCOMMAND_H
-
-/*
- *  setoutdircommand.h
- *  Mothur
- *
- *  Created by westcott on 1/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-/**********************************************************/
-
-class SetDirectoryCommand : public Command {
-       
-public:
-       SetDirectoryCommand(string);
-       SetDirectoryCommand() { abort = true; calledHelp = true; setParameters(); }
-       ~SetDirectoryCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "set.dir";             }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Set.dir"; }
-       string getDescription()         { return "set input, output and default directories"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       CommandFactory* commandFactory;
-       string output, input, tempdefault;
-       bool abort;
-       vector<string> outputNames;
-       
-               
-};
-
-/**********************************************************/
-#endif
-
diff --git a/setlogfilecommand.cpp b/setlogfilecommand.cpp
deleted file mode 100644 (file)
index 576a37c..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *  setlogfilecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 4/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "setlogfilecommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> SetLogFileCommand::setParameters(){     
-       try {
-               CommandParameter pappend("append", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pappend);
-               CommandParameter pname("name", "String", "", "", "", "", "",false,true); parameters.push_back(pname);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetLogFileCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SetLogFileCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The set.logfile command can be used to provide a specific name for your logfile and/or to append the log generated by mothur to an existing file.\n";
-               helpString += "The set.logfile command parameters are name and append, name is required. Append is set to false by default.\n";
-               helpString += "The set.logfile command should be in the following format: set.logfile(name=yourLogFileName, append=T).\n";
-               helpString += "Example set.logfile(name=/Users/lab/desktop/output.txt, append=T).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. name), '=' and parameters (i.e.yourLogFileName).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetLogFileCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SetLogFileCommand::SetLogFileCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-               
-                       name = validParameter.validFile(parameters, "name", false);                     
-                       if (name == "not found") {  m->mothurOut("name is a required parameter for the set.logfile command."); abort = true; } 
-                       
-                       string temp = validParameter.validFile(parameters, "append", false);            if (temp == "not found") {  temp = "F";  }
-                       append = m->isTrue(temp);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetLogFileCommand", "SetLogFileCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int SetLogFileCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               commandFactory = CommandFactory::getInstance();
-               
-               commandFactory->setLogfileName(name, append);
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SetLogFileCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************/
diff --git a/setlogfilecommand.h b/setlogfilecommand.h
deleted file mode 100644 (file)
index 8d3bfcd..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef SETLOGFILECOMMAND_H
-#define SETLOGFILECOMMAND_H
-
-/*
- *  setlogfilecommand.h
- *  Mothur
- *
- *  Created by westcott on 4/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "commandfactory.hpp"
-
-/**********************************************************/
-
-class SetLogFileCommand : public Command {
-       
-public:
-       SetLogFileCommand(string);
-       SetLogFileCommand() { setParameters(); abort = true; calledHelp = true; }
-       ~SetLogFileCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "set.logfile";         }
-       string getCommandCategory()             { return "General";                     }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Set.logfile"; }
-       string getDescription()         { return "set logfile name"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       CommandFactory* commandFactory;
-       string name;
-       bool abort, append;
-       vector<string> outputNames;
-               
-};
-
-/**********************************************************/
-#endif
-
-
diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp
deleted file mode 100644 (file)
index 20caead..0000000
+++ /dev/null
@@ -1,1159 +0,0 @@
-/*
- *  sffinfocommand.cpp
- *  Mothur
- *
- *  Created by westcott on 7/7/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sffinfocommand.h"
-#include "endiannessmacros.h"
-
-//**********************************************************************************************************************
-vector<string> SffInfoCommand::setParameters(){        
-       try {           
-               CommandParameter psff("sff", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(psff);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-               CommandParameter psfftxt("sfftxt", "String", "", "", "", "", "",false,false); parameters.push_back(psfftxt);
-               CommandParameter pflow("flow", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pflow);
-               CommandParameter ptrim("trim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(ptrim);
-               CommandParameter pfasta("fasta", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pqfile("name", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqfile);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SffInfoCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The sffinfo command reads a sff file and extracts the sequence data, or you can use it to parse a sfftxt file.\n";
-               helpString += "The sffinfo command parameters are sff, fasta, qfile, accnos, flow, sfftxt, and trim. sff is required. \n";
-               helpString += "The sff parameter allows you to enter the sff file you would like to extract data from.  You may enter multiple files by separating them by -'s.\n";
-               helpString += "The fasta parameter allows you to indicate if you would like a fasta formatted file generated.  Default=True. \n";
-               helpString += "The qfile parameter allows you to indicate if you would like a quality file generated.  Default=True. \n";
-               helpString += "The flow parameter allows you to indicate if you would like a flowgram file generated.  Default=True. \n";
-               helpString += "The sfftxt parameter allows you to indicate if you would like a sff.txt file generated.  Default=False. \n";
-               helpString += "If you want to parse an existing sfftxt file into flow, fasta and quality file, enter the file name using the sfftxt parameter. \n";
-               helpString += "The trim parameter allows you to indicate if you would like a sequences and quality scores trimmed to the clipQualLeft and clipQualRight values.  Default=True. \n";
-               helpString += "The accnos parameter allows you to provide a accnos file containing the names of the sequences you would like extracted. You may enter multiple files by separating them by -'s. \n";
-               helpString += "Example sffinfo(sff=mySffFile.sff, trim=F).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. sff), '=' and parameters (i.e.yourSffFileName).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-SffInfoCommand::SffInfoCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["flow"] = tempOutNames;
-               outputTypes["sfftxt"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SffInfoCommand::SffInfoCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               hasAccnos = false;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       //valid paramters for this command
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["flow"] = tempOutNames;
-                       outputTypes["sfftxt"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);        if (inputDir == "not found"){ inputDir = "";          }
-
-                       sffFilename = validParameter.validFile(parameters, "sff", false);
-                       if (sffFilename == "not found") { sffFilename = "";  }
-                       else { 
-                               m->splitAtDash(sffFilename, filenames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < filenames.size(); i++) {
-                                       bool ignore = false;
-                                       if (filenames[i] == "current") { 
-                                               filenames[i] = m->getSFFFile(); 
-                                               if (filenames[i] != "") {  m->mothurOut("Using " + filenames[i] + " as input file for the sff parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current sfffile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       filenames.erase(filenames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(filenames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       filenames[i] = inputDir + filenames[i];         }
-                                               }
-               
-                                               ifstream in;
-                                               int ableToOpen = m->openInputFile(filenames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(filenames[i]);
-                                                               m->mothurOut("Unable to open " + filenames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               filenames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(filenames[i]);
-                                                               m->mothurOut("Unable to open " + filenames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               filenames[i] = tryPath;
-                                                       }
-                                               }
-                                               
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + filenames[i] + ". It will be disregarded."); m->mothurOutEndLine();
-                                                       //erase from file list
-                                                       filenames.erase(filenames.begin()+i);
-                                                       i--;
-                                               }else { m->setSFFFile(filenames[i]); }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (filenames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       accnosName = validParameter.validFile(parameters, "accnos", false);
-                       if (accnosName == "not found") { accnosName = "";  }
-                       else { 
-                               hasAccnos = true;
-                               m->splitAtDash(accnosName, accnosFileNames);
-                               
-                               //go through files and make sure they are good, if not, then disregard them
-                               for (int i = 0; i < accnosFileNames.size(); i++) {
-                                       bool ignore = false;
-                                       if (accnosFileNames[i] == "current") { 
-                                               accnosFileNames[i] = m->getAccnosFile(); 
-                                               if (accnosFileNames[i] != "") {  m->mothurOut("Using " + accnosFileNames[i] + " as input file for the accnos parameter where you had given current."); m->mothurOutEndLine(); }
-                                               else {  
-                                                       m->mothurOut("You have no current accnosfile, ignoring current."); m->mothurOutEndLine(); ignore=true; 
-                                                       //erase from file list
-                                                       accnosFileNames.erase(accnosFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                                       
-                                       if (!ignore) {
-                                       
-                                               if (inputDir != "") {
-                                                       string path = m->hasPath(accnosFileNames[i]);
-                                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                                       if (path == "") {       accnosFileNames[i] = inputDir + accnosFileNames[i];             }
-                                               }
-               
-                                               ifstream in;
-                                               int ableToOpen = m->openInputFile(accnosFileNames[i], in, "noerror");
-                                       
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getDefaultPath() != "") { //default path is set
-                                                               string tryPath = m->getDefaultPath() + m->getSimpleName(accnosFileNames[i]);
-                                                               m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               accnosFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               //if you can't open it, try default location
-                                               if (ableToOpen == 1) {
-                                                       if (m->getOutputDir() != "") { //default path is set
-                                                               string tryPath = m->getOutputDir() + m->getSimpleName(accnosFileNames[i]);
-                                                               m->mothurOut("Unable to open " + accnosFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                                               ifstream in2;
-                                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                                               in2.close();
-                                                               accnosFileNames[i] = tryPath;
-                                                       }
-                                               }
-                                               in.close();
-                                               
-                                               if (ableToOpen == 1) { 
-                                                       m->mothurOut("Unable to open " + accnosFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine();
-                                                       //erase from file list
-                                                       accnosFileNames.erase(accnosFileNames.begin()+i);
-                                                       i--;
-                                               }
-                                       }
-                               }
-                               
-                               //make sure there is at least one valid file left
-                               if (accnosFileNames.size() == 0) { m->mothurOut("no valid files."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       
-                       if (hasAccnos) {
-                               if (accnosFileNames.size() != filenames.size()) { abort = true; m->mothurOut("If you provide a accnos file, you must have one for each sff file."); m->mothurOutEndLine(); }
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "qfile", false);                     if (temp == "not found"){       temp = "T";                             }
-                       qual = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "fasta", false);                            if (temp == "not found"){       temp = "T";                             }
-                       fasta = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "flow", false);                                     if (temp == "not found"){       temp = "T";                             }
-                       flow = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "trim", false);                                     if (temp == "not found"){       temp = "T";                             }
-                       trim = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "sfftxt", false);                           
-                       if (temp == "not found")        {       temp = "F";      sfftxt = false; sfftxtFilename = "";           }
-                       else if (m->isTrue(temp))       {       sfftxt = true;          sfftxtFilename = "";                            }
-                       else {
-                               //you are a filename
-                               if (inputDir != "") {
-                                       map<string,string>::iterator it = parameters.find("sfftxt");
-                                       //user has given a template file
-                                       if(it != parameters.end()){ 
-                                               string path = m->hasPath(it->second);
-                                               //if the user has not given a path then, add inputdir. else leave path alone.
-                                               if (path == "") {       parameters["sfftxt"] = inputDir + it->second;           }
-                                       }
-                               }
-                               
-                               sfftxtFilename = validParameter.validFile(parameters, "sfftxt", true);
-                               if (sfftxtFilename == "not found") { sfftxtFilename = "";  }
-                               else if (sfftxtFilename == "not open") { sfftxtFilename = "";  }
-                       }
-                       
-                       if ((sfftxtFilename == "") && (filenames.size() == 0)) {  
-                               //if there is a current sff file, use it
-                               string filename = m->getSFFFile(); 
-                               if (filename != "") { filenames.push_back(filename); m->mothurOut("Using " + filename + " as input file for the sff parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("[ERROR]: you must provide a valid sff or sfftxt file."); m->mothurOutEndLine(); abort=true;  }
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "SffInfoCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               for (int s = 0; s < filenames.size(); s++) {
-                       
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } return 0; }
-                       
-                       int start = time(NULL);
-                       
-                       m->mothurOut("Extracting info from " + filenames[s] + " ..." ); m->mothurOutEndLine();
-                       
-                       string accnos = "";
-                       if (hasAccnos) { accnos = accnosFileNames[s]; }
-                       
-                       int numReads = extractSffInfo(filenames[s], accnos);
-
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to extract " + toString(numReads) + ".");
-               }
-               
-               if (sfftxtFilename != "") {  parseSffTxt(); }
-               
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("qfile");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-               }
-               
-               itTypes = outputTypes.find("flow");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFlowFile(current); }
-               }
-               
-               //report output filenames
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::extractSffInfo(string input, string accnos){
-       try {
-               
-               if (outputDir == "") {  outputDir += m->hasPath(input); }
-               
-               if (accnos != "")       {  readAccnosFile(accnos);  }
-               else                            {       seqNames.clear();               }
-
-               ofstream outSfftxt, outFasta, outQual, outFlow;
-               string outFastaFileName, outQualFileName;
-        string rootName = outputDir + m->getRootName(m->getSimpleName(input));
-        if(rootName.find_last_of(".") == rootName.npos){ rootName += "."; }
-        
-               string sfftxtFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "sff.txt";
-               string outFlowFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "flow";
-               if (trim) {
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "qual";
-               }else{
-                       outFastaFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.fasta";
-                       outQualFileName = outputDir + m->getRootName(m->getSimpleName(input)) + "raw.qual";
-               }
-               
-               if (sfftxt) { m->openOutputFile(sfftxtFileName, outSfftxt); outSfftxt.setf(ios::fixed, ios::floatfield); outSfftxt.setf(ios::showpoint);  outputNames.push_back(sfftxtFileName);  outputTypes["sfftxt"].push_back(sfftxtFileName); }
-               if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
-               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qfile"].push_back(outQualFileName);  }
-               if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  outFlow.setf(ios::fixed, ios::floatfield); outFlow.setf(ios::showpoint); outputTypes["flow"].push_back(outFlowFileName);  }
-               
-               ifstream in;
-               in.open(input.c_str(), ios::binary);
-               
-               CommonHeader header; 
-               readCommonHeader(in, header);
-       
-               int count = 0;
-               mycount = 0;
-               
-               //check magic number and version
-               if (header.magicNumber != 779314790) { m->mothurOut("Magic Number is not correct, not a valid .sff file"); m->mothurOutEndLine(); return count; }
-               if (header.version != "0001") { m->mothurOut("Version is not supported, only support version 0001."); m->mothurOutEndLine(); return count; }
-       
-               //print common header
-               if (sfftxt) {   printCommonHeader(outSfftxt, header);           }
-               if (flow)       {       outFlow << header.numFlowsPerRead << endl;      }
-                       
-               //read through the sff file
-               while (!in.eof()) {
-                       
-                       bool print = true;
-                       
-                       //read header
-                       Header readheader;
-                       readHeader(in, readheader);
-                       
-                       //read data
-                       seqRead read; 
-                       readSeqData(in, read, header.numFlowsPerRead, readheader.numBases);
-            bool okay = sanityCheck(readheader, read);
-            if (!okay) { break; }
-            
-                       //if you have provided an accosfile and this seq is not in it, then dont print
-                       if (seqNames.size() != 0) {   if (seqNames.count(readheader.name) == 0) { print = false; }  }
-                       
-                       //print 
-                       if (print) {
-                               if (sfftxt) { printHeader(outSfftxt, readheader); printSffTxtSeqData(outSfftxt, read, readheader); }
-                               if (fasta)      {       printFastaSeqData(outFasta, read, readheader);  }
-                               if (qual)       {       printQualSeqData(outQual, read, readheader);    }
-                               if (flow)       {       printFlowSeqData(outFlow, read, readheader);    }
-                       }
-                       
-                       count++;
-                       mycount++;
-               
-                       //report progress
-                       if((count+1) % 10000 == 0){     m->mothurOut(toString(count+1)); m->mothurOutEndLine();         }
-               
-                       if (m->control_pressed) { count = 0; break;   }
-                       
-                       if (count >= header.numReads) { break; }
-               }
-               
-               //report progress
-               if (!m->control_pressed) {   if((count) % 10000 != 0){  m->mothurOut(toString(count)); m->mothurOutEndLine();           }  }
-               
-               in.close();
-               
-               if (sfftxt) {  outSfftxt.close();       }
-               if (fasta)      {  outFasta.close();    }
-               if (qual)       {  outQual.close();             }
-               if (flow)       {  outFlow.close();             }
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "extractSffInfo");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::readCommonHeader(ifstream& in, CommonHeader& header){
-       try {
-
-               if (!in.eof()) {
-
-                       //read magic number
-                       char buffer[4];
-                       in.read(buffer, 4);
-                       header.magicNumber = be_int4(*(unsigned int *)(&buffer));
-               
-                       //read version
-                       char buffer9[4];
-                       in.read(buffer9, 4);
-                       header.version = "";
-                       for (int i = 0; i < 4; i++) {  header.version += toString((int)(buffer9[i])); }
-                               
-                       //read offset
-                       char buffer2 [8];
-                       in.read(buffer2, 8);
-                       header.indexOffset =  be_int8(*(unsigned long long *)(&buffer2));
-                       
-                       //read index length
-                       char buffer3 [4];
-                       in.read(buffer3, 4);
-                       header.indexLength =  be_int4(*(unsigned int *)(&buffer3));
-                       
-                       //read num reads
-                       char buffer4 [4];
-                       in.read(buffer4, 4);
-                       header.numReads =  be_int4(*(unsigned int *)(&buffer4));
-                               
-                       //read header length
-                       char buffer5 [2];
-                       in.read(buffer5, 2);
-                       header.headerLength =  be_int2(*(unsigned short *)(&buffer5));
-                                       
-                       //read key length
-                       char buffer6 [2];
-                       in.read(buffer6, 2);
-                       header.keyLength = be_int2(*(unsigned short *)(&buffer6));
-                       
-                       //read number of flow reads
-                       char buffer7 [2];
-                       in.read(buffer7, 2);
-                       header.numFlowsPerRead =  be_int2(*(unsigned short *)(&buffer7));
-                               
-                       //read format code
-                       char buffer8 [1];
-                       in.read(buffer8, 1);
-                       header.flogramFormatCode = (int)(buffer8[0]);
-                       
-                       //read flow chars
-                       char* tempBuffer = new char[header.numFlowsPerRead];
-                       in.read(&(*tempBuffer), header.numFlowsPerRead); 
-                       header.flowChars = tempBuffer;
-                       if (header.flowChars.length() > header.numFlowsPerRead) { header.flowChars = header.flowChars.substr(0, header.numFlowsPerRead);  }
-                       delete[] tempBuffer;
-                       
-                       //read key
-                       char* tempBuffer2 = new char[header.keyLength];
-                       in.read(&(*tempBuffer2), header.keyLength);
-                       header.keySequence = tempBuffer2;
-                       if (header.keySequence.length() > header.keyLength) { header.keySequence = header.keySequence.substr(0, header.keyLength);  }
-                       delete[] tempBuffer2;
-                               
-                       /* Pad to 8 chars */
-                       unsigned long long spotInFile = in.tellg();
-                       unsigned long long spot = (spotInFile + 7)& ~7;  // ~ inverts
-                       in.seekg(spot);
-                       
-               }else{
-                       m->mothurOut("Error reading sff common header."); m->mothurOutEndLine();
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "readCommonHeader");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::readHeader(ifstream& in, Header& header){
-       try {
-       
-               if (!in.eof()) {
-                       
-                       //read header length
-                       char buffer [2];
-                       in.read(buffer, 2);
-                       header.headerLength = be_int2(*(unsigned short *)(&buffer));
-                                               
-                       //read name length
-                       char buffer2 [2];
-                       in.read(buffer2, 2);
-                       header.nameLength = be_int2(*(unsigned short *)(&buffer2));
-
-                       //read num bases
-                       char buffer3 [4];
-                       in.read(buffer3, 4);
-                       header.numBases =  be_int4(*(unsigned int *)(&buffer3));
-                       
-                       //read clip qual left
-                       char buffer4 [2];
-                       in.read(buffer4, 2);
-                       header.clipQualLeft =  be_int2(*(unsigned short *)(&buffer4));
-                       header.clipQualLeft = 5; 
-                       
-                       //read clip qual right
-                       char buffer5 [2];
-                       in.read(buffer5, 2);
-                       header.clipQualRight =  be_int2(*(unsigned short *)(&buffer5));
-                       
-                       //read clipAdapterLeft
-                       char buffer6 [2];
-                       in.read(buffer6, 2);
-                       header.clipAdapterLeft = be_int2(*(unsigned short *)(&buffer6));
-
-                       //read clipAdapterRight
-                       char buffer7 [2];
-                       in.read(buffer7, 2);
-                       header.clipAdapterRight = be_int2(*(unsigned short *)(&buffer7));
-               
-                       //read name
-                       char* tempBuffer = new char[header.nameLength];
-                       in.read(&(*tempBuffer), header.nameLength);
-                       header.name = tempBuffer;
-                       if (header.name.length() > header.nameLength) { header.name = header.name.substr(0, header.nameLength);  }
-                       delete[] tempBuffer;
-                       
-                       //extract info from name
-                       decodeName(header.timestamp, header.region, header.xy, header.name);
-                       
-                       /* Pad to 8 chars */
-                       unsigned long long spotInFile = in.tellg();
-                       unsigned long long spot = (spotInFile + 7)& ~7;
-                       in.seekg(spot);
-                       
-               }else{
-                       m->mothurOut("Error reading sff header info."); m->mothurOutEndLine();
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "readHeader");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, int numBases){
-       try {
-       
-               if (!in.eof()) {
-       
-                       //read flowgram
-                       read.flowgram.resize(numFlowReads);
-                       for (int i = 0; i < numFlowReads; i++) {  
-                               char buffer [2];
-                               in.read(buffer, 2);
-                               read.flowgram[i] = be_int2(*(unsigned short *)(&buffer));
-                       }
-            
-                       //read flowIndex
-                       read.flowIndex.resize(numBases);
-                       for (int i = 0; i < numBases; i++) {  
-                               char temp[1];
-                               in.read(temp, 1);
-                               read.flowIndex[i] = be_int1(*(unsigned char *)(&temp));
-                       }
-       
-                       //read bases
-                       char* tempBuffer = new char[numBases];
-                       in.read(&(*tempBuffer), numBases);
-                       read.bases = tempBuffer;
-                       if (read.bases.length() > numBases) { read.bases = read.bases.substr(0, numBases);  }
-                       delete[] tempBuffer;
-
-                       //read qual scores
-                       read.qualScores.resize(numBases);
-                       for (int i = 0; i < numBases; i++) {  
-                               char temp[1];
-                               in.read(temp, 1);
-                               read.qualScores[i] = be_int1(*(unsigned char *)(&temp));
-                       }
-       
-                       /* Pad to 8 chars */
-                       unsigned long long spotInFile = in.tellg();
-                       unsigned long long spot = (spotInFile + 7)& ~7;
-                       in.seekg(spot);
-                       
-               }else{
-                       m->mothurOut("Error reading."); m->mothurOutEndLine();
-               }
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "readSeqData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::decodeName(string& timestamp, string& region, string& xy, string name) {
-       try {
-               
-               if (name.length() >= 6) {
-                       string time = name.substr(0, 6);
-                       unsigned int timeNum = m->fromBase36(time);
-                       
-                       int q1 = timeNum / 60;
-                       int sec = timeNum - 60 * q1;
-                       int q2 = q1 / 60;
-                       int minute = q1 - 60 * q2;
-                       int q3 = q2 / 24;
-                       int hr = q2 - 24 * q3;
-                       int q4 = q3 / 32;
-                       int day = q3 - 32 * q4;
-                       int q5 = q4 / 13;
-                       int mon = q4 - 13 * q5;
-                       int year = 2000 + q5;
-               
-                       timestamp = toString(year) + "_" + toString(mon) + "_" + toString(day) + "_" + toString(hr) + "_" + toString(minute) + "_" + toString(sec);
-               }
-               
-               if (name.length() >= 9) {
-                       region = name.substr(7, 2);
-               
-                       string xyNum = name.substr(9);
-                       unsigned int myXy = m->fromBase36(xyNum);
-                       int x = myXy >> 12;
-                       int y = myXy & 4095;
-               
-                       xy = toString(x) + "_" + toString(y);
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "decodeName");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::printCommonHeader(ofstream& out, CommonHeader& header) {
-       try {
-       
-               out << "Common Header:\nMagic Number: " << header.magicNumber << endl;
-               out << "Version: " << header.version << endl;
-               out << "Index Offset: " << header.indexOffset << endl;
-               out << "Index Length: " << header.indexLength << endl;
-               out << "Number of Reads: " << header.numReads << endl;
-               out << "Header Length: " << header.headerLength << endl;
-               out << "Key Length: " << header.keyLength << endl;
-               out << "Number of Flows: " << header.numFlowsPerRead << endl;
-               out << "Format Code: " << header.flogramFormatCode << endl;
-               out << "Flow Chars: " << header.flowChars << endl;
-               out << "Key Sequence: " << header.keySequence << endl << endl;
-                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printCommonHeader");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::printHeader(ofstream& out, Header& header) {
-       try {
-               
-               out << ">" << header.name << endl;
-               out << "Run Prefix: " << header.timestamp << endl;
-               out << "Region #:  " << header.region << endl;
-               out << "XY Location: " << header.xy << endl << endl;
-               
-               out << "Run Name:  " << endl;
-               out << "Analysis Name:  " << endl;
-               out << "Full Path: " << endl << endl;
-               
-               out << "Read Header Len: " << header.headerLength << endl;
-               out << "Name Length: " << header.nameLength << endl;
-               out << "# of Bases: " << header.numBases << endl;
-               out << "Clip Qual Left: " << header.clipQualLeft << endl;
-               out << "Clip Qual Right: " << header.clipQualRight << endl;
-               out << "Clip Adap Left: " << header.clipAdapterLeft << endl;
-               out << "Clip Adap Right: " << header.clipAdapterRight << endl << endl;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printHeader");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-bool SffInfoCommand::sanityCheck(Header& header, seqRead& read) {
-       try {
-        bool okay = true;
-        string message = "[WARNING]: Your sff file may be corrupted! Sequence: " + header.name + "\n";
-        
-        if (header.clipQualLeft > read.bases.length()) {
-            okay = false; message += "Clip Qual Left = " + toString(header.clipQualLeft) + ", but we only read " + toString(read.bases.length()) + " bases.\n";
-        }
-        if (header.clipQualRight > read.bases.length()) {
-            okay = false; message += "Clip Qual Right = " + toString(header.clipQualRight) + ", but we only read " + toString(read.bases.length()) + " bases.\n";
-        }
-        if (header.clipQualLeft > read.qualScores.size()) {
-            okay = false; message += "Clip Qual Left = " + toString(header.clipQualLeft) + ", but we only read " + toString(read.qualScores.size()) + " quality scores.\n";
-        }
-        if (header.clipQualRight > read.qualScores.size()) {
-            okay = false; message += "Clip Qual Right = " + toString(header.clipQualRight) + ", but we only read " + toString(read.qualScores.size()) + " quality scores.\n";
-        }
-        
-        if (okay == false) {
-            m->mothurOut(message); m->mothurOutEndLine();
-        }
-        
-               return okay;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "sanityCheck");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& header) {
-       try {
-               out << "Flowgram: ";
-               for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t';  }
-               
-               out << endl <<  "Flow Indexes: ";
-               int sum = 0;
-               for (int i = 0; i < read.flowIndex.size(); i++) {  sum +=  read.flowIndex[i];  out << sum << '\t'; }
-               
-               //make the bases you want to clip lowercase and the bases you want to keep upper case
-               if(header.clipQualRight == 0){  header.clipQualRight = read.bases.length();     }
-               for (int i = 0; i < (header.clipQualLeft-1); i++) { read.bases[i] = tolower(read.bases[i]); }
-               for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) {   read.bases[i] = toupper(read.bases[i]);  }
-               for (int i = (header.clipQualRight-1); i < read.bases.length(); i++) {   read.bases[i] = tolower(read.bases[i]);  }
-               
-               out << endl <<  "Bases: " << read.bases << endl << "Quality Scores: ";
-               for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
-       
-               
-               out << endl << endl;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printSffTxtSeqData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) {
-       try {
-               string seq = read.bases;
-               
-        if (trim) {
-                       if(header.clipQualRight < header.clipQualLeft){
-                               seq = "NNNN";
-                       }
-                       else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){
-                               seq = seq.substr((header.clipQualLeft-1), (header.clipQualRight-header.clipQualLeft));
-                       }
-                       else {
-                               seq = seq.substr(header.clipQualLeft-1);
-                       }
-               }else{
-                       //if you wanted the sfftxt then you already converted the bases to the right case
-                       if (!sfftxt) {
-                               //make the bases you want to clip lowercase and the bases you want to keep upper case
-                               if(header.clipQualRight == 0){  header.clipQualRight = seq.length();    }
-                               for (int i = 0; i < (header.clipQualLeft-1); i++) { seq[i] = tolower(seq[i]);  }
-                               for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++)  {   seq[i] = toupper(seq[i]);  }
-                               for (int i = (header.clipQualRight-1); i < seq.length(); i++) {   seq[i] = tolower(seq[i]);  }
-                       }
-               }
-               
-               out << ">" << header.name  << " xy=" << header.xy << endl;
-               out << seq << endl;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printFastaSeqData");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int SffInfoCommand::printQualSeqData(ofstream& out, seqRead& read, Header& header) {
-       try {
-               
-               if (trim) {
-                       if(header.clipQualRight < header.clipQualLeft){
-                               out << ">" << header.name << " xy=" << header.xy << endl;
-                               out << "0\t0\t0\t0";
-                       }
-                       else if((header.clipQualRight != 0) && ((header.clipQualRight-header.clipQualLeft) >= 0)){
-                               out << ">" << header.name << " xy=" << header.xy << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;
-                               for (int i = (header.clipQualLeft-1); i < (header.clipQualRight-1); i++) {   out << read.qualScores[i] << '\t'; }
-                       }
-                       else{
-                               out << ">" << header.name << " xy=" << header.xy << " length=" << (header.clipQualRight-header.clipQualLeft) << endl;
-                               for (int i = (header.clipQualLeft-1); i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';   }                       
-                       }
-               }else{
-                       out << ">" << header.name << " xy=" << header.xy << " length=" << read.qualScores.size() << endl;
-                       for (int i = 0; i < read.qualScores.size(); i++) {   out << read.qualScores[i] << '\t';  }
-               }
-               
-               out << endl;
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printQualSeqData");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int SffInfoCommand::printFlowSeqData(ofstream& out, seqRead& read, Header& header) {
-       try {
-               if(header.clipQualRight > header.clipQualLeft){
-                       
-                       int rightIndex = 0;
-                       for (int i = 0; i < header.clipQualRight; i++) {  rightIndex +=  read.flowIndex[i];     }
-
-                       out << header.name << ' ' << rightIndex;
-                       for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << ' ' << (read.flowgram[i]/(float)100);  }
-                       out << endl;
-               }
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "printFlowSeqData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::readAccnosFile(string filename) {
-       try {
-               //remove old names
-               seqNames.clear();
-               
-               ifstream in;
-               m->openInputFile(filename, in);
-               string name;
-               
-               while(!in.eof()){
-                       in >> name; m->gobble(in);
-                                               
-                       seqNames.insert(name);
-                       
-                       if (m->control_pressed) { seqNames.clear(); break; }
-               }
-               in.close();             
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "readAccnosFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SffInfoCommand::parseSffTxt() {
-       try {
-               
-               ifstream inSFF;
-               m->openInputFile(sfftxtFilename, inSFF);
-               
-               if (outputDir == "") {  outputDir += m->hasPath(sfftxtFilename); }
-               
-               //output file names
-               ofstream outFasta, outQual, outFlow;
-               string outFastaFileName, outQualFileName;
-               string fileRoot = m->getRootName(m->getSimpleName(sfftxtFilename));
-               if (fileRoot.length() > 0) {
-                       //rip off last .
-                       fileRoot = fileRoot.substr(0, fileRoot.length()-1);
-                       fileRoot = m->getRootName(fileRoot);
-               }
-               
-               string outFlowFileName = outputDir + fileRoot + "flow";
-               if (trim) {
-                       outFastaFileName = outputDir + fileRoot + "fasta";
-                       outQualFileName = outputDir + fileRoot + "qual";
-               }else{
-                       outFastaFileName = outputDir + fileRoot + "raw.fasta";
-                       outQualFileName = outputDir + fileRoot + "raw.qual";
-               }
-               
-               if (fasta)      { m->openOutputFile(outFastaFileName, outFasta);        outputNames.push_back(outFastaFileName); outputTypes["fasta"].push_back(outFastaFileName); }
-               if (qual)       { m->openOutputFile(outQualFileName, outQual);          outputNames.push_back(outQualFileName); outputTypes["qual"].push_back(outQualFileName);  }
-               if (flow)       { m->openOutputFile(outFlowFileName, outFlow);          outputNames.push_back(outFlowFileName);  outFlow.setf(ios::fixed, ios::floatfield); outFlow.setf(ios::showpoint); outputTypes["flow"].push_back(outFlowFileName);  }
-               
-               //read common header
-               string commonHeader = m->getline(inSFF);
-               string magicNumber = m->getline(inSFF); 
-               string version = m->getline(inSFF);
-               string indexOffset = m->getline(inSFF);
-               string indexLength = m->getline(inSFF);
-               int numReads = parseHeaderLineToInt(inSFF);
-               string headerLength = m->getline(inSFF);
-               string keyLength = m->getline(inSFF);
-               int numFlows = parseHeaderLineToInt(inSFF);
-               string flowgramCode = m->getline(inSFF);
-               string flowChars = m->getline(inSFF);
-               string keySequence = m->getline(inSFF);
-               m->gobble(inSFF);
-               
-               string seqName;
-               
-               if (flow)       {       outFlow << numFlows << endl;    }
-               
-               for(int i=0;i<numReads;i++){
-                       
-                       //sanity check
-                       if (inSFF.eof()) { m->mothurOut("[ERROR]: Expected " + toString(numReads) + " but reached end of file at " + toString(i+1) + "."); m->mothurOutEndLine(); break; }
-                       
-                       Header header;
-                       
-                       //parse read header
-                       inSFF >> seqName;
-                       seqName = seqName.substr(1);
-                       m->gobble(inSFF);
-                       header.name = seqName;
-                       
-                       string runPrefix = parseHeaderLineToString(inSFF);              header.timestamp = runPrefix;
-                       string regionNumber = parseHeaderLineToString(inSFF);   header.region = regionNumber;
-                       string xyLocation = parseHeaderLineToString(inSFF);             header.xy = xyLocation;
-                       m->gobble(inSFF);
-                               
-                       string runName = parseHeaderLineToString(inSFF);
-                       string analysisName = parseHeaderLineToString(inSFF);
-                       string fullPath = parseHeaderLineToString(inSFF);
-                       m->gobble(inSFF);
-                       
-                       string readHeaderLen = parseHeaderLineToString(inSFF);  convert(readHeaderLen, header.headerLength);
-                       string nameLength = parseHeaderLineToString(inSFF);             convert(nameLength, header.nameLength);
-                       int numBases = parseHeaderLineToInt(inSFF);                             header.numBases = numBases;
-                       string clipQualLeft = parseHeaderLineToString(inSFF);   convert(clipQualLeft, header.clipQualLeft);
-                       int clipQualRight = parseHeaderLineToInt(inSFF);                header.clipQualRight = clipQualRight;
-                       string clipAdapLeft = parseHeaderLineToString(inSFF);   convert(clipAdapLeft, header.clipAdapterLeft);
-                       string clipAdapRight = parseHeaderLineToString(inSFF);  convert(clipAdapRight, header.clipAdapterRight);
-                       m->gobble(inSFF);
-                               
-                       seqRead read;
-                       
-                       //parse read
-                       vector<unsigned short> flowVector = parseHeaderLineToFloatVector(inSFF, numFlows);      read.flowgram = flowVector;
-                       vector<unsigned int> flowIndices = parseHeaderLineToIntVector(inSFF, numBases); 
-                       
-                       //adjust for print
-                       vector<unsigned int> flowIndicesAdjusted; flowIndicesAdjusted.push_back(flowIndices[0]);
-                       for (int j = 1; j < flowIndices.size(); j++) {   flowIndicesAdjusted.push_back(flowIndices[j] - flowIndices[j-1]);   }
-                       read.flowIndex = flowIndicesAdjusted;
-                       
-                       string bases = parseHeaderLineToString(inSFF);                                                                          read.bases = bases;
-                       vector<unsigned int> qualityScores = parseHeaderLineToIntVector(inSFF, numBases);       read.qualScores = qualityScores;
-                       m->gobble(inSFF);
-                                       
-                       //if you have provided an accosfile and this seq is not in it, then dont print
-                       bool print = true;
-                       if (seqNames.size() != 0) {   if (seqNames.count(header.name) == 0) { print = false; }  }
-                       
-                       //print 
-                       if (print) {
-                               if (fasta)      {       printFastaSeqData(outFasta, read, header);      }
-                               if (qual)       {       printQualSeqData(outQual, read, header);        }
-                               if (flow)       {       printFlowSeqData(outFlow, read, header);        }
-                       }
-                       
-                       //report progress
-                       if((i+1) % 10000 == 0){ m->mothurOut(toString(i+1)); m->mothurOutEndLine();             }
-                       
-                       if (m->control_pressed) {  break;  }
-               }
-               
-               //report progress
-               if (!m->control_pressed) {   if((numReads) % 10000 != 0){       m->mothurOut(toString(numReads)); m->mothurOutEndLine();                }  }
-               
-               inSFF.close();
-               
-               if (fasta)      {  outFasta.close();    }
-               if (qual)       {  outQual.close();             }
-               if (flow)       {  outFlow.close();             }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "parseSffTxt");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SffInfoCommand::parseHeaderLineToInt(ifstream& file){
-       try {
-               int number;
-               
-               while (!file.eof())     {
-                       
-                       char c = file.get(); 
-                       if (c == ':'){
-                               file >> number;
-                               break;
-                       }
-                       
-               }
-               m->gobble(file);
-               return number;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "parseHeaderLineToInt");
-               exit(1);
-       }
-       
-}
-
-//**********************************************************************************************************************
-
-string SffInfoCommand::parseHeaderLineToString(ifstream& file){
-       try {
-               string text;
-               
-               while (!file.eof())     {
-                       char c = file.get(); 
-                       
-                       if (c == ':'){
-                               //m->gobble(file);
-                               //text = m->getline(file);      
-                               file >> text;
-                               break;
-                       }
-               }
-               m->gobble(file);
-               
-               return text;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "parseHeaderLineToString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-vector<unsigned short> SffInfoCommand::parseHeaderLineToFloatVector(ifstream& file, int length){
-       try {
-               vector<unsigned short> floatVector(length);
-               
-               while (!file.eof())     {
-                       char c = file.get(); 
-                       if (c == ':'){
-                               float temp;
-                               for(int i=0;i<length;i++){
-                                       file >> temp;
-                                       floatVector[i] = temp * 100;
-                               }
-                               break;
-                       }
-               }
-               m->gobble(file);        
-               return floatVector;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "parseHeaderLineToFloatVector");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-vector<unsigned int> SffInfoCommand::parseHeaderLineToIntVector(ifstream& file, int length){
-       try {
-               vector<unsigned int> intVector(length);
-               
-               while (!file.eof())     {
-                       char c = file.get(); 
-                       if (c == ':'){
-                               for(int i=0;i<length;i++){
-                                       file >> intVector[i];
-                               }
-                               break;
-                       }
-               }
-               m->gobble(file);        
-               return intVector;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SffInfoCommand", "parseHeaderLineToIntVector");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-                               
-                               
diff --git a/sffinfocommand.h b/sffinfocommand.h
deleted file mode 100644 (file)
index 837435b..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-#ifndef SFFINFOCOMMAND_H
-#define SFFINFOCOMMAND_H
-
-/*
- *  sffinfocommand.h
- *  Mothur
- *
- *  Created by westcott on 7/7/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-
-/**********************************************************/
-struct CommonHeader {
-       unsigned int magicNumber;
-       string version;
-       unsigned long long indexOffset;
-       unsigned int indexLength;
-       unsigned int numReads;
-       unsigned short headerLength;
-       unsigned short keyLength;
-       unsigned short numFlowsPerRead;
-       int flogramFormatCode;
-       string flowChars; //length depends on number flow reads
-       string keySequence; //length depends on key length
-       
-       CommonHeader(){ magicNumber=0; indexOffset=0; indexLength=0; numReads=0; headerLength=0; keyLength=0; numFlowsPerRead=0; flogramFormatCode='s'; } 
-       ~CommonHeader() { }
-};
-/**********************************************************/
-struct Header {
-       unsigned short headerLength;
-       unsigned short nameLength;
-       unsigned int numBases;
-       unsigned short clipQualLeft;
-       unsigned short clipQualRight;
-       unsigned short clipAdapterLeft;
-       unsigned short clipAdapterRight;
-       string name; //length depends on nameLength
-       string timestamp;
-       string region;
-       string xy;
-       
-       Header() { headerLength=0; nameLength=0; numBases=0; clipQualLeft=0; clipQualRight=0; clipAdapterLeft=0; clipAdapterRight=0; }
-       ~Header() { } 
-};
-/**********************************************************/
-struct seqRead {
-       vector<unsigned short> flowgram;
-       vector<unsigned int> flowIndex;
-       string bases;
-       vector<unsigned int> qualScores;
-       
-       seqRead() { } 
-       ~seqRead() { } 
-};
-/**********************************************************/
-
-class SffInfoCommand : public Command {
-       
-public:
-       SffInfoCommand(string);
-       SffInfoCommand();
-       ~SffInfoCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "sffinfo";                                     }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Sffinfo"; }
-       string getDescription()         { return "extract sequences reads from a .sff file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       string sffFilename, sfftxtFilename, outputDir, accnosName;
-       vector<string> filenames, outputNames, accnosFileNames;
-       bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos;
-       int mycount;
-       set<string> seqNames;
-    
-       //extract sff file functions
-       int extractSffInfo(string, string);
-       int readCommonHeader(ifstream&, CommonHeader&);
-       int readHeader(ifstream&, Header&);
-       int readSeqData(ifstream&, seqRead&, int, int);
-       int decodeName(string&, string&, string&, string);
-       
-       int printCommonHeader(ofstream&, CommonHeader&); 
-       int printHeader(ofstream&, Header&);
-       int printSffTxtSeqData(ofstream&, seqRead&, Header&);
-       int printFlowSeqData(ofstream&, seqRead&, Header&);
-       int printFastaSeqData(ofstream&, seqRead&, Header&);
-       int printQualSeqData(ofstream&, seqRead&, Header&);
-       int readAccnosFile(string);
-       int parseSffTxt();
-       bool sanityCheck(Header&, seqRead&);
-    
-       //parsesfftxt file functions
-       int parseHeaderLineToInt(ifstream&);
-       vector<unsigned short> parseHeaderLineToFloatVector(ifstream&, int);
-       vector<unsigned int> parseHeaderLineToIntVector(ifstream&, int);
-       string parseHeaderLineToString(ifstream&);
-};
-
-/**********************************************************/
-#endif
-
-
diff --git a/sgram.f b/sgram.f
deleted file mode 100644 (file)
index a8cb6de..0000000
--- a/sgram.f
+++ /dev/null
@@ -1,142 +0,0 @@
-C Output from Public domain Ratfor, version 1.0
-
-C PURPOSE
-C       Calculation of the cubic B-spline smoothness prior
-C       for "usual" interior knot setup.
-C       Uses BSPVD and INTRV in the CMLIB
-C       sgm[0-3](nb)    Symmetric matrix
-C                       whose (i,j)'th element contains the integral of
-C                       B''(i,.) B''(j,.) , i=1,2 ... nb and j=i,...nb.
-C                       Only the upper four diagonals are computed.
-
-      subroutine sgram(sg0,sg1,sg2,sg3,tb,nb)
-
-c      implicit none
-C indices
-      integer nb
-      DOUBLE precision sg0(nb),sg1(nb),sg2(nb),sg3(nb), tb(nb+4)
-c     -------------
-      integer ileft,mflag, i,ii,jj, lentb
-      DOUBLE precision vnikx(4,3),work(16),yw1(4),yw2(4), wpt
-c
-c      integer interv
-c      external interv
-
-      lentb=nb+4
-C Initialise the sigma vectors
-      do 1 i=1,nb
-         sg0(i)=0.d0
-         sg1(i)=0.d0
-         sg2(i)=0.d0
-         sg3(i)=0.d0
- 1    continue
-
-      ileft = 1
-      do 2 i=1,nb
-C     Calculate a linear approximation to the
-C     second derivative of the non-zero B-splines
-C     over the interval [tb(i),tb(i+1)].
-C     call intrv(tb(1),(nb+1),tb(i),ilo,ileft,mflag)
-         call interv(tb(1), nb+1,tb(i), ileft, mflag)
-C     Left end second derivatives
-C     call bspvd (tb,4,3,tb(i),ileft,4,vnikx,work)
-         call bsplvd (tb,lentb,4,tb(i),ileft,work,vnikx,3)
-C     Put values into yw1
-         do 4 ii=1,4
-            yw1(ii) = vnikx(ii,3)
- 4       continue
-
-C     Right end second derivatives
-C     call bspvd (tb,4,3,tb(i+1),ileft,4,vnikx,work)
-         call bsplvd (tb,lentb,4,tb(i+1),ileft,work,vnikx,3)
-
-C     Slope*(length of interval) in Linear Approximation to B''
-         do    6 ii=1,4
-            yw2(ii) = vnikx(ii,3) - yw1(ii)
- 6       continue
-
-         wpt = tb(i+1) - tb(i)
-C     Calculate Contributions to the sigma vectors
-         if(ileft.ge.4) then
-            do 10 ii=1,4
-               jj=ii
-               sg0(ileft-4+ii) = sg0(ileft-4+ii) +
-     &              wpt*(yw1(ii)*yw1(jj)+
-     &                   (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                  + yw2(ii)*yw2(jj)*0.3330d0)
-               jj=ii+1
-               if(jj.le.4)then
-                  sg1(ileft+ii-4) = sg1(ileft+ii-4) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
-               jj=ii+2
-               if(jj.le.4)then
-                  sg2(ileft+ii-4) = sg2(ileft+ii-4) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
-               jj=ii+3
-               if(jj.le.4)then
-                  sg3(ileft+ii-4) = sg3(ileft+ii-4) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
- 10         continue
-
-         else if(ileft.eq.3)then
-            do    20 ii=1,3
-               jj=ii
-               sg0(ileft-3+ii) = sg0(ileft-3+ii) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               jj=ii+1
-               if(jj.le.3)then
-                  sg1(ileft+ii-3) = sg1(ileft+ii-3) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
-               jj=ii+2
-               if(jj.le.3)then
-                  sg2(ileft+ii-3) = sg2(ileft+ii-3) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
- 20         continue
-
-         else if(ileft.eq.2)then
-            do    28 ii=1,2
-               jj=ii
-               sg0(ileft-2+ii) = sg0(ileft-2+ii) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               jj=ii+1
-               if(jj.le.2)then
-                  sg1(ileft+ii-2) = sg1(ileft+ii-2) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
-               endif
- 28         continue
-
-         else if(ileft.eq.1)then
-            do 34 ii=1,1
-               jj=ii
-               sg0(ileft-1+ii) = sg0(ileft-1+ii) +
-     &                 wpt* (yw1(ii)*yw1(jj) +
-     *                       (yw2(ii)*yw1(jj) + yw2(jj)*yw1(ii))*0.5d0
-     &                       +yw2(ii)*yw2(jj)*0.3330d0 )
- 34         continue
-
-         endif
- 2    continue
-
-      return
-      end
diff --git a/shannon.cpp b/shannon.cpp
deleted file mode 100644 (file)
index b38d7fc..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  shannon.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "shannon.h"
-
-/***********************************************************************/
-
-EstOutput Shannon::getValues(SAbundVector* rank){
-       try {
-               //vector<double> shannonData(3,0);
-               data.resize(3,0);
-       
-               double shannon = 0.0000;  //hprime
-               double hvara=0.0000;
-    
-               double maxRank = rank->getMaxRank();
-               int sampled = rank->getNumSeqs();
-               int sobs = rank->getNumBins();
-       
-               for(int i=1;i<=maxRank;i++){
-                       double p = ((double) i)/((double)sampled);
-                       shannon += (double)rank->get(i)*p*log(p); //hprime
-                       hvara  += (double)rank->get(i)*p*pow(log(p),2);
-               }
-               shannon = -shannon;
-    
-               double hvar = (hvara-pow(shannon,2))/(double)sampled+(double)(sobs-1)/(double)(2*sampled*sampled);
-    
-               double ci = 0;
-       
-               if(hvar>0){
-                       ci = 1.96*pow(hvar,0.5);
-               }
-       
-               double shannonhci = shannon + ci;
-               double shannonlci = shannon - ci;
-               
-               data[0] = shannon;
-               data[1] = shannonlci;
-               data[2] = shannonhci;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Shannon", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/shannon.h b/shannon.h
deleted file mode 100644 (file)
index 3d9ecde..0000000
--- a/shannon.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef SHANNON_H
-#define SHANNON_H
-/*
- *  shannon.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Shannon estimator on single group. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Shannon : public Calculator  {
-       
-public:
-       Shannon() : Calculator("shannon", 3, false) {};
-       EstOutput getValues(SAbundVector* rank);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Shannon"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/shannoneven.cpp b/shannoneven.cpp
deleted file mode 100644 (file)
index 77c03e7..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  shannoneven.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "shannoneven.h"
-#include "shannon.h"
-
-/***********************************************************************/
-
-EstOutput ShannonEven::getValues(SAbundVector* rank){
-       try {
-               //vector<double> simpsonData(3,0);
-               data.resize(1,0);
-               vector<double> shanData(3,0);
-               Shannon* shannon = new Shannon();
-               shanData = shannon->getValues(rank);
-               
-               long int sobs = rank->getNumBins();
-               if(sobs > 1){
-                       data[0] = shanData[0] / log(sobs);
-               }
-               else{
-                       data[0] = 1;
-               }
-               
-               delete shannon;
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShannonEven", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/shannoneven.h b/shannoneven.h
deleted file mode 100644 (file)
index 44d0766..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SHANNONEVEN
-#define SHANNONEVEN
-
-/*
- *  shannoneven.h
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class ShannonEven : public Calculator  {
-       
-public:
-       ShannonEven() : Calculator("shannoneven", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Shannoneven"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedace.cpp b/sharedace.cpp
deleted file mode 100644 (file)
index 2a06380..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
- *  sharedace.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedace.h"
-
-/***********************************************************************/
-
-EstOutput SharedAce::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               string label;
-               label = shared[0]->getLabel();
-
-               double fARare, fBRare, S12Rare, S12Abund, S12, f11, tempA, tempB, t10, t01, t11, t21, t12, t22, C12Numerator;
-               fARare = 0; fBRare = 0; S12Rare = 0; S12Abund = 0; S12 = 0; f11 = 0; t10 = 0; t01 = 0; t11= 0; t21= 0; t12= 0; t22= 0; C12Numerator = 0;
-       
-               double Sharedace, C12, part1, part2, part3, part4, part5, Gamma1, Gamma2, Gamma3;
-       
-               /*fARare = number of OTUs with one individual found in A and less than or equal to 10 in B. 
-               fBRare = number of OTUs with one individual found in B and less than or equal to 10 in A. 
-               arare = number of sequences from A that contain less than 10 sequences. 
-               brare = number of sequences from B that contain less than 10 sequences. 
-               S12Rare = number of shared OTUs where both of the communities are represented by less than or equal to 10 sequences 
-               S12Abund = number of shared OTUs where at least one of the communities is represented by more than 10 sequences 
-               S12 = number of shared OTUs in A and B
-               This estimator was changed to reflect Caldwell's changes, eliminating the nrare / nrare - 1 */
-
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       if ((tempA != 0) && (tempB != 0)) {//they are shared
-                               S12++;
-                               //do both A and B have one
-                               if ((tempA == 1) && (tempB == 1))               {       f11++;   }
-                               //is A one and B rare
-                               if ((tempA == 1) && (tempB <= abund))   {  fARare++; }
-                               //is B one and A rare
-                               if ((tempB == 1) && (tempA <= abund))   {  fBRare++; }
-                       
-                               if ((tempA <= abund) && (tempB <= abund)) { //shared and both rare
-                                       S12Rare++;
-                                       t10 += tempA;   //Sum Xi
-                                       t01 += tempB;   //Sum Yi
-                                       
-                                       //calculate top of C12
-                                       // YiI(Xi = 1)
-                                       if (tempA == 1) { C12Numerator += tempB; }
-                                       //XiI(Yi = 1)
-                                       if (tempB == 1) { C12Numerator += tempA; }
-                                       //-I(Xi=Yi=1)
-                                       if ((tempA == 1) && (tempB == 1)) { C12Numerator--; }
-                                       
-                                       //calculate t11 - Sum of XiYi
-                                       t11 += tempA * tempB;
-                                       //calculate t21  - Sum of Xi(Xi - 1)Yi
-                                       t21 += tempA * (tempA - 1) * tempB;
-                                       //calculate t12  - Sum of Xi(Yi - 1)Yi
-                                       t12 += tempA * (tempB - 1) * tempB;
-                                       //calculate t22  - Sum of Xi(Xi - 1)Yi(Yi - 1)
-                                       t22 += tempA * (tempA - 1) * tempB * (tempB - 1);
-
-                               }
-                               if ((tempA > 10) || (tempB > 10)) {
-                                       S12Abund++;
-                               }
-                       }
-               }
-       
-               C12 = 1 - (C12Numerator /(float) t11);
-               part1 = S12Rare / (float)C12;
-               part2 = 1 / (float)C12;
-
-               //calculate gammas
-               Gamma1 = ((S12Rare * t21) / (float)((C12 * t10 * t11)) - 1);
-               Gamma2 = ((S12Rare * t12) / (float)((C12 * t01 * t11)) - 1);
-               Gamma3 = ((S12Rare / C12) * (S12Rare / C12)) * ( t22 / (float)(t10 * t01 * t11));
-               Gamma3 = Gamma3 - ((S12Rare * t11) / (float)(C12 * t01 * t10)) - Gamma1 - Gamma2;       
-
-               if (isnan(Gamma1) || isinf(Gamma1)) { Gamma1 = 0; }
-               if (isnan(Gamma2) || isinf(Gamma2)) { Gamma2 = 0; }
-               if (isnan(Gamma3) || isinf(Gamma3)) { Gamma3 = 0; }
-               if (isnan(part1)  || isinf(part1))  { part1 = 0;  }
-               if (isnan(part2)  || isinf(part2))  { part2 = 0;  }
-               
-               part3 = fARare * Gamma1;
-               part4 = fBRare * Gamma2;
-               part5 = f11 * Gamma3;
-
-               Sharedace = S12Abund + part1 + (part2 * (part3 + part4 + part5));
-               data[0] = Sharedace;
-       
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedAce", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
diff --git a/sharedace.h b/sharedace.h
deleted file mode 100644 (file)
index 9ea0d6a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SHAREDACE_H
-#define SHAREDACE_H
-/*
- *  sharedace.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedAce estimator on two groups. 
-It is a child of the calculator class. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SharedAce : public Calculator  {
-       
-public:
-       SharedAce(int n=10) : abund(n),  Calculator("sharedace", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/SharedAce"; }
-private:
-       int abund;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedanderbergs.cpp b/sharedanderbergs.cpp
deleted file mode 100644 (file)
index cbb9d30..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  sharedanderberg.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedanderbergs.h"
-
-/***********************************************************************/
-
-EstOutput Anderberg::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = 1.0 - S12 / ((float)((2 * S1) + (2 * S2) - (3 * S12)));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Anderberg", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedanderbergs.h b/sharedanderbergs.h
deleted file mode 100644 (file)
index 785e52b..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef ANDERBERG_H
-#define ANDERBERG_H
-/*
- *  sharedanderberg.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Anderberg : public Calculator  {
-       
-       public:
-               Anderberg() :  Calculator("anderberg", 1, false) {};
-               EstOutput getValues(SAbundVector*) {return data;};
-               EstOutput getValues(vector<SharedRAbundVector*>);
-               string getCitation() { return "http://www.mothur.org/wiki/Anderberg"; }
-       private:
-
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedbraycurtis.cpp b/sharedbraycurtis.cpp
deleted file mode 100644 (file)
index 3711ce7..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *  sharedbraycurtis.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedbraycurtis.h"
-
-/***********************************************************************/
-//This is used by SharedJAbund and SharedSorAbund
-EstOutput BrayCurtis::getValues(vector<SharedRAbundVector*> shared) {
-       try {   
-               data.resize(1,0);
-               
-               double sumSharedA, sumSharedB, sumSharedAB, tempA, tempB;
-               sumSharedA = 0; sumSharedB = 0; sumSharedAB = 0; 
-               
-               /*Xi, Yi = abundance of the ith shared OTU in A and B 
-               sumSharedA = the number of otus in A
-               sumSharedB = the sum of all shared otus in B
-               sumSharedAB = the sum of the minimum otus int all shared otus in AB.
-               */
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       sumSharedA += tempA;
-                       sumSharedB += tempB;
-                               
-                       //sum the min of tempA and tempB
-                       if (tempA < tempB) { sumSharedAB += tempA; }
-                       else  { sumSharedAB += tempB; }                         
-               }
-               
-               data[0] = 1.0 - (2 * sumSharedAB) / (float)( sumSharedA + sumSharedB);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-                               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "BrayCurtis", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedbraycurtis.h b/sharedbraycurtis.h
deleted file mode 100644 (file)
index 200f08c..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef BRAYCURTIS_H
-#define BRAYCURTIS_H
-/*
- *  sharedbraycurtis.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/***********************************************************************/
-
-class BrayCurtis : public Calculator  {
-       
-public:
-       BrayCurtis() :  Calculator("braycurtis", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Braycurtis"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-
-
-#endif
diff --git a/sharedchao1.cpp b/sharedchao1.cpp
deleted file mode 100644 (file)
index 8d47ad2..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- *  sharedchao1.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedchao1.h"
-
-/***********************************************************************/
-EstOutput SharedChao1::getValues(vector<SharedRAbundVector*> shared){
-       try {
-               data.resize(1,0);               
-               vector<int> temp; 
-               int numGroups = shared.size();
-               float Chao = 0.0; float leftvalue, rightvalue;
-                               
-               // IntNode is defined in mothur.h
-               // The tree used here is a binary tree used to represent the f1+++, f+1++, f++1+, f+++1, f11++, f1+1+... 
-               // combinations required to solve the chao estimator equation for any number of groups.  Conceptually, think
-               // of each node as having a 1 and a + value, or for f2 values a 2 and a + value, and 2 pointers to intnodes, and 2 coeffient values.
-               // The coeffient value is how many times you chose branch 1 to get to that fvalue.
-               // If you choose left you are selecting the 1 or 2 value and right means the + value.  For instance, to find
-               // the number of bins that have f1+1+ you would start at the root, go left, right, left, and select the rightvalue.
-               // the coeffient is 2.  Note: we only set the coeffient in f2 values.
-               
-               //create and initialize trees to 0.
-               initialTree(numGroups);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //get bin values and calc shared 
-                       bool sharedByAll = true;
-                       temp.clear();
-                       for (int j = 0; j < numGroups; j++) {
-                               temp.push_back(shared[j]->getAbundance(i));
-                               if (temp[j] == 0) { sharedByAll = false; }
-                       }
-                       
-                       //they are shared
-                       if (sharedByAll == true) { 
-                               //find f1 and f2values
-                               updateTree(temp);
-                       }
-               }
-
-               
-               //calculate chao1, (numleaves-1) because numleaves contains the ++ values.
-               bool bias = false;
-               for(int i=0;i<numLeaves;i++){
-                       if (f2leaves[i]->lvalue == 0 || f2leaves[i]->rvalue == 0) { bias = true;}// break;}
-               }
-
-               if(bias){
-                       for (int i = 0; i < numLeaves; i++) {
-                               
-                               leftvalue = (float)(f1leaves[i]->lvalue * (f1leaves[i]->lvalue - 1)) / (float)((pow(2, (float)f2leaves[i]->lcoef)) * (f2leaves[i]->lvalue + 1));
-                               if (i != (numLeaves-1)) {
-                                       rightvalue = (float)(f1leaves[i]->rvalue * (f1leaves[i]->rvalue - 1)) / (float)((pow(2, (float)f2leaves[i]->rcoef)) * (f2leaves[i]->rvalue + 1));
-                               }else{
-                                       //add in sobs
-                                       rightvalue = (float)(f1leaves[i]->rvalue);
-                               }
-                               Chao += leftvalue + rightvalue;
-                       }
-               }
-               else{
-                       
-                       for (int i = 0; i < numLeaves; i++) {
-                               
-                               leftvalue = (float)(f1leaves[i]->lvalue * f1leaves[i]->lvalue) / (float)((pow(2, (float)f2leaves[i]->lcoef)) * f2leaves[i]->lvalue);
-                               if (i != (numLeaves-1)) {
-                                       rightvalue = (float)(f1leaves[i]->rvalue * f1leaves[i]->rvalue) / (float)((pow(2, (float)f2leaves[i]->rcoef)) * f2leaves[i]->rvalue);
-                               }else{
-                                       //add in sobs
-                                       rightvalue = (float)(f1leaves[i]->rvalue);
-                               }
-                               Chao += leftvalue + rightvalue;
-                       }
-               }
-               
-               for (int i = 0; i < numNodes; i++) {
-                       delete f1leaves[i];
-                       delete f2leaves[i];
-               }
-               
-               
-               data[0] = Chao;
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//builds trees structure with n leaf nodes initialized to 0.
-void SharedChao1::initialTree(int n) {  
-       try {
-               // (2^n) / 2. Divide by 2 because each leaf node contains 2 values. One for + and one for 1 or 2.
-               numLeaves = pow(2, (float)n) / 2;
-               numNodes = 2*numLeaves - 1;
-               int countleft = 0;
-               int countright = 1;
-               
-               f1leaves.resize(numNodes);
-               f2leaves.resize(numNodes);
-       
-               //initialize leaf values
-               for (int i = 0; i < numLeaves; i++) {
-                       f1leaves[i] = new IntNode(0, 0, NULL, NULL);
-                       f2leaves[i] = new IntNode(0, 0, NULL, NULL);
-               }
-               
-               //set pointers to children
-               for (int j = numLeaves; j < numNodes; j++) {
-                       f1leaves[j] = new IntNode();
-                       f1leaves[j]->left = f1leaves[countleft];
-                       f1leaves[j]->right = f1leaves[countright];
-                                               
-                       f2leaves[j] = new IntNode();
-                       f2leaves[j]->left = f2leaves[countleft];
-                       f2leaves[j]->right =f2leaves[countright];
-                       
-                       countleft = countleft + 2;
-                       countright = countright + 2;
-               }
-               
-               //point to root
-               f1root = f1leaves[numNodes-1];
-       
-               //point to root
-               f2root = f2leaves[numNodes-1];
-               
-               //set coeffients
-               setCoef(f2root, 0);
-       }
-       catch(exception& e) {
-               if ((toString(e.what()) == "vector::_M_fill_insert") || (toString(e.what()) == "St9bad_alloc")) { m->mothurOut("You are using " + toString(n) + " groups which creates 2^" + toString(n+1) + " nodes. Try reducing the number of groups you selected. "); m->mothurOutEndLine(); exit(1); }
-               m->errorOut(e, "SharedChao1", "initialTree");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//take vector containing the abundance info. for a bin and updates trees.
-void SharedChao1::updateTree(vector<int> bin) { 
-       try {
-               updateBranchf1(f1root, bin, 0);  
-               updateBranchf2(f2root, bin, 0); 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "updateTree");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedChao1::updateBranchf1(IntNode* node, vector<int> bin, int index) {
-       try {
-               //if you have more than one group
-               if (index == (bin.size()-1)) {
-                       if (bin[index] == 1) { node->lvalue++; node->rvalue++; }
-                       else { node->rvalue++;  }
-               }else {
-                       if (bin[index] == 1) {
-                               //follow path as if you are 1
-                               updateBranchf1(node->left, bin, index+1);
-                       }
-                       //follow path as if you are +
-                       updateBranchf1(node->right, bin, index+1);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "updateBranchf1");                
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedChao1::updateBranchf2(IntNode* node, vector<int> bin, int index) {
-       try {
-               //if you have more than one group
-               if (index == (bin.size()-1)) {
-                       if (bin[index] == 2) { node->lvalue++; node->rvalue++; }
-                       else { node->rvalue++;  }
-               }else {
-                       if (bin[index] == 2) {
-                               //follow path as if you are 1
-                               updateBranchf2(node->left, bin, index+1);
-                       }
-                       //follow path as if you are +
-                       updateBranchf2(node->right, bin, index+1);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "updateBranchf2");        
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedChao1::setCoef(IntNode* node, int coef) {
-       try {
-               if (node->left != NULL) {
-                       setCoef(node->left, coef+1);
-                       setCoef(node->right, coef);
-               }else {
-                       node->lcoef = coef+1;
-                       node->rcoef = coef;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "setCoef");       
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-//for debugging purposes
-void SharedChao1::printTree() {
-       
-       m->mothurOut("F1 leaves"); m->mothurOutEndLine();
-       printBranch(f1root);
-       
-       m->mothurOut("F2 leaves"); m->mothurOutEndLine();
-       printBranch(f2root);
-
-
-}
-/*****************************************************************/
-void SharedChao1::printBranch(IntNode* node) {
-       try {
-               
-               // you are not a leaf
-               if (node->left != NULL) {
-                       printBranch(node->left);
-                       printBranch(node->right);
-               }else { //you are a leaf
-                       m->mothurOut(toString(node->lvalue)); m->mothurOutEndLine();
-                       m->mothurOut(toString(node->rvalue)); m->mothurOutEndLine();
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedChao1", "printBranch");   
-               exit(1);
-       }
-}
-
-/*****************************************************************/
-
-
-
-
diff --git a/sharedchao1.h b/sharedchao1.h
deleted file mode 100644 (file)
index ae07a87..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#ifndef SHAREDCHAO1_H
-#define SHAREDCHAO1_H
-/*
- *  sharedchao1.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Sharedchao1 estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-
-class SharedChao1 : public Calculator  {
-       
-       public: 
-               SharedChao1() : Calculator("sharedchao", 1, true) {};
-               EstOutput getValues(SAbundVector*) {return data;};
-               EstOutput getValues(vector<SharedRAbundVector*>);
-               string getCitation() { return "http://www.mothur.org/wiki/Sharedchao"; }
-       private:
-               IntNode* f1root;
-               IntNode* f2root;
-               vector<IntNode*> f1leaves;
-               vector<IntNode*> f2leaves;
-               int numLeaves;
-               int numNodes;
-
-               void initialTree(int);  //builds trees structure with n leaf nodes initialized to 0.
-               void setCoef(IntNode*, int);
-               void updateTree(vector<int>); //take vector containing the abundance info. for a bin and updates trees.
-               void updateBranchf1(IntNode*, vector<int>, int);  //pointer, vector of abundance values, index into vector
-               void updateBranchf2(IntNode*, vector<int>, int);  //pointer, vector of abundance values, index into vector
-               
-               //for debugging
-               void printTree();
-               void printBranch(IntNode*);
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedcommand.cpp b/sharedcommand.cpp
deleted file mode 100644 (file)
index 8f05cfc..0000000
+++ /dev/null
@@ -1,1223 +0,0 @@
-/*
- *  sharedcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedcommand.h"
-#include "sharedutilities.h"
-
-//********************************************************************************************************************
-//sorts lowest to highest
-inline bool compareSharedRabunds(SharedRAbundVector* left, SharedRAbundVector* right){
-       return (left->getGroup() < right->getGroup());  
-}
-//**********************************************************************************************************************
-vector<string> SharedCommand::setParameters(){ 
-       try {
-        CommandParameter pbiom("biom", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "none",false,false); parameters.push_back(pbiom);
-               CommandParameter plist("list", "InputTypes", "", "", "BiomListGroup", "BiomListGroup", "ListGroup",false,false); parameters.push_back(plist);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "ListGroup",false,false); parameters.push_back(pgroup);
-               //CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SharedCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The make.shared command reads a list and group file or a biom file and creates a shared file. If a list and group are provided a rabund file is created for each group.\n";
-               helpString += "The make.shared command parameters are list, group, biom, groups and label. list and group are required unless a current file is available or you provide a biom file.\n";
-               helpString += "The groups parameter allows you to indicate which groups you want to include, group names should be separated by dashes. ex. groups=A-B-C. Default is all groups in your groupfile.\n";
-               helpString += "The label parameter is only valid with the list and group option and allows you to indicate which labels you want to include, label names should be separated by dashes. Default is all labels in your list file.\n";
-               //helpString += "The ordergroup parameter allows you to indicate the order of the groups in the sharedfile, by default the groups are listed alphabetically.\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SharedCommand::SharedCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               //initialize outputTypes
-               vector<string> tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "SharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SharedCommand::SharedCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       
-                        vector<string> myArray = setParameters();
-                        
-                        OptionParser parser(option);
-                        map<string, string> parameters = parser.getParameters();
-                        
-                        ValidParameters validParameter;
-                        map<string, string>::iterator it;
-                        
-                        //check to make sure all parameters are valid for command
-                        for (it = parameters.begin(); it != parameters.end(); it++) { 
-                                if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                        }
-                        
-                        //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                        if (inputDir == "not found"){  inputDir = "";          }
-                        else {
-                                string path;
-                                it = parameters.find("list");
-                                //user has given a template file
-                                if(it != parameters.end()){ 
-                                        path = m->hasPath(it->second);
-                                        //if the user has not given a path then, add inputdir. else leave path alone.
-                                        if (path == "") {      parameters["list"] = inputDir + it->second;             }
-                                }
-                        
-                                it = parameters.find("group");
-                                //user has given a template file
-                                if(it != parameters.end()){ 
-                                        path = m->hasPath(it->second);
-                                        //if the user has not given a path then, add inputdir. else leave path alone.
-                                        if (path == "") {      parameters["group"] = inputDir + it->second;            }
-                                }
-                        
-                                /*it = parameters.find("ordergroup");
-                                //user has given a template file
-                                if(it != parameters.end()){ 
-                                        path = m->hasPath(it->second);
-                                        //if the user has not given a path then, add inputdir. else leave path alone.
-                                        if (path == "") {      parameters["ordergroup"] = inputDir + it->second;               }
-                                }*/
-                 
-                 it = parameters.find("biom");
-                                //user has given a template file
-                                if(it != parameters.end()){ 
-                                        path = m->hasPath(it->second);
-                                        //if the user has not given a path then, add inputdir. else leave path alone.
-                                        if (path == "") {      parameters["biom"] = inputDir + it->second;             }
-                                }
-                        }
-                        
-                        
-                        //if the user changes the output directory command factory will send this info to us in the output parameter 
-                        outputDir = validParameter.validFile(parameters, "outputdir", false);          if (outputDir == "not found"){  outputDir = ""; }
-                        
-                        //check for required parameters
-                        listfile = validParameter.validFile(parameters, "list", true);
-                        if (listfile == "not open") { listfile = ""; abort = true; }
-                        else if (listfile == "not found") { listfile = "";  }
-                        else { m->setListFile(listfile); }     
-            
-             biomfile = validParameter.validFile(parameters, "biom", true);
-             if (biomfile == "not open") { biomfile = ""; abort = true; }
-             else if (biomfile == "not found") { biomfile = "";  }
-             else { m->setBiomFile(biomfile); }                
-                                                       
-                        ordergroupfile = validParameter.validFile(parameters, "ordergroup", true);
-                        if (ordergroupfile == "not open") { abort = true; }    
-                        else if (ordergroupfile == "not found") { ordergroupfile = ""; }
-                                                
-                        groupfile = validParameter.validFile(parameters, "group", true);
-                        if (groupfile == "not open") { groupfile = ""; abort = true; } 
-                        else if (groupfile == "not found") { groupfile = ""; }
-                        else {  m->setGroupFile(groupfile); }
-                        
-            if ((biomfile == "") && (listfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to list, then biom
-                               listfile = m->getListFile(); 
-                               if (listfile != "") {  m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       biomfile = m->getBiomFile(); 
-                                       if (biomfile != "") {  m->mothurOut("Using " + biomfile + " as input file for the biom parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a list or biom file before you can use the make.shared command."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       else if ((biomfile != "") && (listfile != "")) { m->mothurOut("When executing a make.shared command you must enter ONLY ONE of the following: list or biom."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if (listfile != "") {
-                               if (groupfile == "") { 
-                                       groupfile = m->getGroupFile(); 
-                                       if (groupfile != "") {  m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a groupfle if you are going to use the list format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-
-                        
-                        string groups = validParameter.validFile(parameters, "groups", false);                 
-                        if (groups == "not found") { groups = ""; }
-                        else { 
-                                m->splitAtDash(groups, Groups);
-                                m->setGroups(Groups);
-                        }
-                        
-                        //check for optional parameter and set defaults
-                        // ...at some point should added some additional type checking...
-                        string label = validParameter.validFile(parameters, "label", false);                   
-                        if (label == "not found") { label = ""; }
-                        else { 
-                                if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                                else { allLines = 1;  }
-                        }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "SharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SharedCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-                       
-               //getting output filename
-        string filename = "";
-               if (listfile != "") { filename = listfile; }
-        else { filename = biomfile; }
-               
-               if (outputDir == "") { outputDir += m->hasPath(filename); }
-               
-               filename = outputDir + m->getRootName(m->getSimpleName(filename));
-               filename = filename + "shared";
-               outputNames.push_back(filename); outputTypes["shared"].push_back(filename);
-               
-        if (listfile != "") {  createSharedFromListGroup(filename);  }
-        else {   createSharedFromBiom(filename);  }
-        
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); }  }
-        
-               //set rabund file as new current rabundfile
-               string current = "";
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               itTypes = outputTypes.find("shared");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-               }       
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedCommand::createSharedFromBiom(string filename) {
-       try {
-        ofstream out;
-        m->openOutputFile(filename, out);
-        
-        /*{
-            "id":"/Users/SarahsWork/Desktop/release/temp.job2.shared-unique",
-            "format": "Biological Observation Matrix 0.9.1",
-            "format_url": "http://biom-format.org",
-            "type": "OTU table",
-            "generated_by": "mothur1.24.0",
-            "date": "Tue Apr 17 13:12:07 2012", */
-        
-        ifstream in;
-        m->openInputFile(biomfile, in);
-        
-        m->getline(in); m->gobble(in);  //grab first '{'
-        
-        string matrixFormat = "";
-        int numRows = 0;
-        int numCols = 0;
-        int shapeNumRows = 0;
-        int shapeNumCols = 0;
-        vector<string> otuNames;
-        vector<string> groupNames;
-        while (!in.eof()) {
-            
-            if (m->control_pressed) { break; }
-            
-            string line = m->getline(in); m->gobble(in);
-            
-            string tag = getTag(line);
-            
-            if (tag == "type") {
-                //check to make sure this is an OTU table
-                string type = getTag(line);
-                if (type != "OTU table") { m->mothurOut("[ERROR]: " + type + " is not a valid biom type for mothur. Only type allowed is OTU table.\n"); m->control_pressed = true; }
-            }else if (tag == "matrix_type") {
-                //get type and check type
-                matrixFormat = getTag(line);
-                if ((matrixFormat != "sparse") && (matrixFormat != "dense")) { m->mothurOut("[ERROR]: " + matrixFormat + " is not a valid biom matrix_type for mothur. Types allowed are sparse and dense.\n"); m->control_pressed = true; }
-            }else if (tag == "matrix_element_type") {
-                //get type and check type
-                string matrixElementType = getTag(line);
-                if (matrixElementType != "int") { m->mothurOut("[ERROR]: " + matrixElementType + " is not a valid matrix_element_type for mothur. Only type allowed is int.\n"); m->control_pressed = true; }
-            }else if (tag == "rows") {
-                //read otu names
-                otuNames = readRows(line, in, numRows);  
-            }else if (tag == "columns") {
-                //read sample names
-                groupNames = readRows(line, in, numCols); 
-                
-                //if users selected groups, then remove the groups not wanted.
-                SharedUtil util;
-                vector<string> Groups = m->getGroups();
-                vector<string> allGroups = groupNames;
-                util.setGroups(Groups, allGroups);
-                m->setGroups(Groups);
-                
-                //fill filehandles with neccessary ofstreams
-                int i;
-                ofstream* temp;
-                for (i=0; i<Groups.size(); i++) {
-                    temp = new ofstream;
-                    filehandles[Groups[i]] = temp;
-                }
-                
-                //set fileroot
-                fileroot = outputDir + m->getRootName(m->getSimpleName(biomfile));
-                
-                //clears file before we start to write to it below
-                for (int i=0; i<Groups.size(); i++) {
-                    m->mothurRemove((fileroot + Groups[i] + ".rabund"));
-                    outputNames.push_back((fileroot + Groups[i] + ".rabund"));
-                    outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
-                }
-
-            }else if (tag == "shape") {
-                getDims(line, shapeNumRows, shapeNumCols);
-                
-                //check shape
-                if (shapeNumCols != numCols) {
-                    m->mothurOut("[ERROR]: shape indicates " + toString(shapeNumCols) + " columns, but I only read " + toString(numCols) + " columns.\n"); m->control_pressed = true;
-                }
-                
-                if (shapeNumRows != numRows) {
-                    m->mothurOut("[ERROR]: shape indicates " + toString(shapeNumRows) + " rows, but I only read " + toString(numRows) + " rows.\n"); m->control_pressed = true;
-                }
-            }else if (tag == "data") {
-                m->currentBinLabels = otuNames;
-                
-                //read data
-                vector<SharedRAbundVector*> lookup = readData(matrixFormat, line, in, groupNames, otuNames.size());
-
-                m->mothurOutEndLine(); m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                lookup[0]->printHeaders(out); 
-                printSharedData(lookup, out);
-            }
-        }
-        in.close();
-        
-                
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "createSharedFromBiom");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<SharedRAbundVector*> SharedCommand::readData(string matrixFormat, string line, ifstream& in, vector<string>& groupNames, int numOTUs) {
-       try {
-        
-        vector<SharedRAbundVector*> lookup; 
-        
-        //creates new sharedRAbunds
-        for (int i = 0; i < groupNames.size(); i++) {
-            SharedRAbundVector* temp = new SharedRAbundVector(numOTUs); //sets all abunds to 0
-            temp->setLabel("dummy");
-            temp->setGroup(groupNames[i]);
-            lookup.push_back(temp);
-        }
-        
-        bool dataStart = false;
-        bool inBrackets = false;
-        string num = "";
-        vector<int> nums;
-        int otuCount = 0;
-        for (int i = 0; i < line.length(); i++) {
-            
-            if (m->control_pressed) { return lookup; }
-            
-            //look for opening [ to indicate data is starting
-            if ((line[i] == '[') && (!dataStart)) { dataStart = true; i++;  if (!(i < line.length())) { break; } }
-            else if ((line[i] == ']') && dataStart && (!inBrackets)) { break; } //we are done reading data
-                
-            if (dataStart) {
-                if ((line[i] == '[') && (!inBrackets)) { inBrackets = true; i++;  if (!(i < line.length())) { break; } }
-                else if ((line[i] == ']') && (inBrackets)) { 
-                    inBrackets = false; 
-                    int temp;
-                    m->mothurConvert(num, temp);
-                    nums.push_back(temp);
-                    num = "";
-                    
-                    //save info to vectors
-                    if (matrixFormat == "dense") {
-                        
-                        //sanity check
-                        if (nums.size() != lookup.size()) { m->mothurOut("[ERROR]: trouble parsing OTU data.  OTU " + toString(otuCount) + " causing errors.\n"); m->control_pressed = true; }
-                        
-                        //set abundances for this otu
-                        //nums contains [abundSample0, abundSample1, abundSample2, ...] for current OTU
-                        for (int j = 0; j < lookup.size(); j++) { lookup[j]->set(otuCount, nums[j], groupNames[j]); }
-                        
-                        otuCount++;
-                    }else {
-                        //sanity check
-                        if (nums.size() != 3) { m->mothurOut("[ERROR]: trouble parsing OTU data.\n"); m->control_pressed = true; }
-                        
-                        //nums contains [otuNum, sampleNum, abundance]
-                        lookup[nums[1]]->set(nums[0], nums[2], groupNames[nums[1]]);
-                    }
-                    nums.clear();
-                }
-                
-                if (inBrackets) {
-                    if (line[i] == ',') {
-                        int temp;
-                        m->mothurConvert(num, temp);
-                        nums.push_back(temp);
-                        num = "";
-                    }else { if (!isspace(line[i])) { num += line[i]; }  }
-                }
-            }
-        }
-        
-        //same as above just reading from file.
-        while (!in.eof()) {
-            
-            char c = in.get(); m->gobble(in);
-            
-            if (m->control_pressed) { return lookup; }
-            
-            //look for opening [ to indicate data is starting
-            if ((c == '[') && (!dataStart)) { dataStart = true; c = in.get();  if (in.eof()) { break; } }
-            else if ((c == ']') && dataStart && (!inBrackets)) { break; } //we are done reading data
-              
-            if (dataStart) {
-                if ((c == '[') && (!inBrackets)) { inBrackets = true; c = in.get();  if (in.eof()) { break; }  }
-                else if ((c == ']') && (inBrackets)) { 
-                    inBrackets = false; 
-                    int temp;
-                    m->mothurConvert(num, temp);
-                    nums.push_back(temp);
-                    num = "";
-                    
-                    //save info to vectors
-                    if (matrixFormat == "dense") {
-                        
-                        //sanity check
-                        if (nums.size() != lookup.size()) { m->mothurOut("[ERROR]: trouble parsing OTU data.  OTU " + toString(otuCount) + " causing errors.\n"); m->control_pressed = true; }
-                        
-                        //set abundances for this otu
-                        //nums contains [abundSample0, abundSample1, abundSample2, ...] for current OTU
-                        for (int j = 0; j < lookup.size(); j++) { lookup[j]->set(otuCount, nums[j], groupNames[j]); }
-                        
-                        otuCount++;
-                    }else {
-                        //sanity check
-                        if (nums.size() != 3) { m->mothurOut("[ERROR]: trouble parsing OTU data.\n"); m->control_pressed = true; }
-                        
-                        //nums contains [otuNum, sampleNum, abundance]
-                        lookup[nums[1]]->set(nums[0], nums[2], groupNames[nums[1]]);
-                    }
-                    nums.clear();
-                }
-                
-                if (inBrackets) {
-                    if (c == ',') {
-                        int temp;
-                        m->mothurConvert(num, temp);
-                        nums.push_back(temp);
-                        num = "";
-                    }else { if (!isspace(c)) { num += c; }  }
-                }
-            }
-        }
-        
-        SharedUtil util;
-        
-               bool remove = false;
-               for (int i = 0; i < lookup.size(); i++) {
-                       //if this sharedrabund is not from a group the user wants then delete it.
-                       if (util.isValidGroup(lookup[i]->getGroup(), m->getGroups()) == false) { 
-                               remove = true;
-                               delete lookup[i]; lookup[i] = NULL;
-                               lookup.erase(lookup.begin()+i); 
-                               i--; 
-                       }
-               }
-               
-               if (remove) { eliminateZeroOTUS(lookup); }
-
-        
-        return lookup;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "readData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedCommand::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
-    try {
-        
-        vector<SharedRAbundVector*> newLookup;
-        for (int i = 0; i < thislookup.size(); i++) {
-            SharedRAbundVector* temp = new SharedRAbundVector();
-            temp->setLabel(thislookup[i]->getLabel());
-            temp->setGroup(thislookup[i]->getGroup());
-            newLookup.push_back(temp);
-        }
-        
-        //for each bin
-        vector<string> newBinLabels;
-        string snumBins = toString(thislookup[0]->getNumBins());
-        for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-            if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-            
-            //look at each sharedRabund and make sure they are not all zero
-            bool allZero = true;
-            for (int j = 0; j < thislookup.size(); j++) {
-                if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-            }
-            
-            //if they are not all zero add this bin
-            if (!allZero) {
-                for (int j = 0; j < thislookup.size(); j++) {
-                    newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                }
-                
-                //if there is a bin label use it otherwise make one
-                string binLabel = "Otu";
-                string sbinNumber = toString(i+1);
-                if (sbinNumber.length() < snumBins.length()) { 
-                    int diff = snumBins.length() - sbinNumber.length();
-                    for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                }
-                binLabel += sbinNumber; 
-                if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                
-                newBinLabels.push_back(binLabel);
-            }
-        }
-        
-        for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-        
-        thislookup = newLookup;
-        m->currentBinLabels = newBinLabels;
-        
-        return 0;
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "SharedCommand", "eliminateZeroOTUS");
-        exit(1);
-    }
-}
-//**********************************************************************************************************************
-int SharedCommand::getDims(string line, int& shapeNumRows, int& shapeNumCols) {
-       try {
-        //get shape
-        bool inBar = false;
-        string num = "";
-        
-        for (int i = 0; i < line.length(); i++) {
-            
-            //you want to ignore any ; until you reach the next '
-            if ((line[i] == '[') && (!inBar)) {  inBar = true; i++;  if (!(i < line.length())) { break; } } 
-            else if ((line[i] == ']') && (inBar)) {  
-                inBar= false;  
-                m->mothurConvert(num, shapeNumCols);
-                break;
-            } 
-            
-            if (inBar) {  
-                if (line[i] == ',') {
-                    m->mothurConvert(num, shapeNumRows);
-                    num = "";
-                }else { if (!isspace(line[i])) { num += line[i]; }  }
-            }
-        }
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "getDims");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> SharedCommand::readRows(string line, ifstream& in, int& numRows) {
-       try {
-        /*"rows":[
-         {"id":"Otu01", "metadata":{"taxonomy":["Bacteria", "Bacteroidetes", "Bacteroidia", "Bacteroidales", "Porphyromonadaceae", "unclassified"], "bootstrap":[100, 100, 100, 100, 100, 100]}},
-         {"id":"Otu02", "metadata":{"taxonomy":["Bacteria", "Bacteroidetes", "Bacteroidia", "Bacteroidales", "Rikenellaceae", "Alistipes"], "bootstrap":[100, 100, 100, 100, 100, 100]}},
-         ...
-         ],*/
-        vector<string> names;
-        int countOpenBrace = 0;
-        int countClosedBrace = 0;
-        int openParen = 0;
-        int closeParen = 0;
-        string nextRow = "";
-        bool end = false;
-        
-        for (int i = 0; i < line.length(); i++) {
-            
-            if (m->control_pressed) { return names; }
-            
-            if (line[i] == '[')         { countOpenBrace++;     }
-            else if (line[i] == ']')    { countClosedBrace++;   }
-            else if (line[i] == '{')    { openParen++;          }
-            else if (line[i] == '}')    { closeParen++;         }
-            else if (openParen != 0)    { nextRow += line[i];   }  //you are reading the row info
-            
-            //you have reached the end of the rows info
-            if ((countOpenBrace == countClosedBrace) && (countClosedBrace != 0)) { end = true; break; }
-            if ((openParen == closeParen) && (closeParen != 0)) { //process row 
-                numRows++;
-                vector<string> items;
-                m->splitAtChar(nextRow, items, ','); //parse by comma, will return junk for metadata but we aren't using that anyway
-                string part = items[0]; items.clear();
-                m->splitAtChar(part, items, ':'); //split part we want containing the ids
-                string name = items[1];
-                
-                //remove "" if needed
-                int pos = name.find("\"");
-                if (pos != string::npos) {
-                    string newName = "";
-                    for (int k = 0; k < name.length(); k++) {
-                        if (name[k] != '\"') { newName += name[k]; }
-                    }
-                    name = newName;
-                }
-                names.push_back(name);
-                nextRow = "";
-                openParen = 0;
-                closeParen = 0;
-            }
-        }
-        
-        //keep reading
-        if (!end) {
-            while (!in.eof()) {
-                
-                if (m->control_pressed) { break; }
-                
-                char c = in.get(); m->gobble(in);
-                
-                if (c == '[')               { countOpenBrace++;     }
-                else if (c == ']')          { countClosedBrace++;   }
-                else if (c == '{')          { openParen++;          }
-                else if (c == '}')          { closeParen++;         }
-                else if (openParen != 0)    { nextRow += c;         }  //you are reading the row info
-                
-                
-                //you have reached the end of the rows info
-                if ((countOpenBrace == countClosedBrace) && (countClosedBrace != 0)) { end = true; break; }
-                if ((openParen == closeParen) && (closeParen != 0)) { //process row 
-                    numRows++;
-                    vector<string> items;
-                    m->splitAtChar(nextRow, items, ','); //parse by comma, will return junk for metadata but we aren't using that anyway
-                    string part = items[0]; items.clear();
-                    m->splitAtChar(part, items, ':'); //split part we want containing the ids
-                    string name = items[1];
-                    
-                    //remove "" if needed
-                    int pos = name.find("\"");
-                    if (pos != string::npos) {
-                        string newName = "";
-                        for (int k = 0; k < name.length(); k++) {
-                            if (name[k] != '\"') { newName += name[k]; }
-                        }
-                        name = newName;
-                    }
-                    names.push_back(name);
-                    nextRow = "";
-                    openParen = 0;
-                    closeParen = 0;
-                }  
-            }
-        }
-        
-        return names;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "readRows");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//designed for things like "type": "OTU table", returns map type -> OTU table
-string SharedCommand::getTag(string& line) {
-       try {
-        bool inQuotes = false;
-        string tag = "";
-        char c = '\"';
-        
-        for (int i = 0; i < line.length(); i++) {
-        
-            //you want to ignore any ; until you reach the next '
-                       if ((line[i] == c) && (!inQuotes)) {  inQuotes = true;  } 
-                       else if ((line[i] == c) && (inQuotes)) {  
-                inQuotes= false;  
-                line = line.substr(i+1);
-                return tag;
-            } 
-            
-                       if (inQuotes) {  if (line[i] != c) { tag += line[i]; }  }
-        }
-        
-        return tag;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "getInfo");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedCommand::createSharedFromListGroup(string filename) {
-       try {
-        ofstream out;
-        m->openOutputFile(filename, out);
-        
-        GroupMap* groupMap = new GroupMap(groupfile);
-        
-        int groupError = groupMap->readMap();
-        if (groupError == 1) { delete groupMap; return 0; }
-        vector<string> allGroups = groupMap->getNamesOfGroups();
-        m->setAllGroups(allGroups);
-        
-        pickedGroups = false;
-        
-        //if hte user has not specified any groups then use them all
-        if (Groups.size() == 0) {
-            Groups = groupMap->getNamesOfGroups(); m->setGroups(Groups);
-        }else { pickedGroups = true; }
-        
-        //fill filehandles with neccessary ofstreams
-        int i;
-        ofstream* temp;
-        for (i=0; i<Groups.size(); i++) {
-            temp = new ofstream;
-            filehandles[Groups[i]] = temp;
-        }
-        
-        //set fileroot
-        fileroot = outputDir + m->getRootName(m->getSimpleName(listfile));
-        
-        //clears file before we start to write to it below
-        for (int i=0; i<Groups.size(); i++) {
-            m->mothurRemove((fileroot + Groups[i] + ".rabund"));
-            outputNames.push_back((fileroot + Groups[i] + ".rabund"));
-            outputTypes["rabund"].push_back((fileroot + Groups[i] + ".rabund"));
-        }
-        
-        string errorOff = "no error";
-        
-        //if user provided an order file containing the order the shared file should be in read it
-        //if (ordergroupfile != "") { readOrderFile(); }
-        
-        InputData input(listfile, "shared");
-        SharedListVector* SharedList = input.getSharedListVector();
-        string lastLabel = SharedList->getLabel();
-        vector<SharedRAbundVector*> lookup; 
-        
-        if (m->control_pressed) { 
-            delete SharedList; delete groupMap; 
-            for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-            out.close(); m->mothurRemove(filename); 
-            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));                }
-            return 0; 
-        }
-        
-        //sanity check
-        vector<string> groupMapNamesSeqs = groupMap->getNamesSeqs();
-        int error = ListGroupSameSeqs(groupMapNamesSeqs, SharedList);
-        
-        if ((!pickedGroups) && (SharedList->getNumSeqs() != groupMap->getNumSeqs())) {  //if the user has not specified any groups and their files don't match exit with error
-            m->mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine(); 
-            
-            out.close();
-            m->mothurRemove(filename); //remove blank shared file you made
-            
-            createMisMatchFile(SharedList, groupMap);
-            
-            //delete memory
-            for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                delete it3->second;
-            }
-            
-            delete SharedList; delete groupMap; 
-            
-            return 0; 
-        }
-        
-        if (error == 1) { m->control_pressed = true; }
-        
-        //if user has specified groups make new groupfile for them
-        if (pickedGroups) { //make new group file
-            string groups = "";
-            if (m->getNumGroups() < 4) {
-                for (int i = 0; i < m->getNumGroups(); i++) {
-                    groups += (m->getGroups())[i] + ".";
-                }
-            }else { groups = "merge"; }
-            
-            string newGroupFile = outputDir + m->getRootName(m->getSimpleName(listfile)) + groups + "groups";
-            outputTypes["group"].push_back(newGroupFile); 
-            outputNames.push_back(newGroupFile);
-            ofstream outGroups;
-            m->openOutputFile(newGroupFile, outGroups);
-            
-            vector<string> names = groupMap->getNamesSeqs();
-            string groupName;
-            for (int i = 0; i < names.size(); i++) {
-                groupName = groupMap->getGroup(names[i]);
-                if (isValidGroup(groupName, m->getGroups())) {
-                    outGroups << names[i] << '\t' << groupName << endl;
-                }
-            }
-            outGroups.close();
-        }
-        
-        //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-        set<string> processedLabels;
-        set<string> userLabels = labels;       
-        
-        while((SharedList != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-            if (m->control_pressed) { 
-                delete SharedList; delete groupMap;
-                for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                out.close(); m->mothurRemove(filename); 
-                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));            }
-                return 0; 
-            }
-            
-            if(allLines == 1 || labels.count(SharedList->getLabel()) == 1){
-                
-                lookup = SharedList->getSharedRAbundVector();
-                
-                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                if (pickedGroups) { //check for otus with no seqs in them
-                    eliminateZeroOTUS(lookup);
-                }
-                
-                if (m->control_pressed) { 
-                    delete SharedList; delete groupMap; 
-                    for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                    for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                    out.close(); m->mothurRemove(filename); 
-                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));                }
-                    return 0; 
-                }
-                
-                if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                printSharedData(lookup, out); //prints info to the .shared file
-                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                
-                processedLabels.insert(SharedList->getLabel());
-                userLabels.erase(SharedList->getLabel());
-            }
-            
-            if ((m->anyLabelsToProcess(SharedList->getLabel(), userLabels, errorOff) == true) && (processedLabels.count(lastLabel) != 1)) {
-                string saveLabel = SharedList->getLabel();
-                
-                delete SharedList;
-                SharedList = input.getSharedListVector(lastLabel); //get new list vector to process
-                
-                lookup = SharedList->getSharedRAbundVector();
-                m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                if (pickedGroups) { //check for otus with no seqs in them
-                    eliminateZeroOTUS(lookup);
-                }
-                
-                
-                if (m->control_pressed) { 
-                    delete SharedList; delete groupMap; 
-                    for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                    for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;  }
-                    out.close(); m->mothurRemove(filename); 
-                    for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));                }
-                    return 0; 
-                }
-                
-                if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-                printSharedData(lookup, out); //prints info to the .shared file
-                for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-                
-                processedLabels.insert(SharedList->getLabel());
-                userLabels.erase(SharedList->getLabel());
-                
-                //restore real lastlabel to save below
-                SharedList->setLabel(saveLabel);
-            }
-            
-            
-            lastLabel = SharedList->getLabel();
-            
-            delete SharedList;
-            SharedList = input.getSharedListVector(); //get new list vector to process
-        }
-        
-        //output error messages about any remaining user labels
-        set<string>::iterator it;
-        bool needToRun = false;
-        for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-            if (processedLabels.count(lastLabel) != 1) {
-                needToRun = true;
-            }
-        }
-        
-        //run last label if you need to
-        if (needToRun == true)  {
-            if (SharedList != NULL) {  delete SharedList;      }
-            SharedList = input.getSharedListVector(lastLabel); //get new list vector to process
-            
-            lookup = SharedList->getSharedRAbundVector();
-            m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-            if (pickedGroups) { //check for otus with no seqs in them
-                eliminateZeroOTUS(lookup);
-            }
-            
-            if (m->control_pressed) { 
-                delete groupMap;
-                for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {  delete it3->second;   }
-                out.close(); m->mothurRemove(filename); 
-                for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));            }
-                return 0; 
-            }
-            
-            if (!m->printedHeaders) { lookup[0]->printHeaders(out); }
-            printSharedData(lookup, out); //prints info to the .shared file
-            for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-            delete SharedList;
-        }
-        
-        out.close();
-        
-        for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-            delete it3->second;
-        }
-        
-        delete groupMap;
-               
-        if (m->control_pressed) { 
-            m->mothurRemove(filename); 
-            for (int i=0; i<Groups.size(); i++) {  m->mothurRemove((fileroot + Groups[i] + ".rabund"));                }
-            return 0; 
-        }
-
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "createSharedFromListGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-void SharedCommand::printSharedData(vector<SharedRAbundVector*> thislookup, ofstream& out) {
-       try {
-               
-               if (order.size() == 0) { //user has not specified an order so do aplabetically
-                       sort(thislookup.begin(), thislookup.end(), compareSharedRabunds);
-                       
-                       m->clearGroups();
-                       vector<string> Groups;
-                       
-                       //initialize bin values
-                       for (int i = 0; i < thislookup.size(); i++) {
-                               out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
-                               thislookup[i]->print(out);
-                               
-                               Groups.push_back(thislookup[i]->getGroup());
-                               
-                               RAbundVector rav = thislookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
-                               rav.print(*(filehandles[thislookup[i]->getGroup()]));
-                               (*(filehandles[thislookup[i]->getGroup()])).close();
-                       }
-                       m->setGroups(Groups);
-               }else{
-                       //create a map from groupName to each sharedrabund
-                       map<string, SharedRAbundVector*> myMap;
-                       map<string, SharedRAbundVector*>::iterator myIt;
-                       
-                       for (int i = 0; i < thislookup.size(); i++) {
-                               myMap[thislookup[i]->getGroup()] = thislookup[i];
-                       }
-                       
-                       m->clearGroups();
-                       vector<string> Groups;
-                       
-                       //loop through ordered list and print the rabund
-                       for (int i = 0; i < order.size(); i++) {
-                               myIt = myMap.find(order[i]);
-                               
-                               if(myIt != myMap.end()) { //we found it
-                                       out << (myIt->second)->getLabel() << '\t' << (myIt->second)->getGroup() << '\t';
-                                       (myIt->second)->print(out);
-                                       
-                                       Groups.push_back((myIt->second)->getGroup());
-                               
-                                       RAbundVector rav = (myIt->second)->getRAbundVector();
-                                       m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
-                                       rav.print(*(filehandles[(myIt->second)->getGroup()]));
-                                       (*(filehandles[(myIt->second)->getGroup()])).close();
-                               }else{
-                                       m->mothurOut("Can't find shared info for " + order[i] + ", skipping."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       m->setGroups(Groups);
-               
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "printSharedData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedCommand::createMisMatchFile(SharedListVector* SharedList, GroupMap* groupMap) {
-       try {
-               ofstream outMisMatch;
-               string outputMisMatchName = outputDir + m->getRootName(m->getSimpleName(listfile));
-               
-               //you have sequences in your list file that are not in your group file
-               if (SharedList->getNumSeqs() > groupMap->getNumSeqs()) { 
-                       outputMisMatchName += "missing.group";
-                       m->mothurOut("For a list of names that are in your list file and not in your group file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
-                       
-                       m->openOutputFile(outputMisMatchName, outMisMatch);
-                       
-                       set<string> listNames;
-                       set<string>::iterator itList;
-                       
-                       //go through list and if group returns "not found" output it
-                       for (int i = 0; i < SharedList->getNumBins(); i++) {
-                               if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; } 
-                       
-                               string names = SharedList->get(i); 
-                               
-                vector<string> binNames;
-                m->splitAtComma(names, binNames);
-                
-                               for (int j = 0; j < binNames.size(); j++) { 
-                                       string name = binNames[j];
-                                       string group = groupMap->getGroup(name);
-                                       
-                                       if(group == "not found") {      outMisMatch << name << endl;  }
-                                       
-                                       itList = listNames.find(name);
-                                       if (itList != listNames.end()) {  m->mothurOut(name + " is in your list file more than once.  Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
-                                       else { listNames.insert(name); }
-                               }
-                       }
-                       
-                       outMisMatch.close();
-                       
-               
-               }else {//you have sequences in your group file that are not in you list file
-                       
-                       outputMisMatchName += "missing.name";
-                       m->mothurOut("For a list of names that are in your group file and not in your list file, please refer to " + outputMisMatchName + "."); m->mothurOutEndLine();
-                       
-                       map<string, string> namesInList;
-                       map<string, string>::iterator itList;
-                       
-                       //go through listfile and get names
-                       for (int i = 0; i < SharedList->getNumBins(); i++) {
-                               if (m->control_pressed) {  return 0; } 
-
-                               
-                               string names = SharedList->get(i); 
-               
-                               vector<string> binNames;
-                m->splitAtComma(names, binNames);
-                
-                               for (int j = 0; j < binNames.size(); j++) { 
-
-                                       string name = binNames[j];
-                                       
-                                       itList = namesInList.find(name);
-                                       if (itList != namesInList.end()) {  m->mothurOut(name + " is in your list file more than once.  Sequence names must be unique. please correct."); m->mothurOutEndLine(); }
-
-                                       namesInList[name] = name;
-                                       
-                               }
-                       }
-                       
-                       //get names of sequences in groupfile
-                       vector<string> seqNames = groupMap->getNamesSeqs();
-               
-                       map<string, string>::iterator itMatch;
-                       
-                       m->openOutputFile(outputMisMatchName, outMisMatch);
-                       
-                       //loop through names in seqNames and if they aren't in namesIn list output them
-                       for (int i = 0; i < seqNames.size(); i++) {
-                               if (m->control_pressed) { outMisMatch.close(); m->mothurRemove(outputMisMatchName); return 0; } 
-                               
-                               itMatch = namesInList.find(seqNames[i]);
-                               
-                               if (itMatch == namesInList.end()) {
-                               
-                                       outMisMatch << seqNames[i] << endl; 
-                               }
-                       }               
-                       outMisMatch.close();
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "createMisMatchFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedCommand::ListGroupSameSeqs(vector<string>& groupMapsSeqs, SharedListVector* SharedList) {
-       try {
-               int error = 0; 
-               
-               set<string> groupNamesSeqs;
-               for(int i = 0; i < groupMapsSeqs.size(); i++) {
-                       groupNamesSeqs.insert(groupMapsSeqs[i]);
-               }
-               
-               //go through list and if group returns "not found" output it
-               for (int i = 0; i < SharedList->getNumBins(); i++) {
-                       if (m->control_pressed) { return 0; } 
-                       
-                       string names = SharedList->get(i); 
-                       
-                       vector<string> listNames;
-                       m->splitAtComma(names, listNames);
-                       
-                       for (int j = 0; j < listNames.size(); j++) {
-                               int num = groupNamesSeqs.count(listNames[j]);
-                               
-                               if (num == 0) { error = 1; m->mothurOut("[ERROR]: " + listNames[j] + " is in your listfile and not in your groupfile. Please correct."); m->mothurOutEndLine(); }
-                               else { groupNamesSeqs.erase(listNames[j]); }
-                       }
-               }
-               
-               for (set<string>::iterator itGroupSet = groupNamesSeqs.begin(); itGroupSet != groupNamesSeqs.end(); itGroupSet++) {
-                       error = 1; 
-                       m->mothurOut("[ERROR]: " + (*itGroupSet) + " is in your groupfile and not your listfile. Please correct."); m->mothurOutEndLine();
-               }
-                               
-               return error;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "ListGroupSameSeqs");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SharedCommand::~SharedCommand(){
-       //delete list;
-       
-       
-}
-//**********************************************************************************************************************
-int SharedCommand::readOrderFile() {
-       try {
-               //remove old names
-               order.clear();
-               
-               ifstream in;
-               m->openInputFile(ordergroupfile, in);
-               string thisGroup;
-               
-               while(!in.eof()){
-                       in >> thisGroup; m->gobble(in);
-                                               
-                       order.push_back(thisGroup);
-                       
-                       if (m->control_pressed) { order.clear(); break; }
-               }
-               in.close();             
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "readOrderFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-bool SharedCommand::isValidGroup(string groupname, vector<string> groups) {
-       try {
-               for (int i = 0; i < groups.size(); i++) {
-                       if (groupname == groups[i]) { return true; }
-               }
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedCommand", "isValidGroup");
-               exit(1);
-       }
-}
-/************************************************************/
-
-
diff --git a/sharedcommand.h b/sharedcommand.h
deleted file mode 100644 (file)
index 5d0daa2..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef SHAREDCOMMAND_H
-#define SHAREDCOMMAND_H
-/*
- *  sharedcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "sharedlistvector.h"
-#include "inputdata.h"
-
-/* The shared() command:
-       The shared command can only be executed after a successful read.shared command.  
-       The shared command parses a .list file and separates it into groups.  
-       It outputs a .shared file containing the OTU information for each group.  
-       There are no shared command parameters.  The shared command should be in the following format: shared(). */
-
-
-class SharedCommand : public Command {
-       
-public:
-       SharedCommand(string);  
-       SharedCommand();
-       ~SharedCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "make.shared";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Make.shared"; }
-       string getDescription()         { return "make a shared file from a list and group file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       void printSharedData(vector<SharedRAbundVector*>, ofstream&);
-       int createMisMatchFile(SharedListVector*, GroupMap*);
-       int readOrderFile();
-       bool isValidGroup(string, vector<string>);
-       int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
-       int ListGroupSameSeqs(vector<string>&, SharedListVector*);
-    int createSharedFromListGroup(string);
-    int createSharedFromBiom(string);
-    string getTag(string&);
-    vector<string> readRows(string, ifstream&, int&); 
-    int getDims(string, int&, int&);
-    vector<SharedRAbundVector*> readData(string, string, ifstream&, vector<string>&, int);
-       
-       vector<string> Groups, outputNames, order;
-       set<string> labels;
-       string fileroot, outputDir, listfile, groupfile, biomfile, ordergroupfile;
-       bool firsttime, pickedGroups, abort, allLines;
-       map<string, ofstream*> filehandles;
-       map<string, ofstream*>::iterator it3;
-
-};
-
-#endif
diff --git a/sharedjabund.cpp b/sharedjabund.cpp
deleted file mode 100644 (file)
index d86fcb8..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  sharedjabund.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedjabund.h"
-
-/***********************************************************************/
-
-EstOutput JAbund::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               EstOutput UVest;
-               UVest.resize(2,0);
-               data.resize(1,0);
-               
-               UVest = uv->getUVest(shared);
-               
-               //UVest[0] is Uest UVest[1] is Vest
-               data[0] = 1.0-(UVest[0] * UVest[1]) / ((float)(UVest[0] + UVest[1] - (UVest[0] * UVest[1])));
-               if(data[0] > 1){data[0] = 0;    }
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "JAbund", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedjabund.h b/sharedjabund.h
deleted file mode 100644 (file)
index 083ad23..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef JABUND_H
-#define JABUND_H
-/*
- *  sharedjabund.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedJAbund estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class JAbund : public Calculator  {
-       
-public:
-       JAbund() :  Calculator("jabund", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Jabund"; }
-private:
-       UVEst* uv;
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedjackknife.cpp b/sharedjackknife.cpp
deleted file mode 100644 (file)
index 0998db8..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- *  sharedjackknife.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedjackknife.h"
-
-/***************************************************************************************
-
-***************************************************************************************/
-double SharedJackknife::simpson(vector<int> abunds, double numInd, int numBins){
-       double denom = numInd*(numInd-1);
-       double sum = 0;
-       for(int i = 0; i < numBins; i++)
-               sum += (double)abunds[i]*((double)abunds[i]-1)/denom;
-       
-       return sum;
-}
-
-/*****************************************************************************************/
-
-double* SharedJackknife::jackknife(){          
-       int numBins = groups.at(0)->getNumBins()-1;
-       vector<int> cArray(numBins);
-       for(int i = 0; i < numBins; i++)
-               cArray[i] = 0;
-
-       double numInd = 0;
-       for(int i = 0; i < numGroups; i++)
-               for(int j = 0; j < numBins; j++) {
-                       int curAbund = groups.at(i)->get(j+1).abundance;
-                       cArray[j] += curAbund;
-                       numInd += (double)curAbund;
-               }
-
-       double baseD = 1/simpson(cArray, numInd, numBins);
-       
-       vector<double> pseudoVals(numBins);
-       double jackknifeEstimate = 0;
-       for(int i = 0; i < numGroups; i++) {
-               for(int j = 0; j < numBins-1; j++) {
-                       int abundDiff = -groups.at(i)->get(j+1).abundance;
-                       if(i > 0)
-                               abundDiff += groups.at(i-1)->get(j+1).abundance;
-
-                       cArray[j] += abundDiff;
-                       numInd += abundDiff;    
-               }
-               
-               double curD = 1/simpson(cArray, numInd, numBins);
-               pseudoVals[i] = (double)numGroups*(baseD - curD) + curD;
-               jackknifeEstimate += pseudoVals[i];
-       }
-       jackknifeEstimate /= (double)numGroups;
-               
-       double variance = 0;
-       for(int i = 0; i < numGroups; i++)
-               variance += pow(pseudoVals[i]-jackknifeEstimate, 2);
-               
-       variance /= (double)numGroups*((double)numGroups-1);
-       double stErr = sqrt(variance);
-       TDTable table;
-       double confLimit = 0;
-       if(numGroups <= 30)
-               confLimit = table.getConfLimit(numGroups-1, 1);
-       else
-               confLimit = 1.645;
-       
-       confLimit *= stErr;
-       
-       double* rdata = new double[3];
-       rdata[0] = baseD;
-       rdata[1] = jackknifeEstimate - confLimit;
-       rdata[2] = jackknifeEstimate + confLimit;
-       
-       return rdata;
-}
-
-/************************************************************************************************
-************************************************************************************************/
-
-EstOutput SharedJackknife::getValues(vector<SharedRAbundVector*> vectorShared){ //Fix this for collect, mistake was that it was made with summary in mind.
-       try {
-               SharedRAbundVector* shared1 = vectorShared[0];
-               SharedRAbundVector* shared2 = vectorShared[1];
-               if(numGroups == -1) {
-                       numGroups = m->getNumGroups();
-               }
-
-               if(callCount == numGroups*(numGroups-1)/2) {
-                       currentCallDone = true;
-                       callCount = 0;
-               }
-               callCount++;
-
-               if(currentCallDone) {
-                       groups.clear(); 
-                       currentCallDone = false;
-               }
-               
-               if(groups.size() != numGroups) {        
-                       if(groups.size() == 0)
-                               groups.push_back(shared1);
-                       groups.push_back(shared2);
-               }
-               
-               if(groups.size() == numGroups && callCount < numGroups) {
-                       data.resize(3,0);
-
-                       double* rdata = jackknife();
-                       data[0] = rdata[0];
-                       data[1] = rdata[1];
-                       data[2] = rdata[2];
-               
-                       if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-                       if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-                       if (isnan(data[2]) || isinf(data[0])) { data[2] = 0; }
-                       
-                       return data;
-               }
-               
-               data.resize(3,0);
-               data[0] = 0;
-               data[1] = 0;
-               data[2] = 0;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               return data;    
-       }
-               
-       catch(exception& e) {
-               m->errorOut(e, "SharedJackknife", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sharedjackknife.h b/sharedjackknife.h
deleted file mode 100644 (file)
index 1e9cbf5..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef SHAREDJACKKNIFE_H
-#define SHAREDJACKKNIFE_H
-
-/*
- *  sharedjackknife.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/*This class implements the SharedJackknife estimator. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class SharedJackknife : public Calculator  {
-       
-public:
-       SharedJackknife() : numGroups(-1), callCount(0), count(0), currentCallDone(true), Calculator("sharedjackknife", 3, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sharedjackknife"; }
-       
-private:
-       int numGroups, callCount, count;
-       bool currentCallDone;
-       vector<SharedRAbundVector*> groups;
-       double simpson(vector<int>, double, int);
-       double* jackknife();
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/sharedjclass.cpp b/sharedjclass.cpp
deleted file mode 100644 (file)
index ed21335..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  sharedjclass.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedjclass.h"
-
-/***********************************************************************/
-
-EstOutput Jclass::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       //find number of bins in shared1 and shared2
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-                       
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = 1.0 - S12 / (float)(S1 + S2 - S12);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Jclass", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedjclass.h b/sharedjclass.h
deleted file mode 100644 (file)
index 015b8ac..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef JCLASS_H
-#define JCLASS_H
-/*
- *  sharedjclass.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedJclass estimator on two groups. 
-It is a child of the calculator class. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Jclass : public Calculator  {
-       
-public:
-       Jclass() :  Calculator("jclass", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Jclass"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedjest.cpp b/sharedjest.cpp
deleted file mode 100644 (file)
index 9a1cfbb..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *  sharedjest.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "sharedchao1.h"
-#include "chao1.h"
-#include "sharedjest.h"
-
-
-/***********************************************************************/
-
-EstOutput Jest::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               EstOutput S1, S2, S12;
-               S12.resize(1,0);
-               S1.resize(3,0);
-               S2.resize(3,0); 
-               
-               /*S1, S2 = number of OTUs estimated in A and B using the Chao estimator
-               S12 = estimated number of OTUs shared between A and B using the SharedChao estimator*/
-
-               data.resize(1,0);
-               
-               SharedChao1* sharedChao = new SharedChao1();
-               Chao1* chaoS1 = new Chao1();
-               Chao1* chaoS2 = new Chao1();
-               SAbundVector* chaoS1Sabund = new SAbundVector();
-               SAbundVector* chaoS2Sabund = new SAbundVector();
-               
-               *chaoS1Sabund = shared[0]->getSAbundVector();
-               *chaoS2Sabund = shared[1]->getSAbundVector();
-               
-               S12 = sharedChao->getValues(shared);
-               S1 = chaoS1->getValues(chaoS1Sabund);
-               S2 = chaoS2->getValues(chaoS2Sabund);
-               
-               data[0] = 1.0 - S12[0] / (float)(S1[0] + S2[0] - S12[0]);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               delete sharedChao;
-               delete chaoS1;
-               delete chaoS2;
-               delete chaoS1Sabund;
-               delete chaoS2Sabund;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Jest", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedjest.h b/sharedjest.h
deleted file mode 100644 (file)
index 5f06884..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef JEST_H
-#define JEST_H
-/*
- *  sharedjest.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedJest estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Jest : public Calculator  {
-       
-public:
-       Jest() :  Calculator("jest", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Jest"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedkstest.cpp b/sharedkstest.cpp
deleted file mode 100644 (file)
index d914788..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *  kstest.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedkstest.h"
-
-/***********************************************************************/
-
-EstOutput KSTest::getValues(vector<SharedRAbundVector*> shared){
-       try {
-               data.resize(3,0);
-
-               //Must return shared1 and shared2 to original order at conclusion of kstest
-               vector <individual> initData1 = shared[0]->getData();
-               vector <individual> initData2 = shared[1]->getData();
-               shared[0]->sortD();
-               shared[1]->sortD();
-
-               int numNZ1 = shared[0]->numNZ();
-               int numNZ2 = shared[1]->numNZ();
-               double numInd1 = (double)shared[0]->getNumSeqs();
-               double numInd2 = (double)shared[1]->getNumSeqs();
-               
-               double maxDiff = -1;
-               double sum1 = 0;
-               double sum2 = 0;
-               for(int i = 1; i < shared[0]->getNumBins(); i++)
-               {
-                       sum1 += shared[0]->get(i).abundance;
-                       sum2 += shared[1]->get(i).abundance;
-                       double diff = fabs((double)sum1/numInd1 - (double)sum2/numInd2);
-                       if(diff > maxDiff)
-                               maxDiff = diff;
-               }
-               
-               double DStatistic = maxDiff*numNZ1*numNZ2;
-               double a = pow((double)(numNZ1 + numNZ2)/(numNZ1*numNZ2),.5);
-               //double pVal = exp(-2*pow(maxDiff/a,2));
-               double critVal = 1.36*a*numNZ1*numNZ2;
-               
-               shared[0]->setData(initData1);
-               shared[1]->setData(initData2);
-               
-               data[0] = DStatistic;
-               data[1] = critVal;
-               data[2] = 0;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KSTest", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedkstest.h b/sharedkstest.h
deleted file mode 100644 (file)
index 1ffae83..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef KSTEST_H
-#define KSTEST_H
-/*
- *  kstest.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/6/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/*This class implements the KSTest estimator on 2 groups. 
-It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class KSTest : public Calculator  {
-       
-public:
-       KSTest() : Calculator("kstest", 3, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Kstest"; }
-private:
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedkulczynski.cpp b/sharedkulczynski.cpp
deleted file mode 100644 (file)
index 5c91ddb..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  sharedkulczynski.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedkulczynski.h"
-
-/***********************************************************************/
-
-EstOutput Kulczynski::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = 1.0 - S12 / (float)(S1 + S2 - (2 * S12));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Kulczynski", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedkulczynski.h b/sharedkulczynski.h
deleted file mode 100644 (file)
index 675ce4d..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef KULCZYNSKI_H
-#define KULCZYNSKI_H
-/*
- *  sharedkulczynski.h
- *  Mothur
- *
- *  Created by John Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Kulczynski : public Calculator  {
-       
-public:
-       Kulczynski() :  Calculator("kulczynski", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Kulczynski"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedkulczynskicody.cpp b/sharedkulczynskicody.cpp
deleted file mode 100644 (file)
index 8c8b7f7..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  sharedkulczynskicody.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedkulczynskicody.h"
-
-/***********************************************************************/
-
-EstOutput KulczynskiCody::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = 1.0 - 0.5 * ((S12 / (float)S1) + (S12 / (float)S2));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "KulczynskiCody", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedkulczynskicody.h b/sharedkulczynskicody.h
deleted file mode 100644 (file)
index 9cb651f..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef KULCZYNSKICODY_H
-#define KULCZYNSKICODY_H
-
-/*
- *  sharedkulczynskicody.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class KulczynskiCody : public Calculator  {
-       
-public:
-       KulczynskiCody() :  Calculator("kulczynskicody", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Kulczynskicody"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedlennon.cpp b/sharedlennon.cpp
deleted file mode 100644 (file)
index 5219275..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- *  sharedlennon.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedlennon.h"
-
-/***********************************************************************/
-
-EstOutput Lennon::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB, min;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; min = 0;
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               
-               tempA = S1 - S12;  tempB = S2 - S12;
-               
-               if (tempA < tempB) { min = tempA; }
-               else { min = tempB; }
-               
-               data[0] = 1.0 - S12 / (float)(S12 + min);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Lennon", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedlennon.h b/sharedlennon.h
deleted file mode 100644 (file)
index cf1831e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef LENNON_H
-#define LENNON_H
-
-/*
- *  sharedlennon.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Lennon : public Calculator  {
-       
-public:
-       Lennon() :  Calculator("lennon", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Lennon"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedlistvector.cpp b/sharedlistvector.cpp
deleted file mode 100644 (file)
index 6dfcb97..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- *  sharedSharedListVector.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
-#include "ordervector.hpp"
-#include "sharedlistvector.h"
-#include "sharedordervector.h"
-#include "sharedutilities.h"
-
-/***********************************************************************/
-
-SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){ groupmap = NULL; }
-
-/***********************************************************************/
-
-SharedListVector::SharedListVector(int n):     DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){ groupmap = NULL; }
-
-/***********************************************************************/
-SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               //set up groupmap for later.
-               groupmap = new GroupMap(m->getGroupFile());
-               groupmap->readMap(); 
-
-               int hold;
-               string inputData;
-               f >> label >> hold;
-       
-               data.assign(hold, "");
-               
-               for(int i=0;i<hold;i++){
-                       f >> inputData;
-                       set(i, inputData);
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "SharedListVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedListVector::set(int binNumber, string seqNames){
-       try {
-               int nNames_old = m->getNumNames(data[binNumber]);
-               data[binNumber] = seqNames;
-               int nNames_new = m->getNumNames(seqNames);
-       
-               if(nNames_old == 0)                     {       numBins++;                              }
-               if(nNames_new == 0)                     {       numBins--;                              }
-               if(nNames_new > maxRank)        {       maxRank = nNames_new;   }
-       
-               numSeqs += (nNames_new - nNames_old);
-               
-                        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-string SharedListVector::get(int index){
-       return data[index];
-}
-
-/***********************************************************************/
-
-void SharedListVector::push_back(string seqNames){
-       try {
-               data.push_back(seqNames);
-               int nNames = m->getNumNames(seqNames);
-       
-               numBins++;
-       
-               if(nNames > maxRank)    {       maxRank = nNames;       }
-       
-               numSeqs += nNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedListVector::resize(int size){
-       data.resize(size);              
-}
-
-/***********************************************************************/
-
-int SharedListVector::size(){
-       return data.size();
-}
-/***********************************************************************/
-
-void SharedListVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       return data.clear();
-       
-}
-
-/***********************************************************************/
-
-void SharedListVector::print(ostream& output){
-       try {
-               output << label << '\t' << numBins << '\t';
-       
-               for(int i=0;i<data.size();i++){
-                       if(data[i] != ""){
-                               output << data[i] << '\t';
-                       }
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "print");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-RAbundVector SharedListVector::getRAbundVector(){
-       try {
-               RAbundVector rav;
-       
-               for(int i=0;i<data.size();i++){
-                       int binSize = m->getNumNames(data[i]);
-                       rav.push_back(binSize);
-               }
-       
-       //  This was here before to output data in a nice format, but it screws up the name mapping steps
-       //      sort(rav.rbegin(), rav.rend());
-       //      
-       //      for(int i=data.size()-1;i>=0;i--){
-       //              if(rav.get(i) == 0){    rav.pop_back(); }
-       //              else{
-       //                      break;
-       //              }
-       //      }
-               rav.setLabel(label);
-       
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SAbundVector SharedListVector::getSAbundVector(){
-       try {
-               SAbundVector sav(maxRank+1);
-       
-               for(int i=0;i<data.size();i++){
-                       int binSize = m->getNumNames(data[i]);  
-                       sav.set(binSize, sav.get(binSize) + 1); 
-               }
-               sav.set(0, 0);
-               sav.setLabel(label);
-       
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-SharedOrderVector* SharedListVector::getSharedOrderVector(){
-       try {
-               string groupName, names, name;
-       
-               SharedOrderVector* order = new SharedOrderVector();
-               order->setLabel(label);
-       
-               for(int i=0;i<numBins;i++){
-                       int binSize = m->getNumNames(get(i));   //find number of individual in given bin        
-                       names = get(i);
-                       while (names.find_first_of(',') != -1) { 
-                               name = names.substr(0,names.find_first_of(','));
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                               groupName = groupmap->getGroup(name);
-                               
-                               if(groupName == "not found") {  m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                               
-                               order->push_back(i, binSize, groupName);  //i represents what bin you are in
-                       }
-                       //get last name
-                       groupName = groupmap->getGroup(names);
-                       if(groupName == "not found") {  m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                       order->push_back(i, binSize, groupName);
-               }
-
-               random_shuffle(order->begin(), order->end());
-               order->updateStats();
-               
-               return order;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getSharedOrderVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-SharedRAbundVector SharedListVector::getSharedRAbundVector(string groupName) {
-       try {
-               SharedRAbundVector rav(data.size());
-               string group, names, name;
-               
-               for(int i=0;i<numBins;i++){
-                       names = get(i);  
-                       while (names.find_first_of(',') != -1) { 
-                               name = names.substr(0,names.find_first_of(','));
-                               names = names.substr(names.find_first_of(',')+1, names.length());
-                               group = groupmap->getGroup(name);
-                               if(group == "not found") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                               if (group == groupName) { //this name is in the group you want the vector for.
-                                       rav.set(i, rav.getAbundance(i) + 1, group);  //i represents what bin you are in
-                               }
-                       }
-                       
-                       //get last name
-                       groupName = groupmap->getGroup(names);
-                       if(groupName == "not found") {  m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                       if (group == groupName) { //this name is in the group you want the vector for.
-                                       rav.set(i, rav.getAbundance(i) + 1, group);  //i represents what bin you are in
-                       }
-               }
-               
-               rav.setLabel(label);
-               rav.setGroup(groupName);
-
-               return rav;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getSharedRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<SharedRAbundVector*> SharedListVector::getSharedRAbundVector() {
-       try {
-               SharedUtil* util;
-               util = new SharedUtil();
-               vector<SharedRAbundVector*> lookup;  //contains just the groups the user selected
-               map<string, SharedRAbundVector*> finder;  //contains all groups in groupmap
-               string group, names, name;
-               
-               vector<string> Groups = m->getGroups();
-               vector<string> allGroups = groupmap->getNamesOfGroups();
-               util->setGroups(Groups, allGroups);
-               m->setGroups(Groups);
-               delete util;
-
-               for (int i = 0; i < allGroups.size(); i++) {
-                       SharedRAbundVector* temp = new SharedRAbundVector(data.size());
-                       finder[allGroups[i]] = temp;
-                       finder[allGroups[i]]->setLabel(label);
-                       finder[allGroups[i]]->setGroup(allGroups[i]);
-                       if (m->inUsersGroups(allGroups[i], m->getGroups())) {  //if this group is in user groups
-                               lookup.push_back(finder[allGroups[i]]);
-                       }
-               }
-       
-               //fill vectors
-               for(int i=0;i<numBins;i++){
-                       names = get(i);  
-                       int nameLength = names.size();
-                       string seqName = "";
-                       
-                       for(int j=0;j<nameLength;j++){
-                               if(names[j] == ','){
-                                       group = groupmap->getGroup(seqName);
-                                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                                       finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
-                                       
-                                       seqName = "";
-                               }
-                               else{
-                                       seqName += names[j];
-                               }
-                       }
-                       group = groupmap->getGroup(seqName);
-                       if(group == "not found") {      m->mothurOut("Error: Sequence '" + seqName + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-                       finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
-                       
-                       
-                       
-//                     while (names.find_first_of(',') != -1) { 
-//                             name = names.substr(0,names.find_first_of(','));
-//                             names = names.substr(names.find_first_of(',')+1, names.length());
-//                             group = groupmap->getGroup(name);
-//                             if(group == "not found") {      m->mothurOut("Error: Sequence '" + name + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-//                             finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
-//                     }
-                       
-                       //get last name
-//                     group = groupmap->getGroup(names);
-//                     if(group == "not found") {      m->mothurOut("Error: Sequence '" + names + "' was not found in the group file, please correct."); m->mothurOutEndLine();  exit(1); }
-//                     finder[group]->set(i, finder[group]->getAbundance(i) + 1, group);  //i represents what bin you are in
-                       
-               }
-
-               return lookup;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getSharedRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-SharedSAbundVector SharedListVector::getSharedSAbundVector(string groupName) {
-       try { 
-               SharedSAbundVector sav;
-               SharedRAbundVector rav;
-               
-               rav = this->getSharedRAbundVector(groupName);
-               sav = rav.getSharedSAbundVector();
-               
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getSharedSAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-OrderVector SharedListVector::getOrderVector(map<string,int>* orderMap = NULL){
-       
-       try {
-               if(orderMap == NULL){
-                       OrderVector ov;
-               
-                       for(int i=0;i<data.size();i++){
-                               int binSize = m->getNumNames(data[i]);          
-                               for(int j=0;j<binSize;j++){
-                                       ov.push_back(i);
-                               }
-                       }
-                       random_shuffle(ov.begin(), ov.end());
-                       ov.setLabel(label);
-                       ov.getNumBins();
-               
-                       return ov;
-               
-               }
-               else{
-                       OrderVector ov(numSeqs);
-               
-                       for(int i=0;i<data.size();i++){
-                               string listOTU = data[i];
-                               int length = listOTU.size();
-                               
-                               string seqName="";
-                       
-                               for(int j=0;j<length;j++){
-                               
-                                       if(listOTU[j] != ','){
-                                               seqName += listOTU[j];
-                                       }
-                                       else{
-                                               if(orderMap->count(seqName) == 0){
-                                                       m->mothurOut(seqName + " not found, check *.names file\n");
-                                                       exit(1);
-                                               }
-                                       
-                                               ov.set((*orderMap)[seqName], i);
-                                               seqName = "";
-                                       }                                               
-                               }
-                       
-                               if(orderMap->count(seqName) == 0){
-                                       m->mothurOut(seqName + " not found, check *.names file\n");
-                                       exit(1);
-                               }
-                               ov.set((*orderMap)[seqName], i);        
-                       }
-               
-                       ov.setLabel(label);
-                       ov.getNumBins();
-               
-                       return ov;              
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedListVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sharedlistvector.h b/sharedlistvector.h
deleted file mode 100644 (file)
index 56ea802..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef SHAREDLIST_H
-#define SHAREDLIST_H
-
-/*
- *  sharedlistvector.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "datavector.hpp"
-#include "groupmap.h"
-#include "sharedrabundvector.h"
-#include "sharedsabundvector.h"
-
-/* This class is a child to datavector.  It represents OTU information at a certain distance. 
-       A sharedlistvector can be converted into a sharedordervector, sharedrabundvector or sharedsabundvectorand 
-       as well as an ordervector, rabundvector or sabundvector.
-       Each member of the internal container "data" represents an individual OTU.
-       Each individual in the OTU belongs to a group.
-       So data[0] = "a,b,c,d,e,f".
-       example: listvector             =       a,b,c,d,e,f             g,h,i           j,k             l               m  
-                        rabundvector   =       6                               3                       2               1               1
-                        sabundvector   =       2               1               1               0               0               1
-                        ordervector    =       1       1       1       1       1       1       2       2       2       3       3       4       5 */
-
-class SharedListVector : public DataVector {
-       
-public:
-       SharedListVector();
-       SharedListVector(int);
-       SharedListVector(ifstream&);
-       SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){ groupmap = NULL; };
-       ~SharedListVector(){ if (groupmap != NULL) { delete groupmap; } };
-       
-       int getNumBins()                                                        {       return numBins;         }
-       int getNumSeqs()                                                        {       return numSeqs;         }
-       int getMaxRank()                                                        {       return maxRank;         }
-
-       void set(int, string);  
-       string get(int);
-       void push_back(string);
-       void resize(int);
-       void clear();
-       int size();
-       void print(ostream&);
-       
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       SharedOrderVector* getSharedOrderVector();
-       SharedRAbundVector getSharedRAbundVector(string);  //get sharedrabundvector for a certain group
-       SharedSAbundVector getSharedSAbundVector(string);                       //get sharedsabundvector for a certain group
-       vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
-       
-private:
-       vector<string> data;  //data[i] is a list of names of sequences in the ith OTU.
-       GroupMap* groupmap;
-       int maxRank;
-       int numBins;
-       int numSeqs;
-
-};
-
-#endif
diff --git a/sharedmarczewski.cpp b/sharedmarczewski.cpp
deleted file mode 100644 (file)
index 57de5f5..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- *  sharedmarczewski.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedmarczewski.h"
-
-EstOutput SharedMarczewski::getValues(vector<SharedRAbundVector*> vectorShared){
-       try {
-               SharedRAbundVector* shared1 = vectorShared[0];
-               SharedRAbundVector* shared2 = vectorShared[1];
-               
-               data.resize(1,0);
-               
-               double a = 0;
-               double b = 0;
-               double c = 0;
-               for(int i = 1; i < shared1->size(); i++)
-               {
-                       int abund1 = shared1->get(i).abundance;
-                       int abund2 = shared2->get(i).abundance;
-                       
-                       if(abund1 > 0 && abund2 > 0)
-                               a++;
-                       else if(abund1 > 0 && abund2 == 0)
-                               b++;
-                       else if(abund1 == 0 && abund2 > 0)
-                               c++;
-               }
-               data[0] = (b+c)/(a+b+c);
-
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedMarczewski", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedmarczewski.h b/sharedmarczewski.h
deleted file mode 100644 (file)
index 66a18f7..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SHAREDMARCZEWSKI_H
-#define SHAREDMARCZEWSKI_H
-
-/*
- *  sharedmarczewski.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SharedMarczewski : public Calculator  {
-       
-public:
-       SharedMarczewski() : Calculator("sharedmarczewski", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sharedmarczewski"; }
-private:
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedmorisitahorn.cpp b/sharedmorisitahorn.cpp
deleted file mode 100644 (file)
index 16a7590..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *  sharedmorisitahorn.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedmorisitahorn.h"
-
-/***********************************************************************/
-EstOutput MorHorn::getValues(vector<SharedRAbundVector*> shared) {
-       try {   
-               data.resize(1,0);
-               
-               double Atotal, Btotal, tempA, tempB;
-               Atotal = 0; Btotal = 0; 
-               double  morhorn, sumSharedA, sumSharedB, a, b, d;
-               morhorn = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
-               
-               //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       Atotal += shared[0]->getAbundance(i);
-                       Btotal += shared[1]->getAbundance(i);
-               }
-               
-               //calculate the denominator sums
-               for (int j = 0; j < shared[0]->getNumBins(); j++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(j);
-                       tempB = shared[1]->getAbundance(j);
-                       float relA = tempA / Atotal;
-                       float relB = tempB / Btotal;
-                       
-                       a += relA * relA;
-                       b += relB * relB;
-                       d += relA * relB;
-               }
-
-               morhorn = 1- (2 * d) / (a + b);
-
-               if (isnan(morhorn) || isinf(morhorn)) { morhorn = 1; }
-               
-               data[0] = morhorn;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "MorHorn", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedmorisitahorn.h b/sharedmorisitahorn.h
deleted file mode 100644 (file)
index 7f0b6e9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef MORHORN_H
-#define MORHORN_H
-/*
- *  sharedmorisitahorn.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/24/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class MorHorn : public Calculator  {
-       
-public:
-       MorHorn() :  Calculator("morisitahorn", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Morisitahorn"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/sharednseqs.h b/sharednseqs.h
deleted file mode 100644 (file)
index 5d403fa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SHAREDNSEQS_H
-#define SHAREDNSEQS_H
-
-/*
- *  sharednseqs.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/16/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-class SharedNSeqs : public Calculator {
-
-public:
-       SharedNSeqs() : Calculator("sharednseqs", 1, false) {};
-       EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(vector<SharedRAbundVector*> shared) {
-               data.resize(1,0);
-               data[0] = (double)shared[0]->getNumSeqs() + (double)shared[1]->getNumSeqs();
-               return data;
-       }
-       string getCitation() { return "http://www.mothur.org/wiki/Sharednseqs"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedochiai.cpp b/sharedochiai.cpp
deleted file mode 100644 (file)
index b49fa4a..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  sharedochiai.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedochiai.h"
-
-/***********************************************************************/
-
-EstOutput Ochiai::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-                       
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = S12 / ((float)pow((S1 * S2), 0.5));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Ochiai", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedochiai.h b/sharedochiai.h
deleted file mode 100644 (file)
index fb799de..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef OCHIAI_H
-#define OCHIAI_H
-/*
- *  sharedochiai.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Ochiai : public Calculator  {
-       
-public:
-       Ochiai() :  Calculator("ochiai", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/ochiai"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-
-#endif
diff --git a/sharedordervector.cpp b/sharedordervector.cpp
deleted file mode 100644 (file)
index 5231b3c..0000000
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- *  sharedSharedOrderVector.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/9/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedordervector.h"
-#include "sharedutilities.h"
-
-/***********************************************************************/
-
-SharedOrderVector::SharedOrderVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0)  {}
-
-/***********************************************************************/
-
-SharedOrderVector::SharedOrderVector(string id, vector<individual>  ov) : 
-                                                                                       DataVector(id), data(ov)
-{
-               updateStats();
-}
-
-/***********************************************************************/
-//This function is used to read a .shared file for the collect.shared, rarefaction.shared and summary.shared commands
-//if you don't use a list and groupfile.  
-
-SharedOrderVector::SharedOrderVector(ifstream& f) : DataVector() {  //reads in a shared file
-       try {
-               maxRank = 0; numBins = 0; numSeqs = 0;
-                               
-               groupmap = new GroupMap(); 
-               
-               int num, inputData, count;
-               count = 0;  numSeqs = 0;
-               string holdLabel, nextLabel, groupN;
-               individual newguy;
-               
-               //read in first row since you know there is at least 1 group.
-               //are we at the beginning of the file??
-               if (m->saveNextLabel == "") {  
-                       f >> label; 
-                       
-                       //is this a shared file that has headers
-                       if (label == "label") { 
-                               //gets "group"
-                               f >> label; m->gobble(f);
-                               
-                               //gets "numOtus"
-                               f >> label; m->gobble(f);
-                               
-                               //eat rest of line
-                               label = m->getline(f); m->gobble(f);
-                               
-                               //parse labels to save
-                               istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
-                               while(!iStringStream.eof()){
-                                       if (m->control_pressed) { break; }
-                                       string temp;
-                                       iStringStream >> temp;  m->gobble(iStringStream);
-                                       
-                                       m->binLabelsInFile.push_back(temp);
-                               }
-                               
-                               f >> label;
-                       }
-               }else { label = m->saveNextLabel; }
-               
-               //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
-               
-               //read in first row since you know there is at least 1 group.
-               f >> groupN >> num;
-               
-               holdLabel = label;
-               
-               
-               vector<string> allGroups;
-               //save group in groupmap
-               allGroups.push_back(groupN);
-               groupmap->groupIndex[groupN] = 0;
-               
-               
-               for(int i=0;i<num;i++){
-                       f >> inputData;
-                       
-                       for (int j = 0; j < inputData; j++) {
-                               push_back(i, i, groupN);
-                               numSeqs++;
-                       }
-               }
-               
-               m->gobble(f); 
-               
-               if (!(f.eof())) { f >> nextLabel; }
-               
-               //read the rest of the groups info in
-               while ((nextLabel == holdLabel) && (f.eof() != true)) {
-                       f >> groupN >> num;
-                       count++;
-                       
-                       
-                       //save group in groupmap
-                       allGroups.push_back(groupN);
-                       groupmap->groupIndex[groupN] = count;
-                       
-                       
-                       for(int i=0;i<num;i++){
-                               f >> inputData;
-                               
-                               for (int j = 0; j < inputData; j++) {
-                                       push_back(i, i, groupN);
-                                       numSeqs++;
-                               }
-                       }
-                       
-                       m->gobble(f);
-                               
-                       if (f.eof() != true) { f >> nextLabel; }
-
-               }
-               
-               m->saveNextLabel = nextLabel;
-                       
-               groupmap->setNamesOfGroups(allGroups);
-               m->setAllGroups(allGroups);
-               
-               updateStats();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "SharedOrderVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-int SharedOrderVector::getNumBins(){
-       return numBins;
-}
-
-/***********************************************************************/
-
-int SharedOrderVector::getNumSeqs(){
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int SharedOrderVector::getMaxRank(){
-       return maxRank;
-}
-
-
-/***********************************************************************/
-
-
-
-void SharedOrderVector::set(int index, int binNumber, int abund, string groupName){
-       
-       data[index].group = groupName;
-       data[index].bin = binNumber;
-       data[index].abundance = abund;
-       //if (abund > maxRank) { maxRank = abund; }
-       updateStats();
-}
-
-/***********************************************************************/
-
-individual SharedOrderVector::get(int index){
-       return data[index];                     
-}
-
-
-/***********************************************************************/
-//commented updateStats out to improve speed, but whoever calls this must remember to update when they are done with all the pushbacks they are doing 
-void SharedOrderVector::push_back(int binNumber, int abund, string groupName){
-       individual newGuy;
-       newGuy.group = groupName;
-       newGuy.abundance = abund;
-       newGuy.bin = binNumber;
-       data.push_back(newGuy);
-       //numSeqs++;
-       //numBins++;
-       //if (abund > maxRank) { maxRank = abund; }
-       
-       //updateStats();
-}
-
-/***********************************************************************/
-
-void SharedOrderVector::print(ostream& output){
-       try {
-               output << label << '\t' << numSeqs << '\t';
-       
-               for(int i=0;i<data.size();i++){
-                       output << data[i].bin << '\t';
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedOrderVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-}
-/***********************************************************************/
-
-void SharedOrderVector::resize(int){
-       m->mothurOut("resize() did nothing in class SharedOrderVector");
-}
-
-/***********************************************************************/
-
-
-vector<individual>::iterator SharedOrderVector::begin(){
-       return data.begin();    
-}
-
-/***********************************************************************/
-
-vector<individual>::iterator SharedOrderVector::end(){
-       return data.end();              
-}
-
-/***********************************************************************/
-
-int SharedOrderVector::size(){
-       return data.size();                                     
-}
-
-/***********************************************************************/
-
-RAbundVector SharedOrderVector::getRAbundVector(){
-       try {
-               RAbundVector rav(data.size());
-       
-               for(int i=0;i<numSeqs;i++){
-                       rav.set(data[i].bin, rav.get(data[i].bin) + 1);
-               }       
-               sort(rav.rbegin(), rav.rend());
-               for(int i=numSeqs-1;i>=0;i--){
-                       if(rav.get(i) == 0){    rav.pop_back(); }
-                       else{
-                               break;
-                       }
-               }
-               rav.setLabel(label);
-
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "getRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-OrderVector SharedOrderVector::getOrderVector(map<string,int>* nameMap = NULL) {
-       try {
-               OrderVector ov;
-       
-               for (int i = 0; i < data.size(); i++) {
-                       ov.push_back(data[i].bin);
-               }
-               
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);     
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-SAbundVector SharedOrderVector::getSAbundVector(){
-       
-       RAbundVector rav(this->getRAbundVector());
-       return rav.getSAbundVector();
-
-}
-/***********************************************************************/
-SharedRAbundVector SharedOrderVector::getSharedRAbundVector(string group) {
-       try {
-               SharedRAbundVector sharedRav(data.size());
-               
-               sharedRav.setLabel(label);
-               sharedRav.setGroup(group);
-               
-               for (int i = 0; i < data.size(); i++) {
-                       if (data[i].group == group) {
-                               sharedRav.set(data[i].abundance, sharedRav.getAbundance(data[i].abundance) + 1, data[i].group);
-                       }
-               }
-               return sharedRav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<SharedRAbundVector*> SharedOrderVector::getSharedRAbundVector() {
-       try {
-               SharedUtil* util;
-               util = new SharedUtil();
-               vector<SharedRAbundVector*> lookup;
-               
-               vector<string> Groups = m->getGroups();
-               vector<string> allGroups = m->getAllGroups();
-               util->setGroups(Groups, allGroups);
-               util->getSharedVectors(Groups, lookup, this);
-               m->setGroups(Groups);
-               m->setAllGroups(allGroups);
-               
-               return lookup;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "getSharedRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-SharedSAbundVector SharedOrderVector::getSharedSAbundVector(string group) {
-       try {
-               
-               SharedRAbundVector sharedRav(this->getSharedRAbundVector(group));
-               return sharedRav.getSharedSAbundVector();
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "getSharedSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SharedOrderVector SharedOrderVector::getSharedOrderVector(){
-       random_shuffle(data.begin(), data.end());
-       return *this;                   
-}
-
-/***********************************************************************/
-
-void SharedOrderVector::updateStats(){
-       try {
-               needToUpdate = 0;
-               numSeqs = 0;
-               numBins = 0;
-               maxRank = 0;
-       
-               numSeqs = data.size();
-                               
-               vector<int> hold(numSeqs, 0);
-               for(int i=0;i<numSeqs;i++){
-                       hold[data[i].bin] = hold[data[i].bin]+1;
-               }       
-               
-               for(int i=0;i<numSeqs;i++){
-                       if(hold[i] > 0)                         {       numBins++;                              }
-                       if(hold[i] > maxRank)           {       maxRank = hold[i];              }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedOrderVector", "updateStats");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
diff --git a/sharedordervector.h b/sharedordervector.h
deleted file mode 100644 (file)
index 7d383ac..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-#ifndef SHAREDORDER_H
-#define SHAREDORDER_H
-/*
- *  sharedorder.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 12/9/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
- /* This class is a child to datavector.  It represents OTU information at a certain distance. 
-       It is similiar to an order vector except each member of data knows which group it belongs to.
-       Each member of the internal container "data" represents is an individual which knows the OTU from which it came, 
-       the group it is in and the abundance is equal to the OTU number.  */
-
-
-#include "datavector.hpp"
-
-struct individual {
-               string group;
-               int bin;
-               int abundance;
-               bool operator()(const individual& i1, const individual& i2) {
-               return (i1.abundance > i2.abundance);
-               }
-       individual() {  group = ""; bin = 0; abundance = 0; }
-};
-
-struct individualFloat {
-               string group;
-               int bin;
-               float abundance;
-               bool operator()(const individual& i1, const individual& i2) {
-               return (i1.abundance > i2.abundance);
-               }
-       individualFloat() { group = ""; bin = 0; abundance = 0.0; }
-};
-
-
-#include "sabundvector.hpp"
-#include "rabundvector.hpp"
-#include "sharedrabundvector.h"
-#include "sharedsabundvector.h"
-#include "groupmap.h"
-
-class SharedOrderVector : public DataVector {
-       
-public:
-       SharedOrderVector();
-//     SharedOrderVector(int ns, int nb=0, int mr=0)   : DataVector(), data(ns, -1), maxRank(0), numBins(0), numSeqs(0) {};
-       SharedOrderVector(const SharedOrderVector& ov)  : DataVector(ov.label), data(ov.data), maxRank(ov.maxRank), numBins(ov.numBins), numSeqs(ov.numSeqs), needToUpdate(ov.needToUpdate) {if(needToUpdate == 1){     updateStats();}};
-
-       SharedOrderVector(string, vector<individual>);
-       SharedOrderVector(ifstream&);
-       ~SharedOrderVector(){};
-       
-       
-       individual get(int);
-       void resize(int);
-       int size();
-       void print(ostream&);
-       vector<individual>::iterator begin();
-       vector<individual>::iterator end();
-       void push_back(int, int, string);  //OTU, abundance, group  MUST CALL UPDATE STATS AFTER PUSHBACK!!!
-       void updateStats();
-       void clear();
-
-       int getNumBins();
-       int getNumSeqs();
-       int getMaxRank();
-               
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       SharedOrderVector getSharedOrderVector();
-       SharedRAbundVector getSharedRAbundVector(string);  //get the sharedRabundvector for a sepecific group
-       SharedSAbundVector getSharedSAbundVector(string);       //get the sharedSabundvector for a sepecific group
-       vector<SharedRAbundVector*> getSharedRAbundVector(); //returns sharedRabundVectors for all the users groups
-       
-private:
-       GroupMap* groupmap;
-       vector<individual>  data; 
-       map< int, vector<individual> >::iterator it;
-       int maxRank;
-       int numBins;
-       int numSeqs;
-       bool needToUpdate;
-       void set(int, int, int, string);        //index, OTU, abundance, group
-       
-};
-
-#endif
-
diff --git a/sharedrabundfloatvector.cpp b/sharedrabundfloatvector.cpp
deleted file mode 100644 (file)
index b6d916a..0000000
+++ /dev/null
@@ -1,565 +0,0 @@
-/*
- *  sharedrabundfloatvector.cpp
- *  Mothur
- *
- *  Created by westcott on 8/18/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sharedrabundfloatvector.h"
-#include "sharedutilities.h"
-
-/***********************************************************************/
-
-SharedRAbundFloatVector::SharedRAbundFloatVector() : DataVector(), maxRank(0.0), numBins(0), numSeqs(0.0) {}
-/***********************************************************************/
-
-SharedRAbundFloatVector::~SharedRAbundFloatVector() {}
-
-/***********************************************************************/
-SharedRAbundFloatVector::SharedRAbundFloatVector(int n) : DataVector(), maxRank(0.0), numBins(n), numSeqs(0.0) {
-               
-               individualFloat newGuy;
-               //initialize data
-               for (int i=0; i< n; i++) {
-                       newGuy.bin = i;
-                       newGuy.abundance = 0.0;
-                       data.push_back(newGuy);
-               }
-}
-/***********************************************************************/
-//reads a shared file
-SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), maxRank(0.0), numBins(0), numSeqs(0.0) {
-       try {
-               
-               m->clearAllGroups();
-               vector<string> allGroups;
-               
-               int num, count;
-               float inputData;
-               count = 0;  
-               string holdLabel, nextLabel, groupN;
-               individualFloat newguy;
-               
-               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-               lookup.clear();
-               
-               //are we at the beginning of the file??
-               if (m->saveNextLabel == "") {  
-                       f >> label; 
-            
-                       //is this a shared file that has headers
-                       if (label == "label") { 
-                               //gets "group"
-                               f >> label; m->gobble(f);
-                               
-                               //gets "numOtus"
-                               f >> label; m->gobble(f);
-                               
-                               //eat rest of line
-                               label = m->getline(f); m->gobble(f);
-                               
-                               //parse labels to save
-                               istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
-                               while(!iStringStream.eof()){
-                                       if (m->control_pressed) { break; }
-                                       string temp;
-                                       iStringStream >> temp;  m->gobble(iStringStream);
-                    
-                                       m->binLabelsInFile.push_back(temp);
-                               }
-                               
-                               f >> label >> groupN >> num;
-                       }else {
-                //read in first row since you know there is at least 1 group.
-                f >> groupN >> num;
-                
-                //make binlabels because we don't have any
-                string snumBins = toString(num);
-                m->binLabelsInFile.clear();
-                for (int i = 0; i < num; i++) {  
-                    //if there is a bin label use it otherwise make one
-                    string binLabel = "Otu";
-                    string sbinNumber = toString(i+1);
-                    if (sbinNumber.length() < snumBins.length()) { 
-                        int diff = snumBins.length() - sbinNumber.length();
-                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                    }
-                    binLabel += sbinNumber;
-                    m->binLabelsInFile.push_back(binLabel);
-                }
-            }
-               }else { 
-            label = m->saveNextLabel; 
-            
-            //read in first row since you know there is at least 1 group.
-            f >> groupN >> num;
-        }
-               
-               //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
-               
-               holdLabel = label;
-               
-               //add new vector to lookup
-               SharedRAbundFloatVector* temp = new SharedRAbundFloatVector();
-               lookup.push_back(temp);
-               lookup[0]->setLabel(label);
-               lookup[0]->setGroup(groupN);
-               
-               allGroups.push_back(groupN);
-               
-               //fill vector.  data = first sharedrabund in file
-               for(int i=0;i<num;i++){
-                       f >> inputData;
-                       
-                       lookup[0]->push_back(inputData, groupN); //abundance, bin, group
-                       push_back(inputData, groupN);
-                       
-                       if (inputData > maxRank) { maxRank = inputData; }
-               }
-               
-               m->gobble(f);
-               
-               if (f.eof() != true) { f >> nextLabel; }
-               
-               //read the rest of the groups info in
-               while ((nextLabel == holdLabel) && (f.eof() != true)) {
-                       f >> groupN >> num;
-            
-            if (num != 1000) { break; }
-                       count++;
-                       
-                       allGroups.push_back(groupN);
-                       
-                       //add new vector to lookup
-                       temp = new SharedRAbundFloatVector();
-                       lookup.push_back(temp);
-                       lookup[count]->setLabel(label);
-                       lookup[count]->setGroup(groupN);
-
-                       //fill vector.  
-                       for(int i=0;i<num;i++){
-                               f >> inputData;
-                               lookup[count]->push_back(inputData, groupN); //abundance, bin, group
-                       }
-                       
-                       m->gobble(f);
-                               
-                       if (f.eof() != true) { f >> nextLabel; }
-               }
-               
-               m->saveNextLabel = nextLabel;
-               m->setAllGroups(allGroups);
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "SharedRAbundFloatVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedRAbundFloatVector::set(int binNumber, float newBinSize, string groupname){
-       try {
-               float oldBinSize = data[binNumber].abundance;
-               data[binNumber].abundance = newBinSize;
-               data[binNumber].group = groupname;
-               
-               if(newBinSize > maxRank)        {       newBinSize = newBinSize;        }
-       
-               numSeqs += (newBinSize - oldBinSize);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "set");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void SharedRAbundFloatVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-       lookup.clear();
-}
-/***********************************************************************/
-float SharedRAbundFloatVector::getAbundance(int index){
-       return data[index].abundance;   
-}
-/***********************************************************************/
-individualFloat SharedRAbundFloatVector::get(int index){
-       return data[index];     
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::push_back(float binSize, string groupName){
-       try {
-               individualFloat newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = data.size();
-               
-               data.push_back(newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){  maxRank = binSize;      }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "push_back");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::insert(float binSize, int otu, string groupName){
-       try {
-               individualFloat newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = otu;
-               
-               data.insert(data.begin()+otu, newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){  maxRank = binSize;      }
-
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "insert");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedRAbundFloatVector::push_front(float binSize, int otu, string groupName){
-       try {
-               individualFloat newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = otu;
-               
-               data.insert(data.begin(), newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){  maxRank = binSize;      }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "push_front");
-               exit(1);
-       }
-}
-/**********************************************************************/
-void SharedRAbundFloatVector::pop_back(){
-       numSeqs -= data[data.size()-1].abundance;
-       numBins--;
-       data.pop_back();
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::resize(int size){
-       data.resize(size);
-}
-/**********************************************************************/
-int SharedRAbundFloatVector::size(){
-       return data.size();
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::printHeaders(ostream& output){
-       try {
-               string snumBins = toString(numBins);
-               output << "label\tGroup\tnumOtus\t";
-               if (m->sharedHeaderMode == "tax") {
-                       for (int i = 0; i < numBins; i++) {  
-                               
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "PhyloType";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               output << binLabel << '\t'; 
-                       }
-                       output << endl;
-               }else {
-                       for (int i = 0; i < numBins; i++) {  
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               output << binLabel << '\t'; 
-                       }
-                       
-                       output << endl;
-               }
-               
-               m->printedHeaders = true;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "printHeaders");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::print(ostream& output){
-       try {
-               output << numBins << '\t';
-       
-               for(int i=0;i<data.size();i++){         output << data[i].abundance << '\t';            }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "print");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string SharedRAbundFloatVector::getGroup(){
-       return group;
-}
-/***********************************************************************/
-void SharedRAbundFloatVector::setGroup(string groupName){
-       group = groupName;
-}
-/***********************************************************************/
-int SharedRAbundFloatVector::getGroupIndex()  { return index; }
-/***********************************************************************/
-void SharedRAbundFloatVector::setGroupIndex(int vIndex)        { index = vIndex; }
-/***********************************************************************/
-int SharedRAbundFloatVector::getNumBins(){     return numBins; }
-/***********************************************************************/
-float SharedRAbundFloatVector::getNumSeqs(){   return numSeqs; }
-/***********************************************************************/
-float SharedRAbundFloatVector::getMaxRank(){   return maxRank; }
-/***********************************************************************/
-SharedRAbundFloatVector SharedRAbundFloatVector::getSharedRAbundFloatVector(){
-       return *this;                   
-}
-/***********************************************************************
-SharedRAbundVector SharedRAbundFloatVector::getSharedRAbundVector(){
-       try {
-               SharedRAbundVector rav(numBins);
-               rav.setLabel(label);
-               rav.setGroup(group);
-               
-               for (int i = 0; i < data.size(); i++) {
-                       
-                       rav.push_back(data[i].abundance);
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getSharedRAbundVector");
-               exit(1);
-       }               
-}
-***********************************************************************/
-vector<SharedRAbundFloatVector*> SharedRAbundFloatVector::getSharedRAbundFloatVectors(){
-       try {
-               SharedUtil* util;
-               util = new SharedUtil();
-               
-               vector<string> Groups = m->getGroups();
-               vector<string> allGroups = m->getAllGroups();
-               util->setGroups(Groups, allGroups);
-               m->setGroups(Groups);
-               
-               bool remove = false;
-               for (int i = 0; i < lookup.size(); i++) {
-                       //if this sharedrabund is not from a group the user wants then delete it.
-                       if (util->isValidGroup(lookup[i]->getGroup(), m->getGroups()) == false) { 
-                               delete lookup[i]; lookup[i] = NULL;
-                               lookup.erase(lookup.begin()+i); 
-                               i--; 
-                               remove = true;
-                       }
-               }
-               
-               delete util;
-               
-               if (remove) { eliminateZeroOTUS(lookup); }
-       
-               return lookup;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getSharedRAbundFloatVectors");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-RAbundVector SharedRAbundFloatVector::getRAbundVector() {
-       try {
-               RAbundVector rav(numBins);
-               
-               //this is not functional, not sure how to handle it yet, but I need the stub because it is a pure function
-               
-               rav.setLabel(label);
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************
-
-SharedSAbundVector SharedRAbundVector::getSharedSAbundVector(){
-       try {
-               SharedSAbundVector sav(maxRank+1);
-               
-               for(int i=0;i<data.size();i++){
-                       int abund = data[i].abundance;
-                       sav.set(abund, sav.getAbundance(abund) + 1, group);
-               }
-               
-               sav.set(0, 0, group);
-               sav.setLabel(label);
-               sav.setGroup(group);
-               
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSharedSAbundVector");
-               exit(1);
-       }
-}
-***********************************************************************/
-
-SAbundVector SharedRAbundFloatVector::getSAbundVector() {
-       try {
-               SAbundVector sav(ceil(maxRank)+1);
-               
-               //this is not functional, not sure how to handle it yet, but I need the stub because it is a pure function
-               
-               sav.set(0, 0);
-               sav.setLabel(label);
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getSAbundVector");           
-               exit(1);
-       }
-}
-
-/***********************************************************************
-
-SharedOrderVector SharedRAbundFloatVector::getSharedOrderVector() {
-       try {
-               SharedOrderVector ov;
-       
-               for(int i=0;i<data.size();i++){
-                       int round = ceil(data[i].abundance);
-                       for(int j=0;j<round;j++){
-                               ov.push_back(data[i].bin, round, data[i].group);
-                       }
-               }
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);     
-               ov.updateStats();
-               
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getSharedOrderVector");
-               exit(1);
-       }
-}
-***********************************************************************/
-//this is not functional, not sure how to handle it yet, but I need the stub because it is a pure function
-OrderVector SharedRAbundFloatVector::getOrderVector(map<string,int>* nameMap = NULL) {
-       try {
-               OrderVector ov;
-       
-               for(int i=0;i<data.size();i++){
-                       int round = ceil(data[i].abundance);
-                       for(int j=0;j<round;j++){
-                               ov.push_back(i);
-                       }
-               }
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);     
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "getOrderVector");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedRAbundFloatVector::eliminateZeroOTUS(vector<SharedRAbundFloatVector*>& thislookup) {
-       try {
-               
-               vector<SharedRAbundFloatVector*> newLookup;
-               for (int i = 0; i < thislookup.size(); i++) {
-                       SharedRAbundFloatVector* temp = new SharedRAbundFloatVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookup.push_back(temp);
-               }
-               
-               //for each bin
-               vector<string> newBinLabels;
-               string snumBins = toString(thislookup[0]->getNumBins());
-               for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                       if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                       
-                       //look at each sharedRabund and make sure they are not all zero
-                       bool allZero = true;
-                       for (int j = 0; j < thislookup.size(); j++) {
-                               if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                       }
-                       
-                       //if they are not all zero add this bin
-                       if (!allZero) {
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                               }
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               newBinLabels.push_back(binLabel);
-                       }
-               }
-               
-               for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-               
-               thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundFloatVector", "eliminateZeroOTUS");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/sharedrabundfloatvector.h b/sharedrabundfloatvector.h
deleted file mode 100644 (file)
index 965b03a..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef SHAREDRABUNDFLOATVECTOR_H
-#define SHAREDRABUNDFLOATVECTOR_H
-
-/*
- *  sharedrabundfloatvector.h
- *  Mothur
- *
- *  Created by westcott on 8/18/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "datavector.hpp"
-#include "sharedordervector.h"
-#include "sharedsabundvector.h"
-#include "rabundvector.hpp"
-//#include "groupmap.h"
-
-/* This class is a child to datavector.  It represents OTU information at a certain distance. 
-       It is similiar to an rabundvector except each member of data knows which group it belongs to.
-       Each member of the internal container "data" is a struct of type individualFloat. 
-       An individual which knows the OTU from which it came, 
-       the group it is in and its abundance.  */
-
-
-class SharedRAbundFloatVector : public DataVector {
-       
-public:
-       SharedRAbundFloatVector();
-       SharedRAbundFloatVector(int);
-       SharedRAbundFloatVector(const SharedRAbundFloatVector& bv) : DataVector(bv), data(bv.data), maxRank(bv.maxRank), numBins(bv.numBins), numSeqs(bv.numSeqs), group(bv.group), index(bv.index){};
-    SharedRAbundFloatVector(ifstream&);
-       ~SharedRAbundFloatVector();
-
-       int getNumBins();               
-       float getNumSeqs();                                                     
-       float getMaxRank();
-       string getGroup();
-       void setGroup(string);
-       int getGroupIndex();
-       void setGroupIndex(int);                                                                
-
-       void set(int, float, string);                   //OTU, abundance, groupname
-       individualFloat get(int);
-       vector <individual> getData();
-       float getAbundance(int);
-       void push_front(float, int, string); //abundance, otu, groupname
-       void insert(float, int, string); //abundance, otu, groupname
-       void push_back(float, string);  //abundance, groupname
-       void pop_back();
-       void resize(int);
-       void clear();
-       int size();
-       
-       void print(ostream&);
-       void printHeaders(ostream&);
-               
-       RAbundVector getRAbundVector();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       //SharedOrderVector getSharedOrderVector();
-       //SharedSAbundVector getSharedSAbundVector();
-       //SharedRAbundVector getSharedRAbundVector();
-       SharedRAbundFloatVector getSharedRAbundFloatVector();
-       vector<SharedRAbundFloatVector*> getSharedRAbundFloatVectors();
-       
-private:
-       vector<individualFloat>  data; 
-       vector<SharedRAbundFloatVector*> lookup;
-       //GlobalData* globaldata;
-       //GroupMap* groupmap;
-       float maxRank;
-       int numBins;
-       float numSeqs;
-       string group;
-       int index;      
-       
-       int eliminateZeroOTUS(vector<SharedRAbundFloatVector*>&);
-};
-
-
-#endif
-
-
diff --git a/sharedrabundvector.cpp b/sharedrabundvector.cpp
deleted file mode 100644 (file)
index 3901650..0000000
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- *  sharedvector.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/5/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedrabundvector.h" 
-#include "sabundvector.hpp"
-#include "ordervector.hpp"
-#include "sharedutilities.h"
-
-
-/***********************************************************************/
-SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {} 
-/***********************************************************************/
-
-SharedRAbundVector::~SharedRAbundVector() {
-       //for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-
-}
-
-/***********************************************************************/
-
-SharedRAbundVector::SharedRAbundVector(int n) : DataVector(), maxRank(0), numBins(n), numSeqs(0) {
-               individual newGuy;
-               //initialize data
-               for (int i=0; i< n; i++) {
-                       newGuy.bin = i;
-                       newGuy.abundance = 0;
-                       data.push_back(newGuy);
-               }
-}
-
-/***********************************************************************
-
-SharedRAbundVector::SharedRAbundVector(string id, vector<individual> rav) : DataVector(id), data(rav) {
-       try {
-               numBins = 0;
-               maxRank = 0;
-               numSeqs = 0;
-               
-               for(int i=0;i<data.size();i++){
-                       if(data[i].abundance != 0)              {       numBins = i+1;          }
-                       if(data[i].abundance > maxRank) {       maxRank = data[i].abundance;    }
-                       numSeqs += data[i].abundance;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
-               exit(1);
-       }
-}
-
-
-***********************************************************************/
-//reads a shared file
-SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-       try {
-               m->clearAllGroups();
-               vector<string> allGroups;
-               
-               int num, inputData, count;
-               count = 0;  
-               string holdLabel, nextLabel, groupN;
-               individual newguy;
-               
-               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }  lookup.clear();
-               
-               //are we at the beginning of the file??
-               if (m->saveNextLabel == "") {  
-                       f >> label; 
-       
-                       //is this a shared file that has headers
-                       if (label == "label") { 
-                               //gets "group"
-                               f >> label; m->gobble(f);
-                               
-                               //gets "numOtus"
-                               f >> label; m->gobble(f);
-                               
-                               //eat rest of line
-                               label = m->getline(f); m->gobble(f);
-                               
-                               //parse labels to save
-                               istringstream iStringStream(label);
-                               m->binLabelsInFile.clear();
-                               while(!iStringStream.eof()){
-                                       if (m->control_pressed) { break; }
-                                       string temp;
-                                       iStringStream >> temp;  m->gobble(iStringStream);
-               
-                                       m->binLabelsInFile.push_back(temp);
-                               }
-                               
-                               f >> label >> groupN >> num;
-                       }else {
-                //read in first row since you know there is at least 1 group.
-                f >> groupN >> num;
-                
-                //make binlabels because we don't have any
-                string snumBins = toString(num);
-                m->binLabelsInFile.clear();
-                for (int i = 0; i < num; i++) {  
-                    //if there is a bin label use it otherwise make one
-                    string binLabel = "Otu";
-                    string sbinNumber = toString(i+1);
-                    if (sbinNumber.length() < snumBins.length()) { 
-                        int diff = snumBins.length() - sbinNumber.length();
-                        for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                    }
-                    binLabel += sbinNumber;
-                    m->binLabelsInFile.push_back(binLabel);
-                }
-            }
-               }else { 
-            label = m->saveNextLabel; 
-            
-            //read in first row since you know there is at least 1 group.
-            f >> groupN >> num;
-        }
-               
-               //reset labels, currentLabels may have gotten changed as otus were eliminated because of group choices or sampling
-               m->currentBinLabels = m->binLabelsInFile;
-               
-               holdLabel = label;
-               
-               //add new vector to lookup
-               SharedRAbundVector* temp = new SharedRAbundVector();
-               lookup.push_back(temp);
-               lookup[0]->setLabel(label);
-               lookup[0]->setGroup(groupN);
-               
-               allGroups.push_back(groupN);
-               
-               //fill vector.  data = first sharedrabund in file
-               for(int i=0;i<num;i++){
-                       f >> inputData;
-                       
-                       lookup[0]->push_back(inputData, groupN); //abundance, bin, group
-                       push_back(inputData, groupN);
-                       
-                       if (inputData > maxRank) { maxRank = inputData; }
-               }
-               
-               m->gobble(f);
-               
-               if (!(f.eof())) { f >> nextLabel; }
-       
-               //read the rest of the groups info in
-               while ((nextLabel == holdLabel) && (f.eof() != true)) {
-                       f >> groupN >> num;
-                       count++;
-                       
-                       allGroups.push_back(groupN);
-                       
-                       //add new vector to lookup
-                       temp = new SharedRAbundVector();
-                       lookup.push_back(temp);
-                       lookup[count]->setLabel(label);
-                       lookup[count]->setGroup(groupN);
-
-                       //fill vector.  
-                       for(int i=0;i<num;i++){
-                               f >> inputData;
-                               
-                               lookup[count]->push_back(inputData, groupN); //abundance, bin, group
-                       }
-                       
-                       m->gobble(f);
-                               
-                       if (f.eof() != true) { f >> nextLabel; }
-               }
-               m->saveNextLabel = nextLabel;
-               m->setAllGroups(allGroups);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "SharedRAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedRAbundVector::set(int binNumber, int newBinSize, string groupname){
-       try {
-               int oldBinSize = data[binNumber].abundance;
-               data[binNumber].abundance = newBinSize;
-               data[binNumber].group = groupname;
-       
-               if(newBinSize > maxRank)        {       maxRank = newBinSize;   }
-       
-               numSeqs += (newBinSize - oldBinSize);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "set");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void SharedRAbundVector::setData(vector <individual> newData){
-       data = newData;
-}
-
-/***********************************************************************/
-
-int SharedRAbundVector::getAbundance(int index){
-       return data[index].abundance;
-       
-}
-/***********************************************************************/
-
-int SharedRAbundVector::numNZ(){
-       int sum = 0;
-       for(int i = 1; i < numBins; i++)
-               if(data[i].abundance > 0)
-                       sum++;
-       return sum;
-}
-/***********************************************************************/
-
-void SharedRAbundVector::sortD(){
-       struct individual indObj;
-       sort(data.begin()+1, data.end(), indObj);
-}
-/***********************************************************************/
-
-individual SharedRAbundVector::get(int index){
-       return data[index];
-       
-}
-/***********************************************************************/
-
-vector <individual> SharedRAbundVector::getData(){
-       return data;
-}
-/***********************************************************************/
-
-void SharedRAbundVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-       lookup.clear();
-}
-/***********************************************************************/
-
-void SharedRAbundVector::push_back(int binSize, string groupName){
-       try {
-               individual newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = data.size();
-               
-               data.push_back(newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){
-                       maxRank = binSize;
-               }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedRAbundVector::insert(int binSize, int otu, string groupName){
-       try {
-               individual newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = otu;
-               
-               data.insert(data.begin()+otu, newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){
-                       maxRank = binSize;
-               }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "insert");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedRAbundVector::push_front(int binSize, int otu, string groupName){
-       try {
-               individual newGuy;
-               newGuy.abundance = binSize;
-               newGuy.group = groupName;
-               newGuy.bin = otu;
-               
-               data.insert(data.begin(), newGuy);
-               numBins++;
-       
-               if(binSize > maxRank){
-                       maxRank = binSize;
-               }
-       
-               numSeqs += binSize;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "push_front");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-void SharedRAbundVector::pop_back(){
-       numSeqs -= data[data.size()-1].abundance;
-       numBins--;
-       return data.pop_back();
-}
-
-/***********************************************************************/
-
-
-vector<individual>::reverse_iterator SharedRAbundVector::rbegin(){
-       return data.rbegin();                           
-}
-
-/***********************************************************************/
-
-vector<individual>::reverse_iterator SharedRAbundVector::rend(){
-       return data.rend();                                     
-}
-
-/***********************************************************************/
-void SharedRAbundVector::resize(int size){
-       
-       data.resize(size);
-}
-
-/***********************************************************************/
-
-int SharedRAbundVector::size(){
-       return data.size();
-}
-
-
-/***********************************************************************/
-void SharedRAbundVector::printHeaders(ostream& output){
-       try {
-               string snumBins = toString(numBins);
-               output << "label\tGroup\tnumOtus\t";
-               if (m->sharedHeaderMode == "tax") {
-                       for (int i = 0; i < numBins; i++) {  
-                               
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "PhyloType";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               output << binLabel << '\t'; 
-                       }
-                       output << endl;
-               }else {
-                       for (int i = 0; i < numBins; i++) {  
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber;
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               output << binLabel << '\t'; 
-                       }
-                       
-                       output << endl;
-               }
-               m->printedHeaders = true;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "printHeaders");
-               exit(1);
-       }
-}
-/***********************************************************************/
-void SharedRAbundVector::print(ostream& output) {
-       try {
-               output << numBins << '\t';
-       
-               for(int i=0;i<data.size();i++){         output << data[i].abundance << '\t';            }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "print");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string SharedRAbundVector::getGroup(){
-       return group;
-}
-
-/***********************************************************************/
-
-void SharedRAbundVector::setGroup(string groupName){
-       group = groupName;
-}
-/***********************************************************************/
-int SharedRAbundVector::getGroupIndex()  { return index; }
-/***********************************************************************/
-void SharedRAbundVector::setGroupIndex(int vIndex)     { index = vIndex; }
-/***********************************************************************/
-int SharedRAbundVector::getNumBins(){
-               return numBins;
-}
-
-/***********************************************************************/
-
-int SharedRAbundVector::getNumSeqs(){
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int SharedRAbundVector::getMaxRank(){
-       return maxRank;
-}
-/***********************************************************************/
-
-SharedRAbundVector SharedRAbundVector::getSharedRAbundVector(){
-       return *this;                   
-}
-/***********************************************************************/
-vector<SharedRAbundVector*> SharedRAbundVector::getSharedRAbundVectors(){
-       try {
-               SharedUtil* util;
-               util = new SharedUtil();
-               
-               vector<string> Groups = m->getGroups();
-               vector<string> allGroups = m->getAllGroups();
-               util->setGroups(Groups, allGroups);
-               m->setGroups(Groups);
-               
-               bool remove = false;
-               for (int i = 0; i < lookup.size(); i++) {
-                       //if this sharedrabund is not from a group the user wants then delete it.
-                       if (util->isValidGroup(lookup[i]->getGroup(), m->getGroups()) == false) { 
-                               remove = true;
-                               delete lookup[i]; lookup[i] = NULL;
-                               lookup.erase(lookup.begin()+i); 
-                               i--; 
-                       }
-               }
-               
-               delete util;
-               
-               if (remove) { eliminateZeroOTUS(lookup); }
-       
-               return lookup;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSharedRAbundVectors");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SharedRAbundVector::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
-               try {
-                       
-                       vector<SharedRAbundVector*> newLookup;
-                       for (int i = 0; i < thislookup.size(); i++) {
-                               SharedRAbundVector* temp = new SharedRAbundVector();
-                               temp->setLabel(thislookup[i]->getLabel());
-                               temp->setGroup(thislookup[i]->getGroup());
-                               newLookup.push_back(temp);
-                       }
-                       
-                       //for each bin
-                       vector<string> newBinLabels;
-                       string snumBins = toString(thislookup[0]->getNumBins());
-                       for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                               if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                               
-                               //look at each sharedRabund and make sure they are not all zero
-                               bool allZero = true;
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                               }
-                               
-                               //if they are not all zero add this bin
-                               if (!allZero) {
-                                       for (int j = 0; j < thislookup.size(); j++) {
-                                               newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                                       }
-                                       
-                                       //if there is a bin label use it otherwise make one
-                                       string binLabel = "Otu";
-                                       string sbinNumber = toString(i+1);
-                                       if (sbinNumber.length() < snumBins.length()) { 
-                                               int diff = snumBins.length() - sbinNumber.length();
-                                               for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                                       }
-                                       binLabel += sbinNumber; 
-                                       if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                                       
-                                       newBinLabels.push_back(binLabel);
-                               }
-                       }
-                       
-                       for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-                       
-                       thislookup = newLookup;
-                       m->currentBinLabels = newBinLabels;
-                       
-                       return 0;
-                       
-               }
-               catch(exception& e) {
-                       m->errorOut(e, "SharedRAbundVector", "eliminateZeroOTUS");
-                       exit(1);
-               }
-       }
-       
-/***********************************************************************/
-vector<SharedRAbundFloatVector*> SharedRAbundVector::getSharedRAbundFloatVectors(vector<SharedRAbundVector*> thislookup){
-       try {
-               vector<SharedRAbundFloatVector*> newLookupFloat;        
-               for (int i = 0; i < lookup.size(); i++) {
-                       SharedRAbundFloatVector* temp = new SharedRAbundFloatVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookupFloat.push_back(temp);
-               }
-               
-               for (int i = 0; i < thislookup.size(); i++) {
-                       
-                       for (int j = 0; j < thislookup[i]->getNumBins(); j++) {
-                               
-                               if (m->control_pressed) { return newLookupFloat; }
-                               
-                               int abund = thislookup[i]->getAbundance(j);
-                               
-                               float relabund = abund / (float) thislookup[i]->getNumSeqs();
-                               
-                               newLookupFloat[i]->push_back(relabund, thislookup[i]->getGroup());
-                       }
-               }
-               
-               return newLookupFloat;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSharedRAbundVectors");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-RAbundVector SharedRAbundVector::getRAbundVector() {
-       try {
-               RAbundVector rav;
-               
-               for (int i = 0; i < data.size(); i++) {
-                       if(data[i].abundance != 0) {
-                               rav.push_back(data[i].abundance);
-                       }
-               }
-               
-               rav.setLabel(label);
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-RAbundVector SharedRAbundVector::getRAbundVector2() {
-       try {
-               RAbundVector rav;
-               for(int i = 0; i < numBins; i++)
-                       if(data[i].abundance != 0)
-                               rav.push_back(data[i].abundance-1);
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getRAbundVector2");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-SharedSAbundVector SharedRAbundVector::getSharedSAbundVector(){
-       try {
-               SharedSAbundVector sav(maxRank+1);
-               
-               for(int i=0;i<data.size();i++){
-                       int abund = data[i].abundance;
-                       sav.set(abund, sav.getAbundance(abund) + 1, group);
-               }
-               
-               sav.set(0, 0, group);
-               sav.setLabel(label);
-               sav.setGroup(group);
-               
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSharedSAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-SAbundVector SharedRAbundVector::getSAbundVector() {
-       try {
-               SAbundVector sav(maxRank+1);
-               
-               for(int i=0;i<data.size();i++){
-                       int abund = data[i].abundance;
-                       sav.set(abund, sav.get(abund) + 1);
-               }
-               sav.set(0, 0);
-               sav.setLabel(label);
-               return sav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSAbundVector");                
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-SharedOrderVector SharedRAbundVector::getSharedOrderVector() {
-       try {
-               SharedOrderVector ov;
-       
-               for(int i=0;i<data.size();i++){
-                       for(int j=0;j<data[i].abundance;j++){
-                               ov.push_back(data[i].bin, data[i].abundance, data[i].group);
-                       }
-               }
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);     
-               ov.updateStats();
-               
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getSharedOrderVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-OrderVector SharedRAbundVector::getOrderVector(map<string,int>* nameMap = NULL) {
-       try {
-               OrderVector ov;
-               for(int i=0;i<numBins;i++){
-                       for(int j=0;j<data[i].abundance;j++){
-                               ov.push_back(i);
-                       }
-               }
-               random_shuffle(ov.begin(), ov.end());
-               
-               ov.setLabel(label);     
-
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedRAbundVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sharedrabundvector.h b/sharedrabundvector.h
deleted file mode 100644 (file)
index 792543e..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-#ifndef SHAREDRABUNDVECTOR_H
-#define SHAREDRABUNDVECTOR_H
-
-/*
- *  sharedrabundvector.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/5/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "datavector.hpp"
-#include "sharedordervector.h"
-#include "sharedsabundvector.h"
-#include "sharedrabundfloatvector.h"
-#include "rabundvector.hpp"
-//#include "groupmap.h"
-
-/*  DataStructure for a shared file.
-       This class is a child to datavector.  It represents OTU information at a certain distance. 
-       It is similiar to an rabundvector except each member of data knows which group it belongs to.
-       Each member of the internal container "data" is a struct of type individual. 
-       An individual which knows the OTU from which it came, 
-       the group it is in and its abundance.  */
-
-//class GlobalData;
-
-class SharedRAbundVector : public DataVector {
-       
-public:
-       SharedRAbundVector();
-       SharedRAbundVector(int);
-       //SharedRAbundVector(string, vector<int>);
-       SharedRAbundVector(const SharedRAbundVector& bv) : DataVector(bv), data(bv.data), maxRank(bv.maxRank), numBins(bv.numBins), numSeqs(bv.numSeqs), group(bv.group), index(bv.index){};
-    SharedRAbundVector(ifstream&);
-       ~SharedRAbundVector();
-
-       int getNumBins();               
-       int getNumSeqs();                                                       
-       int getMaxRank();
-       string getGroup();
-       void setGroup(string);
-       string getBinLabel();
-       void setBinLabel(string);
-       int getGroupIndex();
-       void setGroupIndex(int);                                                                
-
-       void set(int, int, string);                     //OTU, abundance, groupname
-       void setData(vector <individual>);
-       individual get(int);
-       vector <individual> getData();
-       int getAbundance(int);
-       int numNZ();
-       void sortD();  //Sorts the data in descending order.
-       void push_front(int, int, string); //abundance, otu, groupname
-       void insert(int, int, string); //abundance, otu, groupname
-       void push_back(int, string);  //abundance, groupname
-       void pop_back();
-       void resize(int);
-       int size();
-       void clear();
-       vector<individual>::reverse_iterator rbegin();
-       vector<individual>::reverse_iterator rend();
-       
-       void print(ostream&);
-       void printHeaders(ostream&);
-               
-       RAbundVector getRAbundVector();
-       RAbundVector getRAbundVector2();
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       SharedOrderVector getSharedOrderVector();
-       SharedSAbundVector getSharedSAbundVector();
-       SharedRAbundVector getSharedRAbundVector();
-       vector<SharedRAbundVector*> getSharedRAbundVectors();
-       vector<SharedRAbundFloatVector*> getSharedRAbundFloatVectors(vector<SharedRAbundVector*>);
-       
-private:
-       vector<individual>  data; 
-       vector<SharedRAbundVector*> lookup;
-       //GlobalData* globaldata;
-       //GroupMap* groupmap;
-       int maxRank;
-       int numBins;
-       int numSeqs;
-       string group;
-       int index;      
-       
-       int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
-};
-
-
-#endif
-
diff --git a/sharedsabundvector.cpp b/sharedsabundvector.cpp
deleted file mode 100644 (file)
index efd14bc..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- *  sharedSharedSAbundVector.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/10/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsabundvector.h"
-#include "sabundvector.hpp"
-
-
-/***********************************************************************/
-
-SharedSAbundVector::SharedSAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){  }
-
-/***********************************************************************/
-
-SharedSAbundVector::SharedSAbundVector(int size) :     DataVector(), maxRank(0), numBins(0), numSeqs(0) {
-               individual newGuy;
-               //initialize data
-               for (int i=0; i< size; i++) {
-                       newGuy.bin = i;
-                       newGuy.abundance = 0;
-                       data.push_back(newGuy);
-               }
-}
-
-/***********************************************************************/
-
-void SharedSAbundVector::set(int bin, int abundance, string groupName){
-       try {
-
-               int initSize = data[bin].abundance;
-               data[bin].abundance = abundance;
-               data[bin].group = groupName;
-       
-               if(bin != 0){
-                       numBins += (abundance - initSize);
-               }
-       
-               numSeqs += bin * (abundance - initSize);
-       
-               if(bin > maxRank)       {       maxRank = bin;          }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "set");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-individual SharedSAbundVector::get(int index){
-       return data[index];
-}
-/***********************************************************************/
-
-int SharedSAbundVector::getAbundance(int index){
-       return data[index].abundance;
-}
-
-/***********************************************************************/
-
-void SharedSAbundVector::push_back(int abundance, int bin, string groupName){
-       try {
-               individual newGuy;
-               newGuy.abundance = abundance;
-               newGuy.bin = bin;
-               newGuy.group = groupName;
-               
-               data.push_back(newGuy);
-       
-               maxRank++;      
-       
-               numBins += abundance;
-       
-               numSeqs += (maxRank * abundance);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "push_back");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SharedSAbundVector::resize(int size){
-       data.resize(size);
-}
-
-/***********************************************************************/
-
-int SharedSAbundVector::size(){
-       return data.size();             
-}
-
-/***********************************************************************/
-void SharedSAbundVector::print(ostream& output){
-       try {
-               output << label << '\t' << maxRank << '\t';
-       
-               for(int i=1;i<=maxRank;i++){
-                       output << data[i].abundance << '\t';
-               }
-               output << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "print");
-               exit(1);
-       }
-}
-/***********************************************************************/
-string SharedSAbundVector::getGroup(){
-       return group;
-}
-
-/***********************************************************************/
-
-void SharedSAbundVector::setGroup(string groupName){
-       group = groupName;
-}
-
-/**********************************************************************/
-int SharedSAbundVector::getNumBins(){
-       return numBins;
-}
-
-/***********************************************************************/
-
-int SharedSAbundVector::getNumSeqs(){
-       return numSeqs;
-}
-
-/***********************************************************************/
-
-int SharedSAbundVector::getMaxRank(){
-       return maxRank;
-}
-/***********************************************************************/
-RAbundVector SharedSAbundVector::getRAbundVector(){
-       try {
-               RAbundVector rav;
-       
-               for(int i=1;i<data.size();i++){         
-                       for(int j=0;j<data[i].abundance;j++){
-                               rav.push_back(i);
-                       }
-               }
-               sort(rav.rbegin(), rav.rend());
-       
-               rav.setLabel(label);
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "getRAbundVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-SAbundVector SharedSAbundVector::getSAbundVector(){
-       try {
-               RAbundVector rav;
-               SAbundVector sav;
-               
-               rav = getRAbundVector();
-               sav = rav.getSAbundVector();
-               return sav;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "getSAbundVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-bool compareMembers (individual member, individual member2){
-
-  if(member.abundance < member2.abundance){
-    return true;   }   
-  else{
-       return false; 
-  }
-}
-
-/***********************************************************************/
-SharedRAbundVector SharedSAbundVector::getSharedRAbundVector(){
-       try {
-               SharedRAbundVector rav;
-               
-               for(int i=1;i<data.size();i++){         
-                       for(int j=0;j<data[i].abundance;j++){
-                               rav.push_back(i, data[i].group);
-                       }
-               }
-               sort(rav.rbegin(), rav.rend(), compareMembers);
-       
-               rav.setLabel(label);
-               rav.setGroup(group);
-               
-               return rav;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "getSharedRAbundVector");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-
-SharedSAbundVector SharedSAbundVector::getSharedSAbundVector(){
-       return *this;                   
-}
-
-/***********************************************************************/
-SharedOrderVector SharedSAbundVector::getSharedOrderVector() {
-       try {
-               SharedRAbundVector rav;
-               SharedOrderVector ov;
-               
-               rav = this->getSharedRAbundVector();
-               ov = rav.getSharedOrderVector();
-               
-               ov.updateStats();
-               
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "getSharedOrderVector");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void SharedSAbundVector::clear(){
-       numBins = 0;
-       maxRank = 0;
-       numSeqs = 0;
-       data.clear();
-}
-
-/***********************************************************************/
-OrderVector SharedSAbundVector::getOrderVector(map<string,int>* hold = NULL){
-       try {
-               OrderVector ov;
-       
-               int binIndex = 0;
-       
-               for(int i=1;i<data.size();i++){
-                       for(int j=0;j<data[i].abundance;j++){
-                               for(int k=0;k<i;k++){
-                                       ov.push_back(binIndex);
-                               }
-                               binIndex++;
-                       }
-               }
-       
-               random_shuffle(ov.begin(), ov.end());
-
-               ov.setLabel(label);
-               ov.getNumBins();
-               return ov;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSAbundVector", "getOrderVector");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sharedsabundvector.h b/sharedsabundvector.h
deleted file mode 100644 (file)
index cd78a2e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef SHAREDSABUND_H
-#define SHAREDSABUND_H
-
-
-/*
- *  sharedSharedSAbundVector.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 12/10/08.
- *  Copyright 2008 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "datavector.hpp"
-#include "rabundvector.hpp"
-#include "ordervector.hpp"
-#include "sharedordervector.h"
-#include "sharedrabundvector.h"
-
-/* This class is a child to datavector.  It represents OTU information at a certain distance. 
-       It is similiar to an sabundvector except each member of data knows which group it belongs to.
-       Each member of the internal container "data" is a struct of type individual. 
-       An individual which knows the OTU from which it came, 
-       the group it is in and its abundance.  */
-
-
-class SharedSAbundVector : public DataVector {
-       
-public:
-       SharedSAbundVector();
-       SharedSAbundVector(int);
-       SharedSAbundVector(const SharedSAbundVector& rv) : DataVector(rv.label), data(rv.data), maxRank(rv.maxRank), numBins(rv.numBins), numSeqs(rv.numSeqs){};
-       ~SharedSAbundVector(){};
-
-       int getNumBins();       
-       int getNumSeqs();       
-       int getMaxRank();       
-       string getGroup();
-       void setGroup(string);  
-       
-       void set(int, int, string);      //OTU, abundance, group
-       individual get(int);
-       int getAbundance(int);
-       void push_back(int, int, string);       //abundance, OTU, group
-       void pop_back();
-       void resize(int);
-       int size();
-       void clear();
-
-       void print(ostream&);
-               
-       RAbundVector getRAbundVector(); 
-       SAbundVector getSAbundVector();
-       OrderVector getOrderVector(map<string,int>*);
-       SharedSAbundVector getSharedSAbundVector();
-       SharedRAbundVector getSharedRAbundVector();
-       SharedOrderVector getSharedOrderVector();
-       
-private:
-       vector<individual> data;
-       
-       int maxRank;
-       int numBins;
-       int numSeqs;
-       string group;
-};
-
-#endif
-
diff --git a/sharedsobs.cpp b/sharedsobs.cpp
deleted file mode 100644 (file)
index f9b5edd..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *  sharedsobs.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsobs.h"
-
-/***********************************************************************/
-//This returns the number of unique species observed in several groups.  
-//The shared vector is each groups sharedrabundvector.
-
-EstOutput SharedSobs::getValues(vector<SharedRAbundVector*> shared){
-       try {
-               data.resize(1,0);
-               double observed = 0;
-
-               //loop through the species in each group
-               for (int k = 0; k < shared[0]->getNumBins(); k++) {
-                       //if you have found a new species
-                       if (shared[0]->getAbundance(k) != 0) { observed++; } 
-                       else if ((shared[0]->getAbundance(k) == 0) && (shared[1]->getAbundance(k) != 0)) { observed++; }
-               }
-
-               data[0] = observed;
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSobs", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedsobs.h b/sharedsobs.h
deleted file mode 100644 (file)
index 3fa32ce..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SHAREDSOBS_H
-#define SHAREDSOBS_H
-/*
- *  sharedsobs.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedSobs estimator on two groups for the shared rarefaction command. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-class SharedSobs : public Calculator {
-
-public:
-       SharedSobs() : Calculator("sharedsobs", 1, false) {};
-       EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/sharedsobs"; }
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/sharedsobscollectsummary.cpp b/sharedsobscollectsummary.cpp
deleted file mode 100644 (file)
index fffed02..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  sharedsobscollectsummary.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/12/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsobscollectsummary.h"
-
-/***********************************************************************/
-//This returns the number of shared species observed in several groups.  
-//The shared vector is each groups sharedrabundvector.
-
-EstOutput SharedSobsCS::getValues(vector<SharedRAbundVector*> shared){
-       try {
-               data.resize(1,0);
-               double observed = 0;
-               int numGroups = shared.size();
-
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //get bin values and set sharedByAll 
-                       bool sharedByAll = true;
-                       for (int j = 0; j < numGroups; j++) {
-                               if (shared[j]->getAbundance(i) == 0) { sharedByAll = false; }
-                       }
-                       
-                       //they are shared
-                       if (sharedByAll == true) {  observed++;  }
-               }
-
-               data[0] = observed;
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedSobsCS", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedsobscollectsummary.h b/sharedsobscollectsummary.h
deleted file mode 100644 (file)
index d35a2ac..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SHAREDSOBSCOLLECTSUMMARY_H
-#define SHAREDSOBSCOLLECTSUMMARY_H
-
-/*
- *  sharedsobscollectsummary.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/12/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This calculator returns the number of shared species between 2 groups. */
-
-#include "calculator.h"
-
-/***********************************************************************/
-class SharedSobsCS : public Calculator {
-
-public:
-       SharedSobsCS() : Calculator("sharedsobs", 1, true) {};
-       EstOutput getValues(SAbundVector* rank){ return data; };
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sharedsobs"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedsorabund.cpp b/sharedsorabund.cpp
deleted file mode 100644 (file)
index 9a1bd63..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *  sharedsorabund.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsorabund.h"
-
-/***********************************************************************/
-
-EstOutput SorAbund::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               EstOutput UVest;
-               UVest.resize(2,0);
-               data.resize(1,0);
-               
-               UVest = uv->getUVest(shared);
-               
-               //UVest[0] is Uest, UVest[1] is Vest
-               data[0] = (2 * UVest[0] * UVest[1]) / ((float)(UVest[0] + UVest[1]));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               data[0] = 1-data[0];
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SorAbund", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sharedsorabund.h b/sharedsorabund.h
deleted file mode 100644 (file)
index aa85622..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef SORABUND_H
-#define SORABUND_H
-/*
- *  sharedsorabund.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedSorAbund estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SorAbund : public Calculator  {
-       
-public:
-       SorAbund() :  Calculator("sorabund", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sorabund"; }
-private:
-       UVEst* uv;
-       
-};
-/***********************************************************************/
-
-#endif
diff --git a/sharedsorclass.cpp b/sharedsorclass.cpp
deleted file mode 100644 (file)
index 85609da..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- *  sharedsorclass.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsorclass.h"
-
-/***********************************************************************/
-
-EstOutput SorClass::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               double S1, S2, S12, tempA, tempB;
-               S1 = 0; S2 = 0; S12 = 0; tempA = 0; tempB = 0; 
-               
-               /*S1, S2 = number of OTUs observed or estimated in A and B 
-               S12=number of OTUs shared between A and B */
-
-               data.resize(1,0);
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-
-                       //find number of bins in shared1 and shared2
-                       if (tempA != 0) { S1++; }
-                       if (tempB != 0) { S2++; } 
-                       
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {     S12++; }
-               }
-               
-               data[0] = 1.0-(2 * S12) / (float)(S1 + S2);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SorClass", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedsorclass.h b/sharedsorclass.h
deleted file mode 100644 (file)
index 49ada2d..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef SORCLASS_H
-#define SORCLASS_H
-/*
- *  sharedsorclass.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedSorClass estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SorClass : public Calculator  {
-       
-public:
-       SorClass() :  Calculator("sorclass", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sorclass"; }
-private:
-       
-};
-/***********************************************************************/
-
-#endif
diff --git a/sharedsorest.cpp b/sharedsorest.cpp
deleted file mode 100644 (file)
index b9ab050..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  sharedsorest.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedsorest.h"
-#include "chao1.h"
-#include "sharedchao1.h"
-
-/***********************************************************************/
-
-EstOutput SorEst::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               EstOutput S1, S2, S12;
-               S12.resize(1,0);
-               S1.resize(3,0);
-               S2.resize(3,0); 
-               
-               /*S1, S2 = number of OTUs estimated in A and B using the Chao estimator
-               S12 = estimated number of OTUs shared between A and B using the SharedChao estimator*/
-
-               data.resize(1,0);
-               
-               SharedChao1* sharedChao = new SharedChao1();
-               Chao1* chaoS1 = new Chao1();
-               Chao1* chaoS2 = new Chao1();
-               SAbundVector* chaoS1Sabund = new SAbundVector();
-               SAbundVector* chaoS2Sabund = new SAbundVector();
-               
-               *chaoS1Sabund = shared[0]->getSAbundVector();
-               *chaoS2Sabund = shared[1]->getSAbundVector();
-               
-               S12 = sharedChao->getValues(shared);
-               S1 = chaoS1->getValues(chaoS1Sabund);
-               S2 = chaoS2->getValues(chaoS2Sabund);
-               
-               data[0] = 1.0-(2 * S12[0]) / (float)(S1[0] + S2[0]);
-                
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               delete sharedChao;
-               delete chaoS1;
-               delete chaoS2;
-               delete chaoS1Sabund;
-               delete chaoS2Sabund;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SorEst", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedsorest.h b/sharedsorest.h
deleted file mode 100644 (file)
index 904a712..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef SOREST_H
-#define SOREST_H
-/*
- *  sharedsorest.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedSorEst estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SorEst : public Calculator  {
-       
-public:
-       SorEst() :  Calculator("sorest", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Sorest"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedthetan.cpp b/sharedthetan.cpp
deleted file mode 100644 (file)
index 644adee..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- *  sharedthetan.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedthetan.h"
-
-/***********************************************************************/
-EstOutput ThetaN::getValues(vector<SharedRAbundVector*> shared) {
-       try {   
-               data.resize(1,0);
-               
-               double Atotal, Btotal, tempA, tempB;
-               Atotal = 0; Btotal = 0; 
-               double numerator, denominator, thetaN, sumSharedA, sumSharedB, a, b, d;
-               numerator = 0.0; denominator = 0.0; thetaN = 0.0; sumSharedA = 0.0; sumSharedB = 0.0; a = 0.0; b = 0.0; d = 0.0;
-               
-               //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       Atotal += shared[0]->getAbundance(i);
-                       Btotal += shared[1]->getAbundance(i);
-               }
-               
-               //calculate the theta denominator sums
-               for (int j = 0; j < shared[0]->getNumBins(); j++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(j);
-                       tempB = shared[1]->getAbundance(j);
-                       
-                       //they are shared
-                       if ((tempA != 0) && (tempB != 0)) {
-                               if (Atotal != 0)        { sumSharedA = (tempA / (float)Atotal); }
-                               if (Btotal != 0)        { sumSharedB = (tempB / (float)Btotal); }
-                       
-                               a += sumSharedA;
-                               b += sumSharedB;
-                       }
-               }
-
-               thetaN = (a * b) / (a + b - (a * b));
-               
-               if (isnan(thetaN) || isinf(thetaN)) { thetaN = 0; }
-               
-               data[0] = 1.0 - thetaN;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ThetaN", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedthetan.h b/sharedthetan.h
deleted file mode 100644 (file)
index 2d30ecc..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef THETAN_H
-#define THETAN_H
-/*
- *  sharedthetan.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedThetaN estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class ThetaN : public Calculator  {
-       
-public:
-       ThetaN() :  Calculator("thetan", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Thetan"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sharedthetayc.cpp b/sharedthetayc.cpp
deleted file mode 100644 (file)
index 6c0f6c7..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *  sharedthetayc.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedthetayc.h"
-
-/***********************************************************************/
-EstOutput ThetaYC::getValues(vector<SharedRAbundVector*> shared) {
-       try {   
-               data.resize(3,0.0000);
-               
-               double Atotal = 0;
-               double Btotal = 0;
-               double thetaYC = 0;
-               double pi = 0;
-               double qi = 0;
-               double a = 0;
-               double b = 0;
-               double d = 0;
-               
-               double sumPcubed = 0;
-               double sumQcubed = 0;
-               double sumPQsq = 0;
-               double sumPsqQ = 0;
-               
-               //get the total values we need to calculate the theta denominator sums
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       Atotal += (double)shared[0]->getAbundance(i);
-                       Btotal += (double)shared[1]->getAbundance(i);
-               }
-               
-               //calculate the theta denominator sums
-               for (int j = 0; j < shared[0]->getNumBins(); j++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       pi = shared[0]->getAbundance(j) / Atotal;
-                       qi = shared[1]->getAbundance(j) / Btotal;
-                                       
-                       a += pi * pi;
-                       b += qi * qi;
-                       d += pi * qi;
-                       
-                       sumPcubed += pi * pi * pi;
-                       sumQcubed += qi * qi * qi;
-                       sumPQsq += pi * qi * qi;
-                       sumPsqQ += pi * pi * qi;
-               }
-
-               thetaYC = d / (a + b - d);
-               
-               if (isnan(thetaYC) || isinf(thetaYC)) { thetaYC = 0; }
-               
-               double varA = 4 / Atotal * (sumPcubed - a * a);
-               double varB = 4 / Btotal * (sumQcubed - b * b);
-               double varD = sumPQsq / Atotal + sumPsqQ / Btotal - d * d * (1/Atotal + 1/Btotal);
-               double covAD = 2 / Atotal * (sumPsqQ - a * d);
-               double covBD = 2 / Btotal * (sumPQsq - b* d);
-               
-               double varT = d * d * (varA + varB) / pow(a + b - d, (double)4.0) + pow(a+b, (double)2.0) * varD / pow(a+b-d, (double)4.0)
-                                               - 2.0 * (a + b) * d / pow(a + b - d, (double)4.0) * (covAD + covBD);
-               
-               double ci = 1.95 * sqrt(varT);
-               
-               data[0] = thetaYC;
-               data[1] = thetaYC - ci;
-               data[2] = thetaYC + ci;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-               
-               data[0] = 1.0 - data[0];
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ThetaYC", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/sharedthetayc.h b/sharedthetayc.h
deleted file mode 100644 (file)
index b132a56..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef THETAYC_H
-#define THETAYC_H
-/*
- *  sharedthetayc.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the SharedThetaYC estimator on two groups. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class ThetaYC : public Calculator  {
-       
-public:
-       ThetaYC() :  Calculator("thetayc", 3, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Thetayc"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/sharedutilities.cpp b/sharedutilities.cpp
deleted file mode 100644 (file)
index 151b254..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- *  sharedutilities.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sharedutilities.h"
-#include "sharedrabundvector.h"
-#include "sharedordervector.h"
-
-/**************************************************************************************************/
-
-void SharedUtil::getSharedVectors(vector<string> Groups, vector<SharedRAbundVector*>& lookup, SharedOrderVector* order) {
-       try {
-       
-               //delete each sharedrabundvector in lookup
-               for (int j = 0; j < lookup.size(); j++) {
-                       delete lookup[j];
-               }
-               
-               lookup.clear();
-               
-               //create and initialize vector of sharedvectors, one for each group
-               for (int i = 0; i < Groups.size(); i++) { 
-                       SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
-                       temp->setLabel(order->getLabel());
-                       temp->setGroup(Groups[i]);
-                       lookup.push_back(temp);
-               }
-       
-               int numSeqs = order->size();
-               //sample all the members
-               for(int i=0;i<numSeqs;i++){
-                       //get first sample
-                       individual chosen = order->get(i);
-                       int abundance; 
-                                       
-                       //set info for sharedvector in chosens group
-                       for (int j = 0; j < lookup.size(); j++) { 
-                               if (chosen.group == lookup[j]->getGroup()) {
-                                        abundance = lookup[j]->getAbundance(chosen.bin);
-                                        lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
-                                        break;
-                               }
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "getSharedVectors");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-void SharedUtil::getSharedVectorswithReplacement(vector<string> Groups, vector<SharedRAbundVector*>& lookup, SharedOrderVector* order) {
-       try {
-       
-               //delete each sharedrabundvector in lookup
-               for (int j = 0; j < lookup.size(); j++) {
-                       delete lookup[j];
-               }
-               lookup.clear();
-               
-               //create and initialize vector of sharedvectors, one for each group
-               for (int i = 0; i < Groups.size(); i++) { 
-                       SharedRAbundVector* temp = new SharedRAbundVector(order->getNumBins());
-                       temp->setLabel(order->getLabel());
-                       temp->setGroup(Groups[i]);
-                       lookup.push_back(temp);
-               }
-       
-               int numSeqs = order->size();
-               
-               //sample all the members
-               for(int i=0;i<numSeqs;i++){
-                       //get random number
-                       int random = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
-                       individual chosen = order->get(random);
-
-                       int abundance; 
-                       //set info for sharedvector in chosens group
-                       for (int j = 0; j < lookup.size(); j++) { 
-                               if (chosen.group == lookup[j]->getGroup()) {
-                                        abundance = lookup[j]->getAbundance(chosen.bin);
-                                        lookup[j]->set(chosen.bin, (abundance + 1), chosen.group);
-                                        break;
-                               }
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "getSharedVectorswithReplacement");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-//need to have mode because different commands require different number of valid groups
-void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups) {
-       try {
-               
-               sort(userGroups.begin(), userGroups.end());
-               sort(allGroups.begin(), allGroups.end());
-               
-               if (userGroups.size() != 0) {
-                       if (userGroups[0] != "all") {
-                               //check that groups are valid
-                               for (int i = 0; i < userGroups.size(); i++) {
-                                       if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
-                                               // erase the invalid group from userGroups
-                                               userGroups.erase(userGroups.begin()+i);
-                                               i--;
-                                       }
-                               }
-                               
-                               //if the user only entered invalid groups
-                               if (userGroups.size() == 0) { 
-                                       m->mothurOut("You provided no valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                                       for (int i = 0; i < allGroups.size(); i++) {
-                                               userGroups.push_back(allGroups[i]);
-                                       }
-                               }
-
-                       }else{//user has enter "all" and wants the default groups
-                               userGroups.clear();
-                               for (int i = 0; i < allGroups.size(); i++) {
-                                       userGroups.push_back(allGroups[i]);
-                               }
-                       }
-               }else { //the user has not entered groups
-                       for (int i = 0; i < allGroups.size(); i++) {
-                               userGroups.push_back(allGroups[i]);
-                       }
-               }
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "setGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-//need to have mode because different commands require different number of valid groups
-void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string mode) {
-       try {
-               
-               sort(userGroups.begin(), userGroups.end());
-               sort(allGroups.begin(), allGroups.end());
-               
-               if (userGroups.size() != 0) {
-                       if (userGroups[0] != "all") {
-                               //check that groups are valid
-                               for (int i = 0; i < userGroups.size(); i++) {
-                                       if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
-                                               // erase the invalid group from userGroups
-                                               userGroups.erase(userGroups.begin()+i);
-                                               i--;
-                                       }
-                               }
-
-                       }else{//user has enter "all" and wants the default groups
-                               userGroups.clear();
-                               for (int i = 0; i < allGroups.size(); i++) {
-                                       userGroups.push_back(allGroups[i]);
-                               }
-                       }
-               }else { //the user has not entered groups
-                       for (int i = 0; i < allGroups.size(); i++) {
-                               userGroups.push_back(allGroups[i]);
-                       }
-               }
-                       
-               if ((mode == "collect") || (mode == "rarefact") || (mode == "summary") || (mode == "treegroup")) {
-                               //if the user only entered invalid groups
-                               if ((userGroups.size() == 0) || (userGroups.size() == 1)) { 
-                                       m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                                       for (int i = 0; i < allGroups.size(); i++) {
-                                               userGroups.push_back(allGroups[i]);
-                                       }
-                               }
-               }
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "setGroups");
-               exit(1);
-       }
-}
-
-
-/**************************************************************************************/
-//for parsimony and unifrac commands you set pairwise groups as well as an allgroups in calc
-void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string& label, int& numGroups, string mode){  //globaldata->Groups, your tree or group map, allgroups, mode
-       try {
-               sort(userGroups.begin(), userGroups.end());
-               sort(allGroups.begin(), allGroups.end());
-               
-               numGroups = 0;
-               label = "";
-
-               //if the user has not entered specific groups to analyze then do them all
-               if (userGroups.size() != 0) {
-                       if (userGroups[0] != "all") {
-                               //check that groups are valid
-                               for (int i = 0; i < userGroups.size(); i++) {
-                                       if (isValidGroup(userGroups[i], allGroups) != true) {
-                                               m->mothurOut(userGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
-                                               // erase the invalid group from globaldata->Groups
-                                               userGroups.erase(userGroups.begin()+i);
-                                               i--;
-                                       }
-                               }
-                       }else { //users wants all groups
-                               userGroups.clear();
-                               for (int i=0; i < allGroups.size(); i++) { 
-                                       if (allGroups[i] != "xxx") {
-                                               userGroups.push_back(allGroups[i]);
-                                       }
-                               }
-                       }
-               }else { //the user has not entered groups
-                       for (int i=0; i < allGroups.size(); i++) { 
-                               if (allGroups[i] != "xxx") {
-                                       if (mode == "weighted") {
-                                               userGroups.push_back(allGroups[i]);
-                                       }else {
-                                               numGroups = 1;
-                                               label += allGroups[i] + "-";
-                                       }
-                               }
-                       }
-                       //rip extra - off allgroups 
-                       label = label.substr(0, label.length()-1);
-                       if ((mode != "weighted") && (allGroups.size() > 10)) {  label = "merged";  }
-               }
-               
-               if (mode == "weighted") {
-                       //if the user only entered invalid groups
-                       if (userGroups.size() == 0) { 
-                               for (int i=0; i < allGroups.size(); i++) { 
-                                       if (allGroups[i] != "xxx") {
-                                               userGroups.push_back(allGroups[i]);
-                                       }
-                               }
-                               m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                       }else if (userGroups.size() == 1) { 
-                               m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                               userGroups.clear();
-                               for (int i=0; i < allGroups.size(); i++) { 
-                                       if (allGroups[i] != "xxx") {
-                                               userGroups.push_back(allGroups[i]);
-                                       }
-                               }
-                       }
-                       numGroups = userGroups.size();
-                       
-               }else if ((mode == "unweighted") || (mode == "parsimony")) {
-                               //if the user only entered invalid groups
-                               if ((userGroups.size() == 0) && (numGroups == 0)) { 
-                                       m->mothurOut("When using the groups parameter you must have at least 1 valid group. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
-                                       for (int i = 0; i < allGroups.size(); i++) {
-                                               if (allGroups[i] != "xxx") {
-                                                       userGroups.push_back(allGroups[i]);
-                                               }
-                                       }
-                               }
-                               
-                               if (numGroups != 1) { numGroups = userGroups.size(); }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "setGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-void SharedUtil::getCombos(vector<string>& groupComb, vector<string> userGroups, int& numComp) { //groupcomb, globaldata->Groups, numcomb
-       try {
-               sort(userGroups.begin(), userGroups.end());
-               //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
-               numComp = 0;
-               for (int i=0; i< userGroups.size(); i++) { 
-                       numComp += i; 
-                       for (int l = 0; l < i; l++) {
-                               if (userGroups[i] > userGroups[l]) {
-                                       //set group comparison labels
-                                       groupComb.push_back(userGroups[l] + "-" + userGroups[i]);
-                               }else{
-                                       groupComb.push_back(userGroups[i] + "-" + userGroups[l]);
-                               }
-                       }
-               } 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "getCombos");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-bool SharedUtil::isValidGroup(string groupname, vector<string> groups) {
-       try {
-               for (int i = 0; i < groups.size(); i++) {
-                       if (groupname == groups[i]) { return true; }
-               }
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "isValidGroup");
-               exit(1);
-       }
-}
-
-/**************************************************************************************/
-void SharedUtil::updateGroupIndex(vector<string>& userGroups, map<string, int>& index) {
-       try {
-               index.clear();
-               for (int i = 0; i < userGroups.size(); i++) {
-                       index[userGroups[i]] = i;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SharedUtil", "updateGroupIndex");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-
-
diff --git a/sharedutilities.h b/sharedutilities.h
deleted file mode 100644 (file)
index df7e8d3..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef SHAREDUTIL_H
-#define SHAREDUTIL_H
-/*
- *  sharedutilities.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-class SharedRAbundVector;
-class SharedOrderVector;
-
-/**************************************************************************************************/
-
-class SharedUtil {
-       public:
-               SharedUtil() { m = MothurOut::getInstance(); }
-               ~SharedUtil() {};
-               
-               void getSharedVectors(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
-               void getSharedVectorswithReplacement(vector<string>, vector<SharedRAbundVector*>&, SharedOrderVector*);
-               void setGroups(vector<string>&, vector<string>&);  //globaldata->Groups, your tree or group map
-               void setGroups(vector<string>&, vector<string>&, string);  //globaldata->Groups, your tree or group map, mode
-               void setGroups(vector<string>&, vector<string>&, string&, int&, string);  //globaldata->Groups, your tree or group map, allgroups, numGroups, mode
-               void getCombos(vector<string>&, vector<string>, int&); //groupcomb, globaldata->Groups, numcomb
-               void updateGroupIndex(vector<string>&, map<string, int>&); //globaldata->Groups, groupmap->groupIndex
-               bool isValidGroup(string, vector<string>);
-               
-       private:
-               MothurOut* m;
-               
-};
-
-/**************************************************************************************************/
-
-#endif
diff --git a/shen.cpp b/shen.cpp
deleted file mode 100644 (file)
index dac12bd..0000000
--- a/shen.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  shen.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/18/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "shen.h"
-#include "ace.h"
-
-       
-/***********************************************************************/      
-EstOutput Shen::getValues(SAbundVector* rank){
-
-       try {
-               
-               data.resize(1,0);
-               
-               double n = (double)rank->getNumSeqs();
-               double f1 = (double)rank->get(1);
-               
-               Ace* calc = new Ace(abund);
-               EstOutput ace = calc->getValues(rank);
-               
-               double f0 = ace[0]-rank->getNumBins();
-               
-               data[0] = f0 * (1 - pow(1 - f1/n/f0, f));
-               
-               delete calc;
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Shen", "getValues");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
diff --git a/shen.h b/shen.h
deleted file mode 100644 (file)
index ad0eda4..0000000
--- a/shen.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef SHEN_H
-#define SHEN_H
-
-/*
- *  shen.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/18/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the shen calculator on single group. 
- It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Shen : public Calculator  {
-       
-public: 
-       Shen(int size, int n) : f(size), abund(n), Calculator("shen", 1, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Shen"; }
-private:
-       int f;
-       int abund;
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/shhhercommand.cpp b/shhhercommand.cpp
deleted file mode 100644 (file)
index 89d7828..0000000
+++ /dev/null
@@ -1,3345 +0,0 @@
-/*
- *  shhher.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 12/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "shhhercommand.h"
-
-//**********************************************************************************************************************
-vector<string> ShhherCommand::setParameters(){ 
-       try {
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pflow);
-               CommandParameter pfile("file", "InputTypes", "", "", "none", "fileflow", "none",false,false); parameters.push_back(pfile);
-               CommandParameter plookup("lookup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(plookup);
-               CommandParameter pcutoff("cutoff", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pmaxiter("maxiter", "Number", "", "1000", "", "", "",false,false); parameters.push_back(pmaxiter);
-               CommandParameter psigma("sigma", "Number", "", "60", "", "", "",false,false); parameters.push_back(psigma);
-               CommandParameter pmindelta("mindelta", "Number", "", "0.000001", "", "", "",false,false); parameters.push_back(pmindelta);
-               CommandParameter porder("order", "String", "", "", "", "", "",false,false); parameters.push_back(porder);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ShhherCommand::getHelpString(){ 
-       try {
-               string helpString = "";
-               helpString += "The shhh.flows command reads a file containing flowgrams and creates a file of corrected sequences.\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-ShhherCommand::ShhherCommand(){        
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               
-               //initialize outputTypes
-//             vector<string> tempOutNames;
-//             outputTypes["pn.dist"] = tempOutNames;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "ShhherCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-ShhherCommand::ShhherCommand(string option) {
-       try {
-        
-#ifdef USE_MPI
-               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-               MPI_Comm_size(MPI_COMM_WORLD, &ncpus);
-        
-               if(pid == 0){
-#endif
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-//                     outputTypes["pn.dist"] = tempOutNames;
-                       //                      outputTypes["fasta"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("flow");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["flow"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("lookup");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["lookup"] = inputDir + it->second;           }
-                               }
-
-                               it = parameters.find("file");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["file"] = inputDir + it->second;             }
-                               }
-                       }
-            
-            //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-            
-                       //check for required parameters
-                       flowFileName = validParameter.validFile(parameters, "flow", true);
-                       flowFilesFileName = validParameter.validFile(parameters, "file", true);
-                       if (flowFileName == "not found" && flowFilesFileName == "not found") {
-                               m->mothurOut("values for either flow or file must be provided for the shhh.seqs command.");
-                               m->mothurOutEndLine();
-                               abort = true; 
-                       }
-                       else if (flowFileName == "not open" || flowFilesFileName == "not open") { abort = true; }
-                       
-                       if(flowFileName != "not found"){
-                               compositeFASTAFileName = "";    
-                               compositeNamesFileName = "";    
-                       }
-                       else{
-                               ofstream temp;
-                
-                string thisoutputDir = m->hasPath(flowFilesFileName); //if user entered a file with a path then preserve it
-                
-                               //flow.files = 9 character offset
-                               compositeFASTAFileName = thisoutputDir + flowFilesFileName.substr(0, flowFilesFileName.length()-10) + "shhh.fasta";
-                               m->openOutputFile(compositeFASTAFileName, temp);
-                               temp.close();
-                               
-                               compositeNamesFileName = thisoutputDir + flowFilesFileName.substr(0, flowFilesFileName.length()-10) + "shhh.names";
-                               m->openOutputFile(compositeNamesFileName, temp);
-                               temp.close();
-                       }
-            
-            if(flowFilesFileName != "not found"){
-                string fName;
-                
-                ifstream flowFilesFile;
-                m->openInputFile(flowFilesFileName, flowFilesFile);
-                while(flowFilesFile){
-                    fName = m->getline(flowFilesFile);
-                    
-                    //test if file is valid
-                    ifstream in;
-                    int ableToOpen = m->openInputFile(fName, in, "noerror");
-                    in.close();        
-                    if (ableToOpen == 1) {
-                        if (inputDir != "") { //default path is set
-                            string tryPath = inputDir + fName;
-                            m->mothurOut("Unable to open " + fName + ". Trying input directory " + tryPath); m->mothurOutEndLine();
-                            ifstream in2;
-                            ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                            in2.close();
-                            fName = tryPath;
-                        }
-                    }
-                    
-                    if (ableToOpen == 1) {
-                        if (m->getDefaultPath() != "") { //default path is set
-                            string tryPath = m->getDefaultPath() + m->getSimpleName(fName);
-                            m->mothurOut("Unable to open " + fName + ". Trying default " + tryPath); m->mothurOutEndLine();
-                            ifstream in2;
-                            ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                            in2.close();
-                            fName = tryPath;
-                        }
-                    }
-                    
-                    //if you can't open it its not in current working directory or inputDir, try mothur excutable location
-                    if (ableToOpen == 1) {
-                        string exepath = m->argv;
-                        string tempPath = exepath;
-                        for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
-                        exepath = exepath.substr(0, (tempPath.find_last_of('m')));
-                        
-                        string tryPath = m->getFullPathName(exepath) + m->getSimpleName(fName);
-                        m->mothurOut("Unable to open " + fName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
-                        ifstream in2;
-                        ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                        in2.close();
-                        fName = tryPath;
-                    }
-                    
-                    if (ableToOpen == 1) {  m->mothurOut("Unable to open " + fName + ". Disregarding. "); m->mothurOutEndLine();  }
-                    else { flowFileVector.push_back(fName); }
-                    m->gobble(flowFilesFile);
-                }
-                flowFilesFile.close();
-                if (flowFileVector.size() == 0) {  m->mothurOut("[ERROR]: no valid files."); m->mothurOutEndLine(); abort = true; }
-            }
-            else{
-                outputDir += m->hasPath(flowFileName);
-                flowFileVector.push_back(flowFileName);
-            }
-               
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "lookup", true);
-                       if (temp == "not found")        {       
-                               lookupFileName = "LookUp_Titanium.pat"; 
-                               
-                               int ableToOpen;
-                               ifstream in;
-                               ableToOpen = m->openInputFile(lookupFileName, in, "noerror");
-                               in.close();     
-                               
-                               //if you can't open it, try input location
-                               if (ableToOpen == 1) {
-                                       if (inputDir != "") { //default path is set
-                                               string tryPath = inputDir + lookupFileName;
-                                               m->mothurOut("Unable to open " + lookupFileName + ". Trying input directory " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               in2.close();
-                                               lookupFileName = tryPath;
-                                       }
-                               }
-                               
-                               //if you can't open it, try default location
-                               if (ableToOpen == 1) {
-                                       if (m->getDefaultPath() != "") { //default path is set
-                                               string tryPath = m->getDefaultPath() + m->getSimpleName(lookupFileName);
-                                               m->mothurOut("Unable to open " + lookupFileName + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               in2.close();
-                                               lookupFileName = tryPath;
-                                       }
-                               }
-                               
-                               //if you can't open it its not in current working directory or inputDir, try mothur excutable location
-                               if (ableToOpen == 1) {
-                                       string exepath = m->argv;
-                                       string tempPath = exepath;
-                                       for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
-                                       exepath = exepath.substr(0, (tempPath.find_last_of('m')));
-                                       
-                                       string tryPath = m->getFullPathName(exepath) + m->getSimpleName(lookupFileName);
-                                       m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
-                                       ifstream in2;
-                                       ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                       in2.close();
-                                       lookupFileName = tryPath;
-                               }
-                               
-                               if (ableToOpen == 1) {  m->mothurOut("Unable to open " + lookupFileName + "."); m->mothurOutEndLine(); abort=true;  }
-                       }
-                       else if(temp == "not open")     {       
-                               
-                               lookupFileName = validParameter.validFile(parameters, "lookup", false);
-                               
-                               //if you can't open it its not inputDir, try mothur excutable location
-                               string exepath = m->argv;
-                               string tempPath = exepath;
-                               for (int i = 0; i < exepath.length(); i++) { tempPath[i] = tolower(exepath[i]); }
-                               exepath = exepath.substr(0, (tempPath.find_last_of('m')));
-                                       
-                               string tryPath = m->getFullPathName(exepath) + lookupFileName;
-                               m->mothurOut("Unable to open " + lookupFileName + ". Trying mothur's executable location " + tryPath); m->mothurOutEndLine();
-                               ifstream in2;
-                               int ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                               in2.close();
-                               lookupFileName = tryPath;
-                               
-                               if (ableToOpen == 1) {  m->mothurOut("Unable to open " + lookupFileName + "."); m->mothurOutEndLine(); abort=true;  }
-                       }else                                           {       lookupFileName = temp;  }
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-
-                       temp = validParameter.validFile(parameters, "cutoff", false);   if (temp == "not found"){       temp = "0.01";          }
-                       m->mothurConvert(temp, cutoff); 
-                       
-                       temp = validParameter.validFile(parameters, "mindelta", false); if (temp == "not found"){       temp = "0.000001";      }
-                       m->mothurConvert(temp, minDelta); 
-
-                       temp = validParameter.validFile(parameters, "maxiter", false);  if (temp == "not found"){       temp = "1000";          }
-                       m->mothurConvert(temp, maxIters); 
-
-                       temp = validParameter.validFile(parameters, "sigma", false);if (temp == "not found")    {       temp = "60";            }
-                       m->mothurConvert(temp, sigma); 
-                       
-                       flowOrder = validParameter.validFile(parameters, "order", false);
-                       if (flowOrder == "not found"){ flowOrder = "TACG";              }
-                       else if(flowOrder.length() != 4){
-                               m->mothurOut("The value of the order option must be four bases long\n");
-                       }
-                       
-               }
-#ifdef USE_MPI
-               }                               
-#endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "ShhherCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-#ifdef USE_MPI
-int ShhherCommand::execute(){
-       try {
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int tag = 1976;
-               MPI_Status status; 
-                       
-               if(pid == 0){
-
-                       for(int i=1;i<ncpus;i++){
-                               MPI_Send(&abort, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                       }
-                       if(abort == 1){ return 0;       }
-
-                       processors = ncpus;
-                       
-                       m->mothurOut("\nGetting preliminary data...\n");
-                       getSingleLookUp();      if (m->control_pressed) { return 0; }
-                       getJointLookUp();       if (m->control_pressed) { return 0; }
-                       
-            vector<string> flowFileVector;
-                       if(flowFilesFileName != "not found"){
-                               string fName;
-                
-                               ifstream flowFilesFile;
-                               m->openInputFile(flowFilesFileName, flowFilesFile);
-                               while(flowFilesFile){
-                                       fName = m->getline(flowFilesFile);
-                                       flowFileVector.push_back(fName);
-                                       m->gobble(flowFilesFile);
-                               }
-                       }
-                       else{
-                               flowFileVector.push_back(flowFileName);
-                       }
-            
-                       int numFiles = flowFileVector.size();
-
-                       for(int i=1;i<ncpus;i++){
-                               MPI_Send(&numFiles, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                       }
-                       
-                       for(int i=0;i<numFiles;i++){
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               double begClock = clock();
-                               unsigned long long begTime = time(NULL);
-
-                               flowFileName = flowFileVector[i];
-                               
-                               m->mothurOut("\n>>>>>\tProcessing " + flowFileName + " (file " + toString(i+1) + " of " + toString(numFiles) + ")\t<<<<<\n");
-                               m->mothurOut("Reading flowgrams...\n");
-                               getFlowData();
-                               
-                               if (m->control_pressed) { break; }
-
-                               m->mothurOut("Identifying unique flowgrams...\n");
-                               getUniques();
-                               
-                               if (m->control_pressed) { break; }
-
-                               m->mothurOut("Calculating distances between flowgrams...\n");
-                               char fileName[1024];
-                               strcpy(fileName, flowFileName.c_str());
-
-                               for(int i=1;i<ncpus;i++){
-                                       MPI_Send(&fileName[0], 1024, MPI_CHAR, i, tag, MPI_COMM_WORLD);
-
-                                       MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&numUniques, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&numFlowCells, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&flowDataIntI[0], numSeqs * numFlowCells, MPI_SHORT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&flowDataPrI[0], numSeqs * numFlowCells, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&mapUniqueToSeq[0], numSeqs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&mapSeqToUnique[0], numSeqs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&lengths[0], numSeqs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&jointLookUp[0], NUMBINS * NUMBINS, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&cutoff, 1, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                               }                               
-                                                       
-                               string distFileName = flowDistMPI(0, int(sqrt(1.0/float(ncpus)) * numUniques));
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               int done;
-                               for(int i=1;i<ncpus;i++){
-                                       MPI_Recv(&done, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                       
-                                       m->appendFiles((distFileName + ".temp." + toString(i)), distFileName);
-                                       m->mothurRemove((distFileName + ".temp." + toString(i)));
-                               }
-
-                               string namesFileName = createNamesFile();
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               m->mothurOut("\nClustering flowgrams...\n");
-                               string listFileName = cluster(distFileName, namesFileName);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               getOTUData(listFileName);
-
-                               m->mothurRemove(distFileName);
-                               m->mothurRemove(namesFileName);
-                               m->mothurRemove(listFileName);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               initPyroCluster();
-
-                               if (m->control_pressed) { break; }
-                               
-                               for(int i=1;i<ncpus;i++){
-                                       MPI_Send(&numOTUs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&singleLookUp[0], singleLookUp.size(), MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&uniqueFlowgrams[0], numFlowCells * numUniques, MPI_SHORT, i, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&sigma, 1, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                               }
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               double maxDelta = 0;
-                               int iter = 0;
-                               
-                               int numOTUsOnCPU = numOTUs / ncpus;
-                               int numSeqsOnCPU = numSeqs / ncpus;
-                               m->mothurOut("\nDenoising flowgrams...\n");
-                               m->mothurOut("iter\tmaxDelta\tnLL\t\tcycletime\n");
-                               
-                               while((maxIters == 0 && maxDelta > minDelta) || iter < MIN_ITER || (maxDelta > minDelta && iter < maxIters)){
-                                       
-                                       double cycClock = clock();
-                                       unsigned long long cycTime = time(NULL);
-                                       fill();
-                                       
-                                       if (m->control_pressed) { break; }
-
-                                       int total = singleTau.size();
-                                       for(int i=1;i<ncpus;i++){
-                                               MPI_Send(&total, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&change[0], numOTUs, MPI_SHORT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&centroids[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               
-                                               MPI_Send(&singleTau[0], total, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&seqNumber[0], total, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&seqIndex[0], total, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&nSeqsPerOTU[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&cumNumSeqs[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       calcCentroidsDriver(0, numOTUsOnCPU);
-                                       
-                                       for(int i=1;i<ncpus;i++){
-                                               int otuStart = i * numOTUs / ncpus;
-                                               int otuStop = (i + 1) * numOTUs / ncpus;
-                                               
-                                               vector<int> tempCentroids(numOTUs, 0);
-                                               vector<short> tempChange(numOTUs, 0);
-                                               
-                                               MPI_Recv(&tempCentroids[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                               MPI_Recv(&tempChange[0], numOTUs, MPI_SHORT, i, tag, MPI_COMM_WORLD, &status);
-                                               
-                                               for(int j=otuStart;j<otuStop;j++){
-                                                       centroids[j] = tempCentroids[j];
-                                                       change[j] = tempChange[j];
-                                               }
-                                       }
-                                                                       
-                                       maxDelta = getNewWeights(); if (m->control_pressed) { break; }
-                                       double nLL = getLikelihood(); if (m->control_pressed) { break; }
-                                       checkCentroids(); if (m->control_pressed) { break; }
-                                       
-                                       for(int i=1;i<ncpus;i++){
-                                               MPI_Send(&centroids[0], numOTUs, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&weight[0], numOTUs, MPI_DOUBLE, i, tag, MPI_COMM_WORLD);
-                                               MPI_Send(&change[0], numOTUs, MPI_SHORT, i, tag, MPI_COMM_WORLD);
-                                       }
-                                       
-                                       calcNewDistancesParent(0, numSeqsOnCPU);
-
-                                       total = singleTau.size();
-
-                                       for(int i=1;i<ncpus;i++){
-                                               int childTotal;
-                                               int seqStart = i * numSeqs / ncpus;
-                                               int seqStop = (i + 1) * numSeqs / ncpus;
-                                               
-                                               MPI_Recv(&childTotal, 1, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-
-                                               vector<int> childSeqIndex(childTotal, 0);
-                                               vector<double> childSingleTau(childTotal, 0);
-                                               vector<double> childDist(numSeqs * numOTUs, 0);
-                                               vector<int> otuIndex(childTotal, 0);
-                                               
-                                               MPI_Recv(&childSeqIndex[0], childTotal, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-                                               MPI_Recv(&childSingleTau[0], childTotal, MPI_DOUBLE, i, tag, MPI_COMM_WORLD, &status);
-                                               MPI_Recv(&childDist[0], numOTUs * numSeqs, MPI_DOUBLE, i, tag, MPI_COMM_WORLD, &status);
-                                               MPI_Recv(&otuIndex[0], childTotal, MPI_INT, i, tag, MPI_COMM_WORLD, &status);
-
-                                               int oldTotal = total;
-                                               total += childTotal;
-                                               singleTau.resize(total, 0);
-                                               seqIndex.resize(total, 0);
-                                               seqNumber.resize(total, 0);
-                                               
-                                               int childIndex = 0;
-                                               
-                                               for(int j=oldTotal;j<total;j++){
-                                                       int otuI = otuIndex[childIndex];
-                                                       int seqI = childSeqIndex[childIndex];
-                                                       
-                                                       singleTau[j] = childSingleTau[childIndex];
-                                                       
-                                                       aaP[otuI][nSeqsPerOTU[otuI]] = j;
-                                                       aaI[otuI][nSeqsPerOTU[otuI]] = seqI;
-                                                       nSeqsPerOTU[otuI]++;
-                                                       childIndex++;
-                                               }
-                                               
-                                               int index = seqStart * numOTUs;
-                                               for(int j=seqStart;j<seqStop;j++){
-                                                       for(int k=0;k<numOTUs;k++){
-                                                               dist[index] = childDist[index];
-                                                               index++;
-                                                       }
-                                               }                                       
-                                       }
-                                       
-                                       iter++;
-                                       
-                                       m->mothurOut(toString(iter) + '\t' + toString(maxDelta) + '\t' + toString(nLL) + '\t' + toString(time(NULL) - cycTime) + '\t' + toString((clock() - cycClock)/(double)CLOCKS_PER_SEC) + '\n');                  
-
-                                       if((maxIters == 0 && maxDelta > minDelta) || iter < MIN_ITER || (maxDelta > minDelta && iter < maxIters)){
-                                               int live = 1;
-                                               for(int i=1;i<ncpus;i++){
-                                                       MPI_Send(&live, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
-                                               }
-                                       }
-                                       else{
-                                               int live = 0;
-                                               for(int i=1;i<ncpus;i++){
-                                                       MPI_Send(&live, 1, MPI_INT, i, tag, MPI_COMM_WORLD); //send kill command
-                                               }
-                                       }
-                                       
-                               }       
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               m->mothurOut("\nFinalizing...\n");
-                               fill();
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               setOTUs();
-                               
-                               vector<int> otuCounts(numOTUs, 0);
-                               for(int i=0;i<numSeqs;i++)      {       otuCounts[otuData[i]]++;        }
-                               calcCentroidsDriver(0, numOTUs);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               writeQualities(otuCounts);      if (m->control_pressed) { break; }
-                               writeSequences(otuCounts);      if (m->control_pressed) { break; }
-                               writeNames(otuCounts);          if (m->control_pressed) { break; }
-                               writeClusters(otuCounts);       if (m->control_pressed) { break; }
-                               writeGroups();                          if (m->control_pressed) { break; }
-                               
-                                                                
-                               m->mothurOut("Total time to process " + toString(flowFileName) + ":\t" + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/(double)CLOCKS_PER_SEC) + '\n');                 
-                       }
-               }
-               else{
-                       int abort = 1;
-
-                       MPI_Recv(&abort, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                       if(abort){      return 0;       }
-
-                       int numFiles;
-                       MPI_Recv(&numFiles, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-
-                       for(int i=0;i<numFiles;i++){
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               //Now into the pyrodist part
-                               bool live = 1;
-
-                               char fileName[1024];
-                               MPI_Recv(&fileName, 1024, MPI_CHAR, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&numUniques, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&numFlowCells, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                               flowDataIntI.resize(numSeqs * numFlowCells);
-                               flowDataPrI.resize(numSeqs * numFlowCells);
-                               mapUniqueToSeq.resize(numSeqs);
-                               mapSeqToUnique.resize(numSeqs);
-                               lengths.resize(numSeqs);
-                               jointLookUp.resize(NUMBINS * NUMBINS);
-
-                               MPI_Recv(&flowDataIntI[0], numSeqs * numFlowCells, MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&flowDataPrI[0], numSeqs * numFlowCells, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&mapUniqueToSeq[0], numSeqs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&mapSeqToUnique[0], numSeqs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&lengths[0], numSeqs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&jointLookUp[0], NUMBINS * NUMBINS, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&cutoff, 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-
-                               flowFileName = string(fileName);
-                               int flowDistStart = int(sqrt(float(pid)/float(ncpus)) * numUniques);
-                               int flowDistEnd = int(sqrt(float(pid+1)/float(ncpus)) * numUniques);
-                               
-                               string distanceStringChild = flowDistMPI(flowDistStart, flowDistEnd);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               int done = 1;
-                               MPI_Send(&done, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-
-                               //Now into the pyronoise part
-                               MPI_Recv(&numOTUs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                               singleLookUp.resize(HOMOPS * NUMBINS);
-                               uniqueFlowgrams.resize(numUniques * numFlowCells);
-                               weight.resize(numOTUs);
-                               centroids.resize(numOTUs);
-                               change.resize(numOTUs);
-                               dist.assign(numOTUs * numSeqs, 0);
-                               nSeqsPerOTU.resize(numOTUs);
-                               cumNumSeqs.resize(numOTUs);
-
-                               MPI_Recv(&singleLookUp[0], singleLookUp.size(), MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&uniqueFlowgrams[0], uniqueFlowgrams.size(), MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
-                               MPI_Recv(&sigma, 1, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                               
-                               int startOTU = pid * numOTUs / ncpus;
-                               int endOTU = (pid + 1) * numOTUs / ncpus;
-
-                               int startSeq = pid * numSeqs / ncpus;
-                               int endSeq = (pid + 1) * numSeqs /ncpus;
-                               
-                               int total;
-
-                               while(live){
-                                       
-                                       if (m->control_pressed) { break; }
-                                       
-                                       MPI_Recv(&total, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       singleTau.assign(total, 0.0000);
-                                       seqNumber.assign(total, 0);
-                                       seqIndex.assign(total, 0);
-
-                                       MPI_Recv(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&centroids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&singleTau[0], total, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&seqNumber[0], total, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&seqIndex[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&nSeqsPerOTU[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&cumNumSeqs[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-
-                                       calcCentroidsDriver(startOTU, endOTU);
-
-                                       MPI_Send(&centroids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD);
-
-                                       MPI_Recv(&centroids[0], numOTUs, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&weight[0], numOTUs, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD, &status);
-                                       MPI_Recv(&change[0], numOTUs, MPI_SHORT, 0, tag, MPI_COMM_WORLD, &status);
-
-                                       vector<int> otuIndex(total, 0);
-                                       calcNewDistancesChildMPI(startSeq, endSeq, otuIndex);
-                                       total = otuIndex.size();
-                                       
-                                       MPI_Send(&total, 1, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&seqIndex[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&singleTau[0], total, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&dist[0], numOTUs * numSeqs, MPI_DOUBLE, 0, tag, MPI_COMM_WORLD);
-                                       MPI_Send(&otuIndex[0], total, MPI_INT, 0, tag, MPI_COMM_WORLD);
-                               
-                                       MPI_Recv(&live, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
-                               }
-                       }
-               }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-               
-               MPI_Barrier(MPI_COMM_WORLD);
-
-               
-               if(compositeFASTAFileName != ""){
-                       outputNames.push_back(compositeFASTAFileName);
-                       outputNames.push_back(compositeNamesFileName);
-               }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-string ShhherCommand::createNamesFile(){
-       try{
-               
-               vector<string> duplicateNames(numUniques, "");
-               for(int i=0;i<numSeqs;i++){
-                       duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
-               }
-               
-               string nameFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.names";
-               
-               ofstream nameFile;
-               m->openOutputFile(nameFileName, nameFile);
-               
-               for(int i=0;i<numUniques;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-            //                 nameFile << seqNameVector[mapUniqueToSeq[i]] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
-                       nameFile << mapUniqueToSeq[i] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
-               }
-               
-               nameFile.close();
-               return  nameFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "createNamesFile");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-string ShhherCommand::flowDistMPI(int startSeq, int stopSeq){
-       try{            
-               ostringstream outStream;
-               outStream.setf(ios::fixed, ios::floatfield);
-               outStream.setf(ios::dec, ios::basefield);
-               outStream.setf(ios::showpoint);
-               outStream.precision(6);
-               
-               int begTime = time(NULL);
-               double begClock = clock();
-               
-               for(int i=startSeq;i<stopSeq;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       for(int j=0;j<i;j++){
-                               float flowDistance = calcPairwiseDist(mapUniqueToSeq[i], mapUniqueToSeq[j]);
-                               
-                               if(flowDistance < 1e-6){
-                                       outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << 0.000000 << endl;
-                               }
-                               else if(flowDistance <= cutoff){
-                                       outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << flowDistance << endl;
-                               }
-                       }
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + '\t' + toString(time(NULL) - begTime) + '\t' + toString((clock()-begClock)/CLOCKS_PER_SEC) + '\n');
-                       }
-               }
-               
-               string fDistFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.dist";
-               if(pid != 0){   fDistFileName += ".temp." + toString(pid);      }
-               
-               if (m->control_pressed) { return fDistFileName; }
-               
-               m->mothurOut(toString(stopSeq) + '\t' + toString(time(NULL) - begTime) + '\t' + toString((clock()-begClock)/CLOCKS_PER_SEC) + '\n');
-
-               ofstream distFile(fDistFileName.c_str());
-               distFile << outStream.str();            
-               distFile.close();
-               
-               return fDistFileName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "flowDistMPI");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void ShhherCommand::getOTUData(string listFileName){
-    try {
-        
-        ifstream listFile;
-        m->openInputFile(listFileName, listFile);
-        string label;
-        
-        listFile >> label >> numOTUs;
-        
-        otuData.assign(numSeqs, 0);
-        cumNumSeqs.assign(numOTUs, 0);
-        nSeqsPerOTU.assign(numOTUs, 0);
-        aaP.clear();aaP.resize(numOTUs);
-        
-        seqNumber.clear();
-        aaI.clear();
-        seqIndex.clear();
-        
-        string singleOTU = "";
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            listFile >> singleOTU;
-            
-            istringstream otuString(singleOTU);
-            
-            while(otuString){
-                
-                string seqName = "";
-                
-                for(int j=0;j<singleOTU.length();j++){
-                    char letter = otuString.get();
-                    
-                    if(letter != ','){
-                        seqName += letter;
-                    }
-                    else{
-                        map<string,int>::iterator nmIt = nameMap.find(seqName);
-                        int index = nmIt->second;
-                        
-                        nameMap.erase(nmIt);
-                        
-                        otuData[index] = i;
-                        nSeqsPerOTU[i]++;
-                        aaP[i].push_back(index);
-                        seqName = "";
-                    }
-                }
-                
-                map<string,int>::iterator nmIt = nameMap.find(seqName);
-                
-                int index = nmIt->second;
-                nameMap.erase(nmIt);
-                
-                otuData[index] = i;
-                nSeqsPerOTU[i]++;
-                aaP[i].push_back(index);       
-                
-                otuString.get();
-            }
-            
-            sort(aaP[i].begin(), aaP[i].end());
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                seqNumber.push_back(aaP[i][j]);
-            }
-            for(int j=nSeqsPerOTU[i];j<numSeqs;j++){
-                aaP[i].push_back(0);
-            }
-            
-            
-        }
-        
-        for(int i=1;i<numOTUs;i++){
-            cumNumSeqs[i] = cumNumSeqs[i-1] + nSeqsPerOTU[i-1];
-        }
-        aaI = aaP;
-        seqIndex = seqNumber;
-        
-        listFile.close();      
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getOTUData");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::initPyroCluster(){                          
-    try{
-        if (numOTUs < processors) { processors = 1; }
-        
-        dist.assign(numSeqs * numOTUs, 0);
-        change.assign(numOTUs, 1);
-        centroids.assign(numOTUs, -1);
-        weight.assign(numOTUs, 0);
-        singleTau.assign(numSeqs, 1.0);
-        
-        nSeqsBreaks.assign(processors+1, 0);
-        nOTUsBreaks.assign(processors+1, 0);
-        
-        nSeqsBreaks[0] = 0;
-        for(int i=0;i<processors;i++){
-            nSeqsBreaks[i+1] = nSeqsBreaks[i] + (int)((double) numSeqs / (double) processors);
-            nOTUsBreaks[i+1] = nOTUsBreaks[i] + (int)((double) numOTUs / (double) processors);
-        }
-        nSeqsBreaks[processors] = numSeqs;
-        nOTUsBreaks[processors] = numOTUs;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "initPyroCluster");
-        exit(1);       
-    }
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::fill(){
-    try {
-        int index = 0;
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            cumNumSeqs[i] = index;
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                seqNumber[index] = aaP[i][j];
-                seqIndex[index] = aaI[i][j];
-                
-                index++;
-            }
-        }
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "fill");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-void ShhherCommand::getFlowData(){
-    try{
-        ifstream flowFile;
-        m->openInputFile(flowFileName, flowFile);
-        
-        string seqName;
-        seqNameVector.clear();
-        lengths.clear();
-        flowDataIntI.clear();
-        nameMap.clear();
-        
-        
-        int currentNumFlowCells;
-        
-        float intensity;
-        
-        flowFile >> numFlowCells;
-        int index = 0;//pcluster
-        while(!flowFile.eof()){
-            
-            if (m->control_pressed) { break; }
-            
-            flowFile >> seqName >> currentNumFlowCells;
-            lengths.push_back(currentNumFlowCells);
-            
-            seqNameVector.push_back(seqName);
-            nameMap[seqName] = index++;//pcluster
-            
-            for(int i=0;i<numFlowCells;i++){
-                flowFile >> intensity;
-                if(intensity > 9.99)   {       intensity = 9.99;       }
-                int intI = int(100 * intensity + 0.0001);
-                flowDataIntI.push_back(intI);
-            }
-            m->gobble(flowFile);
-        }
-        flowFile.close();
-        
-        numSeqs = seqNameVector.size();                
-        
-        for(int i=0;i<numSeqs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int iNumFlowCells = i * numFlowCells;
-            for(int j=lengths[i];j<numFlowCells;j++){
-                flowDataIntI[iNumFlowCells + j] = 0;
-            }
-        }
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getFlowData");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-void ShhherCommand::calcNewDistancesChildMPI(int startSeq, int stopSeq, vector<int>& otuIndex){
-       
-       try{
-               vector<double> newTau(numOTUs,0);
-               vector<double> norms(numSeqs, 0);
-               otuIndex.clear();
-               seqIndex.clear();
-               singleTau.clear();
-               
-               for(int i=startSeq;i<stopSeq;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       double offset = 1e8;
-                       int indexOffset = i * numOTUs;
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               
-                               if(weight[j] > MIN_WEIGHT && change[j] == 1){
-                                       dist[indexOffset + j] = getDistToCentroid(centroids[j], i, lengths[i]);
-                               }
-                               if(weight[j] > MIN_WEIGHT && dist[indexOffset + j] < offset){
-                                       offset = dist[indexOffset + j];
-                               }
-                       }
-                       
-                       for(int j=0;j<numOTUs;j++){
-                               if(weight[j] > MIN_WEIGHT){
-                                       newTau[j] = exp(sigma * (-dist[indexOffset + j] + offset)) * weight[j];
-                                       norms[i] += newTau[j];
-                               }
-                               else{
-                                       newTau[j] = 0.0;
-                               }
-                       }
-                       
-                       for(int j=0;j<numOTUs;j++){
-                
-                               newTau[j] /= norms[i];
-                               
-                               if(newTau[j] > MIN_TAU){
-                                       otuIndex.push_back(j);
-                                       seqIndex.push_back(i);
-                                       singleTau.push_back(newTau[j]);
-                               }
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "calcNewDistancesChildMPI");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::calcNewDistancesParent(int startSeq, int stopSeq){
-    
-    try{
-        
-        int total = 0;
-        vector<double> newTau(numOTUs,0);
-        vector<double> norms(numSeqs, 0);
-        nSeqsPerOTU.assign(numOTUs, 0);
-        
-        for(int i=startSeq;i<stopSeq;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int indexOffset = i * numOTUs;
-            
-            double offset = 1e8;
-            
-            for(int j=0;j<numOTUs;j++){
-                
-                if(weight[j] > MIN_WEIGHT && change[j] == 1){
-                    dist[indexOffset + j] = getDistToCentroid(centroids[j], i, lengths[i]);
-                }
-                
-                if(weight[j] > MIN_WEIGHT && dist[indexOffset + j] < offset){
-                    offset = dist[indexOffset + j];
-                }
-            }
-            
-            for(int j=0;j<numOTUs;j++){
-                if(weight[j] > MIN_WEIGHT){
-                    newTau[j] = exp(sigma * (-dist[indexOffset + j] + offset)) * weight[j];
-                    norms[i] += newTau[j];
-                }
-                else{
-                    newTau[j] = 0.0;
-                }
-            }
-            
-            for(int j=0;j<numOTUs;j++){
-                newTau[j] /= norms[i];
-            }
-            
-            for(int j=0;j<numOTUs;j++){
-                if(newTau[j] > MIN_TAU){
-                    
-                    int oldTotal = total;
-                    
-                    total++;
-                    
-                    singleTau.resize(total, 0);
-                    seqNumber.resize(total, 0);
-                    seqIndex.resize(total, 0);
-                    
-                    singleTau[oldTotal] = newTau[j];
-                    
-                    aaP[j][nSeqsPerOTU[j]] = oldTotal;
-                    aaI[j][nSeqsPerOTU[j]] = i;
-                    nSeqsPerOTU[j]++;
-                }
-            }
-            
-        }
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "calcNewDistancesParent");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::setOTUs(){
-    
-    try {
-        vector<double> bigTauMatrix(numOTUs * numSeqs, 0.0000);
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                int index = cumNumSeqs[i] + j;
-                double tauValue = singleTau[seqNumber[index]];
-                int sIndex = seqIndex[index];
-                bigTauMatrix[sIndex * numOTUs + i] = tauValue;                         
-            }
-        }
-        
-        for(int i=0;i<numSeqs;i++){
-            double maxTau = -1.0000;
-            int maxOTU = -1;
-            for(int j=0;j<numOTUs;j++){
-                if(bigTauMatrix[i * numOTUs + j] > maxTau){
-                    maxTau = bigTauMatrix[i * numOTUs + j];
-                    maxOTU = j;
-                }
-            }
-            
-            otuData[i] = maxOTU;
-        }
-        
-        nSeqsPerOTU.assign(numOTUs, 0);                
-        
-        for(int i=0;i<numSeqs;i++){
-            int index = otuData[i];
-            
-            singleTau[i] = 1.0000;
-            dist[i] = 0.0000;
-            
-            aaP[index][nSeqsPerOTU[index]] = i;
-            aaI[index][nSeqsPerOTU[index]] = i;
-            
-            nSeqsPerOTU[index]++;
-        }
-        fill();        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "setOTUs");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-void ShhherCommand::getUniques(){
-    try{
-        
-        
-        numUniques = 0;
-        uniqueFlowgrams.assign(numFlowCells * numSeqs, -1);
-        uniqueCount.assign(numSeqs, 0);                                                        //      anWeights
-        uniqueLengths.assign(numSeqs, 0);
-        mapSeqToUnique.assign(numSeqs, -1);
-        mapUniqueToSeq.assign(numSeqs, -1);
-        
-        vector<short> uniqueFlowDataIntI(numFlowCells * numSeqs, -1);
-        
-        for(int i=0;i<numSeqs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int index = 0;
-            
-            vector<short> current(numFlowCells);
-            for(int j=0;j<numFlowCells;j++){
-                current[j] = short(((flowDataIntI[i * numFlowCells + j] + 50.0)/100.0));
-            }
-            
-            for(int j=0;j<numUniques;j++){
-                int offset = j * numFlowCells;
-                bool toEnd = 1;
-                
-                int shorterLength;
-                if(lengths[i] < uniqueLengths[j])      {       shorterLength = lengths[i];                     }
-                else                                                           {       shorterLength = uniqueLengths[j];       }
-                
-                for(int k=0;k<shorterLength;k++){
-                    if(current[k] != uniqueFlowgrams[offset + k]){
-                        toEnd = 0;
-                        break;
-                    }
-                }
-                
-                if(toEnd){
-                    mapSeqToUnique[i] = j;
-                    uniqueCount[j]++;
-                    index = j;
-                    if(lengths[i] > uniqueLengths[j])  {       uniqueLengths[j] = lengths[i];  }
-                    break;
-                }
-                index++;
-            }
-            
-            if(index == numUniques){
-                uniqueLengths[numUniques] = lengths[i];
-                uniqueCount[numUniques] = 1;
-                mapSeqToUnique[i] = numUniques;//anMap
-                mapUniqueToSeq[numUniques] = i;//anF
-                
-                for(int k=0;k<numFlowCells;k++){
-                    uniqueFlowgrams[numUniques * numFlowCells + k] = current[k];
-                    uniqueFlowDataIntI[numUniques * numFlowCells + k] = flowDataIntI[i * numFlowCells + k];
-                }
-                
-                numUniques++;
-            }
-        }
-        uniqueFlowDataIntI.resize(numFlowCells * numUniques);
-        uniqueLengths.resize(numUniques);      
-        
-        flowDataPrI.resize(numSeqs * numFlowCells, 0);
-        for(int i=0;i<flowDataPrI.size();i++)  {       if (m->control_pressed) { break; } flowDataPrI[i] = getProbIntensity(flowDataIntI[i]);          }
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getUniques");
-        exit(1);
-    }
-}
-
-/**************************************************************************************************/
-
-float ShhherCommand::calcPairwiseDist(int seqA, int seqB){
-    try{
-        int minLength = lengths[mapSeqToUnique[seqA]];
-        if(lengths[seqB] < minLength){ minLength = lengths[mapSeqToUnique[seqB]];      }
-        
-        int ANumFlowCells = seqA * numFlowCells;
-        int BNumFlowCells = seqB * numFlowCells;
-        
-        float dist = 0;
-        
-        for(int i=0;i<minLength;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int flowAIntI = flowDataIntI[ANumFlowCells + i];
-            float flowAPrI = flowDataPrI[ANumFlowCells + i];
-            
-            int flowBIntI = flowDataIntI[BNumFlowCells + i];
-            float flowBPrI = flowDataPrI[BNumFlowCells + i];
-            dist += jointLookUp[flowAIntI * NUMBINS + flowBIntI] - flowAPrI - flowBPrI;
-        }
-        
-        dist /= (float) minLength;
-        return dist;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "calcPairwiseDist");
-        exit(1);
-    }
-}
-
-//**********************************************************************************************************************/
-
-string ShhherCommand::cluster(string distFileName, string namesFileName){
-    try {
-        
-        ReadMatrix* read = new ReadColumnMatrix(distFileName);         
-        read->setCutoff(cutoff);
-        
-        NameAssignment* clusterNameMap = new NameAssignment(namesFileName);
-        clusterNameMap->readMap();
-        read->read(clusterNameMap);
-        
-        ListVector* list = read->getListVector();
-        SparseMatrix* matrix = read->getMatrix();
-        
-        delete read; 
-        delete clusterNameMap; 
-        
-        RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
-        
-        Cluster* cluster = new CompleteLinkage(rabund, list, matrix, cutoff, "furthest"); 
-        string tag = cluster->getTag();
-        
-        double clusterCutoff = cutoff;
-        while (matrix->getSmallDist() <= clusterCutoff && matrix->getNNodes() > 0){
-            
-            if (m->control_pressed) { break; }
-            
-            cluster->update(clusterCutoff);
-        }
-        
-        list->setLabel(toString(cutoff));
-        
-        string listFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.list";
-        ofstream listFile;
-        m->openOutputFile(listFileName, listFile);
-        list->print(listFile);
-        listFile.close();
-        
-        delete matrix; delete cluster; delete rabund; delete list;
-        
-        return listFileName;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "cluster");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::calcCentroidsDriver(int start, int finish){                          
-    
-    //this function gets the most likely homopolymer length at a flow position for a group of sequences
-    //within an otu
-    
-    try{
-        
-        for(int i=start;i<finish;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            double count = 0;
-            int position = 0;
-            int minFlowGram = 100000000;
-            double minFlowValue = 1e8;
-            change[i] = 0; //FALSE
-            
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                count += singleTau[seqNumber[cumNumSeqs[i] + j]];
-            }
-            
-            if(nSeqsPerOTU[i] > 0 && count > MIN_COUNT){
-                vector<double> adF(nSeqsPerOTU[i]);
-                vector<int> anL(nSeqsPerOTU[i]);
-                
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    int index = cumNumSeqs[i] + j;
-                    int nI = seqIndex[index];
-                    int nIU = mapSeqToUnique[nI];
-                    
-                    int k;
-                    for(k=0;k<position;k++){
-                        if(nIU == anL[k]){
-                            break;
-                        }
-                    }
-                    if(k == position){
-                        anL[position] = nIU;
-                        adF[position] = 0.0000;
-                        position++;
-                    }                                          
-                }
-                
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    int index = cumNumSeqs[i] + j;
-                    int nI = seqIndex[index];
-                    
-                    double tauValue = singleTau[seqNumber[index]];
-                    
-                    for(int k=0;k<position;k++){
-                        double dist = getDistToCentroid(anL[k], nI, lengths[nI]);
-                        adF[k] += dist * tauValue;
-                    }
-                }
-                
-                for(int j=0;j<position;j++){
-                    if(adF[j] < minFlowValue){
-                        minFlowGram = j;
-                        minFlowValue = adF[j];
-                    }
-                }
-                
-                if(centroids[i] != anL[minFlowGram]){
-                    change[i] = 1;
-                    centroids[i] = anL[minFlowGram];
-                }
-            }
-            else if(centroids[i] != -1){
-                change[i] = 1;
-                centroids[i] = -1;                     
-            }
-        }
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "calcCentroidsDriver");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-double ShhherCommand::getDistToCentroid(int cent, int flow, int length){
-    try{
-        
-        int flowAValue = cent * numFlowCells;
-        int flowBValue = flow * numFlowCells;
-        
-        double dist = 0;
-        
-        for(int i=0;i<length;i++){
-            dist += singleLookUp[uniqueFlowgrams[flowAValue] * NUMBINS + flowDataIntI[flowBValue]];
-            flowAValue++;
-            flowBValue++;
-        }
-        
-        return dist / (double)length;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getDistToCentroid");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-double ShhherCommand::getNewWeights(){
-    try{
-        
-        double maxChange = 0;
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            double difference = weight[i];
-            weight[i] = 0;
-            
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                int index = cumNumSeqs[i] + j;
-                double tauValue = singleTau[seqNumber[index]];
-                weight[i] += tauValue;
-            }
-            
-            difference = fabs(weight[i] - difference);
-            if(difference > maxChange){        maxChange = difference; }
-        }
-        return maxChange;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getNewWeights");
-        exit(1);       
-    }          
-}
- /**************************************************************************************************/
-double ShhherCommand::getLikelihood(){
-    
-    try{
-        
-        vector<long double> P(numSeqs, 0);
-        int effNumOTUs = 0;
-        
-        for(int i=0;i<numOTUs;i++){
-            if(weight[i] > MIN_WEIGHT){
-                effNumOTUs++;
-            }
-        }
-        
-        string hold;
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            for(int j=0;j<nSeqsPerOTU[i];j++){
-                int index = cumNumSeqs[i] + j;
-                int nI = seqIndex[index];
-                double singleDist = dist[seqNumber[index]];
-                
-                P[nI] += weight[i] * exp(-singleDist * sigma);
-            }
-        }
-        double nLL = 0.00;
-        for(int i=0;i<numSeqs;i++){
-            if(P[i] == 0){     P[i] = DBL_EPSILON;     }
-            
-            nLL += -log(P[i]);
-        }
-        
-        nLL = nLL -(double)numSeqs * log(sigma);
-        
-        return nLL; 
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "getNewWeights");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::checkCentroids(){
-    try{
-        vector<int> unique(numOTUs, 1);
-        
-        for(int i=0;i<numOTUs;i++){
-            if(centroids[i] == -1 || weight[i] < MIN_WEIGHT){
-                unique[i] = -1;
-            }
-        }
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            if(unique[i] == 1){
-                for(int j=i+1;j<numOTUs;j++){
-                    if(unique[j] == 1){
-                        
-                        if(centroids[j] == centroids[i]){
-                            unique[j] = 0;
-                            centroids[j] = -1;
-                            
-                            weight[i] += weight[j];
-                            weight[j] = 0.0;
-                        }
-                    }
-                }
-            }
-        }
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "checkCentroids");
-        exit(1);       
-    }          
-}
- /**************************************************************************************************/
-
-
-void ShhherCommand::writeQualities(vector<int> otuCounts){
-    
-    try {
-        string thisOutputDir = outputDir;
-        if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.qual";
-        
-        ofstream qualityFile;
-        m->openOutputFile(qualityFileName, qualityFile);
-        
-        qualityFile.setf(ios::fixed, ios::floatfield);
-        qualityFile.setf(ios::showpoint);
-        qualityFile << setprecision(6);
-        
-        vector<vector<int> > qualities(numOTUs);
-        vector<double> pr(HOMOPS, 0);
-        
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int index = 0;
-            int base = 0;
-            
-            if(nSeqsPerOTU[i] > 0){
-                qualities[i].assign(1024, -1);
-                
-                while(index < numFlowCells){
-                    double maxPrValue = 1e8;
-                    short maxPrIndex = -1;
-                    double count = 0.0000;
-                    
-                    pr.assign(HOMOPS, 0);
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int lIndex = cumNumSeqs[i] + j;
-                        double tauValue = singleTau[seqNumber[lIndex]];
-                        int sequenceIndex = aaI[i][j];
-                        short intensity = flowDataIntI[sequenceIndex * numFlowCells + index];
-                        
-                        count += tauValue;
-                        
-                        for(int s=0;s<HOMOPS;s++){
-                            pr[s] += tauValue * singleLookUp[s * NUMBINS + intensity];
-                        }
-                    }
-                    
-                    maxPrIndex = uniqueFlowgrams[centroids[i] * numFlowCells + index];
-                    maxPrValue = pr[maxPrIndex];
-                    
-                    if(count > MIN_COUNT){
-                        double U = 0.0000;
-                        double norm = 0.0000;
-                        
-                        for(int s=0;s<HOMOPS;s++){
-                            norm += exp(-(pr[s] - maxPrValue));
-                        }
-                        
-                        for(int s=1;s<=maxPrIndex;s++){
-                            int value = 0;
-                            double temp = 0.0000;
-                            
-                            U += exp(-(pr[s-1]-maxPrValue))/norm;
-                            
-                            if(U>0.00){
-                                temp = log10(U);
-                            }
-                            else{
-                                temp = -10.1;
-                            }
-                            temp = floor(-10 * temp);
-                            value = (int)floor(temp);
-                            if(value > 100){   value = 100;    }
-                            
-                            qualities[i][base] = (int)value;
-                            base++;
-                        }
-                    }
-                    
-                    index++;
-                }
-            }
-            
-            
-            if(otuCounts[i] > 0){
-                qualityFile << '>' << seqNameVector[mapUniqueToSeq[i]] << endl;
-                
-                int j=4;       //need to get past the first four bases
-                while(qualities[i][j] != -1){
-                    qualityFile << qualities[i][j] << ' ';
-                    j++;
-                }
-                qualityFile << endl;
-            }
-        }
-        qualityFile.close();
-        outputNames.push_back(qualityFileName);
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "writeQualities");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeSequences(vector<int> otuCounts){
-    try {
-        string thisOutputDir = outputDir;
-        if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.fasta";
-        ofstream fastaFile;
-        m->openOutputFile(fastaFileName, fastaFile);
-        
-        vector<string> names(numOTUs, "");
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            int index = centroids[i];
-            
-            if(otuCounts[i] > 0){
-                fastaFile << '>' << seqNameVector[aaI[i][0]] << endl;
-                
-                string newSeq = "";
-                
-                for(int j=0;j<numFlowCells;j++){
-                    
-                    char base = flowOrder[j % 4];
-                    for(int k=0;k<uniqueFlowgrams[index * numFlowCells + j];k++){
-                        newSeq += base;
-                    }
-                }
-                
-                fastaFile << newSeq.substr(4) << endl;
-            }
-        }
-        fastaFile.close();
-        
-        outputNames.push_back(fastaFileName);
-        
-        if(compositeFASTAFileName != ""){
-            m->appendFiles(fastaFileName, compositeFASTAFileName);
-        }
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "writeSequences");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeNames(vector<int> otuCounts){
-    try {
-        string thisOutputDir = outputDir;
-        if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.names";
-        ofstream nameFile;
-        m->openOutputFile(nameFileName, nameFile);
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) { break; }
-            
-            if(otuCounts[i] > 0){
-                nameFile << seqNameVector[aaI[i][0]] << '\t' << seqNameVector[aaI[i][0]];
-                
-                for(int j=1;j<nSeqsPerOTU[i];j++){
-                    nameFile << ',' << seqNameVector[aaI[i][j]];
-                }
-                
-                nameFile << endl;
-            }
-        }
-        nameFile.close();
-        outputNames.push_back(nameFileName);
-        
-        
-        if(compositeNamesFileName != ""){
-            m->appendFiles(nameFileName, compositeNamesFileName);
-        }              
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "writeNames");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeGroups(){
-    try {
-        string thisOutputDir = outputDir;
-        if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string fileRoot = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName));
-        string groupFileName = fileRoot + "shhh.groups";
-        ofstream groupFile;
-        m->openOutputFile(groupFileName, groupFile);
-        
-        for(int i=0;i<numSeqs;i++){
-            if (m->control_pressed) { break; }
-            groupFile << seqNameVector[i] << '\t' << fileRoot << endl;
-        }
-        groupFile.close();
-        outputNames.push_back(groupFileName);
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "writeGroups");
-        exit(1);       
-    }          
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeClusters(vector<int> otuCounts){
-    try {
-        string thisOutputDir = outputDir;
-        if (outputDir == "") {  thisOutputDir += m->hasPath(flowFileName);  }
-        string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowFileName)) + "shhh.counts";
-        ofstream otuCountsFile;
-        m->openOutputFile(otuCountsFileName, otuCountsFile);
-        
-        string bases = flowOrder;
-        
-        for(int i=0;i<numOTUs;i++){
-            
-            if (m->control_pressed) {
-                break;
-            }
-            //output the translated version of the centroid sequence for the otu
-            if(otuCounts[i] > 0){
-                int index = centroids[i];
-                
-                otuCountsFile << "ideal\t";
-                for(int j=8;j<numFlowCells;j++){
-                    char base = bases[j % 4];
-                    for(int s=0;s<uniqueFlowgrams[index * numFlowCells + j];s++){
-                        otuCountsFile << base;
-                    }
-                }
-                otuCountsFile << endl;
-                
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    int sequence = aaI[i][j];
-                    otuCountsFile << seqNameVector[sequence] << '\t';
-                    
-                    string newSeq = "";
-                    
-                    for(int k=0;k<lengths[sequence];k++){
-                        char base = bases[k % 4];
-                        int freq = int(0.01 * (double)flowDataIntI[sequence * numFlowCells + k] + 0.5);
-                        
-                        for(int s=0;s<freq;s++){
-                            newSeq += base;
-                            //otuCountsFile << base;
-                        }
-                    }
-                    otuCountsFile << newSeq.substr(4) << endl;
-                }
-                otuCountsFile << endl;
-            }
-        }
-        otuCountsFile.close();
-        outputNames.push_back(otuCountsFileName);
-        
-    }
-    catch(exception& e) {
-        m->errorOut(e, "ShhherCommand", "writeClusters");
-        exit(1);       
-    }          
-}
-
-#else
-//**********************************************************************************************************************
-
-int ShhherCommand::execute(){
-       try {
-               if (abort == true) { return 0; }
-               
-               getSingleLookUp();      if (m->control_pressed) { return 0; }
-               getJointLookUp();       if (m->control_pressed) { return 0; }
-               
-        int numFiles = flowFileVector.size();
-               
-        if (numFiles < processors) { processors = numFiles; }
-        
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-        if (processors == 1) { driver(flowFileVector, compositeFASTAFileName, compositeNamesFileName, 0, flowFileVector.size()); }
-        else { createProcesses(flowFileVector); } //each processor processes one file
-#else
-        driver(flowFileVector, compositeFASTAFileName, compositeNamesFileName, 0, flowFileVector.size());
-#endif
-        
-               if(compositeFASTAFileName != ""){
-                       outputNames.push_back(compositeFASTAFileName);
-                       outputNames.push_back(compositeNamesFileName);
-               }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "execute");
-               exit(1);
-       }
-}
-#endif
-/**************************************************************************************************/
-
-int ShhherCommand::createProcesses(vector<string> filenames){
-    try {
-        vector<int> processIDS;
-               int process = 1;
-               int num = 0;
-               
-               //sanity check
-               if (filenames.size() < processors) { processors = filenames.size(); }
-               
-               //divide the groups between the processors
-               vector<linePair> lines;
-               int numFilesPerProcessor = filenames.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numFilesPerProcessor;
-                       int endIndex = (i+1) * numFilesPerProcessor;
-                       if(i == (processors - 1)){      endIndex = filenames.size();    }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
-               
-        #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               num = driver(filenames, compositeFASTAFileName + toString(getpid()) + ".temp", compositeNamesFileName  + toString(getpid()) + ".temp", lines[process].start, lines[process].end);
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               driver(filenames, compositeFASTAFileName, compositeNamesFileName, lines[0].start, lines[0].end);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-        
-        #else
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-        
-        /////////////////////// NOT WORKING, ACCESS VIOLATION ON READ OF FLOWGRAMS IN THREAD /////////////////
-        
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the shhhFlowsData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<shhhFlowsData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; }
-                       
-            shhhFlowsData* tempFlow = new shhhFlowsData(filenames, (compositeFASTAFileName + extension), (compositeNamesFileName + extension), outputDir, flowOrder, jointLookUp, singleLookUp, m, lines[i].start, lines[i].end, cutoff, sigma, minDelta, maxIters, i);
-                       pDataArray.push_back(tempFlow);
-                       processIDS.push_back(i);
-            
-                       hThreadArray[i] = CreateThread(NULL, 0, ShhhFlowsThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-               //using the main process as a worker saves time and memory
-               //do my part
-               driver(filenames, compositeFASTAFileName, compositeNamesFileName, lines[processors-1].start, lines[processors-1].end);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       for(int j=0; j < pDataArray[i]->outputNames.size(); j++){ outputNames.push_back(pDataArray[i]->outputNames[j]); }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-        #endif
-        
-        for (int i=0;i<processIDS.size();i++) { 
-            if (compositeFASTAFileName != "") {
-                m->appendFiles((compositeFASTAFileName + toString(processIDS[i]) + ".temp"), compositeFASTAFileName);
-                m->appendFiles((compositeNamesFileName + toString(processIDS[i]) + ".temp"), compositeNamesFileName);
-                m->mothurRemove((compositeFASTAFileName + toString(processIDS[i]) + ".temp"));
-                m->mothurRemove((compositeNamesFileName + toString(processIDS[i]) + ".temp"));
-            }
-        }
-        
-        return 0;
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ShhherCommand::driver(vector<string> filenames, string thisCompositeFASTAFileName, string thisCompositeNamesFileName, int start, int end){
-    try {
-        
-        for(int i=start;i<end;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       string flowFileName = filenames[i];
-            
-                       m->mothurOut("\n>>>>>\tProcessing " + flowFileName + " (file " + toString(i+1) + " of " + toString(filenames.size()) + ")\t<<<<<\n");
-                       m->mothurOut("Reading flowgrams...\n");
-                       
-            vector<string> seqNameVector;
-            vector<int> lengths;
-            vector<short> flowDataIntI;
-            vector<double> flowDataPrI;
-            map<string, int> nameMap;
-            vector<short> uniqueFlowgrams;
-            vector<int> uniqueCount;
-            vector<int> mapSeqToUnique;
-            vector<int> mapUniqueToSeq;
-            vector<int> uniqueLengths;
-            int numFlowCells;
-            
-            int numSeqs = getFlowData(flowFileName, seqNameVector, lengths, flowDataIntI, nameMap, numFlowCells);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       m->mothurOut("Identifying unique flowgrams...\n");
-                       int numUniques = getUniques(numSeqs, numFlowCells, uniqueFlowgrams, uniqueCount, uniqueLengths, mapSeqToUnique, mapUniqueToSeq, lengths, flowDataPrI, flowDataIntI);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       m->mothurOut("Calculating distances between flowgrams...\n");
-            string distFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.dist";
-            unsigned long long begTime = time(NULL);
-            double begClock = clock();
-        
-            flowDistParentFork(numFlowCells, distFileName, numUniques, mapUniqueToSeq, mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);    
-            
-            m->mothurOutEndLine();
-            m->mothurOut("Total time: " + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/CLOCKS_PER_SEC) + '\n');
-
-            
-                       string namesFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.names";
-                       createNamesFile(numSeqs, numUniques, namesFileName, seqNameVector, mapSeqToUnique, mapUniqueToSeq);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       m->mothurOut("\nClustering flowgrams...\n");
-            string listFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.list";
-                       cluster(listFileName, distFileName, namesFileName);
-                       
-                       if (m->control_pressed) { break; }
-            
-            vector<int> otuData;
-            vector<int> cumNumSeqs;
-            vector<int> nSeqsPerOTU;
-            vector<vector<int> > aaP;  //tMaster->aanP:        each row is a different otu / each col contains the sequence indices
-            vector<vector<int> > aaI;  //tMaster->aanI:        that are in each otu - can't differentiate between aaP and aaI 
-            vector<int> seqNumber;             //tMaster->anP:         the sequence id number sorted by OTU
-            vector<int> seqIndex;              //tMaster->anI;         the index that corresponds to seqNumber
-
-                       
-                       int numOTUs = getOTUData(numSeqs, listFileName, otuData, cumNumSeqs, nSeqsPerOTU, aaP, aaI, seqNumber, seqIndex, nameMap);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       m->mothurRemove(distFileName);
-                       m->mothurRemove(namesFileName);
-                       m->mothurRemove(listFileName);
-                       
-            vector<double> dist;               //adDist - distance of sequences to centroids
-            vector<short> change;              //did the centroid sequence change? 0 = no; 1 = yes
-            vector<int> centroids;             //the representative flowgram for each cluster m
-            vector<double> weight;
-            vector<double> singleTau;  //tMaster->adTau:       1-D Tau vector (1xnumSeqs)
-            vector<int> nSeqsBreaks;
-            vector<int> nOTUsBreaks;
-            
-                       dist.assign(numSeqs * numOTUs, 0);
-            change.assign(numOTUs, 1);
-            centroids.assign(numOTUs, -1);
-            weight.assign(numOTUs, 0);
-            singleTau.assign(numSeqs, 1.0);
-            
-            nSeqsBreaks.assign(2, 0);
-            nOTUsBreaks.assign(2, 0);
-            
-            nSeqsBreaks[0] = 0;
-            nSeqsBreaks[1] = numSeqs;
-            nOTUsBreaks[1] = numOTUs;
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       double maxDelta = 0;
-                       int iter = 0;
-                       
-                       begClock = clock();
-                       begTime = time(NULL);
-            
-                       m->mothurOut("\nDenoising flowgrams...\n");
-                       m->mothurOut("iter\tmaxDelta\tnLL\t\tcycletime\n");
-                       
-                       while((maxIters == 0 && maxDelta > minDelta) || iter < MIN_ITER || (maxDelta > minDelta && iter < maxIters)){
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               double cycClock = clock();
-                               unsigned long long cycTime = time(NULL);
-                               fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-                               
-                               if (m->control_pressed) { break; }
-                
-                               calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber);
-                               
-                               if (m->control_pressed) { break; }
-                
-                               maxDelta = getNewWeights(numOTUs, cumNumSeqs, nSeqsPerOTU, singleTau, seqNumber, weight);  
-                
-                if (m->control_pressed) { break; }
-                
-                               double nLL = getLikelihood(numSeqs, numOTUs, nSeqsPerOTU, seqNumber, cumNumSeqs, seqIndex, dist, weight); 
-                
-                if (m->control_pressed) { break; }
-                
-                               checkCentroids(numOTUs, centroids, weight);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               calcNewDistances(numSeqs, numOTUs, nSeqsPerOTU,  dist, weight, change, centroids, aaP, singleTau, aaI, seqNumber, seqIndex, uniqueFlowgrams, flowDataIntI, numFlowCells, lengths);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               iter++;
-                               
-                               m->mothurOut(toString(iter) + '\t' + toString(maxDelta) + '\t' + toString(nLL) + '\t' + toString(time(NULL) - cycTime) + '\t' + toString((clock() - cycClock)/(double)CLOCKS_PER_SEC) + '\n');
-                
-                       }       
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       m->mothurOut("\nFinalizing...\n");
-                       fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       setOTUs(numOTUs, numSeqs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, otuData, singleTau, dist, aaP, aaI);
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       vector<int> otuCounts(numOTUs, 0);
-                       for(int i=0;i<numSeqs;i++)      {       otuCounts[otuData[i]]++;        }
-                       
-                       calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber); 
-            
-            if (m->control_pressed) { break; }
-            
-                       writeQualities(numOTUs, numFlowCells, flowFileName, otuCounts, nSeqsPerOTU, seqNumber, singleTau, flowDataIntI, uniqueFlowgrams, cumNumSeqs, mapUniqueToSeq, seqNameVector, centroids, aaI); if (m->control_pressed) { break; }
-                       writeSequences(thisCompositeFASTAFileName, numOTUs, numFlowCells, flowFileName, otuCounts, uniqueFlowgrams, seqNameVector, aaI, centroids);if (m->control_pressed) { break; }
-                       writeNames(thisCompositeNamesFileName, numOTUs, flowFileName, otuCounts, seqNameVector, aaI, nSeqsPerOTU);                              if (m->control_pressed) { break; }
-                       writeClusters(flowFileName, numOTUs, numFlowCells,otuCounts, centroids, uniqueFlowgrams, seqNameVector, aaI, nSeqsPerOTU, lengths, flowDataIntI);                       if (m->control_pressed) { break; }
-                       writeGroups(flowFileName, numSeqs, seqNameVector);                                              if (m->control_pressed) { break; }
-                       
-                       m->mothurOut("Total time to process " + flowFileName + ":\t" + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/(double)CLOCKS_PER_SEC) + '\n');
-               }
-               
-        if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-        
-        return 0;
-        
-    }catch(exception& e) {
-            m->errorOut(e, "ShhherCommand", "driver");
-            exit(1);
-    }
-}
-
-/**************************************************************************************************/
-int ShhherCommand::getFlowData(string filename, vector<string>& thisSeqNameVector, vector<int>& thisLengths, vector<short>& thisFlowDataIntI, map<string, int>& thisNameMap, int& numFlowCells){
-       try{
-       
-               ifstream flowFile;
-       
-               m->openInputFile(filename, flowFile);
-               
-               string seqName;
-               int currentNumFlowCells;
-               float intensity;
-        thisSeqNameVector.clear();
-               thisLengths.clear();
-               thisFlowDataIntI.clear();
-               thisNameMap.clear();
-               
-               flowFile >> numFlowCells;
-               int index = 0;//pcluster
-               while(!flowFile.eof()){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       flowFile >> seqName >> currentNumFlowCells;
-                       thisLengths.push_back(currentNumFlowCells);
-           
-                       thisSeqNameVector.push_back(seqName);
-                       thisNameMap[seqName] = index++;//pcluster
-
-                       for(int i=0;i<numFlowCells;i++){
-                               flowFile >> intensity;
-                               if(intensity > 9.99)    {       intensity = 9.99;       }
-                               int intI = int(100 * intensity + 0.0001);
-                               thisFlowDataIntI.push_back(intI);
-                       }
-                       m->gobble(flowFile);
-               }
-               flowFile.close();
-               
-               int numSeqs = thisSeqNameVector.size();         
-               
-               for(int i=0;i<numSeqs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int iNumFlowCells = i * numFlowCells;
-                       for(int j=thisLengths[i];j<numFlowCells;j++){
-                               thisFlowDataIntI[iNumFlowCells + j] = 0;
-                       }
-               }
-        
-        return numSeqs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getFlowData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int ShhherCommand::flowDistParentFork(int numFlowCells, string distFileName, int stopSeq, vector<int>& mapUniqueToSeq, vector<int>& mapSeqToUnique, vector<int>& lengths, vector<double>& flowDataPrI, vector<short>& flowDataIntI){
-       try{            
-        
-               ostringstream outStream;
-               outStream.setf(ios::fixed, ios::floatfield);
-               outStream.setf(ios::dec, ios::basefield);
-               outStream.setf(ios::showpoint);
-               outStream.precision(6);
-               
-               int begTime = time(NULL);
-               double begClock = clock();
-        
-               for(int i=0;i<stopSeq;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       for(int j=0;j<i;j++){
-                               float flowDistance = calcPairwiseDist(numFlowCells, mapUniqueToSeq[i], mapUniqueToSeq[j], mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);
-                
-                               if(flowDistance < 1e-6){
-                                       outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << 0.000000 << endl;
-                               }
-                               else if(flowDistance <= cutoff){
-                                       outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << flowDistance << endl;
-                               }
-                       }
-                       if(i % 100 == 0){
-                               m->mothurOut(toString(i) + "\t" + toString(time(NULL) - begTime));
-                               m->mothurOut("\t" + toString((clock()-begClock)/CLOCKS_PER_SEC));
-                               m->mothurOutEndLine();
-                       }
-               }
-               
-               ofstream distFile(distFileName.c_str());
-               distFile << outStream.str();            
-               distFile.close();
-               
-               if (m->control_pressed) {}
-               else {
-                       m->mothurOut(toString(stopSeq-1) + "\t" + toString(time(NULL) - begTime));
-                       m->mothurOut("\t" + toString((clock()-begClock)/CLOCKS_PER_SEC));
-                       m->mothurOutEndLine();
-               }
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "flowDistParentFork");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-float ShhherCommand::calcPairwiseDist(int numFlowCells, int seqA, int seqB, vector<int>& mapSeqToUnique, vector<int>& lengths, vector<double>& flowDataPrI, vector<short>& flowDataIntI){
-       try{
-               int minLength = lengths[mapSeqToUnique[seqA]];
-               if(lengths[seqB] < minLength){  minLength = lengths[mapSeqToUnique[seqB]];      }
-               
-               int ANumFlowCells = seqA * numFlowCells;
-               int BNumFlowCells = seqB * numFlowCells;
-               
-               float dist = 0;
-               
-               for(int i=0;i<minLength;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int flowAIntI = flowDataIntI[ANumFlowCells + i];
-                       float flowAPrI = flowDataPrI[ANumFlowCells + i];
-                       
-                       int flowBIntI = flowDataIntI[BNumFlowCells + i];
-                       float flowBPrI = flowDataPrI[BNumFlowCells + i];
-                       dist += jointLookUp[flowAIntI * NUMBINS + flowBIntI] - flowAPrI - flowBPrI;
-               }
-               
-               dist /= (float) minLength;
-               return dist;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "calcPairwiseDist");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int ShhherCommand::getUniques(int numSeqs, int numFlowCells, vector<short>& uniqueFlowgrams, vector<int>& uniqueCount, vector<int>& uniqueLengths, vector<int>& mapSeqToUnique, vector<int>& mapUniqueToSeq, vector<int>& lengths, vector<double>& flowDataPrI, vector<short>& flowDataIntI){
-       try{
-               int numUniques = 0;
-               uniqueFlowgrams.assign(numFlowCells * numSeqs, -1);
-               uniqueCount.assign(numSeqs, 0);                                                 //      anWeights
-               uniqueLengths.assign(numSeqs, 0);
-               mapSeqToUnique.assign(numSeqs, -1);
-               mapUniqueToSeq.assign(numSeqs, -1);
-               
-               vector<short> uniqueFlowDataIntI(numFlowCells * numSeqs, -1);
-               
-               for(int i=0;i<numSeqs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int index = 0;
-                       
-                       vector<short> current(numFlowCells);
-                       for(int j=0;j<numFlowCells;j++){
-                               current[j] = short(((flowDataIntI[i * numFlowCells + j] + 50.0)/100.0));
-                       }
-            
-                       for(int j=0;j<numUniques;j++){
-                               int offset = j * numFlowCells;
-                               bool toEnd = 1;
-                               
-                               int shorterLength;
-                               if(lengths[i] < uniqueLengths[j])       {       shorterLength = lengths[i];                     }
-                               else                                                            {       shorterLength = uniqueLengths[j];       }
-                
-                               for(int k=0;k<shorterLength;k++){
-                                       if(current[k] != uniqueFlowgrams[offset + k]){
-                                               toEnd = 0;
-                                               break;
-                                       }
-                               }
-                               
-                               if(toEnd){
-                                       mapSeqToUnique[i] = j;
-                                       uniqueCount[j]++;
-                                       index = j;
-                                       if(lengths[i] > uniqueLengths[j])       {       uniqueLengths[j] = lengths[i];  }
-                                       break;
-                               }
-                               index++;
-                       }
-                       
-                       if(index == numUniques){
-                               uniqueLengths[numUniques] = lengths[i];
-                               uniqueCount[numUniques] = 1;
-                               mapSeqToUnique[i] = numUniques;//anMap
-                               mapUniqueToSeq[numUniques] = i;//anF
-                               
-                               for(int k=0;k<numFlowCells;k++){
-                                       uniqueFlowgrams[numUniques * numFlowCells + k] = current[k];
-                                       uniqueFlowDataIntI[numUniques * numFlowCells + k] = flowDataIntI[i * numFlowCells + k];
-                               }
-                               
-                               numUniques++;
-                       }
-               }
-               uniqueFlowDataIntI.resize(numFlowCells * numUniques);
-               uniqueLengths.resize(numUniques);       
-               
-               flowDataPrI.resize(numSeqs * numFlowCells, 0);
-               for(int i=0;i<flowDataPrI.size();i++)   {       if (m->control_pressed) { break; } flowDataPrI[i] = getProbIntensity(flowDataIntI[i]);          }
-        
-        return numUniques;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getUniques");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int ShhherCommand::createNamesFile(int numSeqs, int numUniques, string filename, vector<string>& seqNameVector, vector<int>& mapSeqToUnique, vector<int>& mapUniqueToSeq){
-       try{
-               
-               vector<string> duplicateNames(numUniques, "");
-               for(int i=0;i<numSeqs;i++){
-                       duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
-               }
-               
-               ofstream nameFile;
-               m->openOutputFile(filename, nameFile);
-               
-               for(int i=0;i<numUniques;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-            //                 nameFile << seqNameVector[mapUniqueToSeq[i]] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
-                       nameFile << mapUniqueToSeq[i] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
-               }
-               
-               nameFile.close();
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "createNamesFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int ShhherCommand::cluster(string filename, string distFileName, string namesFileName){
-       try {
-               
-               ReadMatrix* read = new ReadColumnMatrix(distFileName);  
-               read->setCutoff(cutoff);
-               
-               NameAssignment* clusterNameMap = new NameAssignment(namesFileName);
-               clusterNameMap->readMap();
-               read->read(clusterNameMap);
-               
-               ListVector* list = read->getListVector();
-               SparseMatrix* matrix = read->getMatrix();
-               
-               delete read; 
-               delete clusterNameMap; 
-        
-               RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
-               
-               Cluster* cluster = new CompleteLinkage(rabund, list, matrix, cutoff, "furthest"); 
-               string tag = cluster->getTag();
-               
-               double clusterCutoff = cutoff;
-               while (matrix->getSmallDist() <= clusterCutoff && matrix->getNNodes() > 0){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       cluster->update(clusterCutoff);
-               }
-               
-               list->setLabel(toString(cutoff));
-               
-               ofstream listFile;
-               m->openOutputFile(filename, listFile);
-               list->print(listFile);
-               listFile.close();
-               
-               delete matrix;  delete cluster; delete rabund; delete list;
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "cluster");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-int ShhherCommand::getOTUData(int numSeqs, string fileName,  vector<int>& otuData,
-                               vector<int>& cumNumSeqs,
-                               vector<int>& nSeqsPerOTU,
-                               vector<vector<int> >& aaP,      //tMaster->aanP:        each row is a different otu / each col contains the sequence indices
-                               vector<vector<int> >& aaI,      //tMaster->aanI:        that are in each otu - can't differentiate between aaP and aaI 
-                               vector<int>& seqNumber,         //tMaster->anP:         the sequence id number sorted by OTU
-                               vector<int>& seqIndex,
-                               map<string, int>& nameMap){
-       try {
-        
-               ifstream listFile;
-               m->openInputFile(fileName, listFile);
-               string label;
-        int numOTUs;
-               
-               listFile >> label >> numOTUs;
-        
-               otuData.assign(numSeqs, 0);
-               cumNumSeqs.assign(numOTUs, 0);
-               nSeqsPerOTU.assign(numOTUs, 0);
-               aaP.clear();aaP.resize(numOTUs);
-               
-               seqNumber.clear();
-               aaI.clear();
-               seqIndex.clear();
-               
-               string singleOTU = "";
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-            
-                       listFile >> singleOTU;
-                       
-                       istringstream otuString(singleOTU);
-            
-                       while(otuString){
-                               
-                               string seqName = "";
-                               
-                               for(int j=0;j<singleOTU.length();j++){
-                                       char letter = otuString.get();
-                                       
-                                       if(letter != ','){
-                                               seqName += letter;
-                                       }
-                                       else{
-                                               map<string,int>::iterator nmIt = nameMap.find(seqName);
-                                               int index = nmIt->second;
-                                               
-                                               nameMap.erase(nmIt);
-                                               
-                                               otuData[index] = i;
-                                               nSeqsPerOTU[i]++;
-                                               aaP[i].push_back(index);
-                                               seqName = "";
-                                       }
-                               }
-                               
-                               map<string,int>::iterator nmIt = nameMap.find(seqName);
-                
-                               int index = nmIt->second;
-                               nameMap.erase(nmIt);
-                
-                               otuData[index] = i;
-                               nSeqsPerOTU[i]++;
-                               aaP[i].push_back(index);        
-                               
-                               otuString.get();
-                       }
-                       
-                       sort(aaP[i].begin(), aaP[i].end());
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               seqNumber.push_back(aaP[i][j]);
-                       }
-                       for(int j=nSeqsPerOTU[i];j<numSeqs;j++){
-                               aaP[i].push_back(0);
-                       }
-                       
-                       
-               }
-               
-               for(int i=1;i<numOTUs;i++){
-                       cumNumSeqs[i] = cumNumSeqs[i-1] + nSeqsPerOTU[i-1];
-               }
-               aaI = aaP;
-               seqIndex = seqNumber;
-               
-               listFile.close();       
-        
-        return numOTUs;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getOTUData");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-int ShhherCommand::calcCentroidsDriver(int numOTUs, 
-                                          vector<int>& cumNumSeqs,
-                                          vector<int>& nSeqsPerOTU,
-                                          vector<int>& seqIndex,
-                                          vector<short>& change,               //did the centroid sequence change? 0 = no; 1 = yes
-                                          vector<int>& centroids,              //the representative flowgram for each cluster m
-                                          vector<double>& singleTau,   //tMaster->adTau:       1-D Tau vector (1xnumSeqs)
-                                          vector<int>& mapSeqToUnique,
-                                          vector<short>& uniqueFlowgrams,
-                                          vector<short>& flowDataIntI,
-                                          vector<int>& lengths,
-                                          int numFlowCells,
-                                          vector<int>& seqNumber){                          
-       
-       //this function gets the most likely homopolymer length at a flow position for a group of sequences
-       //within an otu
-       
-       try{
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       double count = 0;
-                       int position = 0;
-                       int minFlowGram = 100000000;
-                       double minFlowValue = 1e8;
-                       change[i] = 0; //FALSE
-                       
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               count += singleTau[seqNumber[cumNumSeqs[i] + j]];
-                       }
-            
-                       if(nSeqsPerOTU[i] > 0 && count > MIN_COUNT){
-                               vector<double> adF(nSeqsPerOTU[i]);
-                               vector<int> anL(nSeqsPerOTU[i]);
-                               
-                               for(int j=0;j<nSeqsPerOTU[i];j++){
-                                       int index = cumNumSeqs[i] + j;
-                                       int nI = seqIndex[index];
-                                       int nIU = mapSeqToUnique[nI];
-                                       
-                                       int k;
-                                       for(k=0;k<position;k++){
-                                               if(nIU == anL[k]){
-                                                       break;
-                                               }
-                                       }
-                                       if(k == position){
-                                               anL[position] = nIU;
-                                               adF[position] = 0.0000;
-                                               position++;
-                                       }                                               
-                               }
-                               
-                               for(int j=0;j<nSeqsPerOTU[i];j++){
-                                       int index = cumNumSeqs[i] + j;
-                                       int nI = seqIndex[index];
-                                       
-                                       double tauValue = singleTau[seqNumber[index]];
-                                       
-                                       for(int k=0;k<position;k++){
-                                               double dist = getDistToCentroid(anL[k], nI, lengths[nI], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                                               adF[k] += dist * tauValue;
-                                       }
-                               }
-                               
-                               for(int j=0;j<position;j++){
-                                       if(adF[j] < minFlowValue){
-                                               minFlowGram = j;
-                                               minFlowValue = adF[j];
-                                       }
-                               }
-                               
-                               if(centroids[i] != anL[minFlowGram]){
-                                       change[i] = 1;
-                                       centroids[i] = anL[minFlowGram];
-                               }
-                       }
-                       else if(centroids[i] != -1){
-                               change[i] = 1;
-                               centroids[i] = -1;                      
-                       }
-               }
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "calcCentroidsDriver");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-double ShhherCommand::getDistToCentroid(int cent, int flow, int length, vector<short>& uniqueFlowgrams,
-                                        vector<short>& flowDataIntI, int numFlowCells){
-       try{
-               
-               int flowAValue = cent * numFlowCells;
-               int flowBValue = flow * numFlowCells;
-               
-               double dist = 0;
-        
-               for(int i=0;i<length;i++){
-                       dist += singleLookUp[uniqueFlowgrams[flowAValue] * NUMBINS + flowDataIntI[flowBValue]];
-                       flowAValue++;
-                       flowBValue++;
-               }
-               
-               return dist / (double)length;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getDistToCentroid");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-double ShhherCommand::getNewWeights(int numOTUs, vector<int>& cumNumSeqs, vector<int>& nSeqsPerOTU, vector<double>& singleTau, vector<int>& seqNumber, vector<double>& weight){
-       try{
-               
-               double maxChange = 0;
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       double difference = weight[i];
-                       weight[i] = 0;
-                       
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               int index = cumNumSeqs[i] + j;
-                               double tauValue = singleTau[seqNumber[index]];
-                               weight[i] += tauValue;
-                       }
-                       
-                       difference = fabs(weight[i] - difference);
-                       if(difference > maxChange){     maxChange = difference; }
-               }
-               return maxChange;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getNewWeights");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-double ShhherCommand::getLikelihood(int numSeqs, int numOTUs, vector<int>& nSeqsPerOTU, vector<int>& seqNumber, vector<int>& cumNumSeqs, vector<int>& seqIndex, vector<double>& dist, vector<double>& weight){
-       
-       try{
-               
-               vector<long double> P(numSeqs, 0);
-               int effNumOTUs = 0;
-               
-               for(int i=0;i<numOTUs;i++){
-                       if(weight[i] > MIN_WEIGHT){
-                               effNumOTUs++;
-                       }
-               }
-               
-               string hold;
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               int index = cumNumSeqs[i] + j;
-                               int nI = seqIndex[index];
-                               double singleDist = dist[seqNumber[index]];
-                               
-                               P[nI] += weight[i] * exp(-singleDist * sigma);
-                       }
-               }
-               double nLL = 0.00;
-               for(int i=0;i<numSeqs;i++){
-                       if(P[i] == 0){  P[i] = DBL_EPSILON;     }
-            
-                       nLL += -log(P[i]);
-               }
-               
-               nLL = nLL -(double)numSeqs * log(sigma);
-        
-               return nLL; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getNewWeights");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-int ShhherCommand::checkCentroids(int numOTUs, vector<int>& centroids, vector<double>& weight){
-       try{
-               vector<int> unique(numOTUs, 1);
-               
-               for(int i=0;i<numOTUs;i++){
-                       if(centroids[i] == -1 || weight[i] < MIN_WEIGHT){
-                               unique[i] = -1;
-                       }
-               }
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       if(unique[i] == 1){
-                               for(int j=i+1;j<numOTUs;j++){
-                                       if(unique[j] == 1){
-                                               
-                                               if(centroids[j] == centroids[i]){
-                                                       unique[j] = 0;
-                                                       centroids[j] = -1;
-                                                       
-                                                       weight[i] += weight[j];
-                                                       weight[j] = 0.0;
-                                               }
-                                       }
-                               }
-                       }
-               }
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "checkCentroids");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-void ShhherCommand::calcNewDistances(int numSeqs, int numOTUs, vector<int>& nSeqsPerOTU, vector<double>& dist, 
-                                     vector<double>& weight, vector<short>& change, vector<int>& centroids,
-                                     vector<vector<int> >& aaP,        vector<double>& singleTau, vector<vector<int> >& aaI,   
-                                     vector<int>& seqNumber, vector<int>& seqIndex,
-                                     vector<short>& uniqueFlowgrams,
-                                     vector<short>& flowDataIntI, int numFlowCells, vector<int>& lengths){
-       
-       try{
-               
-               int total = 0;
-               vector<double> newTau(numOTUs,0);
-               vector<double> norms(numSeqs, 0);
-               nSeqsPerOTU.assign(numOTUs, 0);
-        
-               for(int i=0;i<numSeqs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int indexOffset = i * numOTUs;
-            
-                       double offset = 1e8;
-                       
-                       for(int j=0;j<numOTUs;j++){
-                
-                               if(weight[j] > MIN_WEIGHT && change[j] == 1){
-                                       dist[indexOffset + j] = getDistToCentroid(centroids[j], i, lengths[i], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                               }
-                
-                               if(weight[j] > MIN_WEIGHT && dist[indexOffset + j] < offset){
-                                       offset = dist[indexOffset + j];
-                               }
-                       }
-            
-                       for(int j=0;j<numOTUs;j++){
-                               if(weight[j] > MIN_WEIGHT){
-                                       newTau[j] = exp(sigma * (-dist[indexOffset + j] + offset)) * weight[j];
-                                       norms[i] += newTau[j];
-                               }
-                               else{
-                                       newTau[j] = 0.0;
-                               }
-                       }
-            
-                       for(int j=0;j<numOTUs;j++){
-                               newTau[j] /= norms[i];
-                       }
-            
-                       for(int j=0;j<numOTUs;j++){
-                               if(newTau[j] > MIN_TAU){
-                                       
-                                       int oldTotal = total;
-                                       
-                                       total++;
-                                       
-                                       singleTau.resize(total, 0);
-                                       seqNumber.resize(total, 0);
-                                       seqIndex.resize(total, 0);
-                                       
-                                       singleTau[oldTotal] = newTau[j];
-                                       
-                                       aaP[j][nSeqsPerOTU[j]] = oldTotal;
-                                       aaI[j][nSeqsPerOTU[j]] = i;
-                                       nSeqsPerOTU[j]++;
-                               }
-                       }
-            
-               }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "calcNewDistances");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-int ShhherCommand::fill(int numOTUs, vector<int>& seqNumber, vector<int>& seqIndex, vector<int>& cumNumSeqs, vector<int>& nSeqsPerOTU, vector<vector<int> >& aaP, vector<vector<int> >& aaI){
-       try {
-               int index = 0;
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       cumNumSeqs[i] = index;
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               seqNumber[index] = aaP[i][j];
-                               seqIndex[index] = aaI[i][j];
-                               
-                               index++;
-                       }
-               }
-        
-        return 0; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "fill");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-void ShhherCommand::setOTUs(int numOTUs, int numSeqs, vector<int>& seqNumber, vector<int>& seqIndex, vector<int>& cumNumSeqs, vector<int>& nSeqsPerOTU,
-                            vector<int>& otuData, vector<double>& singleTau, vector<double>& dist, vector<vector<int> >& aaP, vector<vector<int> >& aaI){
-       
-       try {
-               vector<double> bigTauMatrix(numOTUs * numSeqs, 0.0000);
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                               int index = cumNumSeqs[i] + j;
-                               double tauValue = singleTau[seqNumber[index]];
-                               int sIndex = seqIndex[index];
-                               bigTauMatrix[sIndex * numOTUs + i] = tauValue;                          
-                       }
-               }
-               
-               for(int i=0;i<numSeqs;i++){
-                       double maxTau = -1.0000;
-                       int maxOTU = -1;
-                       for(int j=0;j<numOTUs;j++){
-                               if(bigTauMatrix[i * numOTUs + j] > maxTau){
-                                       maxTau = bigTauMatrix[i * numOTUs + j];
-                                       maxOTU = j;
-                               }
-                       }
-                       
-                       otuData[i] = maxOTU;
-               }
-               
-               nSeqsPerOTU.assign(numOTUs, 0);         
-               
-               for(int i=0;i<numSeqs;i++){
-                       int index = otuData[i];
-                       
-                       singleTau[i] = 1.0000;
-                       dist[i] = 0.0000;
-                       
-                       aaP[index][nSeqsPerOTU[index]] = i;
-                       aaI[index][nSeqsPerOTU[index]] = i;
-                       
-                       nSeqsPerOTU[index]++;
-               }
-        
-               fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);  
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "setOTUs");
-               exit(1);        
-       }               
-}
-/**************************************************************************************************/
-
-void ShhherCommand::writeQualities(int numOTUs, int numFlowCells, string filename, vector<int> otuCounts, vector<int>& nSeqsPerOTU, vector<int>& seqNumber,
-                                   vector<double>& singleTau, vector<short>& flowDataIntI, vector<short>& uniqueFlowgrams, vector<int>& cumNumSeqs,
-                                   vector<int>& mapUniqueToSeq, vector<string>& seqNameVector, vector<int>& centroids, vector<vector<int> >& aaI){
-       
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(filename);  }
-               string qualityFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.qual";
-        
-               ofstream qualityFile;
-               m->openOutputFile(qualityFileName, qualityFile);
-        
-               qualityFile.setf(ios::fixed, ios::floatfield);
-               qualityFile.setf(ios::showpoint);
-               qualityFile << setprecision(6);
-               
-               vector<vector<int> > qualities(numOTUs);
-               vector<double> pr(HOMOPS, 0);
-               
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int index = 0;
-                       int base = 0;
-                       
-                       if(nSeqsPerOTU[i] > 0){
-                               qualities[i].assign(1024, -1);
-                               
-                               while(index < numFlowCells){
-                                       double maxPrValue = 1e8;
-                                       short maxPrIndex = -1;
-                                       double count = 0.0000;
-                                       
-                                       pr.assign(HOMOPS, 0);
-                                       
-                                       for(int j=0;j<nSeqsPerOTU[i];j++){
-                                               int lIndex = cumNumSeqs[i] + j;
-                                               double tauValue = singleTau[seqNumber[lIndex]];
-                                               int sequenceIndex = aaI[i][j];
-                                               short intensity = flowDataIntI[sequenceIndex * numFlowCells + index];
-                                               
-                                               count += tauValue;
-                                               
-                                               for(int s=0;s<HOMOPS;s++){
-                                                       pr[s] += tauValue * singleLookUp[s * NUMBINS + intensity];
-                                               }
-                                       }
-                                       
-                                       maxPrIndex = uniqueFlowgrams[centroids[i] * numFlowCells + index];
-                                       maxPrValue = pr[maxPrIndex];
-                                       
-                                       if(count > MIN_COUNT){
-                                               double U = 0.0000;
-                                               double norm = 0.0000;
-                                               
-                                               for(int s=0;s<HOMOPS;s++){
-                                                       norm += exp(-(pr[s] - maxPrValue));
-                                               }
-                                               
-                                               for(int s=1;s<=maxPrIndex;s++){
-                                                       int value = 0;
-                                                       double temp = 0.0000;
-                                                       
-                                                       U += exp(-(pr[s-1]-maxPrValue))/norm;
-                                                       
-                                                       if(U>0.00){
-                                                               temp = log10(U);
-                                                       }
-                                                       else{
-                                                               temp = -10.1;
-                                                       }
-                                                       temp = floor(-10 * temp);
-                                                       value = (int)floor(temp);
-                                                       if(value > 100){        value = 100;    }
-                                                       
-                                                       qualities[i][base] = (int)value;
-                                                       base++;
-                                               }
-                                       }
-                                       
-                                       index++;
-                               }
-                       }
-                       
-                       
-                       if(otuCounts[i] > 0){
-                               qualityFile << '>' << seqNameVector[mapUniqueToSeq[i]] << endl;
-                       
-                               int j=4;        //need to get past the first four bases
-                               while(qualities[i][j] != -1){
-                    qualityFile << qualities[i][j] << ' ';
-                    if (j > qualities[i].size()) { break; }
-                    j++;
-                               }
-                               qualityFile << endl;
-                       }
-               }
-               qualityFile.close();
-               outputNames.push_back(qualityFileName);
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "writeQualities");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeSequences(string thisCompositeFASTAFileName, int numOTUs, int numFlowCells, string filename, vector<int> otuCounts, vector<short>& uniqueFlowgrams, vector<string>& seqNameVector, vector<vector<int> >& aaI, vector<int>& centroids){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(filename);  }
-               string fastaFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.fasta";
-               ofstream fastaFile;
-               m->openOutputFile(fastaFileName, fastaFile);
-               
-               vector<string> names(numOTUs, "");
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int index = centroids[i];
-                       
-                       if(otuCounts[i] > 0){
-                               fastaFile << '>' << seqNameVector[aaI[i][0]] << endl;
-                               
-                               string newSeq = "";
-                               
-                               for(int j=0;j<numFlowCells;j++){
-                                       
-                                       char base = flowOrder[j % 4];
-                                       for(int k=0;k<uniqueFlowgrams[index * numFlowCells + j];k++){
-                                               newSeq += base;
-                                       }
-                               }
-                               
-                               fastaFile << newSeq.substr(4) << endl;
-                       }
-               }
-               fastaFile.close();
-        
-               outputNames.push_back(fastaFileName);
-        
-               if(thisCompositeFASTAFileName != ""){
-                       m->appendFiles(fastaFileName, thisCompositeFASTAFileName);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "writeSequences");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeNames(string thisCompositeNamesFileName, int numOTUs, string filename, vector<int> otuCounts, vector<string>& seqNameVector, vector<vector<int> >& aaI, vector<int>& nSeqsPerOTU){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(filename);  }
-               string nameFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.names";
-               ofstream nameFile;
-               m->openOutputFile(nameFileName, nameFile);
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       if(otuCounts[i] > 0){
-                               nameFile << seqNameVector[aaI[i][0]] << '\t' << seqNameVector[aaI[i][0]];
-                               
-                               for(int j=1;j<nSeqsPerOTU[i];j++){
-                                       nameFile << ',' << seqNameVector[aaI[i][j]];
-                               }
-                               
-                               nameFile << endl;
-                       }
-               }
-               nameFile.close();
-               outputNames.push_back(nameFileName);
-               
-               
-               if(thisCompositeNamesFileName != ""){
-                       m->appendFiles(nameFileName, thisCompositeNamesFileName);
-               }               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "writeNames");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeGroups(string filename, int numSeqs, vector<string>& seqNameVector){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(filename);  }
-               string fileRoot = thisOutputDir + m->getRootName(m->getSimpleName(filename));
-               string groupFileName = fileRoot + "shhh.groups";
-               ofstream groupFile;
-               m->openOutputFile(groupFileName, groupFile);
-               
-               for(int i=0;i<numSeqs;i++){
-                       if (m->control_pressed) { break; }
-                       groupFile << seqNameVector[i] << '\t' << fileRoot << endl;
-               }
-               groupFile.close();
-               outputNames.push_back(groupFileName);
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "writeGroups");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::writeClusters(string filename, int numOTUs, int numFlowCells, vector<int> otuCounts, vector<int>& centroids, vector<short>& uniqueFlowgrams, vector<string>& seqNameVector, vector<vector<int> >& aaI, vector<int>& nSeqsPerOTU, vector<int>& lengths, vector<short>& flowDataIntI){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(filename);  }
-               string otuCountsFileName = thisOutputDir + m->getRootName(m->getSimpleName(filename)) + "shhh.counts";
-               ofstream otuCountsFile;
-               m->openOutputFile(otuCountsFileName, otuCountsFile);
-               
-               string bases = flowOrder;
-               
-               for(int i=0;i<numOTUs;i++){
-                       
-                       if (m->control_pressed) {
-                               break;
-                       }
-                       //output the translated version of the centroid sequence for the otu
-                       if(otuCounts[i] > 0){
-                               int index = centroids[i];
-                               
-                               otuCountsFile << "ideal\t";
-                               for(int j=8;j<numFlowCells;j++){
-                                       char base = bases[j % 4];
-                                       for(int s=0;s<uniqueFlowgrams[index * numFlowCells + j];s++){
-                                               otuCountsFile << base;
-                                       }
-                               }
-                               otuCountsFile << endl;
-                               
-                               for(int j=0;j<nSeqsPerOTU[i];j++){
-                                       int sequence = aaI[i][j];
-                                       otuCountsFile << seqNameVector[sequence] << '\t';
-                                       
-                                       string newSeq = "";
-                                       
-                                       for(int k=0;k<lengths[sequence];k++){
-                                               char base = bases[k % 4];
-                                               int freq = int(0.01 * (double)flowDataIntI[sequence * numFlowCells + k] + 0.5);
-                        
-                                               for(int s=0;s<freq;s++){
-                                                       newSeq += base;
-                                                       //otuCountsFile << base;
-                                               }
-                                       }
-                                       otuCountsFile << newSeq.substr(4) << endl;
-                               }
-                               otuCountsFile << endl;
-                       }
-               }
-               otuCountsFile.close();
-               outputNames.push_back(otuCountsFileName);
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "writeClusters");
-               exit(1);        
-       }               
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::getSingleLookUp(){
-       try{
-               //      these are the -log probabilities that a signal corresponds to a particular homopolymer length
-               singleLookUp.assign(HOMOPS * NUMBINS, 0);
-               
-               int index = 0;
-               ifstream lookUpFile;
-               m->openInputFile(lookupFileName, lookUpFile);
-               
-               for(int i=0;i<HOMOPS;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       float logFracFreq;
-                       lookUpFile >> logFracFreq;
-                       
-                       for(int j=0;j<NUMBINS;j++)      {
-                               lookUpFile >> singleLookUp[index];
-                               index++;
-                       }
-               }       
-               lookUpFile.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getSingleLookUp");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-void ShhherCommand::getJointLookUp(){
-       try{
-               
-               //      the most likely joint probability (-log) that two intenities have the same polymer length
-               jointLookUp.resize(NUMBINS * NUMBINS, 0);
-               
-               for(int i=0;i<NUMBINS;i++){
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       for(int j=0;j<NUMBINS;j++){             
-                               
-                               double minSum = 100000000;
-                               
-                               for(int k=0;k<HOMOPS;k++){
-                                       double sum = singleLookUp[k * NUMBINS + i] + singleLookUp[k * NUMBINS + j];
-                                       
-                                       if(sum < minSum)        {       minSum = sum;           }
-                               }       
-                               jointLookUp[i * NUMBINS + j] = minSum;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getJointLookUp");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-double ShhherCommand::getProbIntensity(int intIntensity){                          
-       try{
-
-               double minNegLogProb = 100000000; 
-
-               
-               for(int i=0;i<HOMOPS;i++){//loop signal strength
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       float negLogProb = singleLookUp[i * NUMBINS + intIntensity];
-                       if(negLogProb < minNegLogProb)  {       minNegLogProb = negLogProb; }
-               }
-               
-               return minNegLogProb;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhherCommand", "getProbIntensity");
-               exit(1);
-       }
-}
-
-
-
-
diff --git a/shhhercommand.h b/shhhercommand.h
deleted file mode 100644 (file)
index c9772af..0000000
+++ /dev/null
@@ -1,1366 +0,0 @@
-#ifndef SHHHER_H
-#define SHHHER_H
-
-/*
- *  shhher.h
- *  Mothur
- *
- *  Created by Pat Schloss on 12/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "readcolumn.h"
-#include "readmatrix.hpp"
-#include "rabundvector.hpp"
-#include "sabundvector.hpp"
-#include "listvector.hpp"
-#include "cluster.hpp"
-#include "sparsematrix.hpp"
-#include <cfloat>
-
-//**********************************************************************************************************************
-
-#define NUMBINS 1000
-#define HOMOPS 10
-#define MIN_COUNT 0.1
-#define MIN_WEIGHT 0.1
-#define MIN_TAU 0.0001
-#define MIN_ITER 10
-//**********************************************************************************************************************
-
-class ShhherCommand : public Command {
-       
-public:
-       ShhherCommand(string);
-       ShhherCommand();
-       ~ShhherCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "shhh.flows";  }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Shhh.flows"; }
-       string getDescription()         { return "shhh.flows"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-private:
-       
-    struct linePair {
-               int start;
-               int end;
-               linePair(int i, int j) : start(i), end(j) {}
-       };
-    
-       int abort;
-       string outputDir, flowFileName, flowFilesFileName, lookupFileName, compositeFASTAFileName, compositeNamesFileName;
-
-       int processors, maxIters;
-       float cutoff, sigma, minDelta;
-       string flowOrder;
-    
-    vector<string> outputNames;
-       vector<double> singleLookUp;
-       vector<double> jointLookUp;
-    vector<string> flowFileVector;
-       
-    int driver(vector<string>, string, string, int, int);
-    int createProcesses(vector<string>);
-    int getFlowData(string, vector<string>&, vector<int>&, vector<short>&, map<string, int>&, int&);
-    int getUniques(int, int, vector<short>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<double>&, vector<short>&);
-    int flowDistParentFork(int, string, int, vector<int>&, vector<int>&, vector<int>&, vector<double>&, vector<short>&);
-    float calcPairwiseDist(int, int, int, vector<int>&, vector<int>&, vector<double>&, vector<short>&);
-    int createNamesFile(int, int, string, vector<string>&, vector<int>&, vector<int>&);
-    int cluster(string, string, string);
-    int getOTUData(int numSeqs, string,  vector<int>&, vector<int>&, vector<int>&, vector<vector<int> >&, vector<vector<int> >&, vector<int>&, vector<int>&,map<string, int>&);
-    int calcCentroidsDriver(int numOTUs, vector<int>&, vector<int>&, vector<int>&, vector<short>&, vector<int>&, vector<double>&, vector<int>&, vector<short>&, vector<short>&, vector<int>&, int, vector<int>&);
-    double getDistToCentroid(int, int, int, vector<short>&, vector<short>&, int);
-    double getNewWeights(int, vector<int>&, vector<int>&, vector<double>&, vector<int>&, vector<double>&);
-    
-    double getLikelihood(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<double>&, vector<double>&);
-    int checkCentroids(int, vector<int>&, vector<double>&);
-    void calcNewDistances(int, int, vector<int>& , vector<double>&,vector<double>& , vector<short>& change, vector<int>&,vector<vector<int> >&,        vector<double>&, vector<vector<int> >&, vector<int>&, vector<int>&, vector<short>&, vector<short>&, int, vector<int>&);
-    int fill(int, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<vector<int> >&, vector<vector<int> >&);
-    void setOTUs(int, int, vector<int>&, vector<int>&, vector<int>&, vector<int>&,
-                 vector<int>&, vector<double>&, vector<double>&, vector<vector<int> >&, vector<vector<int> >&);
-    void writeQualities(int, int, string, vector<int>, vector<int>&, vector<int>&, vector<double>&, vector<short>&, vector<short>&, vector<int>&, vector<int>&, vector<string>&, vector<int>&, vector<vector<int> >&);
-    void writeSequences(string, int, int, string, vector<int>, vector<short>&, vector<string>&, vector<vector<int> >&, vector<int>&);
-    void writeNames(string, int, string, vector<int>, vector<string>&, vector<vector<int> >&, vector<int>&);
-    void writeGroups(string, int, vector<string>&);
-    void writeClusters(string, int, int, vector<int>, vector<int>&, vector<short>&, vector<string>&, vector<vector<int> >&, vector<int>&, vector<int>&, vector<short>&);
-    
-       void getSingleLookUp();
-       void getJointLookUp();
-    double getProbIntensity(int);
-       
-       
-#ifdef USE_MPI
-       string flowDistMPI(int, int);
-       void calcNewDistancesChildMPI(int, int, vector<int>&);
-
-       int pid, ncpus; 
-    
-     void getFlowData();
-     void getUniques();
-     
-     float calcPairwiseDist(int, int);
-     void flowDistParentFork(string, int, int);
-     
-     string createDistFile(int);
-     string createNamesFile();
-     string cluster(string, string);
-     
-     void getOTUData(string);
-     void initPyroCluster();
-     void fill();
-     void calcCentroids();
-     void calcCentroidsDriver(int, int);
-     double getDistToCentroid(int, int, int);
-     double getNewWeights();
-     double getLikelihood();
-     void checkCentroids();
-     void calcNewDistances();
-     void calcNewDistancesParent(int, int);
-     void calcNewDistancesChild(int, int, vector<int>&, vector<int>&, vector<double>&);
-     
-     
-     void setOTUs();
-     void writeQualities(vector<int>);
-     void writeSequences(vector<int>);
-     void writeNames(vector<int>);
-     void writeGroups();
-     void writeClusters(vector<int>);
-    
-    vector<string> seqNameVector;
-       vector<int> lengths;
-       vector<short> flowDataIntI;
-       vector<double> flowDataPrI;
-       map<string, int> nameMap;
-       vector<int> otuData;
-       vector<int> cumNumSeqs;
-       vector<int> nSeqsPerOTU;
-       vector<vector<int> > aaP;       //tMaster->aanP:        each row is a different otu / each col contains the sequence indices
-       vector<vector<int> > aaI;       //tMaster->aanI:        that are in each otu - can't differentiate between aaP and aaI 
-       vector<int> seqNumber;          //tMaster->anP:         the sequence id number sorted by OTU
-       vector<int> seqIndex;           //tMaster->anI;         the index that corresponds to seqNumber
-       vector<double> dist;            //adDist - distance of sequences to centroids
-       vector<short> change;           //did the centroid sequence change? 0 = no; 1 = yes
-       vector<int> centroids;          //the representative flowgram for each cluster m
-       vector<double> weight;
-       vector<double> singleTau;       //tMaster->adTau:       1-D Tau vector (1xnumSeqs)
-       vector<short> uniqueFlowgrams;
-       vector<int> uniqueCount;
-       vector<int> mapSeqToUnique;
-       vector<int> mapUniqueToSeq;
-       vector<int> uniqueLengths;
-    int numSeqs, numUniques, numOTUs, numFlowCells;
-    vector<int> nSeqsBreaks;
-       vector<int> nOTUsBreaks;
-
-#endif
-       
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct shhhFlowsData {
-       int threadID, maxIters;
-       float cutoff, sigma, minDelta;
-       string flowOrder;
-       vector<double> singleLookUp;
-       vector<double> jointLookUp;
-    vector<string> filenames;
-    vector<string> outputNames;
-    string thisCompositeFASTAFileName, thisCompositeNameFileName, outputDir;
-    int start, stop;
-       MothurOut* m;
-       
-       shhhFlowsData(){}
-       shhhFlowsData(vector<string> f, string cf, string cn, string ou, string flor, vector<double> jl, vector<double> sl, MothurOut* mout, int st, int sp, float cut, float si, float mD, int mx, int tid) {
-               filenames = f;
-        thisCompositeFASTAFileName = cf;
-        thisCompositeNameFileName = cn;
-        outputDir = ou;
-        flowOrder = flor;
-               m = mout;
-               start = st;
-               stop = sp;
-               cutoff= cut;
-        sigma = si;
-        minDelta = mD;
-        maxIters = mx;
-        jointLookUp = jl;
-        singleLookUp = sl;
-               threadID = tid;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){ 
-       shhhFlowsData* pDataArray;
-       pDataArray = (shhhFlowsData*)lpParam;
-       
-       try {
-        
-               for(int l=pDataArray->start;l<pDataArray->stop;l++){
-                       
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       string flowFileName = pDataArray->filenames[l];
-            
-                       pDataArray->m->mothurOut("\n>>>>>\tProcessing " + flowFileName + " (file " + toString(l+1) + " of " + toString(pDataArray->filenames.size()) + ")\t<<<<<\n");
-                       pDataArray->m->mothurOut("Reading flowgrams...\n");
-                       
-            vector<string> seqNameVector;
-            vector<int> lengths;
-            vector<short> flowDataIntI;
-            vector<double> flowDataPrI;
-            map<string, int> nameMap;
-            vector<short> uniqueFlowgrams;
-            vector<int> uniqueCount;
-            vector<int> mapSeqToUnique;
-            vector<int> mapUniqueToSeq;
-            vector<int> uniqueLengths;
-            int numFlowCells;
-            
-            //int numSeqs = getFlowData(flowFileName, seqNameVector, lengths, flowDataIntI, nameMap, numFlowCells);
-            /*****************************************************************************************************/
-            
-            ifstream flowFile;
-           // cout << "herethread " << flowFileName << '\t' << &flowFile << endl;
-            pDataArray->m->openInputFile(flowFileName, flowFile);
-            
-           // cout << "herethread " << flowFileName << endl;
-            string seqName;
-            int currentNumFlowCells;
-            float intensity;
-                        
-            flowFile >> numFlowCells;
-            int index = 0;//pcluster
-            while(!flowFile.eof()){
-                
-                if (pDataArray->m->control_pressed) { flowFile.close(); return 0; }
-                
-                flowFile >> seqName >> currentNumFlowCells;
-                lengths.push_back(currentNumFlowCells);
-             //  cout << "herethread " << seqName << endl;  
-                seqNameVector.push_back(seqName);
-                nameMap[seqName] = index++;//pcluster
-                
-                for(int i=0;i<numFlowCells;i++){
-                    flowFile >> intensity;
-                    if(intensity > 9.99)       {       intensity = 9.99;       }
-                    int intI = int(100 * intensity + 0.0001);
-                    flowDataIntI.push_back(intI);
-                }
-                pDataArray->m->gobble(flowFile);
-            }
-            flowFile.close();
-            
-            int numSeqs = seqNameVector.size();                
-          //  cout << numSeqs << endl;   
-            for(int i=0;i<numSeqs;i++){
-                
-                if (pDataArray->m->control_pressed) { return 0; }
-                
-                int iNumFlowCells = i * numFlowCells;
-                for(int j=lengths[i];j<numFlowCells;j++){
-                    flowDataIntI[iNumFlowCells + j] = 0;
-                }
-            }
-          //  cout << "here" << endl; 
-            /*****************************************************************************************************/
-       
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       pDataArray->m->mothurOut("Identifying unique flowgrams...\n");
-                       //int numUniques = getUniques(numSeqs, numFlowCells, uniqueFlowgrams, uniqueCount, uniqueLengths, mapSeqToUnique, mapUniqueToSeq, lengths, flowDataPrI, flowDataIntI);
-            /*****************************************************************************************************/
-            int numUniques = 0;
-            uniqueFlowgrams.assign(numFlowCells * numSeqs, -1);
-            uniqueCount.assign(numSeqs, 0);                                                    //      anWeights
-            uniqueLengths.assign(numSeqs, 0);
-            mapSeqToUnique.assign(numSeqs, -1);
-            mapUniqueToSeq.assign(numSeqs, -1);
-            
-            vector<short> uniqueFlowDataIntI(numFlowCells * numSeqs, -1);
-            
-            for(int i=0;i<numSeqs;i++){
-                
-                if (pDataArray->m->control_pressed) { return 0; }
-                
-                int index = 0;
-                
-                vector<short> current(numFlowCells);
-                for(int j=0;j<numFlowCells;j++){
-                    current[j] = short(((flowDataIntI[i * numFlowCells + j] + 50.0)/100.0));
-                }
-                
-                for(int j=0;j<numUniques;j++){
-                    int offset = j * numFlowCells;
-                    bool toEnd = 1;
-                    
-                    int shorterLength;
-                    if(lengths[i] < uniqueLengths[j])  {       shorterLength = lengths[i];                     }
-                    else                                                               {       shorterLength = uniqueLengths[j];       }
-                    
-                    for(int k=0;k<shorterLength;k++){
-                        if(current[k] != uniqueFlowgrams[offset + k]){
-                            toEnd = 0;
-                            break;
-                        }
-                    }
-                    
-                    if(toEnd){
-                        mapSeqToUnique[i] = j;
-                        uniqueCount[j]++;
-                        index = j;
-                        if(lengths[i] > uniqueLengths[j])      {       uniqueLengths[j] = lengths[i];  }
-                        break;
-                    }
-                    index++;
-                }
-                
-                if(index == numUniques){
-                    uniqueLengths[numUniques] = lengths[i];
-                    uniqueCount[numUniques] = 1;
-                    mapSeqToUnique[i] = numUniques;//anMap
-                    mapUniqueToSeq[numUniques] = i;//anF
-                    
-                    for(int k=0;k<numFlowCells;k++){
-                        uniqueFlowgrams[numUniques * numFlowCells + k] = current[k];
-                        uniqueFlowDataIntI[numUniques * numFlowCells + k] = flowDataIntI[i * numFlowCells + k];
-                    }
-                    
-                    numUniques++;
-                }
-            }
-            uniqueFlowDataIntI.resize(numFlowCells * numUniques);
-            uniqueLengths.resize(numUniques);  
-            
-            flowDataPrI.resize(numSeqs * numFlowCells, 0);
-            for(int i=0;i<flowDataPrI.size();i++)      {       
-                if (pDataArray->m->control_pressed) { return 0; } 
-                //flowDataPrI[i] = getProbIntensity(flowDataIntI[i]);  
-                
-                flowDataPrI[i] = 100000000; 
-            
-                for(int j=0;j<HOMOPS;j++){//loop signal strength
-                    
-                    if (pDataArray->m->control_pressed) { return 0; }
-                    
-                    float negLogProb = pDataArray->singleLookUp[j * NUMBINS + flowDataIntI[i]];
-                    if(negLogProb < flowDataPrI[i])    {       flowDataPrI[i] = negLogProb; }
-                }
-            }            
-            
-            /*****************************************************************************************************/
-                       
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       pDataArray->m->mothurOut("Calculating distances between flowgrams...\n");
-            string distFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.dist";
-            unsigned long long begTime = time(NULL);
-            double begClock = clock();
-            
-            //flowDistParentFork(numFlowCells, distFileName, numUniques, mapUniqueToSeq, mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);  
-            /*****************************************************************************************************/
-            ostringstream outStream;
-            outStream.setf(ios::fixed, ios::floatfield);
-            outStream.setf(ios::dec, ios::basefield);
-            outStream.setf(ios::showpoint);
-            outStream.precision(6);
-            
-            int thisbegTime = time(NULL);
-            double thisbegClock = clock();
-            
-            for(int i=0;i<numUniques;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                for(int j=0;j<i;j++){
-                    //float flowDistance = calcPairwiseDist(numFlowCells, mapUniqueToSeq[i], mapUniqueToSeq[j], mapSeqToUnique, lengths, flowDataPrI, flowDataIntI);
-                    /*****************************************************************************************************/
-                    int seqA = mapUniqueToSeq[i]; int seqB = mapUniqueToSeq[j];
-                    int minLength = lengths[mapSeqToUnique[seqA]];
-                    if(lengths[seqB] < minLength){     minLength = lengths[mapSeqToUnique[seqB]];      }
-                    
-                    int ANumFlowCells = seqA * numFlowCells;
-                    int BNumFlowCells = seqB * numFlowCells;
-                    
-                    float flowDistance = 0;
-                    
-                    for(int k=0;k<minLength;k++){
-                        
-                        if (pDataArray->m->control_pressed) { break; }
-                        
-                        int flowAIntI = flowDataIntI[ANumFlowCells + k];
-                        float flowAPrI = flowDataPrI[ANumFlowCells + k];
-                        
-                        int flowBIntI = flowDataIntI[BNumFlowCells + k];
-                        float flowBPrI = flowDataPrI[BNumFlowCells + k];
-                        flowDistance += pDataArray->jointLookUp[flowAIntI * NUMBINS + flowBIntI] - flowAPrI - flowBPrI;
-                    }
-                    
-                    flowDistance /= (float) minLength;
-                    /*****************************************************************************************************/
-
-                    if(flowDistance < 1e-6){
-                        outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << 0.000000 << endl;
-                    }
-                    else if(flowDistance <= pDataArray->cutoff){
-                        outStream << mapUniqueToSeq[i] << '\t' << mapUniqueToSeq[j] << '\t' << flowDistance << endl;
-                    }
-                }
-                if(i % 100 == 0){
-                    pDataArray->m->mothurOut(toString(i) + "\t" + toString(time(NULL) - thisbegTime));
-                    pDataArray->m->mothurOut("\t" + toString((clock()-thisbegClock)/CLOCKS_PER_SEC));
-                    pDataArray->m->mothurOutEndLine();
-                }
-            }
-            
-            ofstream distFile(distFileName.c_str());
-            distFile << outStream.str();               
-            distFile.close();
-            
-            if (pDataArray->m->control_pressed) {}
-            else {
-                pDataArray->m->mothurOut(toString(numUniques-1) + "\t" + toString(time(NULL) - thisbegTime));
-                pDataArray->m->mothurOut("\t" + toString((clock()-thisbegClock)/CLOCKS_PER_SEC));
-                pDataArray->m->mothurOutEndLine();
-            }
-            /*****************************************************************************************************/
-
-            pDataArray->m->mothurOutEndLine();
-            pDataArray->m->mothurOut("Total time: " + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/CLOCKS_PER_SEC) + '\n');
-            
-                       string namesFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.names";
-                       //createNamesFile(numSeqs, numUniques, namesFileName, seqNameVector, mapSeqToUnique, mapUniqueToSeq);
-            /*****************************************************************************************************/
-            vector<string> duplicateNames(numUniques, "");
-            for(int i=0;i<numSeqs;i++){
-                duplicateNames[mapSeqToUnique[i]] += seqNameVector[i] + ',';
-            }
-            
-            ofstream nameFile;
-            pDataArray->m->openOutputFile(namesFileName, nameFile);
-            
-            for(int i=0;i<numUniques;i++){
-                if (pDataArray->m->control_pressed) { nameFile.close(); return 0; }
-                nameFile << mapUniqueToSeq[i] << '\t' << duplicateNames[i].substr(0, duplicateNames[i].find_last_of(',')) << endl;
-            }
-            nameFile.close();
-            /*****************************************************************************************************/
-
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       pDataArray->m->mothurOut("\nClustering flowgrams...\n");
-            string listFileName = flowFileName.substr(0,flowFileName.find_last_of('.')) + ".shhh.list";
-                       //cluster(listFileName, distFileName, namesFileName);
-            /*****************************************************************************************************/
-            ReadMatrix* read = new ReadColumnMatrix(distFileName);     
-            read->setCutoff(pDataArray->cutoff);
-            
-            NameAssignment* clusterNameMap = new NameAssignment(namesFileName);
-            clusterNameMap->readMap();
-            read->read(clusterNameMap);
-            
-            ListVector* list = read->getListVector();
-            SparseMatrix* matrix = read->getMatrix();
-            
-            delete read; 
-            delete clusterNameMap; 
-            
-            RAbundVector* rabund = new RAbundVector(list->getRAbundVector());
-            
-            Cluster* cluster = new CompleteLinkage(rabund, list, matrix, pDataArray->cutoff, "furthest"); 
-            string tag = cluster->getTag();
-            
-            double clusterCutoff = pDataArray->cutoff;
-            while (matrix->getSmallDist() <= clusterCutoff && matrix->getNNodes() > 0){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                cluster->update(clusterCutoff);
-            }
-            
-            list->setLabel(toString(pDataArray->cutoff));
-            
-            ofstream listFileOut;
-            pDataArray->m->openOutputFile(listFileName, listFileOut);
-            list->print(listFileOut);
-            listFileOut.close();
-            
-            delete matrix;     delete cluster; delete rabund; delete list;
-            /*****************************************************************************************************/
-
-                       if (pDataArray->m->control_pressed) { return 0; }
-            
-            vector<int> otuData;
-            vector<int> cumNumSeqs;
-            vector<int> nSeqsPerOTU;
-            vector<vector<int> > aaP;  //tMaster->aanP:        each row is a different otu / each col contains the sequence indices
-            vector<vector<int> > aaI;  //tMaster->aanI:        that are in each otu - can't differentiate between aaP and aaI 
-            vector<int> seqNumber;             //tMaster->anP:         the sequence id number sorted by OTU
-            vector<int> seqIndex;              //tMaster->anI;         the index that corresponds to seqNumber
-            
-                       
-                       //int numOTUs = getOTUData(numSeqs, listFileName, otuData, cumNumSeqs, nSeqsPerOTU, aaP, aaI, seqNumber, seqIndex, nameMap);
-                       /*****************************************************************************************************/
-            ifstream listFile;
-            pDataArray->m->openInputFile(listFileName, listFile);
-            string label;
-            int numOTUs;
-            
-            listFile >> label >> numOTUs;
-            
-            otuData.assign(numSeqs, 0);
-            cumNumSeqs.assign(numOTUs, 0);
-            nSeqsPerOTU.assign(numOTUs, 0);
-            aaP.clear();aaP.resize(numOTUs);
-            
-            seqNumber.clear();
-            aaI.clear();
-            seqIndex.clear();
-            
-            string singleOTU = "";
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                listFile >> singleOTU;
-                
-                istringstream otuString(singleOTU);
-                
-                while(otuString){
-                    
-                    string seqName = "";
-                    
-                    for(int j=0;j<singleOTU.length();j++){
-                        char letter = otuString.get();
-                        
-                        if(letter != ','){
-                            seqName += letter;
-                        }
-                        else{
-                            map<string,int>::iterator nmIt = nameMap.find(seqName);
-                            int index = nmIt->second;
-                            
-                            nameMap.erase(nmIt);
-                            
-                            otuData[index] = i;
-                            nSeqsPerOTU[i]++;
-                            aaP[i].push_back(index);
-                            seqName = "";
-                        }
-                    }
-                    
-                    map<string,int>::iterator nmIt = nameMap.find(seqName);
-                    
-                    int index = nmIt->second;
-                    nameMap.erase(nmIt);
-                    
-                    otuData[index] = i;
-                    nSeqsPerOTU[i]++;
-                    aaP[i].push_back(index);   
-                    
-                    otuString.get();
-                }
-                
-                sort(aaP[i].begin(), aaP[i].end());
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    seqNumber.push_back(aaP[i][j]);
-                }
-                for(int j=nSeqsPerOTU[i];j<numSeqs;j++){
-                    aaP[i].push_back(0);
-                }
-                
-                
-            }
-            
-            for(int i=1;i<numOTUs;i++){
-                cumNumSeqs[i] = cumNumSeqs[i-1] + nSeqsPerOTU[i-1];
-            }
-            aaI = aaP;
-            seqIndex = seqNumber;
-            
-            listFile.close();      
-            /*****************************************************************************************************/
-
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       pDataArray->m->mothurRemove(distFileName);
-                       pDataArray->m->mothurRemove(namesFileName);
-                       pDataArray->m->mothurRemove(listFileName);
-                       
-            vector<double> dist;               //adDist - distance of sequences to centroids
-            vector<short> change;              //did the centroid sequence change? 0 = no; 1 = yes
-            vector<int> centroids;             //the representative flowgram for each cluster m
-            vector<double> weight;
-            vector<double> singleTau;  //tMaster->adTau:       1-D Tau vector (1xnumSeqs)
-            vector<int> nSeqsBreaks;
-            vector<int> nOTUsBreaks;
-            
-                       dist.assign(numSeqs * numOTUs, 0);
-            change.assign(numOTUs, 1);
-            centroids.assign(numOTUs, -1);
-            weight.assign(numOTUs, 0);
-            singleTau.assign(numSeqs, 1.0);
-            
-            nSeqsBreaks.assign(2, 0);
-            nOTUsBreaks.assign(2, 0);
-            
-            nSeqsBreaks[0] = 0;
-            nSeqsBreaks[1] = numSeqs;
-            nOTUsBreaks[1] = numOTUs;
-                       
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       double maxDelta = 0;
-                       int iter = 0;
-                       
-                       begClock = clock();
-                       begTime = time(NULL);
-            
-                       pDataArray->m->mothurOut("\nDenoising flowgrams...\n");
-                       pDataArray->m->mothurOut("iter\tmaxDelta\tnLL\t\tcycletime\n");
-                       
-                       while((pDataArray->maxIters == 0 && maxDelta > pDataArray->minDelta) || iter < MIN_ITER || (maxDelta > pDataArray->minDelta && iter < pDataArray->maxIters)){
-                               
-                               if (pDataArray->m->control_pressed) { break; }
-                               
-                               double cycClock = clock();
-                               unsigned long long cycTime = time(NULL);
-                               //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-                /*****************************************************************************************************/
-                int indexFill = 0;
-                for(int i=0;i<numOTUs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { return 0; }
-                    
-                    cumNumSeqs[i] = indexFill;
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        seqNumber[indexFill] = aaP[i][j];
-                        seqIndex[indexFill] = aaI[i][j];
-                        
-                        indexFill++;
-                    }
-                }
-                /*****************************************************************************************************/
-
-                               
-                               if (pDataArray->m->control_pressed) { break; }
-                
-                               //calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber);
-                /*****************************************************************************************************/
-                for(int i=0;i<numOTUs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { break; }
-                    
-                    double count = 0;
-                    int position = 0;
-                    int minFlowGram = 100000000;
-                    double minFlowValue = 1e8;
-                    change[i] = 0; //FALSE
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        count += singleTau[seqNumber[cumNumSeqs[i] + j]];
-                    }
-                    
-                    if(nSeqsPerOTU[i] > 0 && count > MIN_COUNT){
-                        vector<double> adF(nSeqsPerOTU[i]);
-                        vector<int> anL(nSeqsPerOTU[i]);
-                        
-                        for(int j=0;j<nSeqsPerOTU[i];j++){
-                            int index = cumNumSeqs[i] + j;
-                            int nI = seqIndex[index];
-                            int nIU = mapSeqToUnique[nI];
-                            
-                            int k;
-                            for(k=0;k<position;k++){
-                                if(nIU == anL[k]){
-                                    break;
-                                }
-                            }
-                            if(k == position){
-                                anL[position] = nIU;
-                                adF[position] = 0.0000;
-                                position++;
-                            }                                          
-                        }
-                        
-                        for(int j=0;j<nSeqsPerOTU[i];j++){
-                            int index = cumNumSeqs[i] + j;
-                            int nI = seqIndex[index];
-                            
-                            double tauValue = singleTau[seqNumber[index]];
-                            
-                            for(int k=0;k<position;k++){
-                               // double dist = getDistToCentroid(anL[k], nI, lengths[nI], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                                /*****************************************************************************************************/
-                                int flowAValue = anL[k] * numFlowCells;
-                                int flowBValue = nI * numFlowCells;
-                                
-                                double dist = 0;
-                                
-                                for(int l=0;l<lengths[nI];l++){
-                                    dist += pDataArray->singleLookUp[uniqueFlowgrams[flowAValue] * NUMBINS + flowDataIntI[flowBValue]];
-                                    flowAValue++;
-                                    flowBValue++;
-                                }
-                                
-                                dist = dist / (double)lengths[nI];
-                                /*****************************************************************************************************/
-                                adF[k] += dist * tauValue;
-                            }
-                        }
-                        
-                        for(int j=0;j<position;j++){
-                            if(adF[j] < minFlowValue){
-                                minFlowGram = j;
-                                minFlowValue = adF[j];
-                            }
-                        }
-                        
-                        if(centroids[i] != anL[minFlowGram]){
-                            change[i] = 1;
-                            centroids[i] = anL[minFlowGram];
-                        }
-                    }
-                    else if(centroids[i] != -1){
-                        change[i] = 1;
-                        centroids[i] = -1;                     
-                    }
-                }
-                /*****************************************************************************************************/
-
-                               if (pDataArray->m->control_pressed) { break; }
-                
-                               //maxDelta = getNewWeights(numOTUs, cumNumSeqs, nSeqsPerOTU, singleTau, seqNumber, weight);  
-                /*****************************************************************************************************/
-                double maxChange = 0;
-                
-                for(int i=0;i<numOTUs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { break; }
-                    
-                    double difference = weight[i];
-                    weight[i] = 0;
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int index = cumNumSeqs[i] + j;
-                        double tauValue = singleTau[seqNumber[index]];
-                        weight[i] += tauValue;
-                    }
-                    
-                    difference = fabs(weight[i] - difference);
-                    if(difference > maxChange){        maxChange = difference; }
-                }
-                maxDelta = maxChange;
-                /*****************************************************************************************************/
-
-                if (pDataArray->m->control_pressed) { break; }
-                
-                               //double nLL = getLikelihood(numSeqs, numOTUs, nSeqsPerOTU, seqNumber, cumNumSeqs, seqIndex, dist, weight); 
-                /*****************************************************************************************************/
-                vector<long double> P(numSeqs, 0);
-                int effNumOTUs = 0;
-                
-                for(int i=0;i<numOTUs;i++){
-                    if(weight[i] > MIN_WEIGHT){
-                        effNumOTUs++;
-                    }
-                }
-                
-                string hold;
-                for(int i=0;i<numOTUs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { break; }
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int index = cumNumSeqs[i] + j;
-                        int nI = seqIndex[index];
-                        double singleDist = dist[seqNumber[index]];
-                        
-                        P[nI] += weight[i] * exp(-singleDist * pDataArray->sigma);
-                    }
-                }
-                double nLL = 0.00;
-                for(int i=0;i<numSeqs;i++){
-                    if(P[i] == 0){     P[i] = DBL_EPSILON;     }
-                    
-                    nLL += -log(P[i]);
-                }
-                
-                nLL = nLL -(double)numSeqs * log(pDataArray->sigma);
-                /*****************************************************************************************************/
-
-                if (pDataArray->m->control_pressed) { break; }
-                
-                               //checkCentroids(numOTUs, centroids, weight);
-                /*****************************************************************************************************/
-                vector<int> unique(numOTUs, 1);
-                
-                for(int i=0;i<numOTUs;i++){
-                    if(centroids[i] == -1 || weight[i] < MIN_WEIGHT){
-                        unique[i] = -1;
-                    }
-                }
-                
-                for(int i=0;i<numOTUs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { break; }
-                    
-                    if(unique[i] == 1){
-                        for(int j=i+1;j<numOTUs;j++){
-                            if(unique[j] == 1){
-                                
-                                if(centroids[j] == centroids[i]){
-                                    unique[j] = 0;
-                                    centroids[j] = -1;
-                                    
-                                    weight[i] += weight[j];
-                                    weight[j] = 0.0;
-                                }
-                            }
-                        }
-                    }
-                }
-                /*****************************************************************************************************/
-
-                               if (pDataArray->m->control_pressed) { break; }
-                               
-                               //calcNewDistances(numSeqs, numOTUs, nSeqsPerOTU,  dist, weight, change, centroids, aaP, singleTau, aaI, seqNumber, seqIndex, uniqueFlowgrams, flowDataIntI, numFlowCells, lengths);
-                /*****************************************************************************************************/
-                int total = 0;
-                vector<double> newTau(numOTUs,0);
-                vector<double> norms(numSeqs, 0);
-                nSeqsPerOTU.assign(numOTUs, 0);
-                
-                for(int i=0;i<numSeqs;i++){
-                    
-                    if (pDataArray->m->control_pressed) { break; }
-                    
-                    int indexOffset = i * numOTUs;
-                    
-                    double offset = 1e8;
-                    
-                    for(int j=0;j<numOTUs;j++){
-                        
-                        if(weight[j] > MIN_WEIGHT && change[j] == 1){
-                            //dist[indexOffset + j] = getDistToCentroid(centroids[j], i, lengths[i], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                            /*****************************************************************************************************/
-                            int flowAValue = centroids[j] * numFlowCells;
-                            int flowBValue = i * numFlowCells;
-                            
-                            double distTemp = 0;
-                            
-                            for(int l=0;l<lengths[i];l++){
-                                distTemp += pDataArray->singleLookUp[uniqueFlowgrams[flowAValue] * NUMBINS + flowDataIntI[flowBValue]];
-                                flowAValue++;
-                                flowBValue++;
-                            }
-                            
-                            dist[indexOffset + j] = distTemp / (double)lengths[i];
-                            /*****************************************************************************************************/
-
-                        }
-                        
-                        if(weight[j] > MIN_WEIGHT && dist[indexOffset + j] < offset){
-                            offset = dist[indexOffset + j];
-                        }
-                    }
-                    
-                    for(int j=0;j<numOTUs;j++){
-                        if(weight[j] > MIN_WEIGHT){
-                            newTau[j] = exp(pDataArray->sigma * (-dist[indexOffset + j] + offset)) * weight[j];
-                            norms[i] += newTau[j];
-                        }
-                        else{
-                            newTau[j] = 0.0;
-                        }
-                    }
-                    
-                    for(int j=0;j<numOTUs;j++){
-                        newTau[j] /= norms[i];
-                    }
-                    
-                    for(int j=0;j<numOTUs;j++){
-                        if(newTau[j] > MIN_TAU){
-                            
-                            int oldTotal = total;
-                            
-                            total++;
-                            
-                            singleTau.resize(total, 0);
-                            seqNumber.resize(total, 0);
-                            seqIndex.resize(total, 0);
-                            
-                            singleTau[oldTotal] = newTau[j];
-                            
-                            aaP[j][nSeqsPerOTU[j]] = oldTotal;
-                            aaI[j][nSeqsPerOTU[j]] = i;
-                            nSeqsPerOTU[j]++;
-                        }
-                    }
-                    
-                }
-
-                /*****************************************************************************************************/
-
-                               if (pDataArray->m->control_pressed) { break; }
-                               
-                               iter++;
-                               
-                               pDataArray->m->mothurOut(toString(iter) + '\t' + toString(maxDelta) + '\t' + toString(nLL) + '\t' + toString(time(NULL) - cycTime) + '\t' + toString((clock() - cycClock)/(double)CLOCKS_PER_SEC) + '\n');
-                
-                       }       
-                       
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       pDataArray->m->mothurOut("\nFinalizing...\n");
-                       //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);
-            /*****************************************************************************************************/
-            int indexFill = 0;
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { return 0; }
-                
-                cumNumSeqs[i] = indexFill;
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    seqNumber[indexFill] = aaP[i][j];
-                    seqIndex[indexFill] = aaI[i][j];
-                    
-                    indexFill++;
-                }
-            }
-            /*****************************************************************************************************/
-
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       //setOTUs(numOTUs, numSeqs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, otuData, singleTau, dist, aaP, aaI);
-            /*****************************************************************************************************/
-            vector<double> bigTauMatrix(numOTUs * numSeqs, 0.0000);
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    int index = cumNumSeqs[i] + j;
-                    double tauValue = singleTau[seqNumber[index]];
-                    int sIndex = seqIndex[index];
-                    bigTauMatrix[sIndex * numOTUs + i] = tauValue;                             
-                }
-            }
-            
-            for(int i=0;i<numSeqs;i++){
-                double maxTau = -1.0000;
-                int maxOTU = -1;
-                for(int j=0;j<numOTUs;j++){
-                    if(bigTauMatrix[i * numOTUs + j] > maxTau){
-                        maxTau = bigTauMatrix[i * numOTUs + j];
-                        maxOTU = j;
-                    }
-                }
-                
-                otuData[i] = maxOTU;
-            }
-            
-            nSeqsPerOTU.assign(numOTUs, 0);            
-            
-            for(int i=0;i<numSeqs;i++){
-                int index = otuData[i];
-                
-                singleTau[i] = 1.0000;
-                dist[i] = 0.0000;
-                
-                aaP[index][nSeqsPerOTU[index]] = i;
-                aaI[index][nSeqsPerOTU[index]] = i;
-                
-                nSeqsPerOTU[index]++;
-            }
-            
-            //fill(numOTUs, seqNumber, seqIndex, cumNumSeqs, nSeqsPerOTU, aaP, aaI);   
-            /*****************************************************************************************************/
-            indexFill = 0;
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { return 0; }
-                
-                cumNumSeqs[i] = indexFill;
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    seqNumber[indexFill] = aaP[i][j];
-                    seqIndex[indexFill] = aaI[i][j];
-                    
-                    indexFill++;
-                }
-            }
-            /*****************************************************************************************************/
-
-            /*****************************************************************************************************/
-
-                       if (pDataArray->m->control_pressed) { break; }
-                       
-                       vector<int> otuCounts(numOTUs, 0);
-                       for(int i=0;i<numSeqs;i++)      {       otuCounts[otuData[i]]++;        }
-                       
-                       //calcCentroidsDriver(numOTUs, cumNumSeqs, nSeqsPerOTU, seqIndex, change, centroids, singleTau, mapSeqToUnique, uniqueFlowgrams, flowDataIntI, lengths, numFlowCells, seqNumber);       
-            /*****************************************************************************************************/
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                double count = 0;
-                int position = 0;
-                int minFlowGram = 100000000;
-                double minFlowValue = 1e8;
-                change[i] = 0; //FALSE
-                
-                for(int j=0;j<nSeqsPerOTU[i];j++){
-                    count += singleTau[seqNumber[cumNumSeqs[i] + j]];
-                }
-                
-                if(nSeqsPerOTU[i] > 0 && count > MIN_COUNT){
-                    vector<double> adF(nSeqsPerOTU[i]);
-                    vector<int> anL(nSeqsPerOTU[i]);
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int index = cumNumSeqs[i] + j;
-                        int nI = seqIndex[index];
-                        int nIU = mapSeqToUnique[nI];
-                        
-                        int k;
-                        for(k=0;k<position;k++){
-                            if(nIU == anL[k]){
-                                break;
-                            }
-                        }
-                        if(k == position){
-                            anL[position] = nIU;
-                            adF[position] = 0.0000;
-                            position++;
-                        }                                              
-                    }
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int index = cumNumSeqs[i] + j;
-                        int nI = seqIndex[index];
-                        
-                        double tauValue = singleTau[seqNumber[index]];
-                        
-                        for(int k=0;k<position;k++){
-                            // double dist = getDistToCentroid(anL[k], nI, lengths[nI], uniqueFlowgrams, flowDataIntI, numFlowCells);
-                            /*****************************************************************************************************/
-                            int flowAValue = anL[k] * numFlowCells;
-                            int flowBValue = nI * numFlowCells;
-                            
-                            double dist = 0;
-                            
-                            for(int l=0;l<lengths[nI];l++){
-                                dist += pDataArray->singleLookUp[uniqueFlowgrams[flowAValue] * NUMBINS + flowDataIntI[flowBValue]];
-                                flowAValue++;
-                                flowBValue++;
-                            }
-                            
-                            dist = dist / (double)lengths[nI];
-                            /*****************************************************************************************************/
-                            adF[k] += dist * tauValue;
-                        }
-                    }
-                    
-                    for(int j=0;j<position;j++){
-                        if(adF[j] < minFlowValue){
-                            minFlowGram = j;
-                            minFlowValue = adF[j];
-                        }
-                    }
-                    
-                    if(centroids[i] != anL[minFlowGram]){
-                        change[i] = 1;
-                        centroids[i] = anL[minFlowGram];
-                    }
-                }
-                else if(centroids[i] != -1){
-                    change[i] = 1;
-                    centroids[i] = -1;                 
-                }
-            }
-
-            /*****************************************************************************************************/
-
-            if (pDataArray->m->control_pressed) { break; }
-            
-                       //writeQualities(numOTUs, numFlowCells, flowFileName, otuCounts, nSeqsPerOTU, seqNumber, singleTau, flowDataIntI, uniqueFlowgrams, cumNumSeqs, mapUniqueToSeq, seqNameVector, centroids, aaI); 
-            if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
-            string thisOutputDir = pDataArray->outputDir;
-            if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
-            string qualityFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.qual";
-            
-            ofstream qualityFile;
-            pDataArray->m->openOutputFile(qualityFileName, qualityFile);
-            
-            qualityFile.setf(ios::fixed, ios::floatfield);
-            qualityFile.setf(ios::showpoint);
-            qualityFile << setprecision(6);
-            
-            vector<vector<int> > qualities(numOTUs);
-            vector<double> pr(HOMOPS, 0);
-            
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                int index = 0;
-                int base = 0;
-                
-                if(nSeqsPerOTU[i] > 0){
-                    qualities[i].assign(1024, -1);
-                    
-                    while(index < numFlowCells){
-                        double maxPrValue = 1e8;
-                        short maxPrIndex = -1;
-                        double count = 0.0000;
-                        
-                        pr.assign(HOMOPS, 0);
-                        
-                        for(int j=0;j<nSeqsPerOTU[i];j++){
-                            int lIndex = cumNumSeqs[i] + j;
-                            double tauValue = singleTau[seqNumber[lIndex]];
-                            int sequenceIndex = aaI[i][j];
-                            short intensity = flowDataIntI[sequenceIndex * numFlowCells + index];
-                            
-                            count += tauValue;
-                            
-                            for(int s=0;s<HOMOPS;s++){
-                                pr[s] += tauValue * pDataArray->singleLookUp[s * NUMBINS + intensity];
-                            }
-                        }
-                        
-                        maxPrIndex = uniqueFlowgrams[centroids[i] * numFlowCells + index];
-                        maxPrValue = pr[maxPrIndex];
-                        
-                        if(count > MIN_COUNT){
-                            double U = 0.0000;
-                            double norm = 0.0000;
-                            
-                            for(int s=0;s<HOMOPS;s++){
-                                norm += exp(-(pr[s] - maxPrValue));
-                            }
-                            
-                            for(int s=1;s<=maxPrIndex;s++){
-                                int value = 0;
-                                double temp = 0.0000;
-                                
-                                U += exp(-(pr[s-1]-maxPrValue))/norm;
-                                
-                                if(U>0.00){
-                                    temp = log10(U);
-                                }
-                                else{
-                                    temp = -10.1;
-                                }
-                                temp = floor(-10 * temp);
-                                value = (int)floor(temp);
-                                if(value > 100){       value = 100;    }
-                                
-                                qualities[i][base] = (int)value;
-                                base++;
-                            }
-                        }
-                        
-                        index++;
-                    }
-                }
-                
-                
-                if(otuCounts[i] > 0){
-                    qualityFile << '>' << seqNameVector[mapUniqueToSeq[i]] << endl;
-                    
-                    int j=4;   //need to get past the first four bases
-                    while(qualities[i][j] != -1){
-                        qualityFile << qualities[i][j] << ' ';
-                        j++;
-                    }
-                    qualityFile << endl;
-                }
-            }
-            qualityFile.close();
-            pDataArray->outputNames.push_back(qualityFileName);
-            /*****************************************************************************************************/
-
-           // writeSequences(thisCompositeFASTAFileName, numOTUs, numFlowCells, flowFileName, otuCounts, uniqueFlowgrams, seqNameVector, aaI, centroids);
-            if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
-            thisOutputDir = pDataArray->outputDir;
-            if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
-            string fastaFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.fasta";
-            ofstream fastaFile;
-            pDataArray->m->openOutputFile(fastaFileName, fastaFile);
-            
-            vector<string> names(numOTUs, "");
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                int index = centroids[i];
-                
-                if(otuCounts[i] > 0){
-                    fastaFile << '>' << seqNameVector[aaI[i][0]] << endl;
-                    
-                    string newSeq = "";
-                    
-                    for(int j=0;j<numFlowCells;j++){
-                        
-                        char base = pDataArray->flowOrder[j % 4];
-                        for(int k=0;k<uniqueFlowgrams[index * numFlowCells + j];k++){
-                            newSeq += base;
-                        }
-                    }
-                    
-                    fastaFile << newSeq.substr(4) << endl;
-                }
-            }
-            fastaFile.close();
-            
-            pDataArray->outputNames.push_back(fastaFileName);
-            
-            if(pDataArray->thisCompositeFASTAFileName != ""){
-                pDataArray->m->appendFiles(fastaFileName, pDataArray->thisCompositeFASTAFileName);
-            }
-
-            /*****************************************************************************************************/
-
-            //writeNames(thisCompositeNamesFileName, numOTUs, flowFileName, otuCounts, seqNameVector, aaI, nSeqsPerOTU);                               
-            if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
-            thisOutputDir = pDataArray->outputDir;
-            if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
-            string nameFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.names";
-            ofstream nameFileOut;
-            pDataArray->m->openOutputFile(nameFileName, nameFileOut);
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) { break; }
-                
-                if(otuCounts[i] > 0){
-                    nameFileOut << seqNameVector[aaI[i][0]] << '\t' << seqNameVector[aaI[i][0]];
-                    
-                    for(int j=1;j<nSeqsPerOTU[i];j++){
-                        nameFileOut << ',' << seqNameVector[aaI[i][j]];
-                    }
-                    
-                    nameFileOut << endl;
-                }
-            }
-            nameFileOut.close();
-            pDataArray->outputNames.push_back(nameFileName);
-            
-            
-            if(pDataArray->thisCompositeNameFileName != ""){
-                pDataArray->m->appendFiles(nameFileName, pDataArray->thisCompositeNameFileName);
-            }          
-            /*****************************************************************************************************/
-
-            //writeClusters(flowFileName, numOTUs, numFlowCells,otuCounts, centroids, uniqueFlowgrams, seqNameVector, aaI, nSeqsPerOTU, lengths, flowDataIntI);                        
-            if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
-            thisOutputDir = pDataArray->outputDir;
-            if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
-            string otuCountsFileName = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName)) + "shhh.counts";
-            ofstream otuCountsFile;
-            pDataArray->m->openOutputFile(otuCountsFileName, otuCountsFile);
-            
-            string bases = pDataArray->flowOrder;
-            
-            for(int i=0;i<numOTUs;i++){
-                
-                if (pDataArray->m->control_pressed) {
-                    break;
-                }
-                //output the translated version of the centroid sequence for the otu
-                if(otuCounts[i] > 0){
-                    int index = centroids[i];
-                    
-                    otuCountsFile << "ideal\t";
-                    for(int j=8;j<numFlowCells;j++){
-                        char base = bases[j % 4];
-                        for(int s=0;s<uniqueFlowgrams[index * numFlowCells + j];s++){
-                            otuCountsFile << base;
-                        }
-                    }
-                    otuCountsFile << endl;
-                    
-                    for(int j=0;j<nSeqsPerOTU[i];j++){
-                        int sequence = aaI[i][j];
-                        otuCountsFile << seqNameVector[sequence] << '\t';
-                        
-                        string newSeq = "";
-                        
-                        for(int k=0;k<lengths[sequence];k++){
-                            char base = bases[k % 4];
-                            int freq = int(0.01 * (double)flowDataIntI[sequence * numFlowCells + k] + 0.5);
-                            
-                            for(int s=0;s<freq;s++){
-                                newSeq += base;
-                                //otuCountsFile << base;
-                            }
-                        }
-                        otuCountsFile << newSeq.substr(4) << endl;
-                    }
-                    otuCountsFile << endl;
-                }
-            }
-            otuCountsFile.close();
-            pDataArray->outputNames.push_back(otuCountsFileName);
-            /*****************************************************************************************************/
-
-            //writeGroups(flowFileName, numSeqs, seqNameVector);                                               
-            if (pDataArray->m->control_pressed) { break; }
-            /*****************************************************************************************************/
-            thisOutputDir = pDataArray->outputDir;
-            if (pDataArray->outputDir == "") {  thisOutputDir += pDataArray->m->hasPath(flowFileName);  }
-            string fileRoot = thisOutputDir + pDataArray->m->getRootName(pDataArray->m->getSimpleName(flowFileName));
-            string groupFileName = fileRoot + "shhh.groups";
-            ofstream groupFile;
-            pDataArray->m->openOutputFile(groupFileName, groupFile);
-            
-            for(int i=0;i<numSeqs;i++){
-                if (pDataArray->m->control_pressed) { break; }
-                groupFile << seqNameVector[i] << '\t' << fileRoot << endl;
-            }
-            groupFile.close();
-            pDataArray->outputNames.push_back(groupFileName);
-            /*****************************************************************************************************/
-
-            pDataArray->m->mothurOut("Total time to process " + flowFileName + ":\t" + toString(time(NULL) - begTime) + '\t' + toString((clock() - begClock)/(double)CLOCKS_PER_SEC) + '\n');
-               }
-               
-        if (pDataArray->m->control_pressed) { for (int i = 0; i < pDataArray->outputNames.size(); i++) { pDataArray->m->mothurRemove(pDataArray->outputNames[i]); } return 0; }
-        
-        return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ShhherCommand", "ShhhFlowsThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-#endif
-
diff --git a/shhhseqscommand.cpp b/shhhseqscommand.cpp
deleted file mode 100644 (file)
index 5c6359e..0000000
+++ /dev/null
@@ -1,725 +0,0 @@
-/*
- *  shhhseqscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "shhhseqscommand.h"
-
-
-
-//**********************************************************************************************************************
-vector<string> ShhhSeqsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               CommandParameter psigma("sigma", "Number", "", "0.01", "", "", "",false,false); parameters.push_back(psigma);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string ShhhSeqsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The shhh.seqs command reads a fasta and name file and ....\n";
-               helpString += "The shhh.seqs command parameters are fasta, name, group, sigma and processors.\n";
-               helpString += "The fasta parameter allows you to enter the fasta file containing your sequences, and is required, unless you have a valid current fasta file. \n";
-               helpString += "The name parameter allows you to provide a name file associated with your fasta file. It is required. \n";
-               helpString += "The group parameter allows you to provide a group file.  When checking sequences, only sequences from the same group as the query sequence will be used as the reference. \n";
-               helpString += "The processors parameter allows you to specify how many processors you would like to use.  The default is 1. \n";
-               helpString += "The sigma parameter ....  The default is 0.01. \n";
-               helpString += "The shhh.seqs command should be in the following format: \n";
-               helpString += "shhh.seqs(fasta=yourFastaFile, name=yourNameFile) \n";
-               helpString += "Example: shhh.seqs(fasta=AD.align, name=AD.names) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFastaFile).\n";       
-               return helpString;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-ShhhSeqsCommand::ShhhSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["map"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "ShhhSeqsCommand");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-ShhhSeqsCommand::ShhhSeqsCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string, string>::iterator it2 = parameters.begin(); it2 != parameters.end(); it2++) { 
-                               if (validParameter.isValidParameter(it2->first, myArray, it2->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["map"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not found") {                                 
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (fastafile == "not open") { abort = true; }     
-                       else { m->setFastaFile(fastafile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not found") {                  
-                               namefile = m->getNameFile(); 
-                               if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current namefile and the name parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }
-                       else if (namefile == "not open") { namefile =  ""; abort = true; }      
-                       else {  m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not found") { groupfile =  "";   }
-                       else if (groupfile == "not open") { abort = true; groupfile =  ""; }    
-                       else {   m->setGroupFile(groupfile);  }
-                       
-                       string temp     = validParameter.validFile(parameters, "sigma", false);         if(temp == "not found"){        temp = "0.01"; }
-                       m->mothurConvert(temp, sigma); 
-                       sigma = 1/sigma;
-            
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "ShhhSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ShhhSeqsCommand::execute() {
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (outputDir == "") { outputDir = m->hasPath(fastafile);  }//if user entered a file with a path then preserve it                               
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "shhh.fasta";
-               string nameFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + "shhh.names";
-               string mapFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + "shhh.map";
-               
-               if (groupfile != "") {
-                       //Parse sequences by group
-                       SequenceParser parser(groupfile, fastafile, namefile);
-                       vector<string> groups = parser.getNamesOfGroups();
-                       
-                       if (m->control_pressed) {  return 0; }
-                       
-                       //clears files
-                       ofstream out, out1, out2;
-                       m->openOutputFile(outputFileName, out); out.close(); 
-                       m->openOutputFile(nameFileName, out1); out1.close();
-                       mapFileName = outputDir + m->getRootName(m->getSimpleName(fastafile))  + "shhh.";
-                       
-                       vector<string> mapFileNames;
-                       if(processors == 1)     {       mapFileNames = driverGroups(parser, outputFileName, nameFileName, mapFileName, 0, groups.size(), groups);       }
-                       else                            {       mapFileNames = createProcessesGroups(parser, outputFileName, nameFileName, mapFileName, groups);                        }
-                       
-                       if (m->control_pressed) {    return 0;  }       
-                       
-                       for (int j = 0; j < mapFileNames.size(); j++) { outputNames.push_back(mapFileNames[j]); outputTypes["map"].push_back(mapFileNames[j]); }
-                       
-                       //deconvolute results by running unique.seqs
-                       deconvoluteResults(outputFileName, nameFileName);
-                       
-                       if (m->control_pressed) {   return 0;   }                               
-                       
-               }else{  
-                       vector<string> sequences;
-                       vector<string> uniqueNames;
-                       vector<string> redundantNames;
-                       vector<int> seqFreq;
-                       
-                       seqNoise noise;
-                       correctDist* correct = new correctDist(processors);
-                       
-                       //reads fasta and name file and loads them in order
-                       readData(correct, noise, sequences, uniqueNames, redundantNames, seqFreq);
-                       if (m->control_pressed) { return 0; }
-                       
-                       //calc distances for cluster
-                       string distFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + "shhh.dist";
-                       correct->execute(distFileName);
-                       delete correct;
-                       
-                       if (m->control_pressed) { m->mothurRemove(distFileName); return 0; }
-                       
-                       driver(noise, sequences, uniqueNames, redundantNames, seqFreq, distFileName, outputFileName, nameFileName, mapFileName); 
-                       outputNames.push_back(mapFileName); outputTypes["map"].push_back(mapFileName);
-               }
-               
-               if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) {        m->mothurRemove(outputNames[j]);        } return 0; }
-               
-               outputNames.push_back(outputFileName); outputTypes["fasta"].push_back(outputFileName);
-               outputNames.push_back(nameFileName); outputTypes["name"].push_back(nameFileName);
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }       
-               m->mothurOutEndLine();
-               
-               //set accnos file as new current accnosfile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ShhhSeqsCommand::readData(correctDist* correct, seqNoise& noise, vector<string>& seqs, vector<string>& uNames, vector<string>& rNames, vector<int>& freq) {
-       try {
-               map<string, string> nameMap; 
-               map<string, string>::iterator it;
-               m->readNames(namefile, nameMap);
-               bool error = false;
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               while (!in.eof()) {
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       Sequence seq(in); m->gobble(in);
-                       
-                       if (seq.getName() != "") {
-                               correct->addSeq(seq.getName(), seq.getAligned());
-                               
-                               it = nameMap.find(seq.getName());
-                               if (it != nameMap.end()) {
-                                       noise.addSeq(seq.getAligned(), seqs);
-                                       noise.addRedundantName(it->first, it->second, uNames, rNames, freq);
-                               }else {
-                                       m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file and not in your namefile, please correct.");
-                                       error = true;
-                               }
-                       }
-               }
-               in.close();
-               
-               if (error) { m->control_pressed = true; }
-               
-               return seqs.size();
-               
-       }catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "readData");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ShhhSeqsCommand::loadData(correctDist* correct, seqNoise& noise, vector<string>& seqs, vector<string>& uNames, vector<string>& rNames, vector<int>& freq, map<string, string>& nameMap, vector<Sequence>& sequences) {
-       try {
-               bool error = false;
-               map<string, string>::iterator it;
-               
-               for (int i = 0; i < sequences.size(); i++) {
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       if (sequences[i].getName() != "") {
-                               correct->addSeq(sequences[i].getName(), sequences[i].getAligned());
-                               
-                               it = nameMap.find(sequences[i].getName());
-                               if (it != nameMap.end()) {
-                                       noise.addSeq(sequences[i].getAligned(), seqs);
-                                       noise.addRedundantName(it->first, it->second, uNames, rNames, freq);
-                               }else {
-                                       m->mothurOut("[ERROR]: " + sequences[i].getName() + " is in your fasta file and not in your namefile, please correct.");
-                                       error = true;
-                               }
-                       }
-               }
-                               
-               if (error) { m->control_pressed = true; }
-               
-               return seqs.size();
-               
-       }catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "loadData");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<string> ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, string newFName, string newNName, string newMName, vector<string> groups) {
-       try {
-               
-               vector<int> processIDS;
-               int process = 1;
-               vector<string> mapfileNames;
-               
-               //sanity check
-               if (groups.size() < processors) { processors = groups.size(); }
-               
-               //divide the groups between the processors
-               vector<linePair> lines;
-               int numGroupsPerProcessor = groups.size() / processors;
-               for (int i = 0; i < processors; i++) {
-                       int startIndex =  i * numGroupsPerProcessor;
-                       int endIndex = (i+1) * numGroupsPerProcessor;
-                       if(i == (processors - 1)){      endIndex = groups.size();       }
-                       lines.push_back(linePair(startIndex, endIndex));
-               }
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)         
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               mapfileNames = driverGroups(parser, newFName + toString(getpid()) + ".temp", newNName + toString(getpid()) + ".temp", newMName, lines[process].start, lines[process].end, groups);
-                               
-                               //pass filenames to parent
-                               ofstream out;
-                               string tempFile = newMName + toString(getpid()) + ".temp";
-                               m->openOutputFile(tempFile, out);
-                               out << mapfileNames.size() << endl;
-                               for (int i = 0; i < mapfileNames.size(); i++) {
-                                       out << mapfileNames[i] << endl;
-                               }
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do my part
-               mapfileNames = driverGroups(parser, newFName, newNName, newMName, lines[0].start, lines[0].end, groups);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       ifstream in;
-                       string tempFile =  newMName + toString(processIDS[i]) + ".temp";
-                       m->openInputFile(tempFile, in);
-                       if (!in.eof()) { 
-                               int tempNum = 0; in >> tempNum;  m->gobble(in);
-                               for (int j = 0; j < tempNum; j++) {
-                                       string filename;
-                                       in >> filename; m->gobble(in);
-                                       mapfileNames.push_back(filename);
-                               }
-                       }
-                       in.close(); m->mothurRemove(tempFile);
-                       
-               }
-#else
-               
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the shhhseqsData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<shhhseqsData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=1; i<processors; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = toString(i) + ".temp";
-
-                       shhhseqsData* tempShhhseqs = new shhhseqsData(fastafile, namefile, groupfile, (newFName+extension), (newNName+extension), newMName, groups, m, lines[i].start, lines[i].end, sigma, i);
-                       pDataArray.push_back(tempShhhseqs);
-                       processIDS.push_back(i);
-                       
-                       //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i-1] = CreateThread(NULL, 0, MyShhhSeqsThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-               }
-               
-               
-               //using the main process as a worker saves time and memory
-               mapfileNames = driverGroups(parser, newFName, newNName, newMName, lines[0].start, lines[0].end, groups);
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       for (int j = 0; j < pDataArray[i]->mapfileNames.size(); j++) {
-                               mapfileNames.push_back(pDataArray[i]->mapfileNames[j]);
-                       }
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-#endif         
-               
-               //append output files
-               for(int i=0;i<processIDS.size();i++){
-                       m->appendFiles((newFName + toString(processIDS[i]) + ".temp"), newFName);
-                       m->mothurRemove((newFName + toString(processIDS[i]) + ".temp"));
-                       
-                       m->appendFiles((newNName + toString(processIDS[i]) + ".temp"), newNName);
-                       m->mothurRemove((newNName + toString(processIDS[i]) + ".temp"));
-               }
-               
-               return mapfileNames;    
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "createProcessesGroups");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-vector<string> ShhhSeqsCommand::driverGroups(SequenceParser& parser, string newFFile, string newNFile, string newMFile, int start, int end, vector<string> groups){
-       try {
-               
-               vector<string> mapFileNames;
-               
-               for (int i = start; i < end; i++) {
-                       
-                       start = time(NULL);
-                       
-                       if (m->control_pressed) {  return mapFileNames; }
-                       
-                       m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[i] + ":"); m->mothurOutEndLine();
-                       
-                       map<string, string> thisNameMap;
-                       thisNameMap = parser.getNameMap(groups[i]); 
-                       vector<Sequence> thisSeqs = parser.getSeqs(groups[i]);
-                       
-                       vector<string> sequences;
-                       vector<string> uniqueNames;
-                       vector<string> redundantNames;
-                       vector<int> seqFreq;
-                       
-                       seqNoise noise;
-                       correctDist* correct = new correctDist(1); //we use one processor since we already split up the work load.
-                       
-                       //load this groups info in order
-                       loadData(correct, noise, sequences, uniqueNames, redundantNames, seqFreq, thisNameMap, thisSeqs);
-                       if (m->control_pressed) { return mapFileNames; }
-                       
-                       //calc distances for cluster
-                       string distFileName = outputDir + m->getRootName(m->getSimpleName(fastafile)) + groups[i] + ".shhh.dist";
-                       correct->execute(distFileName);
-                       delete correct;
-                       
-                       if (m->control_pressed) { m->mothurRemove(distFileName); return mapFileNames; }
-                       
-                       driver(noise, sequences, uniqueNames, redundantNames, seqFreq, distFileName, newFFile+groups[i], newNFile+groups[i], newMFile+groups[i]+".map"); 
-                       
-                       if (m->control_pressed) { return mapFileNames; }
-                       
-                       m->appendFiles(newFFile+groups[i], newFFile); m->mothurRemove(newFFile+groups[i]);
-                       m->appendFiles(newNFile+groups[i], newNFile); m->mothurRemove(newNFile+groups[i]);
-                       mapFileNames.push_back(newMFile+groups[i]+".map");
-                       
-                       m->mothurOut("It took " + toString(time(NULL) - start) + " secs to process group " + groups[i] + "."); m->mothurOutEndLine(); 
-               }
-               
-               return mapFileNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "driverGroups");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int ShhhSeqsCommand::driver(seqNoise& noise, 
-                                                       vector<string>& sequences, 
-                                                       vector<string>& uniqueNames, 
-                                                       vector<string>& redundantNames, 
-                                                       vector<int>& seqFreq, 
-                                                       string distFileName, string outputFileName, string nameFileName, string mapFileName) {
-       try {
-               double cutOff = 0.08;
-               int minIter = 10;
-               int maxIter = 1000;
-               double minDelta = 1e-6;
-               int numIters = 0;
-               double maxDelta = 1e6;
-               int numSeqs = sequences.size();
-                               
-               //run cluster command
-               string inputString = "phylip=" + distFileName + ", method=furthest, cutoff=0.08";
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               m->mothurOut("Running command: cluster(" + inputString + ")"); m->mothurOutEndLine(); 
-               
-               Command* clusterCommand = new ClusterCommand(inputString);
-               clusterCommand->execute();
-               
-               map<string, vector<string> > filenames = clusterCommand->getOutputFiles();
-               string listFileName = filenames["list"][0];
-               string rabundFileName = filenames["rabund"][0]; m->mothurRemove(rabundFileName);
-               string sabundFileName = filenames["sabund"][0]; m->mothurRemove(sabundFileName);
-       
-               delete clusterCommand;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               
-               if (m->control_pressed) { m->mothurRemove(distFileName); m->mothurRemove(listFileName); return 0; }
-               
-               vector<double> distances(numSeqs * numSeqs);
-               noise.getDistanceData(distFileName, distances);
-               m->mothurRemove(distFileName); 
-               if (m->control_pressed) { m->mothurRemove(listFileName); return 0; }
-               
-               vector<int> otuData(numSeqs);
-               vector<int> otuFreq;
-               vector<vector<int> > otuBySeqLookUp;
-               noise.getListData(listFileName, cutOff, otuData, otuFreq, otuBySeqLookUp);
-               m->mothurRemove(listFileName);
-               if (m->control_pressed) { return 0; }
-               
-               int numOTUs = otuFreq.size();
-               
-               vector<double> weights(numOTUs, 0);
-               vector<int> change(numOTUs, 1);
-               vector<int> centroids(numOTUs, -1);
-               vector<int> cumCount(numOTUs, 0);
-               
-               vector<double> tau(numSeqs, 1);
-               vector<int> anP(numSeqs, 0);
-               vector<int> anI(numSeqs, 0);
-               vector<int> anN(numSeqs, 0);
-               vector<vector<int> > aanI = otuBySeqLookUp;
-               
-               while(numIters < minIter || ((maxDelta > minDelta) && (numIters < maxIter))){
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       noise.updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount); if (m->control_pressed) { return 0; }
-                       maxDelta = noise.calcNewWeights(weights, seqFreq, anI, cumCount, anP, otuFreq, tau);  if (m->control_pressed) { return 0; }
-                       
-                       noise.calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau); if (m->control_pressed) { return 0; }
-                       noise.checkCentroids(weights, centroids); if (m->control_pressed) { return 0; }
-                        
-                       otuFreq.assign(numOTUs, 0);
-                       
-                       int total = 0;
-                       
-                       for(int i=0;i<numSeqs;i++){
-                               if (m->control_pressed) { return 0; }
-                               
-                               double offset = 1e6;
-                               double norm = 0.0000;
-                               double minWeight = 0.1;
-                               vector<double> currentTau(numOTUs);
-                               
-                               for(int j=0;j<numOTUs;j++){
-                                       if (m->control_pressed) { return 0; }
-                                       if(weights[j] > minWeight && distances[i * numSeqs+centroids[j]] < offset){
-                                               offset = distances[i * numSeqs+centroids[j]];
-                                       }
-                               }
-                               
-                               for(int j=0;j<numOTUs;j++){
-                                       if (m->control_pressed) { return 0; }
-                                       if(weights[j] > minWeight){
-                                               currentTau[j] = exp(sigma * (-distances[(i * numSeqs + centroids[j])] + offset)) * weights[j];
-                                               norm += currentTau[j];
-                                       }
-                                       else{
-                                               currentTau[j] = 0.0000;
-                                       }
-                               }                       
-                               
-                               for(int j=0;j<numOTUs;j++){
-                                       if (m->control_pressed) { return 0; }
-                                       currentTau[j] /= norm;
-                               }
-                               
-                               for(int j=0;j<numOTUs;j++){
-                                       if (m->control_pressed) { return 0; }
-                                       
-                                       if(currentTau[j] > 1.0e-4){
-                                               int oldTotal = total;
-                                               total++;
-                                               
-                                               tau.resize(oldTotal+1);
-                                               tau[oldTotal] = currentTau[j];
-                                               otuBySeqLookUp[j][otuFreq[j]] = oldTotal;
-                                               aanI[j][otuFreq[j]] = i;
-                                               otuFreq[j]++;
-                                               
-                                       }
-                               }
-                               
-                               anP.resize(total);
-                               anI.resize(total);
-                       }
-                       
-                       numIters++;
-               }
-               
-               noise.updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount);  if (m->control_pressed) { return 0; }
-               
-               vector<double> percentage(numSeqs);
-               noise.setUpOTUData(otuData, percentage, cumCount, tau, otuFreq, anP, anI);  if (m->control_pressed) { return 0; }
-               noise.finishOTUData(otuData, otuFreq, anP, anI, cumCount, otuBySeqLookUp, aanI, tau);  if (m->control_pressed) { return 0; }
-               
-               change.assign(numOTUs, 1);
-               noise.calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau); if (m->control_pressed) { return 0; }
-               
-               
-               vector<int> finalTau(numOTUs, 0);
-               for(int i=0;i<numSeqs;i++){
-                       if (m->control_pressed) { return 0; }
-                       finalTau[otuData[i]] += int(seqFreq[i]);
-               }
-               
-               noise.writeOutput(outputFileName, nameFileName, mapFileName, finalTau, centroids, otuData, sequences, uniqueNames, redundantNames, seqFreq, distances);
-               
-               return 0;
-               
-       }catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "driver");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int ShhhSeqsCommand::deconvoluteResults(string fastaFile, string nameFile){
-       try {
-               m->mothurOutEndLine(); m->mothurOut("Deconvoluting results:"); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               //use unique.seqs to create new name and fastafile
-               string inputString = "fasta=" + fastaFile + ", name=" + nameFile;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-               m->mothurCalling = true;
-        
-               Command* uniqueCommand = new DeconvoluteCommand(inputString);
-               uniqueCommand->execute();
-               
-               map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-               
-               delete uniqueCommand;
-               m->mothurCalling = false;
-               m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-               
-               string newnameFile = filenames["name"][0];
-               string newfastaFile = filenames["fasta"][0];
-               
-               m->mothurRemove(fastaFile); rename(newfastaFile.c_str(), fastaFile.c_str()); 
-               if (nameFile != newnameFile) { m->mothurRemove(nameFile); rename(newnameFile.c_str(), nameFile.c_str()); }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ShhhSeqsCommand", "deconvoluteResults");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
-
diff --git a/shhhseqscommand.h b/shhhseqscommand.h
deleted file mode 100644 (file)
index 7174ac7..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-#ifndef SHHHSEQSCOMMAND_H
-#define SHHHSEQSCOMMAND_H
-
-/*
- *  shhhseqscommand.h
- *  Mothur
- *
- *  Created by westcott on 11/8/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "myseqdist.h"
-#include "seqnoise.h"
-#include "sequenceparser.h"
-#include "deconvolutecommand.h"
-#include "clustercommand.h"
-
-//**********************************************************************************************************************
-
-class ShhhSeqsCommand : public Command {
-       
-public:
-       ShhhSeqsCommand(string);
-       ShhhSeqsCommand();
-       ~ShhhSeqsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "shhh.seqs";   }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Shhh.seqs"; }
-       string getDescription()         { return "shhh.seqs"; }
-       
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }          
-       
-private:
-       
-       struct linePair {
-               int start;
-               int end;
-               linePair(int i, int j) : start(i), end(j) {}
-       };
-       
-       bool abort;
-       string outputDir, fastafile, namefile, groupfile;
-       int processors;
-       double sigma;
-       vector<string> outputNames;
-       
-       int readData(correctDist*, seqNoise&, vector<string>&, vector<string>&, vector<string>&, vector<int>&);
-       int loadData(correctDist*, seqNoise&, vector<string>&, vector<string>&, vector<string>&, vector<int>&, map<string, string>&, vector<Sequence>&);
-
-       int driver(seqNoise&, vector<string>&, vector<string>&, vector<string>&, vector<int>&, string, string, string, string);
-       vector<string> driverGroups(SequenceParser&, string, string, string, int, int, vector<string>);
-       vector<string> createProcessesGroups(SequenceParser&, string, string, string, vector<string>);
-       int deconvoluteResults(string, string);
-
-
-
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct shhhseqsData {
-       string fastafile; 
-       string namefile; 
-       string groupfile;
-       string newFName, newNName, newMName;
-       MothurOut* m;
-       int start;
-       int end;
-       int sigma, threadID;
-       vector<string> groups;
-       vector<string> mapfileNames;
-       
-       shhhseqsData(){}
-       shhhseqsData(string f, string n, string g, string nff,  string nnf, string nmf, vector<string> gr, MothurOut* mout, int st, int en, int s, int tid) {
-               fastafile = f;
-               namefile = n;
-               groupfile = g;
-               newFName = nff;
-               newNName = nnf;
-               newMName = nmf;
-               m = mout;
-               start = st;
-               end = en;
-               sigma = s;
-               threadID = tid;
-               groups = gr;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyShhhSeqsThreadFunction(LPVOID lpParam){ 
-       shhhseqsData* pDataArray;
-       pDataArray = (shhhseqsData*)lpParam;
-       
-       try {
-               
-               //parse fasta and name file by group
-               SequenceParser parser(pDataArray->groupfile, pDataArray->fastafile, pDataArray->namefile);
-                                               
-               //precluster each group
-               for (int k = pDataArray->start; k < pDataArray->end; k++) {
-                       
-                       int start = time(NULL);
-                       
-                       if (pDataArray->m->control_pressed) {  return 0; }
-                       
-                       pDataArray->m->mothurOutEndLine(); pDataArray->m->mothurOut("Processing group " + pDataArray->groups[k] + ":"); pDataArray->m->mothurOutEndLine();
-
-                       map<string, string> thisNameMap;
-                       thisNameMap = parser.getNameMap(pDataArray->groups[k]); 
-                       vector<Sequence> thisSeqs = parser.getSeqs(pDataArray->groups[k]);
-                       
-                       if (pDataArray->m->control_pressed) {  return 0; }
-                       
-                       vector<string> sequences;
-                       vector<string> uniqueNames;
-                       vector<string> redundantNames;
-                       vector<int> seqFreq;
-                       
-                       seqNoise noise;
-                       correctDist* correct = new correctDist(1); //we use one processor since we already split up the work load.
-                       
-                       //load this groups info in order
-                       //loadData(correct, noise, sequences, uniqueNames, redundantNames, seqFreq, thisNameMap, thisSeqs);
-                       //////////////////////////////////////////////////////////////////////////////////////////////////
-                       bool error = false;
-                       map<string, string>::iterator it;
-                       
-                       for (int i = 0; i < thisSeqs.size(); i++) {
-                               
-                               if (pDataArray->m->control_pressed) { return 0; }
-                               
-                               if (thisSeqs[i].getName() != "") {
-                                       correct->addSeq(thisSeqs[i].getName(), thisSeqs[i].getAligned());
-                                       
-                                       it = thisNameMap.find(thisSeqs[i].getName());
-                                       if (it != thisNameMap.end()) {
-                                               noise.addSeq(thisSeqs[i].getAligned(), sequences);
-                                               noise.addRedundantName(it->first, it->second, uniqueNames, redundantNames, seqFreq);
-                                       }else {
-                                               pDataArray->m->mothurOut("[ERROR]: " + thisSeqs[i].getName() + " is in your fasta file and not in your namefile, please correct.");
-                                               error = true;
-                                       }
-                               }
-                       }
-                       
-                       if (error) { return 0; }
-                       //////////////////////////////////////////////////////////////////////////////////////////////////
-                       
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       //calc distances for cluster
-                       string distFileName = pDataArray->m->getRootName(pDataArray->m->getSimpleName(pDataArray->fastafile)) + pDataArray->groups[k] + ".shhh.dist";
-                       correct->execute(distFileName);
-                       delete correct;
-                       
-                       if (pDataArray->m->control_pressed) { pDataArray->m->mothurRemove(distFileName); return 0; }
-                       
-                       //driver(noise, sequences, uniqueNames, redundantNames, seqFreq, distFileName, newFFile+groups[i], newNFile+groups[i], newMFile+groups[i]+".map"); 
-                       ///////////////////////////////////////////////////////////////////////////////////////////////////
-                       double cutOff = 0.08;
-                       int minIter = 10;
-                       int maxIter = 1000;
-                       double minDelta = 1e-6;
-                       int numIters = 0;
-                       double maxDelta = 1e6;
-                       int numSeqs = sequences.size();
-                       
-                       //run cluster command
-                       string inputString = "phylip=" + distFileName + ", method=furthest, cutoff=0.08";
-                       pDataArray->m->mothurOut("/******************************************/"); pDataArray->m->mothurOutEndLine(); 
-                       pDataArray->m->mothurOut("Running command: cluster(" + inputString + ")"); pDataArray->m->mothurOutEndLine(); 
-                       
-                       Command* clusterCommand = new ClusterCommand(inputString);
-                       clusterCommand->execute();
-                       
-                       map<string, vector<string> > filenames = clusterCommand->getOutputFiles();
-                       string listFileName = filenames["list"][0];
-                       string rabundFileName = filenames["rabund"][0]; pDataArray->m->mothurRemove(rabundFileName);
-                       string sabundFileName = filenames["sabund"][0]; pDataArray->m->mothurRemove(sabundFileName);
-                       
-                       delete clusterCommand;
-                       pDataArray->m->mothurOut("/******************************************/"); pDataArray->m->mothurOutEndLine(); 
-                       
-                       if (pDataArray->m->control_pressed) { pDataArray->m->mothurRemove(distFileName); pDataArray->m->mothurRemove(listFileName); return 0; }
-                       
-                       vector<double> distances(numSeqs * numSeqs);
-                       noise.getDistanceData(distFileName, distances);
-                       pDataArray->m->mothurRemove(distFileName); 
-                       if (pDataArray->m->control_pressed) { pDataArray->m->mothurRemove(listFileName); return 0; }
-                       
-                       vector<int> otuData(numSeqs);
-                       vector<int> otuFreq;
-                       vector<vector<int> > otuBySeqLookUp;
-                       noise.getListData(listFileName, cutOff, otuData, otuFreq, otuBySeqLookUp);
-                       pDataArray->m->mothurRemove(listFileName);
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       int numOTUs = otuFreq.size();
-                       
-                       vector<double> weights(numOTUs, 0);
-                       vector<int> change(numOTUs, 1);
-                       vector<int> centroids(numOTUs, -1);
-                       vector<int> cumCount(numOTUs, 0);
-                       
-                       vector<double> tau(numSeqs, 1);
-                       vector<int> anP(numSeqs, 0);
-                       vector<int> anI(numSeqs, 0);
-                       vector<int> anN(numSeqs, 0);
-                       vector<vector<int> > aanI = otuBySeqLookUp;
-                       
-                       while(numIters < minIter || ((maxDelta > minDelta) && (numIters < maxIter))){
-                               
-                               if (pDataArray->m->control_pressed) { return 0; }
-                               
-                               noise.updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount); if (pDataArray->m->control_pressed) { return 0; }
-                               maxDelta = noise.calcNewWeights(weights, seqFreq, anI, cumCount, anP, otuFreq, tau);  if (pDataArray->m->control_pressed) { return 0; }
-                               
-                               noise.calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau); if (pDataArray->m->control_pressed) { return 0; }
-                               noise.checkCentroids(weights, centroids); if (pDataArray->m->control_pressed) { return 0; }
-                               
-                               otuFreq.assign(numOTUs, 0);
-                               
-                               int total = 0;
-                               
-                               for(int i=0;i<numSeqs;i++){
-                                       if (pDataArray->m->control_pressed) { return 0; }
-                                       
-                                       double offset = 1e6;
-                                       double norm = 0.0000;
-                                       double minWeight = 0.1;
-                                       vector<double> currentTau(numOTUs);
-                                       
-                                       for(int j=0;j<numOTUs;j++){
-                                               if (pDataArray->m->control_pressed) { return 0; }
-                                               if(weights[j] > minWeight && distances[i * numSeqs+centroids[j]] < offset){
-                                                       offset = distances[i * numSeqs+centroids[j]];
-                                               }
-                                       }
-                                       
-                                       for(int j=0;j<numOTUs;j++){
-                                               if (pDataArray->m->control_pressed) { return 0; }
-                                               if(weights[j] > minWeight){
-                                                       currentTau[j] = exp(pDataArray->sigma * (-distances[(i * numSeqs + centroids[j])] + offset)) * weights[j];
-                                                       norm += currentTau[j];
-                                               }
-                                               else{
-                                                       currentTau[j] = 0.0000;
-                                               }
-                                       }                       
-                                       
-                                       for(int j=0;j<numOTUs;j++){
-                                               if (pDataArray->m->control_pressed) { return 0; }
-                                               currentTau[j] /= norm;
-                                       }
-                                       
-                                       for(int j=0;j<numOTUs;j++){
-                                               if (pDataArray->m->control_pressed) { return 0; }
-                                               
-                                               if(currentTau[j] > 1.0e-4){
-                                                       int oldTotal = total;
-                                                       total++;
-                                                       
-                                                       tau.resize(oldTotal+1);
-                                                       tau[oldTotal] = currentTau[j];
-                                                       otuBySeqLookUp[j][otuFreq[j]] = oldTotal;
-                                                       aanI[j][otuFreq[j]] = i;
-                                                       otuFreq[j]++;
-                                                       
-                                               }
-                                       }
-                                       
-                                       anP.resize(total);
-                                       anI.resize(total);
-                               }
-                               
-                               numIters++;
-                       }
-                       
-                       noise.updateOTUCountData(otuFreq, otuBySeqLookUp, aanI, anP, anI, cumCount);  if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       vector<double> percentage(numSeqs);
-                       noise.setUpOTUData(otuData, percentage, cumCount, tau, otuFreq, anP, anI);  if (pDataArray->m->control_pressed) { return 0; }
-                       noise.finishOTUData(otuData, otuFreq, anP, anI, cumCount, otuBySeqLookUp, aanI, tau);  if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       change.assign(numOTUs, 1);
-                       noise.calcCentroids(anI, anP, change, centroids, cumCount, distances, seqFreq, otuFreq, tau); if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       
-                       vector<int> finalTau(numOTUs, 0);
-                       for(int i=0;i<numSeqs;i++){
-                               if (pDataArray->m->control_pressed) { return 0; }
-                               finalTau[otuData[i]] += int(seqFreq[i]);
-                       }
-                       
-                       noise.writeOutput(pDataArray->newFName+pDataArray->groups[k], pDataArray->newNName+pDataArray->groups[k], pDataArray->newMName+pDataArray->groups[k]+".map", finalTau, centroids, otuData, sequences, uniqueNames, redundantNames, seqFreq, distances);
-                       
-                       ///////////////////////////////////////////////////////////////////////////////////////////////////
-                       
-                       if (pDataArray->m->control_pressed) { return 0; }
-                       
-                       pDataArray->m->appendFiles(pDataArray->newFName+pDataArray->groups[k], pDataArray->newFName); pDataArray->m->mothurRemove(pDataArray->newFName+pDataArray->groups[k]);
-                       pDataArray->m->appendFiles(pDataArray->newNName+pDataArray->groups[k], pDataArray->newNName); pDataArray->m->mothurRemove(pDataArray->newNName+pDataArray->groups[k]);
-                       pDataArray->mapfileNames.push_back(pDataArray->newMName+pDataArray->groups[k]+".map");
-                       
-                       pDataArray->m->mothurOut("It took " + toString(time(NULL) - start) + " secs to process group " + pDataArray->groups[k] + "."); pDataArray->m->mothurOutEndLine(); 
-               }
-               
-               return 0;
-               
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "ShhhSeqsCommand", "MyShhhSeqsThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-/**************************************************************************************************/
-
-#endif
diff --git a/simpson.cpp b/simpson.cpp
deleted file mode 100644 (file)
index edc35bd..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- *  simpson.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "simpson.h"
-
-/***********************************************************************/
-
-EstOutput Simpson::getValues(SAbundVector* rank){
-       try {
-               //vector<double> simpsonData(3,0);
-               data.resize(3,0);
-               double simpson = 0.0000;
-               double ci = 0;
-       
-               double maxRank = (double)rank->getMaxRank();
-               double sampled = (double)rank->getNumSeqs();
-               double sobs = (double)rank->getNumBins();
-       
-               double firstTerm = 0;
-               double secondTerm = 0;
-       
-               if(sobs != 0){
-                       double simnum=0.0000;
-               
-                       for(unsigned long long i=1;i<=maxRank;i++){
-                               simnum += (double)(rank->get(i)*i*(i-1));
-                       }
-                       
-                       simpson = simnum / (sampled*(sampled-1));
-               
-                       for(unsigned long long i=1;i<=maxRank;i++){
-                               double piI = (double) i / (double)sampled;
-                               firstTerm += rank->get(i) * pow(piI, 3);
-                               secondTerm += rank->get(i) * pow(piI, 2);
-                       }
-               
-                       double var = (4.0 / sampled) * (firstTerm - secondTerm*secondTerm);
-                       ci = 1.95 * pow(var, 0.5);
-               }
-       
-               double simpsonlci = simpson - ci;
-               double simpsonhci = simpson + ci;
-               
-               data[0] = simpson;
-               data[1] = simpsonlci;
-               data[2] = simpsonhci;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               if (isnan(data[1]) || isinf(data[1])) { data[1] = 0; }
-               if (isnan(data[2]) || isinf(data[2])) { data[2] = 0; }
-       
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Simpson", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/simpson.h b/simpson.h
deleted file mode 100644 (file)
index d3d93a7..0000000
--- a/simpson.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SIMPSON_H
-#define SIMPSON_H
-/*
- *  simpson.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Simpson estimator on single group. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Simpson : public Calculator  {
-
-public:
-       Simpson() : Calculator("simpson", 3, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Simpson"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/simpsoneven.cpp b/simpsoneven.cpp
deleted file mode 100644 (file)
index e34534a..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- *  simpsoneven.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "simpsoneven.h"
-#include "invsimpson.h"
-
-/***********************************************************************/
-
-EstOutput SimpsonEven::getValues(SAbundVector* rank){
-       try {
-               data.resize(1,0);
-
-               InvSimpson* simp = new InvSimpson();
-               vector<double> invSimpData = simp->getValues(rank);
-               
-               data[0] = invSimpData[0] / double(rank->getNumBins());
-               
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SimpsonEven", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/simpsoneven.h b/simpsoneven.h
deleted file mode 100644 (file)
index b793e54..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef SIMPSONEVEN_H
-#define SIMPSONEVEN_H
-
-/*
- *  simpsoneven.h
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SimpsonEven : public Calculator  {
-       
-public:
-       SimpsonEven() : Calculator("simpsoneven", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Simpsoneven"; }
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/sinerp.f b/sinerp.f
deleted file mode 100644 (file)
index 061aee1..0000000
--- a/sinerp.f
+++ /dev/null
@@ -1,98 +0,0 @@
-C Output from Public domain Ratfor, version 1.0
-      subroutine sinerp(abd,ld4,nk,p1ip,p2ip,ldnk,flag)
-c
-C Purpose :  Computes Inner Products between columns of L^{-1}
-C            where L = abd is a Banded Matrix with 3 subdiagonals
-
-C The algorithm works in two passes:
-C
-C               Pass 1 computes (cj,ck) k=j,j-1,j-2,j-3 ;  j=nk, .. 1
-C               Pass 2 computes (cj,ck) k <= j-4  (If flag == 1 ).
-C
-C               A refinement of Elden's trick is used.
-c Args
-      integer ld4,nk,ldnk,flag
-      DOUBLE precision abd(ld4,nk),p1ip(ld4,nk), p2ip(ldnk,nk)
-c Locals
-      integer i,j,k
-      DOUBLE precision  wjm3(3),wjm2(2),wjm1(1),c0,c1,c2,c3
-c
-c     unnecessary initialization of c1 c2 c3 to keep g77 -Wall happy
-c
-      c1 = 0.0d0
-      c2 = 0.0d0
-      c3 = 0.0d0
-C
-C Pass 1
-      wjm3(1)=0d0
-      wjm3(2)=0d0
-      wjm3(3)=0d0
-      wjm2(1)=0d0
-      wjm2(2)=0d0
-      wjm1(1)=0d0
-      do 100 i=1,nk
-         j=nk-i+1
-         c0 = 1d0/abd(4,j)
-         if(j.le.nk-3)then
-            c1 = abd(1,j+3)*c0
-            c2 = abd(2,j+2)*c0
-            c3 = abd(3,j+1)*c0
-         else if(j.eq.nk-2)then
-            c1 = 0d0
-            c2 = abd(2,j+2)*c0
-            c3 = abd(3,j+1)*c0
-         else if(j.eq.nk-1)then
-            c1 = 0d0
-            c2 = 0d0
-            c3 = abd(3,j+1)*c0
-         else if(j.eq.nk)then
-            c1 = 0d0
-            c2 = 0d0
-            c3 = 0d0
-         endif
-         p1ip(1,j) = 0d0- (c1*wjm3(1)+c2*wjm3(2)+c3*wjm3(3))
-         p1ip(2,j) = 0d0- (c1*wjm3(2)+c2*wjm2(1)+c3*wjm2(2))
-         p1ip(3,j) = 0d0- (c1*wjm3(3)+c2*wjm2(2)+c3*wjm1(1))
-         p1ip(4,j) = c0**2 + c1**2*wjm3(1) + 2d0*c1*c2*wjm3(2)+
-     &        2d0*c1*c3*wjm3(3) + c2**2*wjm2(1) + 2d0*c2*c3*wjm2(2) +
-     &        c3**2*wjm1(1)
-         wjm3(1)=wjm2(1)
-         wjm3(2)=wjm2(2)
-         wjm3(3)=p1ip(2,j)
-         wjm2(1)=wjm1(1)
-         wjm2(2)=p1ip(3,j)
-         wjm1(1)=p1ip(4,j)
- 100  continue
-
-      if(flag.ne.0)then
-
-C     ____ Pass 2 _____
-
-C     Compute p2ip
-         do 120 i=1,nk
-            j=nk-i+1
-C           for(k=1;k<=4 & j+k-1<=nk;k=k+1) { p2ip(.) = .. }:
-            do 160 k=1,4
-               if(j+k-1 .gt. nk)goto 120
-               p2ip(j,j+k-1) = p1ip(5-k,j)
- 160        continue
- 120     continue
-
-         do 170 i=1,nk
-            j=nk-i+1
-c           for(k=j-4;k>=1;k=k-1){
-            if(j-4 .ge. 1) then
-               do 210 k= j-4,1, -1
-                  c0 = 1d0/abd(4,k)
-                  c1 = abd(1,k+3)*c0
-                  c2 = abd(2,k+2)*c0
-                  c3 = abd(3,k+1)*c0
-                  p2ip(k,j)= 0d0 - ( c1*p2ip(k+3,j) + c2*p2ip(k+2,j) +
-     &                 c3*p2ip(k+1,j) )
- 210           continue
-            endif
- 170     continue
-      endif
-      return
-      end
-
diff --git a/singlelinkage.cpp b/singlelinkage.cpp
deleted file mode 100644 (file)
index 1a1b2ae..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-
-#include "mothur.h"
-#include "cluster.hpp"
-
-
-/***********************************************************************/
-
-SingleLinkage::SingleLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
-Cluster(rav, lv, dm, c, s)
-{}
-
-
-/***********************************************************************/
-//This function returns the tag of the method.
-string SingleLinkage::getTag() {
-       return("nn");
-}
-
-/***********************************************************************/
-//This function clusters based on the single linkage method.
-void  SingleLinkage::update(double& cutOFF){
-       try {
-               getRowColCells();       
-       
-               vector<bool> deleted(nRowCells, false);
-               int rowInd;
-               int search;
-               bool changed;
-
-               // The vector has to be traversed in reverse order to preserve the index
-               // for faster removal in removeCell()
-               for (int i=nRowCells-1;i>=0;i--) {
-                       if ((rowCells[i]->row == smallRow) && (rowCells[i]->column == smallCol)) {
-                               rowInd = i;   // The index of the smallest distance cell in rowCells
-                       } else {
-                               if (rowCells[i]->row == smallRow) {
-                                       search = rowCells[i]->column;
-                               } else {
-                                       search = rowCells[i]->row;
-                               }
-               
-                               for (int j=0;j<nColCells;j++) {
-                                       if (!((colCells[j]->row == smallRow) && (colCells[j]->column == smallCol))) {
-                                               if (colCells[j]->row == search || colCells[j]->column == search) {
-                                                       changed = updateDistance(colCells[j], rowCells[i]);
-                                                       // If the cell's distance changed and it had the same distance as 
-                                                       // the smallest distance, invalidate the mins vector in SparseMatrix
-                                                       if (changed) {
-                                                               if (colCells[j]->vectorMap != NULL) {
-                                                                       *(colCells[j]->vectorMap) = NULL;
-                                                                       colCells[j]->vectorMap = NULL;
-                                                               }
-                                                       }
-                                                       removeCell(rowCells[i], i , -1);
-                                                       deleted[i] = true;
-                                                       break;
-                                               }
-                                       }
-                               }
-                               if (!deleted[i]) {
-                                       // Assign the cell to the new cluster 
-                                       // remove the old cell from seqVec and add the cell
-                                       // with the new row and column assignment again
-                                       removeCell(rowCells[i], i , -1, false);
-                                       if (search < smallCol){
-                                               rowCells[i]->row = smallCol;
-                                               rowCells[i]->column = search;
-                                       } else {
-                                               rowCells[i]->row = search;
-                                               rowCells[i]->column = smallCol;
-                                       }
-                                       seqVec[rowCells[i]->row].push_back(rowCells[i]);
-                                       seqVec[rowCells[i]->column].push_back(rowCells[i]);
-                               }
-                       }       
-               }
-               clusterBins();
-               clusterNames();
-               // remove also the cell with the smallest distance
-
-               removeCell(rowCells[rowInd], -1 , -1);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SingleLinkage", "update");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
-//This function updates the distance based on the nearest neighbor method.
-bool SingleLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
-       try {
-               bool changed = false;
-               if (colCell->dist > rowCell->dist) {
-                       colCell->dist = rowCell->dist;
-               }
-               return(changed);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SingleLinkage", "updateDistance");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/slayer.cpp b/slayer.cpp
deleted file mode 100644 (file)
index a787f27..0000000
+++ /dev/null
@@ -1,587 +0,0 @@
-/*
- *  slayer.cpp
- *  Mothur
- *
- *  Created by westcott on 9/25/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "slayer.h"
-
-/***********************************************************************/
-Slayer::Slayer(int win, int increment, int parentThreshold, float div, int i, int snp, int mi) :
-               minBS(mi), windowSize(win), windowStep(increment), parentFragmentThreshold(parentThreshold), divRThreshold(div), iters(i), percentSNPSample(snp){ m = MothurOut::getInstance(); }
-/***********************************************************************/
-string Slayer::getResults(Sequence query, vector<Sequence> refSeqs) {
-       try {
-               vector<data_struct> all; all.clear();
-               myQuery = query;
-
-               for (int i = 0; i < refSeqs.size(); i++) {
-               
-                       for (int j = i+1; j < refSeqs.size(); j++) {
-                       
-                               if (m->control_pressed) { return "no";  }
-       
-                               //make copies of query and each parent because runBellerophon removes gaps and messes them up
-                               Sequence q(query.getName(), query.getAligned());
-                               Sequence leftParent(refSeqs[i].getName(), refSeqs[i].getAligned());
-                               Sequence rightParent(refSeqs[j].getName(), refSeqs[j].getAligned());
-                               
-                               //cout << q->getName() << endl << q->getAligned() << endl << endl;      
-                               //cout << leftParent.getName() << '\t' << leftParent.getAligned().length() << endl << endl;
-                               //cout << rightParent.getName() << '\t' << rightParent.getAligned().length() << endl << endl;
-                               //cout << q.getName() << '\t' << q.getAligned().length() << endl << endl;
-                               //cout << rightParent->getName() << endl << rightParent->getAligned() << endl << endl;  
-                               //cout << " length = " << rightParent->getAligned().length() << endl;
-       
-                               map<int, int> spots;  //map from spot in original sequence to spot in filtered sequence for query and both parents
-                               vector<data_struct> divs = runBellerophon(q, leftParent, rightParent, spots);
-       
-                               if (m->control_pressed) { return "no"; }
-//                             cout << "examining:\t" << refSeqs[i]->getName() << '\t' << refSeqs[j]->getName() << endl;
-                               vector<data_struct> selectedDivs;
-                               for (int k = 0; k < divs.size(); k++) {
-                                       
-                                       vector<snps> snpsLeft = getSNPS(divs[k].parentA.getAligned(), divs[k].querySeq.getAligned(), divs[k].parentB.getAligned(), divs[k].winLStart, divs[k].winLEnd);
-                                       vector<snps> snpsRight = getSNPS(divs[k].parentA.getAligned(), divs[k].querySeq.getAligned(), divs[k].parentB.getAligned(), divs[k].winRStart, divs[k].winREnd);
-       
-                                       if (m->control_pressed) {  return "no"; }
-                                       
-                                       int numSNPSLeft = snpsLeft.size();
-                                       int numSNPSRight = snpsRight.size();
-                                       
-//                                     cout << numSNPSLeft << '\t' << numSNPSRight << endl;
-                                       //require at least 4 SNPs on each side of the break
-                                       if ((numSNPSLeft >= 4) && (numSNPSRight >= 4)) {
-                                                       
-                                               float BS_A, BS_B;
-                                               bootstrapSNPS(snpsLeft, snpsRight, BS_A, BS_B, iters);
-                                               
-                                               if (m->control_pressed) { return "no"; }
-
-                                               divs[k].bsa = BS_A;
-                                               divs[k].bsb = BS_B;
-                                               divs[k].bsMax = max(BS_A, BS_B);
-                                               divs[k].chimeraMax = max(divs[k].qla_qrb, divs[k].qlb_qra);
-                                               
-                                               
-                                               //are we within 10 points of the bootstrap cutoff?
-//                                             if ((divs[k].bsMax >= (minBS-10)) && (iters < 1000)) {
-//                                                     bootstrapSNPS(snpsLeft, snpsRight, BS_A, BS_B, 1000);
-//                                                             
-//                                                     if (m->control_pressed) { delete q; delete leftParent; delete rightParent; return "no"; }
-//                                                             
-//                                                     divs[k].bsa = BS_A;
-//                                                     divs[k].bsb = BS_B;
-//                                                     divs[k].bsMax = max(BS_A, BS_B);
-//                                                     divs[k].chimeraMax = max(divs[k].qla_qrb, divs[k].qlb_qra);
-//                                             }
-                                               
-                                               //so results reflect orignal alignment
-                                               divs[k].winLStart = spots[divs[k].winLStart];
-                                               divs[k].winLEnd = spots[divs[k].winLEnd];  
-                                               divs[k].winRStart = spots[divs[k].winRStart]; 
-                                               divs[k].winREnd = spots[divs[k].winREnd]; 
-                                               
-                                               selectedDivs.push_back(divs[k]);
-                                       }
-                               }
-
-                               //save selected
-                               for (int mi = 0; mi < selectedDivs.size(); mi++) {  all.push_back(selectedDivs[mi]);    }
-                       }
-               }
-               
-
-               // compute bootstrap support
-               if (all.size() > 0) {
-                       //sort them
-                       sort(all.begin(), all.end(), compareDataStruct);
-                       reverse(all.begin(), all.end());
-                                               
-                       outputResults = all;
-                       return "yes"; 
-               }else {
-                       outputResults = all;
-                       return "no";
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "getResults");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<data_struct> Slayer::runBellerophon(Sequence q, Sequence pA, Sequence pB, map<int, int>& spots) {
-       try{
-               
-               vector<data_struct> data;
-               
-               //vertical filter
-               //cout << q.getName() << endl << q.getAligned() << endl << endl;        
-               //cout << pA.getName() << endl << pA.getUnaligned() << endl << endl;            
-               //cout << pB.getName() << endl << pB.getUnaligned() << endl << endl;    
-               
-               //maps spot in new alignment to spot in alignment before filter
-               spots = verticalFilter(q, pA, pB);  //fills baseSpots
-               
-               //get these to avoid numerous function calls
-               string query = q.getAligned();
-               string parentA = pA.getAligned();
-               string parentB = pB.getAligned();
-               int length = query.length();
-//cout << q.getName() << endl << q.getAligned() << endl << endl;       
-//cout << pA.getName() << endl << pA.getUnaligned() << endl << endl;           
-//cout << pB.getName() << endl << pB.getUnaligned() << endl << endl;   
-//cout << " length = " << length << endl;
-       
-               //check window size
-               if (length < (2*windowSize+windowStep)) { 
-//                     m->mothurOut("Your window size is too large for " + q->getName() + ". I will make the window size " + toString(length/4) + " which is 1/4 the filtered length."); m->mothurOutEndLine();        
-                       windowSize = length / 4;
-               }
-               
-               for (int i = windowSize-1; i <= (length - windowSize); i += windowStep) {
-               
-                       if (m->control_pressed) { return data; }
-               
-                       int breakpoint = i;
-                       int leftLength = breakpoint + 1;
-                       int rightLength = length - leftLength;
-                               
-                       float QLA = computePercentID(query, parentA, 0, breakpoint);
-                       float QRB = computePercentID(query, parentB, breakpoint+1, length-1);
-               
-                       float QLB = computePercentID(query, parentB, 0, breakpoint);
-                       float QRA = computePercentID(query, parentA, breakpoint+1, length-1);
-               
-                       float LAB = computePercentID(parentA, parentB, 0, breakpoint);
-                       float RAB = computePercentID(parentA, parentB, breakpoint+1, length-1); 
-                       
-                       float AB = ((LAB*leftLength) + (RAB*rightLength)) / (float) length;
-                       float QA = ((QLA*leftLength) + (QRA*rightLength)) / (float) length;
-                       float QB = ((QLB*leftLength) + (QRB*rightLength)) / (float) length;
-               
-                       float QLA_QRB = ((QLA*leftLength) + (QRB*rightLength)) / (float) length;
-                       float QLB_QRA = ((QLB*leftLength) + (QRA*rightLength)) / (float) length;
-               
-                       //in original and not used
-                       //float avgQA_QB = ((QA*leftLength) + (QB*rightLength)) / (float) length;
-               
-                       float divR_QLA_QRB = min((QLA_QRB/QA), (QLA_QRB/QB));
-                       float divR_QLB_QRA = min((QLB_QRA/QA), (QLB_QRA/QB));
-                       
-                       
-                       //cout << q->getName() << '\t';
-                       //cout << pA->getName() << '\t';
-                       //cout << pB->getName() << '\t';
-                   //cout << "bp: " << breakpoint << " CHIM_TYPE_A\t" << divR_QLA_QRB << "\tQLA: " << QLA << "\tQRB: " << QRB << "\tQLA_QRB: " << QLA_QRB;
-                       //cout << "\tCHIM_TYPE_B\t" << divR_QLB_QRA << "\tQLB: " << QLB << "\tQRA: " << QRA << "\tQLB_QRA: " << QLB_QRA << endl;
-//cout << leftLength << '\t' << rightLength << '\t' << QLA << '\t' << QRB << '\t' << QLB << '\t' << QRA  << '\t' << LAB << '\t' << RAB << '\t' << AB << '\t' << QA << '\t' << QB << '\t' << QLA_QRB << '\t' <<  QLB_QRA <<    endl;                    
-
-//cout << divRThreshold << endl;
-//cout << breakpoint << '\t' << divR_QLA_QRB << '\t' << divR_QLB_QRA << endl;
-                       //is one of them above the 
-                       if (divR_QLA_QRB >= divRThreshold || divR_QLB_QRA >= divRThreshold) {
-                               
-                               if (((QLA_QRB > QA) && (QLA_QRB > QB) && (QLA >= parentFragmentThreshold) && (QRB >= parentFragmentThreshold))  ||
-                                       ((QLB_QRA > QA) && (QLB_QRA > QB) && (QLB >=parentFragmentThreshold) && (QRA >= parentFragmentThreshold)))  {
-                                       
-                                       data_struct member;
-                                       
-                                       member.divr_qla_qrb = divR_QLA_QRB;
-                                       member.divr_qlb_qra = divR_QLB_QRA;
-                                       member.qla_qrb = QLA_QRB;
-                                       member.qlb_qra = QLB_QRA;
-                                       member.qla = QLA;
-                                       member.qrb = QRB;
-                                       member.ab = AB; 
-                                       member.qa = QA;
-                                       member.qb = QB; 
-                                       member.lab = LAB; 
-                                       member.rab = RAB; 
-                                       member.qra = QRA; 
-                                       member.qlb = QLB; 
-                                       member.winLStart = 0;
-                                       member.winLEnd = breakpoint;  
-                                       member.winRStart = breakpoint+1; 
-                                       member.winREnd = length-1; 
-                                       member.querySeq = q;
-                                       member.parentA = pA;
-                                       member.parentB = pB;
-                                       member.bsa = 0;
-                                       member.bsb = 0;
-                                       member.bsMax = 0;
-                                       member.chimeraMax = 0;
-                                       
-                                       data.push_back(member);
-                                       
-                               }//if
-                       }//if
-               }//for
-               
-               
-               return data;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "runBellerophon");
-               exit(1);
-       }
-}
-/***********************************************************************/
-vector<snps> Slayer::getSNPS(string parentA, string query, string parentB, int left, int right) {
-       try {
-       
-               vector<snps> data;
-
-               for (int i = left; i <= right; i++) {
-                       
-                       char A = parentA[i];
-                       char Q = query[i];
-                       char B = parentB[i];
-                       
-                       if ((A != Q) || (B != Q)) {
-
-                               //ensure not neighboring a gap. change to 12/09 release of chimeraSlayer - not sure what this adds, but it eliminates alot of SNPS
-
-                               
-                               if (
-                                       //did query loose a base here during filter??
-                                       ( i == 0 || abs (baseSpots[0][i] - baseSpots[0][i-1]) == 1) &&
-                                       ( i == query.length()-1 || abs (baseSpots[0][i] - baseSpots[0][i+1]) == 1)
-                                       &&
-                                       //did parentA loose a base here during filter??
-                                       ( i == 0 || abs (baseSpots[1][i] - baseSpots[1][i-1]) == 1) &&
-                                       ( i == parentA.length()-1 || abs (baseSpots[1][i] - baseSpots[1][i+1]) == 1) 
-                                       &&
-                                       //did parentB loose a base here during filter??
-                                       ( i == 0 || abs (baseSpots[2][i] - baseSpots[2][i-1]) == 1) &&
-                                       ( i == parentB.length()-1 || abs (baseSpots[2][i] - baseSpots[2][i+1]) == 1)
-                                       ) 
-                               { 
-                                       snps member;
-                                       member.queryChar = Q;
-                                       member.parentAChar = A;
-                                       member.parentBChar = B;
-                                       data.push_back(member);
-                               }
-                       }
-               }
-               
-               return data;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "getSNPS");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int Slayer::bootstrapSNPS(vector<snps> left, vector<snps> right, float& BSA, float& BSB, int numIters) {
-       try {
-
-               srand((unsigned)time( NULL ));
-
-               int count_A = 0; // sceneario QLA,QRB supported
-               int count_B = 0; // sceneario QLB,QRA supported
-       
-               int numLeft = max(1, int(left.size() * percentSNPSample/(float)100 + 0.5));
-               int numRight = max(1, int(right.size() * percentSNPSample/(float)100 + 0.5));
-
-               for (int i = 0; i < numIters; i++) {
-                       //random sampling with replacement.
-               
-                       if (m->control_pressed) { return 0;  }
-                       
-                       vector<snps> selectedLeft;
-
-                       for (int j = 0; j < numLeft; j++) {
-                               int index = int(rand() % left.size());
-                               selectedLeft.push_back(left[index]);
-                       }
-
-                       vector<snps> selectedRight;
-                       for (int j = 0; j < numRight; j++) {
-                               int index = int(rand() % right.size());
-                               selectedRight.push_back(right[index]);
-                       }
-               
-                       /* A  ------------------------------------------
-                       #       QLA                     QRA
-                       # Q  ------------------------------------------
-                       #                      |
-                       #                      |
-                       # Q  ------------------------------------------
-                       #       QLB                     QRB
-                       # B  ------------------------------------------ */
-               
-               
-                       float QLA = snpQA(selectedLeft);
-                       float QRA = snpQA(selectedRight);
-               
-                       float QLB = snpQB(selectedLeft);
-                       float QRB = snpQB(selectedRight);
-       
-                       //in original - not used - not sure why?
-                       //float ALB = snpAB(selectedLeft);
-                       //float ARB = snpAB(selectedRight);
-               
-                       if ((QLA > QLB) && (QRB > QRA)) {
-                               count_A++;
-                       }
-               
-                       if ((QLB > QLA) && (QRA > QRB)) {
-                               count_B++;
-                       }
-                       
-//cout << "selected left snp: \n";
-//for (int j = 0; j < selectedLeft.size(); j++) {  cout << selectedLeft[j].parentAChar;  } 
-//cout << endl;
-//for (int j = 0; j < selectedLeft.size(); j++) {  cout << selectedLeft[j].queryChar;  }
-//cout << endl;
-//for (int j = 0; j < selectedLeft.size(); j++) {  cout << selectedLeft[j].parentBChar;  }
-//cout << endl;
-//cout << "selected right snp: \n";
-//for (int j = 0; j < selectedRight.size(); j++) {  cout << selectedRight[j].parentAChar;  } 
-//cout << endl;
-//for (int i = 0; i < selectedRight.size(); i++) {  cout << selectedRight[i].queryChar;  }
-//cout << endl;
-//for (int i = 0; i < selectedRight.size(); i++) {  cout << selectedRight[i].parentBChar;  }
-//cout << endl;                
-               }
-
-
-               //cout << count_A << '\t' << count_B << endl;
-
-               BSA = (float) count_A / (float) numIters * 100;
-               BSB = (float) count_B / (float) numIters * 100;
-//cout << "bsa = " << BSA << " bsb = " << BSB << endl;
-
-               return 0;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "bootstrapSNPS");
-               exit(1);
-       }
-}
-/***********************************************************************/
-float Slayer::snpQA(vector<snps> data) {
-       try {
-       
-               int numIdentical = 0;
-       
-               for (int i = 0; i < data.size(); i++) {
-                       if (data[i].parentAChar == data[i].queryChar) {
-                               numIdentical++;
-                       }
-               }
-
-               float percentID = (numIdentical / (float) data.size()) * 100;
-               
-               return percentID;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "snpQA");
-               exit(1);
-       }
-}
-/***********************************************************************/
-float Slayer::snpQB(vector<snps> data) {
-       try {
-       
-               int numIdentical = 0;
-       
-               for (int i = 0; i < data.size(); i++) {
-                       if (data[i].parentBChar == data[i].queryChar) {
-                               numIdentical++;
-                       }
-               }
-
-               float percentID = (numIdentical / (float) data.size()) * 100;
-               
-               return percentID;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "snpQB");
-               exit(1);
-       }
-}
-/***********************************************************************/
-float Slayer::snpAB(vector<snps> data) {
-       try {
-               int numIdentical = 0;
-       
-               for (int i = 0; i < data.size(); i++) {
-                       if (data[i].parentAChar == data[i].parentBChar) {
-                               numIdentical++;
-                       }
-               }
-
-               float percentID = (numIdentical / (float) data.size()) * 100;
-               
-               return percentID;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "snpAB");
-               exit(1);
-       }
-}
-/***********************************************************************/
-float Slayer::computePercentID(string queryAlign, string chimera, int left, int right) {
-       try {
-                               
-               int numIdentical = 0;
-               int countA = 0;
-               int countB = 0;
-               for (int i = left; i <= right; i++) {
-                       if (((queryAlign[i] != 'G') && (queryAlign[i] != 'T') && (queryAlign[i] != 'A') && (queryAlign[i] != 'C')&& (queryAlign[i] != '.') && (queryAlign[i] != '-')) ||
-                               ((chimera[i] != 'G') && (chimera[i] != 'T') && (chimera[i] != 'A') && (chimera[i] != 'C')&& (chimera[i] != '.') && (chimera[i] != '-'))) {}
-                       else {
-                               
-                               bool charA = false; bool charB = false;
-                               if ((queryAlign[i] == 'G') || (queryAlign[i] == 'T') || (queryAlign[i] == 'A') || (queryAlign[i] == 'C')) { charA = true; }
-                               if ((chimera[i] == 'G') || (chimera[i] == 'T') || (chimera[i] == 'A') || (chimera[i] == 'C')) { charB = true; }
-                               
-                               if (charA || charB) {
-                                       
-                                       if (charA) { countA++; }
-                                       if (charB) { countB++; }
-                                       
-                                       if (queryAlign[i] == chimera[i]) {
-                                               numIdentical++;
-                                       }
-                               }
-                       }
-                       
-               }
-               
-               float numBases = (countA + countB) /(float) 2;
-               
-               if (numBases == 0) { return 0; }
-               
-               float percentIdentical = (numIdentical/(float)numBases) * 100;
-
-               return percentIdentical;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "computePercentID");
-               exit(1);
-       }
-}
-/***********************************************************************/
-//remove columns that contain any gaps
-map<int, int> Slayer::verticalFilter(Sequence& q, Sequence& pA, Sequence& pB) {
-       try {
-               //find baseSpots
-               baseSpots.clear(); 
-               baseSpots.resize(3);  //query, parentA, parentB
-       
-               vector<int> gaps;       gaps.resize(q.getAligned().length(), 0);
-               
-               string filterString = (string(q.getAligned().length(), '1'));
-               
-               string seqAligned = q.getAligned();
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //if this spot is a gap
-                       if ((seqAligned[j] == '-') || (seqAligned[j] == '.') || (toupper(seqAligned[j]) == 'N'))        {   gaps[j]++;  }
-               }
-               
-               seqAligned = pA.getAligned();
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //if this spot is a gap
-                       if ((seqAligned[j] == '-') || (seqAligned[j] == '.') || (toupper(seqAligned[j]) == 'N'))        {   gaps[j]++;  }
-               }
-               
-               seqAligned = pB.getAligned();
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //if this spot is a gap
-                       if ((seqAligned[j] == '-') || (seqAligned[j] == '.') || (toupper(seqAligned[j]) == 'N'))        {   gaps[j]++;  }
-               }
-               
-               
-               //zero out spot where any sequences have blanks
-               int numColRemoved = 0;
-               int count = 0;
-               map<int, int> maskMap; maskMap.clear();
-
-               for(int i = 0; i < q.getAligned().length(); i++){
-                       if(gaps[i] != 0)        {       filterString[i] = '0';  numColRemoved++;  }
-                       else {
-                               maskMap[count] = i;
-                               count++;
-                       }
-               }
-
-               seqAligned = q.getAligned();
-               string newAligned = "";
-                       
-               int baseCount = 0;
-               count = 0;
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //are you a base
-                       if ((seqAligned[j] != '-') && (seqAligned[j] != '.') && (toupper(seqAligned[j]) != 'N'))        { baseCount++; }
-                       
-                       //if this spot is not a gap
-                       if (filterString[j] == '1') { 
-                               newAligned += seqAligned[j]; 
-                               baseSpots[0][count] = baseCount;
-                               count++;
-                       }
-               }
-                       
-               q.setAligned(newAligned);
-               
-               seqAligned = pA.getAligned();
-               newAligned = "";
-               
-               baseCount = 0;
-               count = 0;
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //are you a base
-                       if ((seqAligned[j] != '-') && (seqAligned[j] != '.') && (toupper(seqAligned[j]) != 'N'))        { baseCount++; }
-                       
-                       //if this spot is not a gap
-                       if (filterString[j] == '1') { 
-                               newAligned += seqAligned[j]; 
-                               baseSpots[1][count] = baseCount;
-                               count++;
-                       }
-               }
-               
-               pA.setAligned(newAligned);
-               
-               seqAligned = pB.getAligned();
-               newAligned = "";
-               
-               baseCount = 0;
-               count = 0;
-               for (int j = 0; j < seqAligned.length(); j++) {
-                       //are you a base
-                       if ((seqAligned[j] != '-') && (seqAligned[j] != '.') && (toupper(seqAligned[j]) != 'N'))        { baseCount++; }
-                       
-                       //if this spot is not a gap
-                       if (filterString[j] == '1') { 
-                               newAligned += seqAligned[j]; 
-                               baseSpots[2][count] = baseCount;
-                               count++;
-                       }
-               }
-               
-               pB.setAligned(newAligned);
-               
-               
-               return maskMap;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Slayer", "verticalFilter");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/slayer.h b/slayer.h
deleted file mode 100644 (file)
index eeefc62..0000000
--- a/slayer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef SLAYER_H
-#define SLAYER_H
-/*
- *  slayer.h
- *  Mothur
- *
- *  Created by westcott on 9/25/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "sequence.hpp"
-#include "chimera.h"
-
-/***********************************************************************/
-//This class was modeled after the chimeraSlayer written by the Broad Institute
-/***********************************************************************/
-struct snps { 
-       char queryChar;
-       char parentAChar;
-       char parentBChar;
-};
-
-/***********************************************************************/
-
-
-class Slayer {
-
-       public:
-               
-               Slayer(int, int, int, float, int, int, int);
-               ~Slayer() {};
-               
-               string getResults(Sequence, vector<Sequence>);
-               vector<data_struct> getOutput()  {      return outputResults;                   }
-               
-                               
-       private:
-               
-               int windowSize, windowStep, parentFragmentThreshold, iters, percentSNPSample, minBS;
-               float divRThreshold; 
-               vector<data_struct>  outputResults;
-               vector< map<int, int> > baseSpots;
-               Sequence myQuery;
-               
-               map<int, int> verticalFilter(Sequence&, Sequence&, Sequence&);
-               float computePercentID(string, string, int, int);
-               
-               vector<data_struct> runBellerophon(Sequence, Sequence, Sequence, map<int, int>&);
-               vector<snps> getSNPS(string, string, string, int, int);
-               int bootstrapSNPS(vector<snps>, vector<snps>, float&, float&, int);
-               float snpQA(vector<snps>);
-               float snpQB(vector<snps>);
-               float snpAB(vector<snps>);
-               MothurOut* m;
-                               
-};
-
-/***********************************************************************/
-
-#endif
-
-
diff --git a/slibshuff.cpp b/slibshuff.cpp
deleted file mode 100644 (file)
index 92998e6..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *  slibshuff.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "slibshuff.h"
-
-/***********************************************************************/
-
-SLibshuff::SLibshuff(FullMatrix* D, int it, float co) : Libshuff(D, it, 0, co){}
-
-/***********************************************************************/
-
-float SLibshuff::evaluatePair(int i, int j){
-       return sCalculate(i,j);
-}
-
-/***********************************************************************/
-
-vector<vector<double> > SLibshuff::evaluateAll(){
-       try{
-               savedMins.resize(numGroups);
-               vector<vector<double> > dCXYValues(numGroups);
-
-               for(int i=0;i<numGroups;i++){
-                       dCXYValues[i].resize(numGroups);
-                       savedMins[i].resize(numGroups);
-                       for(int j=0;j<numGroups;j++){
-                               if(i!=j){
-                                       dCXYValues[i][j] = sCalculate(i,j);     
-                                       savedMins[i][j] = minXY;
-                               }
-
-                               if(savedMins[i][i].size() == 0){
-                                       savedMins[i][i] = minX;
-                               }
-
-                       }
-               }               
-               return dCXYValues;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SLibshuff", "evaluateAll");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-double SLibshuff::sCalculate(int x, int y){
-       try{
-               double sum = 0.0,t=0.0;
-               
-               minX = getMinX(x);
-               
-               if (m->control_pressed) { return sum; }
-               
-               minXY = getMinXY(x,y);
-               
-               if (m->control_pressed) { return sum; }
-
-               sort(minX.begin(), minX.end());
-               
-               if (m->control_pressed) { return sum; }
-               
-               sort(minXY.begin(), minXY.end());
-               
-               if (m->control_pressed) { return sum; }
-
-               int ix=0,iy=0;
-               while( (ix < groupSizes[x]) && (iy < groupSizes[x]) ) {
-                       double h = (ix-iy)/double(groupSizes[x]);
-                       
-                       if(minX[ix] < minXY[iy]) {
-                               sum += (minX[ix] - t)*h*h;
-                               t = minX[ix++];
-                       }
-                       else {
-                               sum += (minXY[iy] - t)*h*h;
-                               t = minXY[iy++];
-                       }
-                       
-               }
-               
-               if(ix < groupSizes[x]) {
-                       
-                       while(ix < groupSizes[x]) {
-                               double h = (ix-iy)/double(groupSizes[x]);
-                               sum += (minX[ix] - t)*h*h;
-                               t = minX[ix++];
-                       }
-                       
-               }
-               else {
-                       
-                       while(iy < groupSizes[x]) {
-                               double h = (ix-iy)/double(groupSizes[x]);
-                               sum += (minXY[iy] - t)*h*h;
-                               t = minXY[iy++];
-                       }
-                       
-               }
-               
-               return sum;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SLibshuff", "sCalculate");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/slibshuff.h b/slibshuff.h
deleted file mode 100644 (file)
index 8e034f9..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef SLIBSHUFF
-#define SLIBSHUFF
-
-/*
- *  slibshuff.h
- *  Mothur
- *
- *  Created by Pat Schloss on 4/8/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "fullmatrix.h"
-#include "libshuff.h"
-
-class SLibshuff : public Libshuff {
-
-public:
-       SLibshuff(FullMatrix*, int, float);
-       vector<vector<double> > evaluateAll();
-       float evaluatePair(int, int);
-       
-private:
-       double sCalculate(int, int);
-};
-
-#endif
diff --git a/smithwilson.cpp b/smithwilson.cpp
deleted file mode 100644 (file)
index ec04196..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- *  smithwilson.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "smithwilson.h"
-
-/***********************************************************************/
-
-EstOutput SmithWilson::getValues(SAbundVector* rank){
-       try {
-
-               data.resize(1,0);
-
-               double maxRank = rank->getMaxRank();
-               double sobs = rank->getNumBins();
-               
-               double innerSum = 0;
-               for(int i=1;i<=maxRank;i++){
-                       innerSum += rank->get(i) * log(i);
-               }
-               innerSum /= sobs;
-
-               double outerSum = 0;
-               for(int i=1;i<=maxRank;i++){
-                       outerSum += rank->get(i) * (log(i) - innerSum) * (log(i) - innerSum);
-               }
-               outerSum /= sobs;
-
-               if(outerSum > 0){
-                       data[0] = 1.0000 - 2.0000 / (3.14159 * atan(outerSum));
-               }
-               else{
-                       data[0] = 1.0000;
-               }
-               
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "InvSimpson", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/smithwilson.h b/smithwilson.h
deleted file mode 100644 (file)
index 46c3af9..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef SMITHWILSON
-#define SMITHWILSON
-
-/*
- *  smithwilson.h
- *  Mothur
- *
- *  Created by Pat Schloss on 8/21/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SmithWilson : public Calculator  {
-       
-public:
-       SmithWilson() : Calculator("smithwilson", 1, false) {};
-       EstOutput getValues(SAbundVector*);
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Smithwilson"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/sobs.h b/sobs.h
deleted file mode 100644 (file)
index 05956a4..0000000
--- a/sobs.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef SOBS_H
-#define SOBS_H
-
-/*
- *  sobs.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/7/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-/* This class implements the Sobs estimator on single group. 
-It is a child of the calculator class. */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Sobs : public Calculator {
-
-public:
-       Sobs() : Calculator("sobs", 1, false) {};
-       EstOutput getValues(SAbundVector* rank){
-               data.resize(1,0);
-               data[0] = (double)rank->getNumBins();
-               return data;
-       }
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Sobs"; }
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/soergel.cpp b/soergel.cpp
deleted file mode 100644 (file)
index b2fdf84..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *  soergel.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "soergel.h"
-
-/***********************************************************************/
-EstOutput Soergel::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumNum = 0.0;
-               double sumMax = 0.0;
-               
-               //calc the 2 denominators
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       sumNum += abs((Aij - Bij));
-                       sumMax += max(Aij, Bij);
-               }
-               
-               data[0] = sumNum / sumMax;
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Soergel", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/soergel.h b/soergel.h
deleted file mode 100644 (file)
index 11df65e..0000000
--- a/soergel.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SOERGEL_H
-#define SOERGEL_H
-
-/*
- *  soergel.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Soergel : public Calculator  {
-       
-public:
-       Soergel() :  Calculator("soergel", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Soergel"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
diff --git a/solow.cpp b/solow.cpp
deleted file mode 100644 (file)
index 33f3afb..0000000
--- a/solow.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  solow.cpp
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "solow.h"
-#include <math.h>
-
-       
-/***********************************************************************/      
-EstOutput Solow::getValues(SAbundVector* rank){
-
-       try {
-               data.resize(1,0);
-               
-               double n = (double)rank->getNumSeqs();
-               double f1 = (double)rank->get(1);
-               double f2 = (double)rank->get(2);
-
-               data[0] = f1*f1/2/f2 * (1 - pow(1 - 2*f2/n/f1, f));
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Solow", "getValues");
-               exit(1);
-       }
-}
-
-
-/***********************************************************************/
diff --git a/solow.h b/solow.h
deleted file mode 100644 (file)
index 38e7776..0000000
--- a/solow.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef SOLOW_H
-#define SOLOW_H
-
-/*
- *  solow.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 5/13/09.
- *  Copyright 2009Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "calculator.h"
-
-/* This class implements the solow calculator on single group. 
- It is a child of the calculator class. */
-
-/***********************************************************************/
-
-class Solow : public Calculator  {
-       
-public: 
-       Solow(int size) : f(size), Calculator("solow", 1, false) {};
-       EstOutput getValues(SAbundVector*);     
-       EstOutput getValues(vector<SharedRAbundVector*>) {return data;};
-       string getCitation() { return "http://www.mothur.org/wiki/Solow"; }
-private:
-       int f;
-};
-
-
-/***********************************************************************/
-
-#endif
diff --git a/sortseqscommand.cpp b/sortseqscommand.cpp
deleted file mode 100644 (file)
index 0236a50..0000000
+++ /dev/null
@@ -1,1090 +0,0 @@
-//
-//  sortseqscommand.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 2/3/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "sortseqscommand.h"
-#include "sequence.hpp"
-#include "qualityscores.h"
-
-//**********************************************************************************************************************
-vector<string> SortSeqsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pfasta);
-        CommandParameter pflow("flow", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pflow);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(ptaxonomy);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter plarge("large", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(plarge);
-               CommandParameter paccnos("accnos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(paccnos);
-        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SortSeqsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The sort.seqs command puts the sequences in the same order for the following file types: accnos fasta, name, group, taxonomy, flow or quality file.\n";
-        helpString += "The sort.seqs command parameters are accnos, fasta, name, group, taxonomy, flow, qfile and large.\n";
-        helpString += "The accnos file allows you to specify the order you want the files in.  If none is provided, mothur will use the order of the first file it reads.\n";
-        helpString += "The large parameters is used to indicate your files are too large to fit in RAM.\n";
-               helpString += "The sort.seqs command should be in the following format: sort.seqs(fasta=yourFasta).\n";
-               helpString += "Example sort.seqs(fasta=amazon.fasta).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-SortSeqsCommand::SortSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["taxonomy"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-        outputTypes["flow"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "SortSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SortSeqsCommand::SortSeqsCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["taxonomy"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-            outputTypes["flow"] = tempOutNames;
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = "";         }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                
-                it = parameters.find("accnos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["accnos"] = inputDir + it->second;           }
-                               }
-                
-                it = parameters.find("flow");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["flow"] = inputDir + it->second;             }
-                               }
-                       }
-            
-                       
-                       //check for parameters
-            accnosfile = validParameter.validFile(parameters, "accnos", true);
-                       if (accnosfile == "not open") { accnosfile = ""; abort = true; }
-                       else if (accnosfile == "not found") {  accnosfile = "";  }      
-                       else { m->setAccnosFile(accnosfile); }
-            
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }
-                       else if (fastafile == "not found") {  fastafile = "";  }        
-                       else { m->setFastaFile(fastafile); }
-            
-            flowfile = validParameter.validFile(parameters, "flow", true);
-                       if (flowfile == "not open") { flowfile = ""; abort = true; }
-                       else if (flowfile == "not found") {  flowfile = "";  }  
-                       else { m->setFlowFile(flowfile); }
-            
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") {  namefile = "";  }  
-                       else { m->setNameFile(namefile); } 
-            
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") {  groupfile = "";  }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { abort = true; }
-                       else if (taxfile == "not found") {  taxfile = "";  }
-                       else { m->setTaxonomyFile(taxfile); }
-                       
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { abort = true; }
-                       else if (qualfile == "not found") {  qualfile = "";  }                  
-                       else { m->setQualFile(qualfile); }
-                       
-            string temp = validParameter.validFile(parameters, "large", false);                if (temp == "not found") { temp = "f"; }
-                       large = m->isTrue(temp);
-            
-                       if ((fastafile == "") && (namefile == "") && (groupfile == "") && (taxfile == "") && (flowfile == "") && (qualfile == ""))  { m->mothurOut("You must provide at least one of the following: fasta, name, group, taxonomy, flow or quality."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile != "") && (namefile == "")) {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "SortSeqsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SortSeqsCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //read through the correct file and output lines you want to keep
-        if (accnosfile != "")          {               readAccnos();   }
-               if (fastafile != "")            {               readFasta();    }
-        if (flowfile != "")         {          readFlow();     }
-        if (qualfile != "")                    {               readQual();             }
-        if (namefile != "")                    {               readName();             }
-               if (groupfile != "")            {               readGroup();    }
-        if (taxfile != "")                     {               readTax();              }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); } return 0; }
-        
-               if (outputNames.size() != 0) {
-                       m->mothurOutEndLine();
-                       m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-                       m->mothurOutEndLine();
-                       
-                       //set fasta file as new current fastafile
-                       string current = "";
-                       itTypes = outputTypes.find("fasta");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("name");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("group");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-                       }
-                       
-                       
-                       itTypes = outputTypes.find("taxonomy");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); }
-                       }
-                       
-                       itTypes = outputTypes.find("qfile");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-                       }       
-            
-            itTypes = outputTypes.find("flow");
-                       if (itTypes != outputTypes.end()) {
-                               if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFlowFile(current); }
-                       }       
-               }
-               
-               return 0;               
-       }
-    
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int SortSeqsCommand::readFasta(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "sorted" + m->getExtension(fastafile);
-               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               string name;
-               
-        if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-            
-            if (large) { //if the file is too large to fit in memory we can still process it, but the io will be very time consuming.
-                //read through the file looking for 1000 seqs at a time. Once we find them output them and start looking for the next 1000.
-                //this way we only store 1000 seqs in memory at a time.
-                
-                int numNames = names.size();
-                int numNamesInFile = 0;
-                
-                //to make sure we dont miss any seqs, add any seqs that are not in names but in the file to the end of names
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    Sequence currSeq(in);
-                    name = currSeq.getName();
-                    
-                    if (name != "") {
-                        numNamesInFile++;
-                        map<string, int>::iterator it = names.find(name);
-                        if (it == names.end()) { 
-                            names[name] = numNames; numNames++;
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();
-                out.close();
-                
-                int numLeft = names.size();
-                if (numNamesInFile < numLeft) { numLeft = numNamesInFile; }
-                
-                int size = 1000; //assume that user can hold 1000 seqs in memory
-                if (numLeft < size) { size = numLeft; }
-                int times = 0;
-                
-                vector<Sequence> seqs; seqs.resize(size);
-                for (int i = 0; i < seqs.size(); i++) { seqs[i].setName(""); } //this is so if some of the seqs are missing we dont print out garbage
-                
-                while (numLeft > 0) {
-                    
-                    ifstream in2;
-                    m->openInputFile(fastafile, in2);
-                    
-                    if (m->control_pressed) { in2.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    int found = 0;
-                    int needToFind = size;
-                    if (numLeft < size) { needToFind = numLeft; }
-                    
-                    while(!in2.eof()){
-                        if (m->control_pressed) { in2.close();   m->mothurRemove(outputFileName);  return 0; }
-                        
-                        //stop reading if we already found the seqs we are looking for
-                        if (found >= needToFind) { break; }
-                        
-                        Sequence currSeq(in2);
-                        name = currSeq.getName();
-                        
-                        if (name != "") {
-                            map<string, int>::iterator it = names.find(name);
-                            if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                                //is it in the set of seqs we are looking for this time around
-                                int thisSeqsPlace = it->second;
-                                thisSeqsPlace -= (times * size);
-                                if ((thisSeqsPlace < size) && (thisSeqsPlace >= 0)) {
-                                    seqs[thisSeqsPlace] = currSeq; 
-                                    found++;
-                                }
-                            }else { m->mothurOut("[ERROR]: in logic of readFasta function.\n"); m->control_pressed = true; }
-                        }
-                        m->gobble(in2);
-                    }
-                    in2.close();       
-
-                    ofstream out2;
-                    m->openOutputFileAppend(outputFileName, out2);
-                    
-                    int output = seqs.size();
-                    if (numLeft < seqs.size()) { output = numLeft; }
-                        
-                    for (int i = 0; i < output; i++) {
-                        if (seqs[i].getName() != "") { seqs[i].printSequence(out2); }
-                    }
-                    out2.close();
-                    
-                    times++;
-                    numLeft -= output;
-                }
-                
-                m->mothurOut("Ordered " + toString(numNamesInFile) + " sequences from " + fastafile + ".\n");
-            }else {
-                
-                vector<Sequence> seqs; seqs.resize(names.size());
-                for (int i = 0; i < seqs.size(); i++) { seqs[i].setName(""); } //this is so if some of the seqs are missing we dont print out garbage
-                
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    Sequence currSeq(in);
-                    name = currSeq.getName();
-                    
-                    if (name != "") {
-                        map<string, int>::iterator it = names.find(name);
-                        if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                            seqs[it->second] = currSeq;  
-                        }else { //if we cant find it then add it to the end
-                            names[name] = seqs.size();
-                            seqs.push_back(currSeq);
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();    
-                
-                int count = 0;
-                for (int i = 0; i < seqs.size(); i++) {
-                    if (seqs[i].getName() != "") {
-                        seqs[i].printSequence(out); count++;
-                    }
-                }
-                out.close();
-                
-                m->mothurOut("Ordered " + toString(count) + " sequences from " + fastafile + ".\n");
-            }
-                        
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                Sequence currSeq(in);
-                name = currSeq.getName();
-                
-                if (name != "") {
-                    //if this name is in the accnos file
-                    names[name] = count;
-                    count++;
-                    currSeq.printSequence(out);
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + fastafile + " to determine the order. It contains " + toString(count) + " sequences.\n");
-        }
-                               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SortSeqsCommand::readFlow(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(flowfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(flowfile)) + "sorted" + m->getExtension(flowfile);
-               outputTypes["flow"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(flowfile, in);
-        int numFlows;
-               string name;
-        
-        in >> numFlows; m->gobble(in);
-               
-        if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-            
-            if (large) { //if the file is too large to fit in memory we can still process it, but the io will be very time consuming.
-                //read through the file looking for 1000 seqs at a time. Once we find them output them and start looking for the next 1000.
-                //this way we only store 1000 seqs in memory at a time.
-                
-                int numNames = names.size();
-                int numNamesInFile = 0;
-                
-                //to make sure we dont miss any seqs, add any seqs that are not in names but in the file to the end of names
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    in >> name;        
-                    string rest = m->getline(in);
-                    
-                    if (name != "") {
-                        numNamesInFile++;
-                        map<string, int>::iterator it = names.find(name);
-                        if (it == names.end()) { 
-                            names[name] = numNames; numNames++;
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();
-                out.close();
-                
-                int numLeft = names.size();
-                if (numNamesInFile < numLeft) { numLeft = numNamesInFile; }
-                
-                int size = 1000; //assume that user can hold 1000 seqs in memory
-                if (numLeft < size) { size = numLeft; }
-                int times = 0;
-                
-                vector<string> seqs; seqs.resize(size, "");
-                
-                while (numLeft > 0) {
-                    
-                    ifstream in2;
-                    m->openInputFile(flowfile, in2); in2 >> numFlows; m->gobble(in2);
-                    
-                    if (m->control_pressed) { in2.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    int found = 0;
-                    int needToFind = size;
-                    if (numLeft < size) { needToFind = numLeft; }
-                    
-                    while(!in2.eof()){
-                        if (m->control_pressed) { in2.close();   m->mothurRemove(outputFileName);  return 0; }
-                        
-                        //stop reading if we already found the seqs we are looking for
-                        if (found >= needToFind) { break; }
-                        
-                        in2 >> name;   
-                        string rest = m->getline(in2);
-                        
-                        if (name != "") {
-                            map<string, int>::iterator it = names.find(name);
-                            if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                                //is it in the set of seqs we are looking for this time around
-                                int thisSeqsPlace = it->second;
-                                thisSeqsPlace -= (times * size);
-                                if ((thisSeqsPlace < size) && (thisSeqsPlace >= 0)) {
-                                    seqs[thisSeqsPlace] = (name +'\t' + rest); 
-                                    found++;
-                                }
-                            }else { m->mothurOut("[ERROR]: in logic of readFlow function.\n"); m->control_pressed = true; }
-                        }
-                        m->gobble(in2);
-                    }
-                    in2.close();       
-                    
-                    ofstream out2;
-                    m->openOutputFileAppend(outputFileName, out2);
-                    
-                    int output = seqs.size();
-                    if (numLeft < seqs.size()) { output = numLeft; }
-                    
-                    for (int i = 0; i < output; i++) {
-                        if (seqs[i] != "") {
-                            out2 << seqs[i] << endl;
-                        }
-                    }
-                    out2.close();
-                    
-                    times++;
-                    numLeft -= output;
-                }
-                
-                m->mothurOut("Ordered " + toString(numNamesInFile) + " flows from " + flowfile + ".\n");
-            }else {
-                
-                vector<string> seqs; seqs.resize(names.size(), "");
-                
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    in >> name;        
-                    string rest = m->getline(in);
-                    
-                    if (name != "") {
-                        map<string, int>::iterator it = names.find(name);
-                        if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                            seqs[it->second] = (name + '\t' + rest);  
-                        }else { //if we cant find it then add it to the end
-                            names[name] = seqs.size();
-                            seqs.push_back((name + '\t' + rest));
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();    
-                
-                int count = 0;
-                for (int i = 0; i < seqs.size(); i++) {
-                    if (seqs[i] != "") {
-                        out << seqs[i] << endl;
-                        count++;
-                    }
-                }
-                out.close();
-                
-                m->mothurOut("Ordered " + toString(count) + " flows from " + flowfile + ".\n");
-            }
-            
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> name;    
-                string rest = m->getline(in);
-                
-                if (name != "") {
-                    //if this name is in the accnos file
-                    names[name] = count;
-                    count++;
-                    out << name << '\t' << rest << endl;
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + flowfile + " to determine the order. It contains " + toString(count) + " flows.\n");
-        }
-        
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readFlow");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int SortSeqsCommand::readQual(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(qualfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(qualfile)) + "sorted" +  m->getExtension(qualfile);
-        outputTypes["qfile"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               ifstream in;
-               m->openInputFile(qualfile, in);
-               string name;
-               
-        if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-            
-            if (large) { //if the file is too large to fit in memory we can still process it, but the io will be very time consuming.
-                //read through the file looking for 1000 seqs at a time. Once we find them output them and start looking for the next 1000.
-                //this way we only store 1000 seqs in memory at a time.
-                
-                int numNames = names.size();
-                int numNamesInFile = 0;
-                
-                //to make sure we dont miss any seqs, add any seqs that are not in names but in the file to the end of names
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    QualityScores currQual;
-                    currQual = QualityScores(in); 
-                    name = currQual.getName();
-                    
-                    if (name != "") {
-                        numNamesInFile++;
-                        map<string, int>::iterator it = names.find(name);
-                        if (it == names.end()) { 
-                            names[name] = numNames; numNames++;
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();
-                out.close();
-                
-                int numLeft = names.size();
-                if (numNamesInFile < numLeft) { numLeft = numNamesInFile; }
-                
-                int size = 1000; //assume that user can hold 1000 seqs in memory
-                if (numLeft < size) { size = numLeft; }
-                int times = 0;
-
-                
-                vector<QualityScores> seqs; seqs.resize(size);
-                for (int i = 0; i < seqs.size(); i++) { seqs[i].setName(""); } //this is so if some of the seqs are missing we dont print out garbage
-                
-                while (numLeft > 0) {
-                    
-                    ifstream in2;
-                    m->openInputFile(qualfile, in2);
-                    
-                    if (m->control_pressed) { in2.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    int found = 0;
-                    int needToFind = size;
-                    if (numLeft < size) { needToFind = numLeft; }
-                    
-                    while(!in2.eof()){
-                        if (m->control_pressed) { in2.close();   m->mothurRemove(outputFileName);  return 0; }
-                        
-                        //stop reading if we already found the seqs we are looking for
-                        if (found >= needToFind) { break; }
-                        
-                        QualityScores currQual;
-                        currQual = QualityScores(in2); 
-                        name = currQual.getName();
-                        
-                        if (name != "") {
-                            map<string, int>::iterator it = names.find(name);
-                            if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                                //is it in the set of seqs we are looking for this time around
-                                int thisSeqsPlace = it->second;
-                                thisSeqsPlace -= (times * size);
-                                if ((thisSeqsPlace < size) && (thisSeqsPlace >= 0)) {
-                                    seqs[thisSeqsPlace] = currQual; 
-                                    found++;
-                                }
-                            }else { m->mothurOut("[ERROR]: in logic of readQual function.\n"); m->control_pressed = true; }
-                        }
-                        m->gobble(in2);
-                    }
-                    in2.close();       
-                    
-                    ofstream out2;
-                    m->openOutputFileAppend(outputFileName, out2);
-                    
-                    int output = seqs.size();
-                    if (numLeft < seqs.size()) { output = numLeft; }
-                    
-                    for (int i = 0; i < output; i++) {
-                        if (seqs[i].getName() != "") {
-                            seqs[i].printQScores(out2);
-                        }
-                    }
-                    out2.close();
-                    
-                    times++;
-                    numLeft -= output;
-                }
-                
-                 m->mothurOut("Ordered " + toString(numNamesInFile) + " sequences from " + qualfile + ".\n");
-                
-            }else {
-                
-                vector<QualityScores> seqs; seqs.resize(names.size());
-                for (int i = 0; i < seqs.size(); i++) { seqs[i].setName(""); } //this is so if some of the seqs are missing we dont print out garbage
-                
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    QualityScores currQual;
-                    currQual = QualityScores(in); 
-                    name = currQual.getName();
-                    
-                    if (name != "") {
-                        map<string, int>::iterator it = names.find(name);
-                        if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                            seqs[it->second] = currQual;  
-                        }else { //if we cant find it then add it to the end
-                            names[name] = seqs.size();
-                            seqs.push_back(currQual);
-                            m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                    m->gobble(in);
-                }
-                in.close();    
-                
-                int count = 0;
-                for (int i = 0; i < seqs.size(); i++) {
-                    if (seqs[i].getName() != "") { seqs[i].printQScores(out); count++; }
-                }
-                out.close();
-                
-                m->mothurOut("Ordered " + toString(count) + " sequences from " + qualfile + ".\n");
-            }
-            
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                QualityScores currQual;
-                currQual = QualityScores(in);  
-                               
-                m->gobble(in);
-                
-                if (currQual.getName() != "") {
-                    //if this name is in the accnos file
-                    names[currQual.getName()] = count;
-                    count++;
-                    currQual.printQScores(out);
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + qualfile + " to determine the order. It contains " + toString(count) + " sequences.\n");
-        }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readQual");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SortSeqsCommand::readName(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(namefile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(namefile)) + "sorted" + m->getExtension(namefile);
-        outputTypes["name"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(namefile, in);
-               string name, firstCol, secondCol;
-               
-        if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-        
-                vector<string> seqs; seqs.resize(names.size(), "");
-                
-                while(!in.eof()){
-                    if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                    
-                    in >> firstCol;            m->gobble(in);          
-                    in >> secondCol;    m->gobble(in);
-                    
-                    if (firstCol != "") {
-                        map<string, int>::iterator it = names.find(firstCol);
-                        if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                            seqs[it->second] = firstCol + '\t' + secondCol;  
-                        }else { //if we cant find it then add it to the end
-                            names[firstCol] = seqs.size();
-                            seqs.push_back((firstCol + '\t' + secondCol));
-                            m->mothurOut(firstCol + " was not in the contained the file which determined the order, adding it to the end.\n");
-                        }
-                    }
-                }
-                in.close();    
-                
-                int count = 0;
-                for (int i = 0; i < seqs.size(); i++) {
-                    if (seqs[i] != "") { out << seqs[i] << endl; count++; }
-                }
-                out.close();
-                
-                m->mothurOut("Ordered " + toString(count) + " sequences from " + namefile + ".\n");
-            
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> firstCol;                m->gobble(in);          
-                in >> secondCol;    m->gobble(in);
-                
-                if (firstCol != "") {
-                    //if this name is in the accnos file
-                    names[firstCol] = count;
-                    count++;
-                    out << firstCol << '\t' << secondCol << endl;
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + namefile + " to determine the order. It contains " + toString(count) + " representative sequences.\n");
-        }
-                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readName");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-int SortSeqsCommand::readGroup(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(groupfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "pick" + m->getExtension(groupfile);
-               outputTypes["group"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(groupfile, in);
-               string name, group;
-               
-               if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-            
-            vector<string> seqs; seqs.resize(names.size(), "");
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> name;            m->gobble(in);          
-                in >> group;    m->gobble(in);
-                
-                if (name != "") {
-                    map<string, int>::iterator it = names.find(name);
-                    if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                        seqs[it->second] = name + '\t' + group;  
-                    }else { //if we cant find it then add it to the end
-                        names[name] = seqs.size();
-                        seqs.push_back((name + '\t' + group));
-                        m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                    }
-                }
-            }
-            in.close();        
-            
-            int count = 0;
-            for (int i = 0; i < seqs.size(); i++) {
-                if (seqs[i] != "") { out << seqs[i] << endl; count++; }
-            }
-            out.close();
-            
-            m->mothurOut("Ordered " + toString(count) + " sequences from " + groupfile + ".\n");
-            
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> name;            m->gobble(in);          
-                in >> group;    m->gobble(in);
-                
-                if (name != "") {
-                    //if this name is in the accnos file
-                    names[name] = count;
-                    count++;
-                    out << name << '\t' << group << endl;
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + groupfile + " to determine the order. It contains " + toString(count) + " sequences.\n");
-        }
-        
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readGroup");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SortSeqsCommand::readTax(){
-       try {
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(taxfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(taxfile)) + "pick" + m->getExtension(taxfile);
-        outputTypes["taxonomy"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-        
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-        
-               ifstream in;
-               m->openInputFile(taxfile, in);
-               string name, tax;
-               
-               if (names.size() != 0) {//this is not the first file we are reading so we need to use the order we already have
-            
-            vector<string> seqs; seqs.resize(names.size(), "");
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> name;            m->gobble(in);          
-                in >> tax;    m->gobble(in);
-                
-                if (name != "") {
-                    map<string, int>::iterator it = names.find(name);
-                    if (it != names.end()) { //we found it, so put it in the vector in the right place.
-                        seqs[it->second] = name + '\t' + tax;  
-                    }else { //if we cant find it then add it to the end
-                        names[name] = seqs.size();
-                        seqs.push_back((name + '\t' + tax));
-                        m->mothurOut(name + " was not in the contained the file which determined the order, adding it to the end.\n");
-                    }
-                }
-            }
-            in.close();        
-            
-            int count = 0;
-            for (int i = 0; i < seqs.size(); i++) {
-                if (seqs[i] != "") { out << seqs[i] << endl; count++; }
-            }
-            out.close();
-            
-            m->mothurOut("Ordered " + toString(count) + " sequences from " + taxfile + ".\n");
-            
-        }else { //read in file to fill names
-            int count = 0;
-            
-            while(!in.eof()){
-                if (m->control_pressed) { in.close();  out.close();  m->mothurRemove(outputFileName);  return 0; }
-                
-                in >> name;            m->gobble(in);          
-                in >> tax;    m->gobble(in);
-                
-                if (name != "") {
-                    //if this name is in the accnos file
-                    names[name] = count;
-                    count++;
-                    out << name << '\t' << tax << endl;
-                }
-                m->gobble(in);
-            }
-            in.close();        
-            out.close();
-            
-            m->mothurOut("\nUsing " + taxfile + " to determine the order. It contains " + toString(count) + " sequences.\n");
-        }
-        
-               return 0;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readTax");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SortSeqsCommand::readAccnos(){
-       try {
-               
-               ifstream in;
-               m->openInputFile(accnosfile, in);
-               string name;
-        int count = 0;
-               
-               while(!in.eof()){
-            
-            if (m->control_pressed) { break; }
-            
-                       in >> name; m->gobble(in);
-            
-            if (name != "") {
-                names[name] = count;
-                count++;
-            }
-               }
-               in.close();             
-        
-        m->mothurOut("\nUsing " + accnosfile + " to determine the order. It contains " + toString(count) + " representative sequences.\n");
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SortSeqsCommand", "readAccnos");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-
-
-
-
diff --git a/sortseqscommand.h b/sortseqscommand.h
deleted file mode 100644 (file)
index 0685d3b..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef Mothur_sortseqscommand_h
-#define Mothur_sortseqscommand_h
-
-
-//
-//  sortseqscommand.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 2/3/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-
-
-#include "command.hpp"
-
-class SortSeqsCommand : public Command {
-       
-public:
-       
-    SortSeqsCommand(string);   
-    SortSeqsCommand();
-    ~SortSeqsCommand(){}
-       
-    vector<string> setParameters();
-    string getCommandName()                    { return "sort.seqs";                           }
-    string getCommandCategory()                { return "Sequence Processing";         }
-    string getHelpString();    
-    string getCitation() { return "http://www.mothur.org/wiki/Sort.seqs"; }
-    string getDescription()            { return "puts sequences from a fasta, name, group, quality, flow or taxonomy file in the same order"; }
-    
-    int execute(); 
-    void help() { m->mothurOut(getHelpString()); }     
-       
-       
-private:
-    map<string, int> names;
-    string accnosfile, fastafile, namefile, groupfile, taxfile, qualfile, flowfile, outputDir;
-    bool abort, large;
-    vector<string> outputNames;
-    
-    int readFasta();
-    int readFlow();
-    int readName();
-    int readGroup();
-    int readAccnos();
-    int readTax();
-    int readQual();
-    
-};
-
-#endif
-
-
diff --git a/sparsematrix.cpp b/sparsematrix.cpp
deleted file mode 100644 (file)
index 3a0ec65..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-
-#include "sparsematrix.hpp"
-#include "listvector.hpp"
-
-
-/***********************************************************************/
-
-SparseMatrix::SparseMatrix() : numNodes(0), minsIndex(0), smallDist(1e6){  m = MothurOut::getInstance();  }
-
-/***********************************************************************/
-
-int SparseMatrix::getNNodes(){
-       return numNodes; 
-}
-
-/***********************************************************************/
-
-float SparseMatrix::getSmallDist(){
-       return smallDist;
-}
-
-/***********************************************************************/
-
-MatData SparseMatrix::rmCell(MatData data){
-       try {
-               if(data->vectorMap != NULL ){
-                       *(data->vectorMap) = NULL;
-                       data->vectorMap = NULL;
-               }
-               data = matrix.erase(data);              
-               numNodes--;
-               return(data);
-       //  seems like i should be updating smallDist here, but the only time we remove cells is when
-       //  clustering and the clustering algorithm updates smallDist
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "rmCell");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SparseMatrix::addCell(PCell value){
-       try {
-               matrix.push_back(value);
-               numNodes++;
-               if(value.dist < smallDist){
-                       smallDist = value.dist;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "addCell");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SparseMatrix::clear(){
-       try {
-               matrix.clear();
-               mins.clear();
-               numNodes = 0;
-               minsIndex = 0;
-               smallDist = 1e6;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "clear");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-MatData SparseMatrix::begin(){
-       return matrix.begin();  
-}
-
-/***********************************************************************/
-
-MatData SparseMatrix::end(){
-       return matrix.end();    
-}
-
-/***********************************************************************/
-
-void SparseMatrix::print(){
-       try {
-               int index = 0;
-       
-               cout << endl << "Index\tRow\tColumn\tDistance" << endl;
-       
-               for(MatData currentCell=matrix.begin();currentCell!=matrix.end();currentCell++){
-                       cout << index << '\t' << currentCell->row  << '\t' << currentCell->column << '\t' << currentCell->dist << endl;
-                       index++;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-void SparseMatrix::print(ListVector* list){
-       try {
-               int index = 0;
-       
-               m->mothurOutEndLine(); m->mothurOut("Index\tRow\tColumn\tDistance"); m->mothurOutEndLine();
-       
-               for(MatData currentCell=matrix.begin();currentCell!=matrix.end();currentCell++){
-                       m->mothurOut(toString(index) + "\t" + toString(list->get(currentCell->row))  + "\t" + toString(list->get(currentCell->column)) + "\t" + toString(currentCell->dist)); m->mothurOutEndLine();
-                       index++;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "print");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-PCell* SparseMatrix::getSmallestCell(){
-       try {
-       //      this is where I check to see if the next small distance has the correct distance
-       //      if it doesn't then I remove the offending Cell -> should also be able to check for
-       //      invalid iterator / pointer -- right???
-       
-               while(!mins.empty() && mins.back() == NULL){
-                       mins.pop_back();                
-               }
-       
-       //      if the mins vector is empty go here...
-               if(mins.empty()){               
-                       mins.clear();
-       
-                       smallDist = begin()->dist;  //set the first candidate small distance
-               
-                       for(MatData currentCell=begin();currentCell!=end();currentCell++){
-                       
-                               float dist = currentCell->dist;
-                       
-                               if(dist < smallDist){  //found a new smallest distance
-                                       mins.clear();
-                                       smallDist = dist;
-                                       mins.push_back(&*currentCell);  //this is the address of the data in the list being pointed to by the MatData iterator
-                               }
-                               else if(dist == smallDist){  //if a subsequent distance is the same as mins distance add the new iterator to the mins vector
-                                       mins.push_back(&*currentCell); //this is the address of the data in the list being pointed to by the MatData iterator
-                               }
-
-                       }
-                       random_shuffle(mins.begin(), mins.end());  //randomize the order of the iterators in the mins vector
-
-                       for(int i=0;i<mins.size();i++){
-                               mins[i]->vectorMap = &mins[i];  //assign vectorMap to the address for the container
-                       }
-                       
-               }
-       
-               smallCell = mins.back();        //make the smallestCell the last element of the vector
-
-               mins.pop_back();                        //remove the last element from the vector
-
-               return smallCell;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SparseMatrix", "getSmallestCell");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/sparsematrix.hpp b/sparsematrix.hpp
deleted file mode 100644 (file)
index c8a11d7..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef SPARSEMATRIX_H
-#define SPARSEMATRIX_H
-
-#include "mothur.h"
-#include "mothurout.h"
-
-
-class ListVector;
-
-/***********************************************************************/
-
-
- struct PCell{
-       ull row;
-       ull column;
-       float dist;
-       PCell** vectorMap;
-       PCell() : row(0), column(0), dist(0), vectorMap(NULL) {};
-       PCell(ull r, ull c, float d) : row(r), column(c), dist(d), vectorMap(NULL) {};
-};
-
-/***********************************************************************/
-
-typedef list<PCell>::iterator MatData;
-
-class SparseMatrix {
-       
-public:
-       SparseMatrix();
-       ~SparseMatrix(){  while(!mins.empty() && mins.back() == NULL){  mins.pop_back();        }  }
-       int getNNodes();
-       void print();                                   //Print the contents of the matrix
-       void print(ListVector*);                //Print the contents of the matrix
-       PCell* getSmallestCell();               //Return the cell with the smallest distance
-       float getSmallDist();
-       
-       MatData rmCell(MatData);
-       void addCell(PCell);
-       void clear();
-       MatData begin();
-       MatData end();
-
-private:
-       PCell* smallCell;                               //The cell with the smallest distance
-       int numNodes;
-
-       list<PCell> matrix;
-       
-       vector<PCell*> mins;
-       float smallDist;
-       int minsIndex;
-       MothurOut* m;
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/spearman.cpp b/spearman.cpp
deleted file mode 100644 (file)
index 49d5265..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- *  spearman.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "spearman.h"
-
-/***********************************************************************/
-
-EstOutput Spearman::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               SAbundVector savA = shared[0]->getSAbundVector();
-               SAbundVector savB = shared[1]->getSAbundVector();
-               
-               double sumRanks = 0.0;
-               int numOTUS = shared[0]->getNumBins();
-               
-               vector<double> rankVectorA(savA.getMaxRank()+1, 0);
-               int currentRankA = 0;
-               for(int i=savA.getMaxRank();i>0;i--){   
-                       int numWithAbundanceI = savA.get(i);
-
-                       if(numWithAbundanceI > 1){      rankVectorA[i] = (currentRankA + 1 + currentRankA + numWithAbundanceI) / 2.0;   }
-                       else                                    {       rankVectorA[i] = currentRankA+numWithAbundanceI;        }
-                       currentRankA += numWithAbundanceI;
-               }
-               rankVectorA[0] = (numOTUS + currentRankA + 1) / 2.0;
-               
-               
-               vector<double> rankVectorB(savB.getMaxRank()+1, 0);
-               int currentRankB = 0;
-               for(int i=savB.getMaxRank();i>0;i--){   
-                       int numWithAbundanceI = savB.get(i);
-                       
-                       if(numWithAbundanceI > 1){      rankVectorB[i] = (currentRankB + 1 + currentRankB + numWithAbundanceI) / 2.0;   }
-                       else                                    {       rankVectorB[i] = currentRankB+numWithAbundanceI;        }
-                       currentRankB += numWithAbundanceI;
-               }
-               rankVectorB[0] = (numOTUS + currentRankB + 1) / 2.0;
-               
-               
-
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       float rankA = rankVectorA[Aij];
-                       float rankB = rankVectorB[Bij];
-                       
-                       sumRanks += ((rankA - rankB) * (rankA - rankB));
-               }
-               data[0] = 1.0 - ((6 * sumRanks) / (float) (numOTUS * ((numOTUS*numOTUS)-1)));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Spearman", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
diff --git a/spearman.h b/spearman.h
deleted file mode 100644 (file)
index 06a4aa9..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef SPEARMAN_H
-#define SPEARMAN_H
-
-/*
- *  spearman.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class Spearman : public Calculator  {
-       
-public:
-       Spearman() :  Calculator("spearman", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Spearman"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
-
-
diff --git a/speciesprofile.cpp b/speciesprofile.cpp
deleted file mode 100644 (file)
index c225a8a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  speciesprofile.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "speciesprofile.h"
-
-/***********************************************************************/
-EstOutput SpeciesProfile::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumA = 0.0;
-               double sumB = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       sumA += shared[0]->getAbundance(i);
-                       sumB += shared[1]->getAbundance(i);
-               }
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       sum += (((A / sumA) - (B / sumB)) * ((A / sumA) - (B / sumB)));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SpeciesProfile", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/speciesprofile.h b/speciesprofile.h
deleted file mode 100644 (file)
index f2c5ff4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef SPECIESPROFILE_H
-#define SPECIESPROFILE_H
-
-/*
- *  speciesprofile.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class SpeciesProfile : public Calculator  {
-       
-public:
-       SpeciesProfile() :  Calculator("speciesprofile", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Speciesprofile"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
diff --git a/spline.cpp b/spline.cpp
deleted file mode 100644 (file)
index f81bd4e..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-
-#include "spline.h"
-
-
-extern"C" {
-       void sgram_(double *sg0, double *sg1, double *sg2,
-                               double *sg3, double* knot, int* nk);
-       void stxwx_(double *xs, double *ys, double *ws, int *n,
-                               double *knot, int *nk, double *xwy, double *hs0, double *hs1, double *hs2, double *hs3);
-       void sslvrg_(double *penalt, double *dofoff, double *xs, double *ys, double *ws, double *ssw, int *n,
-                                double *knot, int *nk,
-                                double *coef, double *sz, double *lev, double *crit, int *icrit, double *lspar, double *xwy,
-                                double *hs0, double *hs1, double *hs2, double *hs3,
-                                double *sg0, double *sg1, double *sg2, double *sg3, double *abd,
-                                double *p1ip, double *p2ip, int *ld4, int *ldnk, int *ier);
-}
-/***********************************************************/
-// used as reference - http://www.koders.com/fortran/fid8AA63B49CF22F0138E9B3DBDC405696F4A62C1CF.aspx
-//  http://www.koders.com/c/fidD995301A8A5549CE0361F4E7FFDFD3CDC4B4E4A3.aspx
-/* A Cubic B-spline Smoothing routine.
- // sbart.f -- translated by f2c (version 20010821).
- // ------- and f2c-clean,v 1.9 2000/01/13
- //
- // According to the GAMFIT sources, this was derived from code by
- // Finbarr O'Sullivan.
- //
- The algorithm minimises:
- (1/n) * sum ws(i)^2 * (ys(i)-sz(i))^2 + lambda* int ( s"(x) )^2 dx
- lambda is a function of the spar which is assumed to be between 0 and 1
- INPUT
- -----
- penalt                        A penalty > 1 to be used in the gcv criterion
- dofoff                        either `df.offset' for GCV or `df' (to be matched).
- n                             number of data points
- ys(n)                 vector of length n containing the observations
- ws(n)                 vector containing the weights given to each data point
- NB: the code alters the values here.
- xs(n)                 vector containing the ordinates of the observations
- ssw                   `centered weighted sum of y^2'
- nk                            number of b-spline coefficients to be estimated
- nk <= n+2
- knot(nk+4)            vector of knot points defining the cubic b-spline basis.
- To obtain full cubic smoothing splines one might
- have (provided the xs-values are strictly increasing)
- spar                  penalised likelihood smoothing parameter
- ispar                 indicating if spar is supplied (ispar=1) or to be estimated
- lspar, uspar  lower and upper values for spar search;  0.,1. are good values
- tol, eps              used in Golden Search routine
- isetup                        setup indicator [initially 0
- icrit                 indicator saying which cross validation score is to be computed
- 0: none ;  1: GCV ;  2: CV ;  3: 'df matching'
- ld4                   the leading dimension of abd (ie ld4=4)
- ldnk                  the leading dimension of p2ip (not referenced)
- OUTPUT
- ------
- coef(nk)              vector of spline coefficients
- sz(n)                 vector of smoothed z-values
- lev(n)                        vector of leverages
- crit                  either ordinary or generalized CV score
- spar                  if ispar != 1
- lspar                 == lambda (a function of spar and the design)
- iter                  number of iterations needed for spar search (if ispar != 1)
- ier                   error indicator
- ier = 0 ___  everything fine
- ier = 1 ___  spar too small or too big
- problem in cholesky decomposition
- Working arrays/matrix
- xwy                           X'Wy
- hs0,hs1,hs2,hs3       the diagonals of the X'WX matrix
- sg0,sg1,sg2,sg3       the diagonals of the Gram matrix SIGMA
- abd (ld4,nk)          [ X'WX + lambda*SIGMA ] in diagonal form
- p1ip(ld4,nk)          inner products between columns of L inverse
- p2ip(ldnk,nk)         all inner products between columns of L inverse
- where  L'L = [X'WX + lambda*SIGMA]  NOT REFERENCED
- */
-
-int Spline::sbart
-(double *penalt, double *dofoff,
- double *xs, double *ys, double *ws, double *ssw,
- int *n, double *knot, int *nk, double *coef,
- double *sz, double *lev, double *crit, int *icrit,
- double *spar, int *ispar, int *iter, double *lspar,
- double *uspar, double *tol, double *eps, int *isetup,
- int *ld4, int *ldnk, int *ier)
-{
-       try{
-       /* A Cubic B-spline Smoothing routine.
-        
-        The algorithm minimises:
-        
-        (1/n) * sum ws(i)^2 * (ys(i)-sz(i))^2 + lambda* int ( s(x) )^2 dx
-        
-        lambda is a function of the spar which is assumed to be between 0 and 1
-        
-        INPUT
-        -----
-        penalt A penalty > 1 to be used in the gcv criterion
-        dofoff either `df.offset' for GCV or `df' (to be matched).
-        n              number of data points
-        ys(n)  vector of length n containing the observations
-        ws(n)  vector containing the weights given to each data point
-        NB: the code alters the values here.
-        xs(n)  vector containing the ordinates of the observations
-        ssw          `centered weighted sum of y^2
-        nk             number of b-spline coefficients to be estimated
-        nk <= n+2
-        knot(nk+4)     vector of knot points defining the cubic b-spline basis.
-        To obtain full cubic smoothing splines one might
-        have (provided the xs-values are strictly increasing)
-        spar           penalised likelihood smoothing parameter
-        ispar  indicating if spar is supplied (ispar=1) or to be estimated
-        lspar, uspar lower and upper values for spar search;  0.,1. are good values
-        tol, eps       used in Golden Search routine
-        isetup setup indicator [initially 0
-        icrit  indicator saying which cross validation score is to be computed
-        0: none ;  1: GCV ;  2: CV ;  3: 'df matching'
-        ld4            the leading dimension of abd (ie ld4=4)
-        ldnk           the leading dimension of p2ip (not referenced)
-        
-        OUTPUT
-        ------
-        coef(nk)       vector of spline coefficients
-        sz(n)  vector of smoothed z-values
-        lev(n) vector of leverages
-        crit           either ordinary or generalized CV score
-        spar         if ispar != 1
-        lspar         == lambda (a function of spar and the design)
-        iter           number of iterations needed for spar search (if ispar != 1)
-        ier            error indicator
-        ier = 0 ___  everything fine
-        ier = 1 ___  spar too small or too big
-        problem in cholesky decomposition
-        
-        Working arrays/matrix
-        xwy                    XWy
-        hs0,hs1,hs2,hs3        the diagonals of the XWX matrix
-        sg0,sg1,sg2,sg3        the diagonals of the Gram matrix SIGMA
-        abd (ld4,nk)           [ XWX + lambda*SIGMA ] in diagonal form
-        p1ip(ld4,nk)           inner products between columns of L inverse
-        p2ip(ldnk,nk)  all inner products between columns of L inverse
-        where  LL = [XWX + lambda*SIGMA]  NOT REFERENCED
-        */
-       
-#define CRIT(FX) (*icrit == 3 ? FX - 3. : FX)
-               /* cancellation in (3 + eps) - 3, but still...informative */
-               
-#define BIG_f (1e100)
-               
-               /* c_Gold is the squared inverse of the golden ratio */
-               static const double c_Gold = 0.381966011250105151795413165634;
-               /* == (3. - sqrt(5.)) / 2. */
-               
-               /* Local variables */
-               static double ratio;/* must be static (not needed in R) */
-               
-               double a, b, d, e, p, q, r, u, v, w, x;
-               double ax, fu, fv, fw, fx, bx, xm;
-               double t1, t2, tol1, tol2;
-               double* xwy = new double[*nk];
-               double* hs0 = new double[*nk];
-               double* hs1 = new double[*nk];
-               double* hs2 = new double[*nk];
-               double* hs3 = new double[*nk];
-               double* sg0 = new double[*nk];
-               double* sg1 = new double[*nk];
-               double* sg2 = new double[*nk];
-               double* sg3 = new double[*nk];
-               double* abd = new double[*nk*(*ld4)]; 
-               double* p1ip = new double[*nk*(*ld4)]; 
-               double* p2ip = new double[*nk]; 
-               int i, maxit;
-
-               /* unnecessary initializations to keep  -Wall happy */
-               d = 0.; fu = 0.; u = 0.;
-               ratio = 1.;
-               
-               /*  Compute SIGMA, X' W X, X' W z, trace ratio, s0, s1.
-                
-                SIGMA  -> sg0,sg1,sg2,sg3
-                X' W X -> hs0,hs1,hs2,hs3
-                X' W Z -> xwy
-                */
-               
-               /* trevor fixed this 4/19/88
-                * Note: sbart, i.e. stxwx() and sslvrg() {mostly, not always!}, use
-                *       the square of the weights; the following rectifies that */
-               for (i = 0; i < *n; ++i)
-                       if (ws[i] > 0.)
-                               ws[i] = sqrt(ws[i]);
-               
-               if (*isetup == 0) {
-                       /* SIGMA[i,j] := Int  B''(i,t) B''(j,t) dt  {B(k,.) = k-th B-spline} */
-                       sgram_(sg0, sg1, sg2, sg3, knot, nk);
-                       stxwx_(xs, ys, ws, n,
-                                                       knot, nk,
-                                                       xwy,
-                                                       hs0, hs1, hs2, hs3);
-                       /* Compute ratio :=  tr(X' W X) / tr(SIGMA) */
-                       t1 = t2 = 0.;
-                       for (i = 3 - 1; i < (*nk - 3); ++i) {
-                               t1 += hs0[i];
-                               t2 += sg0[i];
-                       }
-                       ratio = t1 / t2;
-                       *isetup = 1;
-               }
-               /*     Compute estimate */
-               
-               if (*ispar == 1) { /* Value of spar supplied */
-                       *lspar = ratio * pow(16.0, (*spar * 6.0 - 2.0));
-                       sslvrg_(penalt, dofoff, xs, ys, ws, ssw, n,
-                                                        knot, nk,
-                                                        coef, sz, lev, crit, icrit, lspar, xwy,
-                                                        hs0, hs1, hs2, hs3,
-                                                        sg0, sg1, sg2, sg3, abd,
-                                                        p1ip, p2ip, ld4, ldnk, ier);
-                       /* got through check 2 */
-                       return 0;
-               }
-               
-               /* ELSE ---- spar not supplied --> compute it ! ---------------------------
-                
-                Use Forsythe Malcom and Moler routine to MINIMIZE criterion
-                f denotes the value of the criterion
-                
-                an approximation       x  to the point where   f  attains a minimum  on
-                the interval  (ax,bx)  is determined.
-                */
-               ax = *lspar;
-               bx = *uspar;
-               
-               /* INPUT
-                
-                ax      left endpoint of initial interval
-                bx      right endpoint of initial interval
-                f       function subprogram which evaluates  f(x)  for any  x
-         in the interval  (ax,bx)
-                tol     desired length of the interval of uncertainty of the final
-         result ( >= 0 )
-                
-                OUTPUT
-                
-                fmin    abcissa approximating the point where  f  attains a minimum
-                */
-               
-               /*
-                The method used is a combination of  golden  section  search  and
-                successive parabolic interpolation.    convergence is never much slower
-                than    that  for  a  fibonacci search.  if  f  has a continuous second
-                derivative which is positive at the minimum (which is not  at  ax  or
-                bx),    then  convergence  is  superlinear, and usually of the order of
-                about  1.324....
-                the function  f  is never evaluated at two points closer together
-                than    eps*abs(fmin) + (tol/3), where eps is  approximately the square
-                root    of  the  relative  machine  precision.   if   f   is a unimodal
-                function and the computed values of     f   are  always  unimodal  when
-                separated by at least  eps*abs(x) + (tol/3), then  fmin  approximates
-                the abcissa of the global minimum of    f  on the interval  ax,bx  with
-                an error less than  3*eps*abs(fmin) + tol.  if   f     is not unimodal,
-                then fmin may approximate a local, but perhaps non-global, minimum to
-                the same accuracy.
-                this function subprogram is a slightly modified        version  of  the
-                algol  60 procedure    localmin  given in richard brent, algorithms for
-                minimization without derivatives, prentice - hall, inc. (1973).
-                
-                Double  a,b,c,d,e,eps,xm,p,q,r,tol1,tol2,u,v,w
-                Double  fu,fv,fw,fx,x
-                */
-               
-               /*  eps is approximately the square root of the relative machine
-                precision.
-                
-                -       eps = 1e0
-                - 10    eps = eps/2e0
-                -       tol1 = 1e0 + eps
-                -       if (tol1 > 1e0) go to 10
-                -       eps = sqrt(eps)
-                R Version <= 1.3.x had
-                eps = .000244     ( = sqrt(5.954 e-8) )
-                -- now eps is passed as argument
-                */
-               
-               /* initialization */
-               
-               maxit = *iter;
-               *iter = 0;
-               a = ax;
-               b = bx;
-               v = a + c_Gold * (b - a);
-               w = v;
-               x = v;
-               e = 0.;
-               *spar = x;
-               *lspar = ratio * pow(16.0, (*spar * 6.0 - 2.0));
-               sslvrg_(penalt, dofoff, xs, ys, ws, ssw, n,
-                                                knot, nk,
-                                                coef, sz, lev, crit, icrit, lspar, xwy,
-                               hs0, hs1, hs2, hs3,
-                               sg0, sg1, sg2, sg3, abd,
-                               p1ip, p2ip, ld4, ldnk, ier);
-               fx = *crit;
-               fv = fx;
-               fw = fx;
-               
-               /* main loop
-                --------- */
-               while(*ier == 0) { /* L20: */
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       xm = (a + b) * .5;
-                       tol1 = *eps * fabs(x) + *tol / 3.;
-                       tol2 = tol1 * 2.;
-                       ++(*iter);
-                       
-                       
-                       /* Check the (somewhat peculiar) stopping criterion: note that
-                        the RHS is negative as long as the interval [a,b] is not small:*/
-                       if (fabs(x - xm) <= tol2 - (b - a) * .5 || *iter > maxit)
-                               goto L_End;
-                       
-                       
-                       /* is golden-section necessary */
-                       
-                       if (fabs(e) <= tol1 ||
-                               /*  if had Inf then go to golden-section */
-                               fx >= BIG_f || fv >= BIG_f || fw >= BIG_f) goto L_GoldenSect;
-                       
-                       /* Fit Parabola */
-                       
-                       r = (x - w) * (fx - fv);
-                       q = (x - v) * (fx - fw);
-                       p = (x - v) * q - (x - w) * r;
-                       q = (q - r) * 2.;
-                       if (q > 0.)
-                               p = -p;
-                       q = fabs(q);
-                       r = e;
-                       e = d;
-                       
-                       /* is parabola acceptable?  Otherwise do golden-section */
-                       
-                       if (fabs(p) >= fabs(.5 * q * r) ||
-                               q == 0.)
-                       /* above line added by BDR;
-                        * [the abs(.) >= abs() = 0 should have branched..]
-                        * in FTN: COMMON above ensures q is NOT a register variable */
-                               
-                               goto L_GoldenSect;
-                       
-                       if (p <= q * (a - x) ||
-                               p >= q * (b - x))                       goto L_GoldenSect;
-                       
-                       
-                       
-                       /* Parabolic Interpolation step */
-                       d = p / q;
-                       u = x + d;
-                       
-                       /* f must not be evaluated too close to ax or bx */
-                       if ((u - a < tol2 || b - u < tol2)) {
-                               d = abs(tol1) * sgn(xm - x);
-                       }       
-                       
-                       goto L50;
-                       /*------*/
-                       
-               L_GoldenSect: /* a golden-section step */
-                       
-                       if (x >= xm)    e = a - x;
-                       else/* x < xm*/ e = b - x;
-                       d = c_Gold * e;
-                       
-                       
-               L50:
-                       u = x + ((fabs(d) >= tol1) ? d : (abs(tol1)*sgn(d)));
-                       /*  tol1 check : f must not be evaluated too close to x */
-                       
-                       *spar = u;
-                       *lspar = ratio * pow(16.0, (*spar * 6.0 - 2.0));
-                       sslvrg_(penalt, dofoff, xs, ys, ws, ssw, n,
-                                                        knot, nk,
-                                                        coef, sz, lev, crit, icrit, lspar, xwy,
-                                       hs0, hs1, hs2, hs3,
-                                       sg0, sg1, sg2, sg3, abd,
-                                       p1ip, p2ip, ld4, ldnk, ier);
-                       fu = *crit;
-                       
-                       if(isnan(fu)) {
-                               fu = 2. * BIG_f;
-                       }
-                       
-                       /*  update  a, b, v, w, and x */
-                       
-                       if (fu <= fx) {
-                               if (u >= x) a = x; else b = x;
-                               
-                               v = w; fv = fw;
-                               w = x; fw = fx;
-                               x = u; fx = fu;
-                       }
-                       else {
-                               if (u < x)  a = u; else b = u;
-                               
-                               if (fu <= fw || w == x) {                       /* L70: */
-                                       v = w; fv = fw;
-                                       w = u; fw = fu;
-                               } else if (fu <= fv || v == x || v == w) {      /* L80: */
-                                       v = u; fv = fu;
-                               }
-                       }
-               }/* end main loop -- goto L20; */
-               
-       L_End:
-               
-               *spar = x;
-               *crit = fx;
-                               
-               //free memory
-               delete [] xwy;
-               delete [] hs0;
-               delete [] hs1;
-               delete [] hs2;
-               delete [] hs3;
-               delete [] sg0;
-               delete [] sg1;
-               delete [] sg2;
-               delete [] sg3;
-               delete [] abd;
-               delete [] p1ip;
-               delete [] p2ip;
-               
-               return 0;
-               /* sbart */
-
-       }catch(exception& e) {
-               m->errorOut(e, "Spline", "sbart");
-               exit(1);
-       }
-}      
-
-/***********************************************************/
diff --git a/spline.h b/spline.h
deleted file mode 100644 (file)
index 94a0c64..0000000
--- a/spline.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef SPLINE
-#define SPLINE
-
-
-/*
- *  spline.h
- *  Mothur
- *
- *  Created by westcott on 12/6/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-//This class was translated into c++ using c and fortran code from www.koders.com as a reference.
-
-#include "mothurout.h"
-
-class Spline {
-       
-       public:
-               Spline() { m = MothurOut::getInstance(); }
-               ~Spline() {}
-               
-               int sbart(double *penalt, double *dofoff,
-                          double *xs, double *ys, double *ws, double *ssw,
-                          int *n, double *knot, int *nk, double *coef,
-                          double *sz, double *lev, double *crit, int *icrit,
-                          double *spar, int *ispar, int *iter, double *lspar,
-                          double *uspar, double *tol, double *eps, int *isetup,
-                          int *ld4, int *ldnk, int *ier);
-               
-       private:
-               MothurOut* m;
-};
-
-#endif
-
-
diff --git a/splitabundcommand.cpp b/splitabundcommand.cpp
deleted file mode 100644 (file)
index 8131fa9..0000000
+++ /dev/null
@@ -1,1026 +0,0 @@
-/*
- *  splitabundcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 5/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "splitabundcommand.h"
-
-//**********************************************************************************************************************
-vector<string> SplitAbundCommand::setParameters(){     
-       try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FNGLT", "none",false,false); parameters.push_back(plist);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcutoff("cutoff", "Number", "", "0", "", "", "",false,true); parameters.push_back(pcutoff);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter paccnos("accnos", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(paccnos);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SplitAbundCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The split.abund command reads a fasta file and a list or a names file splits the sequences into rare and abundant groups. \n";
-               helpString += "The split.abund command parameters are fasta, list, name, cutoff, group, label, groups, cutoff and accnos.\n";
-               helpString += "The fasta and a list or name parameter are required, and you must provide a cutoff value.\n";
-               helpString += "The cutoff parameter is used to qualify what is abundant and rare.\n";
-               helpString += "The group parameter allows you to parse a group file into rare and abundant groups.\n";
-               helpString += "The label parameter is used to read specific labels in your listfile you want to use.\n";
-               helpString += "The accnos parameter allows you to output a .rare.accnos and .abund.accnos files to use with the get.seqs and remove.seqs commands.\n";
-               helpString += "The groups parameter allows you to parse the files into rare and abundant files by group.  \n";
-               helpString += "For example if you set groups=A-B-C, you will get a .A.abund, .A.rare, .B.abund, .B.rare, .C.abund, .C.rare files.  \n";
-               helpString += "If you want .abund and .rare files for all groups, set groups=all.  \n";
-               helpString += "The split.abund command should be used in the following format: split.abund(fasta=yourFasta, list=yourListFile, group=yourGroupFile, label=yourLabels, cutoff=yourCutoff).\n";
-               helpString += "Example: split.abund(fasta=abrecovery.fasta, list=abrecovery.fn.list, group=abrecovery.groups, label=0.03, cutoff=2).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. list), '=' and parameters (i.e.yourListfile).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-SplitAbundCommand::SplitAbundCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["accnos"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "SplitAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SplitAbundCommand::SplitAbundCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["accnos"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;                    
-                                                                                               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                       }
-
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else{ inputFile = listfile; m->setListFile(listfile); } 
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }    
-                       else{ inputFile = namefile; m->setNameFile(namefile); } 
-               
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {                            
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") {  groupfile = ""; abort = true; } 
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else {  
-                               groupMap = new GroupMap(groupfile);
-                               
-                               int error = groupMap->readMap();
-                               if (error == 1) { abort = true; }
-                               m->setGroupFile(groupfile);
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);         
-                       if (groups == "not found") { groups = ""; }
-                       else if (groups == "all") { 
-                               if (groupfile != "") {  Groups = groupMap->getNamesOfGroups();  } 
-                               else {  m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = "";   }
-                       }else { 
-                               m->splitAtDash(groups, Groups);
-                       }
-                       
-                       if ((groupfile == "") && (groups != "")) {  m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = "";  Groups.clear(); }
-                       
-                       //do you have all files needed
-                       if ((listfile == "") && (namefile == "")) { 
-                               namefile = m->getNameFile(); 
-                               if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                               else {                          
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else {  m->mothurOut("You have no current list or namefile and the list or name parameter is required."); m->mothurOutEndLine(); abort = true; }
-                               }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = "";  allLines = 1; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "accnos", false);            if (temp == "not found") { temp = "F"; }
-                       accnos = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                           if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, cutoff); 
-
-                       if (cutoff == 0) {  m->mothurOut("You must provide a cutoff to qualify what is abundant for the split.abund command. "); m->mothurOutEndLine(); abort = true;  }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "SplitAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SplitAbundCommand::~SplitAbundCommand(){ 
-       if (groupfile != "") {  delete groupMap;  } 
-}
-//**********************************************************************************************************************
-int SplitAbundCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (listfile != "") { //you are using a listfile to determine abundance
-                       if (outputDir == "") { outputDir = m->hasPath(listfile); }
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;        
-                       
-                       input = new InputData(listfile, "list");
-                       list = input->getListVector();
-                       string lastLabel = list->getLabel();
-                       
-                       //do you have a namefile or do we need to similate one?
-                       if (namefile != "") {  readNamesFile();         }
-                       else                            { createNameMap(list);  }
-                       
-                       if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                               if (m->control_pressed) { delete input; delete list; for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]); } return 0; }
-                               
-                               if(allLines == 1 || labels.count(list->getLabel()) == 1){
-                                               
-                                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                               splitList(list);
-                                                                                       
-                                               processedLabels.insert(list->getLabel());
-                                               userLabels.erase(list->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                               string saveLabel = list->getLabel();
-                                               
-                                               delete list;
-                                               list = input->getListVector(lastLabel); //get new list vector to process
-                                               
-                                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                                               splitList(list);
-                                               
-                                               processedLabels.insert(list->getLabel());
-                                               userLabels.erase(list->getLabel());
-                                               
-                                               //restore real lastlabel to save below
-                                               list->setLabel(saveLabel);
-                               }
-                               
-                       
-                               lastLabel = list->getLabel();
-                                       
-                               delete list;
-                               list = input->getListVector(); //get new list vector to process
-                       }
-                       
-                       if (m->control_pressed) { delete input;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-
-                       }
-                       
-                       if (m->control_pressed) { delete input;  for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (list != NULL) {     delete list;    }
-                               list = input->getListVector(lastLabel); //get new list vector to process
-                               
-                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                               splitList(list);                
-                               
-                               delete list;
-                       }
-                       
-                       delete input;
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]); }      return 0;       }
-                                                                       
-               }else { //you are using the namefile to determine abundance
-                       if (outputDir == "") { outputDir = m->hasPath(namefile); }
-                       
-                       splitNames(); 
-                       writeNames();
-                       
-                       string tag = "";
-                       if (groupfile != "")                            {  parseGroup(tag);             }
-                       if (accnos)                                                     {  writeAccnos(tag);    }
-                       if (fastafile != "")                            {  parseFasta(tag);             }
-               }
-               
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               itTypes = outputTypes.find("accnos");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setAccnosFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "execute");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::splitList(ListVector* thisList) {
-       try {
-               rareNames.clear();
-               abundNames.clear();
-               
-               //get rareNames and abundNames
-               for (int i = 0; i < thisList->getNumBins(); i++) {
-                       if (m->control_pressed) { return 0; }
-                       
-                       string bin = thisList->get(i);
-                                               
-                       vector<string> names;
-                       m->splitAtComma(bin, names);  //parses bin into individual sequence names
-                       int size = names.size();
-                               
-                       if (size <= cutoff) {
-                               for (int j = 0; j < names.size(); j++) {  rareNames.insert(names[j]);  }
-                       }else{
-                               for (int j = 0; j < names.size(); j++) {  abundNames.insert(names[j]);  }
-                       }
-               }//end for
-
-               
-               string tag = thisList->getLabel() + ".";
-               
-               writeList(thisList, tag);
-               
-               if (groupfile != "")                            {  parseGroup(tag);             }
-               if (accnos)                                                     {  writeAccnos(tag);    }
-               if (fastafile != "")                            {  parseFasta(tag);             }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "splitList");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::writeList(ListVector* thisList, string tag) { 
-       try {
-               
-               map<string, ofstream*> filehandles;
-               
-               if (Groups.size() == 0) {
-                       SAbundVector* sabund = new SAbundVector();
-                       *sabund = thisList->getSAbundVector();
-               
-                       //find out how many bins are rare and how many are abundant so you can process the list vector one bin at a time
-                       // and don't have to store the bins until you are done with the whole vector, this save alot of space.
-                       int numRareBins = 0;
-                       for (int i = 0; i <= sabund->getMaxRank(); i++) {
-                               if (i > cutoff) { break; }
-                               numRareBins += sabund->get(i);
-                       }
-                       int numAbundBins = thisList->getNumBins() - numRareBins;
-                       delete sabund;
-
-                       ofstream aout;
-                       ofstream rout;
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "rare.list";
-                       m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare); outputTypes["list"].push_back(rare);
-                       
-                       string abund = outputDir + m->getRootName(m->getSimpleName(listfile)) + tag + "abund.list";
-                       m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund); outputTypes["list"].push_back(abund);
-
-                       if (rareNames.size() != 0)      {  rout << thisList->getLabel() << '\t' << numRareBins << '\t';         }
-                       if (abundNames.size() != 0) {   aout << thisList->getLabel() << '\t' << numAbundBins << '\t';   }
-
-                       for (int i = 0; i < thisList->getNumBins(); i++) {
-                               if (m->control_pressed) { break; }
-                       
-                               string bin = list->get(i); 
-                       
-                               int size = m->getNumNames(bin);
-                       
-                               if (size <= cutoff) {  rout << bin << '\t';  }
-                               else                            {  aout << bin << '\t'; }
-                       }
-                       
-                       if (rareNames.size() != 0)      { rout << endl; }
-                       if (abundNames.size() != 0) { aout << endl; }
-                       
-                       rout.close();
-                       aout.close();
-                       
-               }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(listfile));
-                       ofstream* temp;
-                       ofstream* temp2;
-                       //map<string, bool> wroteFile;
-                       map<string, ofstream*> filehandles;
-                       map<string, ofstream*>::iterator it3;
-
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]+".rare"] = temp;
-                               temp2 = new ofstream;
-                               filehandles[Groups[i]+".abund"] = temp2;
-                               
-                               m->openOutputFile(fileroot + Groups[i] + tag + ".rare.list", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + Groups[i] + tag + ".abund.list", *(filehandles[Groups[i]+".abund"]));
-                               outputNames.push_back(fileroot + Groups[i] + tag + ".rare.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".rare.list");
-                               outputNames.push_back(fileroot + Groups[i] + tag + ".abund.list"); outputTypes["list"].push_back(fileroot + Groups[i] + tag + ".abund.list");
-                       }
-                       
-                       map<string, string> groupVector;
-                       map<string, string>::iterator itGroup;
-                       map<string, int> groupNumBins;
-               
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                               groupNumBins[it3->first] = 0;
-                               groupVector[it3->first] = "";
-                       }
-               
-                       for (int i = 0; i < thisList->getNumBins(); i++) {
-                               if (m->control_pressed) { break; }
-                       
-                               map<string, string> groupBins;
-                               string bin = list->get(i); 
-                       
-                               vector<string> names;
-                               m->splitAtComma(bin, names);  //parses bin into individual sequence names
-                       
-                               //parse bin into list of sequences in each group
-                               for (int j = 0; j < names.size(); j++) {
-                                       string rareAbund;
-                                       if (rareNames.count(names[j]) != 0) { //you are a rare name
-                                               rareAbund = ".rare";
-                                       }else{ //you are a abund name
-                                               rareAbund = ".abund";
-                                       }
-                                       
-                                       string group = groupMap->getGroup(names[j]);
-                               
-                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                               itGroup = groupBins.find(group+rareAbund);
-                                               if(itGroup == groupBins.end()) {
-                                                       groupBins[group+rareAbund] = names[j];  //add first name
-                                                       groupNumBins[group+rareAbund]++;
-                                               }else{ //add another name
-                                                       groupBins[group+rareAbund] +=  "," + names[j];
-                                               }
-                                       }else if(group == "not found") {
-                                               m->mothurOut(names[j] + " is not in your groupfile. Ignoring."); m->mothurOutEndLine();
-                                       }
-                               }
-                       
-                       
-                               for (itGroup = groupBins.begin(); itGroup != groupBins.end(); itGroup++) {
-                                       groupVector[itGroup->first] +=  itGroup->second + '\t'; 
-                               }
-                       }
-                       
-                       //end list vector
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                               (*(filehandles[it3->first])) << thisList->getLabel() << '\t' << groupNumBins[it3->first] << '\t' << groupVector[it3->first] << endl;  // label numBins  listvector for that group
-                               (*(filehandles[it3->first])).close();
-                               delete it3->second;
-                       }
-               }
-               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "writeList");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::splitNames() { //namefile
-       try {
-               
-               rareNames.clear();
-               abundNames.clear();     
-                       
-               //open input file
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       
-                       nameMap[firstCol] = secondCol;
-                       
-                       int size = m->getNumNames(secondCol);
-                               
-                       if (size <= cutoff) {
-                               rareNames.insert(firstCol); 
-                       }else{
-                               abundNames.insert(firstCol); 
-                       }
-               }
-               in.close();
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "splitNames");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::readNamesFile() { 
-       try {
-               //open input file
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               while (!in.eof()) {
-                       if (m->control_pressed) { break; }
-                       
-                       string firstCol, secondCol;
-                       in >> firstCol >> secondCol; m->gobble(in);
-                       
-                       nameMap[firstCol] = secondCol;
-               }
-               in.close();
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "readNamesFile");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::createNameMap(ListVector* thisList) {
-       try {
-               
-               if (thisList != NULL) {
-                       for (int i = 0; i < thisList->getNumBins(); i++) {
-                               if (m->control_pressed) { return 0; }
-                               
-                               string bin = thisList->get(i);
-                                                       
-                               vector<string> names;
-                               m->splitAtComma(bin, names);  //parses bin into individual sequence names
-                               
-                               for (int j = 0; j < names.size(); j++) {  nameMap[names[j]] = names[j];  }
-                       }//end for
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "createNameMap");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::writeNames() { //namefile
-       try {
-               
-               map<string, ofstream*> filehandles;
-
-               if (Groups.size() == 0) {
-                       ofstream aout;
-                       ofstream rout;
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(namefile))  + "rare.names";
-                       m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare); outputTypes["name"].push_back(rare);
-                       
-                       string abund = outputDir + m->getRootName(m->getSimpleName(namefile))  + "abund.names";
-                       m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund); outputTypes["name"].push_back(abund);
-                       
-                       if (rareNames.size() != 0) {
-                               for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
-                                       rout << (*itRare) << '\t' << nameMap[(*itRare)] << endl;
-                               }
-                       }
-                       rout.close();
-                       
-                       if (abundNames.size() != 0) {
-                               for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
-                                       aout << (*itAbund) << '\t' << nameMap[(*itAbund)] << endl;
-                               }
-                       }
-                       aout.close();
-                       
-               }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(namefile));
-                       ofstream* temp;
-                       ofstream* temp2;
-                       map<string, ofstream*> filehandles;
-                       map<string, ofstream*>::iterator it3;
-
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]+".rare"] = temp;
-                               temp2 = new ofstream;
-                               filehandles[Groups[i]+".abund"] = temp2;
-                               
-                               m->openOutputFile(fileroot + Groups[i] + ".rare.names", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + Groups[i] + ".abund.names", *(filehandles[Groups[i]+".abund"]));
-                       }
-                       
-                       for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
-                               vector<string> names;
-                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
-                               
-                               string rareAbund;
-                               if (rareNames.count(itName->first) != 0) { //you are a rare name
-                                               rareAbund = ".rare";
-                               }else{ //you are a abund name
-                                               rareAbund = ".abund";
-                               }
-                               
-                               map<string, string> outputStrings;
-                               map<string, string>::iterator itout;
-                               for (int i = 0; i < names.size(); i++) {
-                                       
-                                       string group = groupMap->getGroup(names[i]);
-                                       
-                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                               itout = outputStrings.find(group+rareAbund);
-                                               if (itout == outputStrings.end()) {  
-                                                       outputStrings[group+rareAbund] = names[i] + '\t' + names[i];
-                                               }else {   outputStrings[group+rareAbund] += "," + names[i]; }
-                                       }else if(group == "not found") {
-                                               m->mothurOut(names[i] + " is not in your groupfile. Ignoring."); m->mothurOutEndLine();
-                                       }
-                               }
-                               
-                               for (itout = outputStrings.begin(); itout != outputStrings.end(); itout++) { *(filehandles[itout->first]) << itout->second << endl;     }
-                       }
-                       
-                       
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
-                               (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + it3->first + ".names");  outputTypes["name"].push_back(fileroot + it3->first + ".names");
-                               delete it3->second;
-                       }
-               }
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "writeNames");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-//just write the unique names - if a namesfile is given
-int SplitAbundCommand::writeAccnos(string tag) { 
-       try {
-               
-               map<string, ofstream*> filehandles;
-               
-               if (Groups.size() == 0) {
-                       ofstream aout;
-                       ofstream rout;
-                       
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(inputFile))  + tag + "rare.accnos";
-                       m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare); outputTypes["accnos"].push_back(rare); 
-                       
-                       for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
-                               rout << (*itRare) << endl;
-                       }
-                       rout.close();
-               
-                       string abund = outputDir + m->getRootName(m->getSimpleName(inputFile)) + tag  + "abund.accnos";
-                       m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund); outputTypes["accnos"].push_back(abund);
-                       
-                       for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
-                               aout << (*itAbund) << endl;
-                       }
-                       aout.close();
-                       
-               }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(inputFile));
-                       ofstream* temp;
-                       ofstream* temp2;
-                       map<string, ofstream*> filehandles;
-                       map<string, ofstream*>::iterator it3;
-                       
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]+".rare"] = temp;
-                               temp2 = new ofstream;
-                               filehandles[Groups[i]+".abund"] = temp2;
-                               
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.accnos", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.accnos", *(filehandles[Groups[i]+".abund"]));
-                       }
-                       
-                       //write rare
-                       for (set<string>::iterator itRare = rareNames.begin(); itRare != rareNames.end(); itRare++) {
-                                       string group = groupMap->getGroup(*itRare);
-                                       
-                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                               *(filehandles[group+".rare"]) << *itRare << endl;
-                                       }
-                       }
-                               
-                       //write abund   
-                       for (set<string>::iterator itAbund = abundNames.begin(); itAbund != abundNames.end(); itAbund++) {
-                                       string group = groupMap->getGroup(*itAbund);
-                                       
-                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                               *(filehandles[group+".abund"]) << *itAbund << endl;
-                                       }
-                       }
-                       
-                       //close files
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
-                               (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".accnos");  outputTypes["accnos"].push_back(fileroot + tag + it3->first + ".accnos");
-                               delete it3->second;
-                       }
-               }
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "writeAccnos");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::parseGroup(string tag) { //namefile
-       try {
-               
-               map<string, ofstream*> filehandles;
-       
-               if (Groups.size() == 0) {
-                       ofstream aout;
-                       ofstream rout;
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "rare.groups";
-                       m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare); outputTypes["group"].push_back(rare);
-               
-                       string abund = outputDir + m->getRootName(m->getSimpleName(groupfile))  + tag + "abund.groups";
-                       m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund); outputTypes["group"].push_back(abund);
-                       
-                       for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
-                               vector<string> names;
-                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
-                               
-                               for (int i = 0; i < names.size(); i++) {
-                               
-                                       string group = groupMap->getGroup(names[i]);
-                               
-                                       if (group == "not found") { 
-                                               m->mothurOut(names[i] + " is not in your groupfile, ignoring, please correct."); m->mothurOutEndLine();
-                                       }else {
-                                               if (rareNames.count(itName->first) != 0) { //you are a rare name
-                                                       rout << names[i] << '\t' << group << endl;
-                                               }else{ //you are a abund name
-                                                       aout << names[i] << '\t' << group << endl;
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       rout.close(); 
-                       aout.close(); 
-
-               }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(groupfile));
-                       ofstream* temp;
-                       ofstream* temp2;
-                       map<string, ofstream*> filehandles;
-                       map<string, ofstream*>::iterator it3;
-
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]+".rare"] = temp;
-                               temp2 = new ofstream;
-                               filehandles[Groups[i]+".abund"] = temp2;
-                               
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.groups", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.groups", *(filehandles[Groups[i]+".abund"]));
-                       }
-                       
-                       for (map<string, string>::iterator itName = nameMap.begin(); itName != nameMap.end(); itName++) {                               
-                               vector<string> names;
-                               m->splitAtComma(itName->second, names);  //parses bin into individual sequence names
-                               
-                               string rareAbund;
-                               if (rareNames.count(itName->first) != 0) { //you are a rare name
-                                       rareAbund = ".rare";
-                               }else{ //you are a abund name
-                                       rareAbund = ".abund";
-                               }
-                               
-                               for (int i = 0; i < names.size(); i++) {
-                               
-                                       string group = groupMap->getGroup(names[i]);
-                                                                       
-                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                               *(filehandles[group+rareAbund]) << names[i] << '\t' << group << endl;
-                                       }
-                               }
-                       }
-                       
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
-                               (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".groups");  outputTypes["group"].push_back(fileroot + tag + it3->first + ".groups");
-                               delete it3->second;
-                       }
-               }
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "parseGroups");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-int SplitAbundCommand::parseFasta(string tag) { //namefile
-       try {
-               
-               map<string, ofstream*> filehandles;
-               
-               if (Groups.size() == 0) {
-                       ofstream aout;
-                       ofstream rout;
-                       
-                       string rare = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "rare.fasta";
-                       m->openOutputFile(rare, rout);
-                       outputNames.push_back(rare); outputTypes["fasta"].push_back(rare);
-               
-                       string abund = outputDir + m->getRootName(m->getSimpleName(fastafile))  + tag + "abund.fasta";
-                       m->openOutputFile(abund, aout);
-                       outputNames.push_back(abund); outputTypes["fasta"].push_back(abund);
-               
-                       //open input file
-                       ifstream in;
-                       m->openInputFile(fastafile, in);
-       
-                       while (!in.eof()) {
-                               if (m->control_pressed) { break; }
-               
-                               Sequence seq(in); m->gobble(in);
-                               
-                               if (seq.getName() != "") { 
-                                       
-                                       map<string, string>::iterator itNames;
-                                       
-                                       itNames = nameMap.find(seq.getName());
-                                       
-                                       if (itNames == nameMap.end()) {
-                                               m->mothurOut(seq.getName() + " is not in your namesfile, ignoring."); m->mothurOutEndLine();
-                                       }else{
-                                               if (rareNames.count(seq.getName()) != 0) { //you are a rare name
-                                                       seq.printSequence(rout);
-                                               }else{ //you are a abund name
-                                                       seq.printSequence(aout);
-                                               }
-                                       }
-                               }
-                       }
-                       in.close();
-                       rout.close(); 
-                       aout.close(); 
-
-               }else{ //parse names by abundance and group
-                       string fileroot =  outputDir + m->getRootName(m->getSimpleName(fastafile));
-                       ofstream* temp;
-                       ofstream* temp2;
-                       map<string, ofstream*> filehandles;
-                       map<string, ofstream*>::iterator it3;
-
-                       for (int i=0; i<Groups.size(); i++) {
-                               temp = new ofstream;
-                               filehandles[Groups[i]+".rare"] = temp;
-                               temp2 = new ofstream;
-                               filehandles[Groups[i]+".abund"] = temp2;
-                               
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".rare.fasta", *(filehandles[Groups[i]+".rare"]));
-                               m->openOutputFile(fileroot + tag + Groups[i] + ".abund.fasta", *(filehandles[Groups[i]+".abund"]));
-                       }
-                       
-                       //open input file
-                       ifstream in;
-                       m->openInputFile(fastafile, in);
-       
-                       while (!in.eof()) {
-                               if (m->control_pressed) { break; }
-               
-                               Sequence seq(in); m->gobble(in);
-                               
-                               if (seq.getName() != "") { 
-                                       map<string, string>::iterator itNames = nameMap.find(seq.getName());
-                                       
-                                       if (itNames == nameMap.end()) {
-                                               m->mothurOut(seq.getName() + " is not in your namesfile, ignoring."); m->mothurOutEndLine();
-                                       }else{
-                                               vector<string> names;
-                                               m->splitAtComma(itNames->second, names);  //parses bin into individual sequence names
-                               
-                                               string rareAbund;
-                                               if (rareNames.count(itNames->first) != 0) { //you are a rare name
-                                                       rareAbund = ".rare";
-                                               }else{ //you are a abund name
-                                                       rareAbund = ".abund";
-                                               }
-                               
-                                               for (int i = 0; i < names.size(); i++) {
-                               
-                                                       string group = groupMap->getGroup(seq.getName());
-                                       
-                                                       if (m->inUsersGroups(group, Groups)) { //only add if this is in a group we want
-                                                               seq.printSequence(*(filehandles[group+rareAbund]));
-                                                       }else if(group == "not found") {
-                                                               m->mothurOut(seq.getName() + " is not in your groupfile. Ignoring."); m->mothurOutEndLine();
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       in.close();
-                       
-                       for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) { 
-                               (*(filehandles[it3->first])).close();
-                               outputNames.push_back(fileroot + tag + it3->first + ".fasta");  outputTypes["fasta"].push_back(fileroot + tag + it3->first + ".fasta");
-                               delete it3->second;
-                       }
-               }
-                               
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitAbundCommand", "parseFasta");
-               exit(1);
-       }
-}
-/**********************************************************************************************************************/
-
diff --git a/splitabundcommand.h b/splitabundcommand.h
deleted file mode 100644 (file)
index df925f3..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef SPLITABUNDCOMMAND_H
-#define SPLITABUNDCOMMAND_H
-
-/*
- *  splitabundcommand.h
- *  Mothur
- *
- *  Created by westcott on 5/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-/* split.abund - given a list or name file and a number (cutoff), make two files - *rare* and *abund* 
-- where rare has data for otus that have fewer sequences than the cutoff and abund has data for otus 
-that have as many or more sequences as the cutoff. 
-also allow an option where a user can give a group file with the list or names file and split the group file into rare and abund. */
-
-
-#include "command.hpp"
-#include "groupmap.h"
-#include "inputdata.h"
-#include "listvector.hpp"
-#include "sequence.hpp"
-
-/***************************************************************************************/
-
-class SplitAbundCommand : public Command {
-       
-public:
-       SplitAbundCommand(string);      
-       SplitAbundCommand();
-       ~SplitAbundCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "split.abund";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Split.abund"; }
-       string getDescription()         { return "split a list, name, group or fasta file based on abundance"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       int splitList(ListVector*);
-       int splitNames(); //namefile
-       int writeNames(); 
-       int writeList(ListVector*, string); 
-       int writeAccnos(string); 
-       int parseGroup(string); 
-       int parseFasta(string); 
-       int readNamesFile(); //namefile
-       int createNameMap(ListVector*);
-       
-       vector<string> outputNames;
-       ListVector* list;
-       GroupMap* groupMap;
-       InputData* input;
-       
-       string outputDir, listfile, namefile, groupfile, label, groups, fastafile, inputFile;
-       set<string> labels, rareNames, abundNames;
-       vector<string> Groups;
-       bool abort, allLines, accnos;
-       int cutoff;
-       //map<string, bool> wroteListFile;
-       map<string, string> nameMap;
-       
-       
-
-};
-
-/***************************************************************************************/
-
-#endif
-
-
diff --git a/splitgroupscommand.cpp b/splitgroupscommand.cpp
deleted file mode 100644 (file)
index 2671655..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- *  splitgroupscommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "splitgroupscommand.h"
-#include "sharedutilities.h"
-#include "sequenceparser.h"
-
-//**********************************************************************************************************************
-vector<string> SplitGroupCommand::setParameters(){     
-       try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SplitGroupCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The split.group command reads a group file, and parses your fasta and names files by groups. \n";
-               helpString += "The split.group command parameters are fasta, name, group and groups.\n";
-               helpString += "The fasta and group parameters are required.\n";
-               helpString += "The groups parameter allows you to select groups to create files for.  \n";
-               helpString += "For example if you set groups=A-B-C, you will get a .A.fasta, .A.names, .B.fasta, .B.names, .C.fasta, .C.names files.  \n";
-               helpString += "If you want .fasta and .names files for all groups, set groups=all.  \n";
-               helpString += "The split.group command should be used in the following format: split.group(fasta=yourFasta, group=yourGroupFile).\n";
-               helpString += "Example: split.group(fasta=abrecovery.fasta, group=abrecovery.groups).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SplitGroupCommand::SplitGroupCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "SplitGroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SplitGroupCommand::SplitGroupCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-               
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-
-                       }
-
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }    
-                       else { m->setNameFile(namefile); }
-               
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { abort = true; }
-                       else if (fastafile == "not found") {                    
-                               fastafile = m->getFastaFile(); 
-                               if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setFastaFile(fastafile); }   
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") {  groupfile = ""; abort = true; } 
-                       else if (groupfile == "not found") {                    
-                               groupfile = m->getGroupFile(); 
-                               if (groupfile != "") { m->mothurOut("Using " + groupfile + " as input file for the group parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current groupfile and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else {  m->setGroupFile(groupfile); }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);         
-                       if (groups == "not found") { groups = ""; }
-                       else { m->splitAtDash(groups, Groups);  }
-                                               
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(groupfile);      }
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "SplitAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SplitGroupCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               SequenceParser* parser;
-               
-               if (namefile == "") {   parser = new SequenceParser(groupfile, fastafile);                              }
-               else                            {       parser = new SequenceParser(groupfile, fastafile, namefile);    }
-               
-               if (m->control_pressed) { delete parser; return 0; }
-
-               vector<string> namesGroups = parser->getNamesOfGroups();
-               SharedUtil util;  util.setGroups(Groups, namesGroups);  
-               
-               string fastafileRoot = outputDir + m->getRootName(m->getSimpleName(fastafile));
-               string namefileRoot = outputDir + m->getRootName(m->getSimpleName(namefile));
-               
-               m->mothurOutEndLine();
-               for (int i = 0; i < Groups.size(); i++) {
-                       
-                       m->mothurOut("Processing group: " + Groups[i]); m->mothurOutEndLine();
-                       
-                       string newFasta = fastafileRoot + Groups[i] + ".fasta";
-                       string newName = namefileRoot + Groups[i] + ".names";
-                       
-                       parser->getSeqs(Groups[i], newFasta, false);
-                       outputNames.push_back(newFasta); outputTypes["fasta"].push_back(newFasta);
-                       if (m->control_pressed) { delete parser; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);        } return 0; }
-
-                       if (namefile != "") { 
-                               parser->getNameMap(Groups[i], newName); 
-                               outputNames.push_back(newName); outputTypes["name"].push_back(newName);
-                       }
-                       
-                       if (m->control_pressed) { delete parser; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]);        } return 0; }
-               }
-               
-               delete parser;
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);        } return 0; }
-               
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitGroupCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-
diff --git a/splitgroupscommand.h b/splitgroupscommand.h
deleted file mode 100644 (file)
index a6b8854..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef SPLITGROUPSCOMMAND_H
-#define SPLITGROUPSCOMMAND_H
-
-/*
- *  splitgroupscommand.h
- *  Mothur
- *
- *  Created by westcott on 9/20/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-/* split.groups - given a group file, split sequences and names files in to separate files *.group1.fasta and .group1.names. */
-
-
-#include "command.hpp"
-#include "groupmap.h"
-#include "sequence.hpp"
-
-/***************************************************************************************/
-
-class SplitGroupCommand : public Command {
-       
-public:
-       SplitGroupCommand(string);      
-       SplitGroupCommand();
-       ~SplitGroupCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "split.group";                         }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Split.group"; }
-       string getDescription()         { return "split a name or fasta file by group"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       vector<string> outputNames;
-               
-       string outputDir, namefile, groupfile, groups, fastafile;
-       vector<string> Groups;
-       bool abort;
-};
-
-/***************************************************************************************/
-
-#endif
-
-
-
diff --git a/splitmatrix.cpp b/splitmatrix.cpp
deleted file mode 100644 (file)
index dabcd04..0000000
+++ /dev/null
@@ -1,907 +0,0 @@
-/*
- *  splitmatrix.cpp
- *  Mothur
- *
- *  Created by westcott on 5/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "splitmatrix.h"
-#include "phylotree.h"
-#include "distancecommand.h"
-#include "seqsummarycommand.h"
-
-/***********************************************************************/
-
-SplitMatrix::SplitMatrix(string distfile, string name, string tax, float c, string t, bool l){
-       m = MothurOut::getInstance();
-       distFile = distfile;
-       cutoff = c;
-       namefile = name;
-       method = t;
-       taxFile = tax;
-       large = l;
-}
-/***********************************************************************/
-
-SplitMatrix::SplitMatrix(string ffile, string name, string tax, float c, float cu, string t, int p, string output){
-       m = MothurOut::getInstance();
-       fastafile = ffile;
-       namefile = name;
-       taxFile = tax;
-       cutoff = c;  //tax level cutoff
-       distCutoff = cu; //for fasta method if you are creating distance matrix you need a cutoff for that
-       method = t;
-       processors = p;
-       outputDir = output;
-}
-
-/***********************************************************************/
-
-int SplitMatrix::split(){
-       try {
-        
-               if (method == "distance") {  
-                       splitDistance();
-               }else if ((method == "classify") || (method == "fasta")) {
-                       splitClassify();
-               }else {
-                       m->mothurOut("Unknown splitting method, aborting split."); m->mothurOutEndLine();
-                       map<string, string> temp;
-                       temp[distFile] = namefile;
-                       dists.push_back(temp);
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "split");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int SplitMatrix::splitDistance(){
-       try {
-        
-               if (large)      { splitDistanceLarge(); }
-               else            { splitDistanceRAM();   }
-               
-               return 0;
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitDistance");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-int SplitMatrix::splitClassify(){
-       try {
-               cutoff = int(cutoff);
-                               
-               map<string, int> seqGroup;
-               map<string, int>::iterator it;
-               map<string, int>::iterator it2;
-               
-               int numGroups = 0;
-               
-               //build tree from users taxonomy file
-               PhyloTree* phylo = new PhyloTree();
-               
-               ifstream in;
-               m->openInputFile(taxFile, in);
-                       
-               //read in users taxonomy file and add sequences to tree
-               string seqname, tax;
-               while(!in.eof()){
-                       in >> seqname >> tax; m->gobble(in);
-                       phylo->addSeqToTree(seqname, tax);
-               }
-               in.close();
-               
-               phylo->assignHeirarchyIDs(0);
-
-               //make sure the cutoff is not greater than maxlevel
-               if (cutoff > phylo->getMaxLevel()) { m->mothurOut("splitcutoff is greater than the longest taxonomy, using " + toString(phylo->getMaxLevel())); m->mothurOutEndLine(); cutoff = phylo->getMaxLevel(); }
-       
-               //for each node in tree
-               for (int i = 0; i < phylo->getNumNodes(); i++) {
-               
-                       //is this node within the cutoff
-                       TaxNode taxon = phylo->get(i);
-       
-                       if (taxon.level == cutoff) {//if yes, then create group containing this nodes sequences
-                               if (taxon.accessions.size() > 1) { //if this taxon just has one seq its a singleton
-                                       for (int j = 0; j < taxon.accessions.size(); j++) {
-                                               seqGroup[taxon.accessions[j]] = numGroups;
-                                       }
-                                       numGroups++;
-                               }
-                       }
-               }
-       
-               delete phylo;
-               
-               if (method == "classify") {
-                       splitDistanceFileByTax(seqGroup, numGroups);
-               }else {
-                       createDistanceFilesFromTax(seqGroup, numGroups);
-               }
-               
-               return 0;
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitClassify");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int SplitMatrix::createDistanceFilesFromTax(map<string, int>& seqGroup, int numGroups){
-       try {
-               map<string, int> copyGroups = seqGroup;
-               map<string, int>::iterator it;
-               set<string> names;
-                               
-               for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case
-                       m->mothurRemove((fastafile + "." + toString(i) + ".temp"));
-               }
-                       
-               ifstream in;
-               m->openInputFile(fastafile, in);
-       
-               //parse fastafile
-               ofstream outFile;
-               while (!in.eof()) {
-                       Sequence query(in); m->gobble(in);
-                       if (query.getName() != "") {
-               
-                               it = seqGroup.find(query.getName());
-                               
-                               //save names in case no namefile is given
-                               if (namefile == "") {  names.insert(query.getName()); }
-                       
-                               if (it != seqGroup.end()) { //not singleton 
-                                       m->openOutputFileAppend((fastafile + "." + toString(it->second) + ".temp"), outFile);
-                                       query.printSequence(outFile); 
-                                       outFile.close();
-                                       
-                                       copyGroups.erase(query.getName());
-                               }
-                       }
-               }
-               in.close();
-               
-               //warn about sequence in groups that are not in fasta file
-               for(it = copyGroups.begin(); it != copyGroups.end(); it++) {
-                       m->mothurOut("ERROR: " + it->first + " is missing from your fastafile. This could happen if your taxonomy file is not unique and your fastafile is, or it could indicate and error."); m->mothurOutEndLine();
-                       exit(1);
-               }
-               
-               copyGroups.clear();
-               
-               //process each distance file
-               for (int i = 0; i < numGroups; i++) { 
-                       
-                       string options = "fasta=" + (fastafile + "." + toString(i) + ".temp") + ", processors=" + toString(processors) + ", cutoff=" + toString(distCutoff);
-                       if (outputDir != "") { options += ", outputdir=" + outputDir; }
-                       
-                       Command* command = new DistanceCommand(options);
-                       
-                       command->execute();
-                       delete command;
-                       
-                       m->mothurRemove((fastafile + "." + toString(i) + ".temp"));
-                       
-                       //remove old names files just in case
-                       m->mothurRemove((namefile + "." + toString(i) + ".temp"));
-               }
-                       
-               singleton = namefile + ".extra.temp";
-               ofstream remainingNames;
-               m->openOutputFile(singleton, remainingNames);
-               
-               bool wroteExtra = false;
-
-               ifstream bigNameFile;
-               m->openInputFile(namefile, bigNameFile);
-               
-               string name, nameList;
-               while(!bigNameFile.eof()){
-                       bigNameFile >> name >> nameList;  m->gobble(bigNameFile);
-                       
-                       //did this sequence get assigned a group
-                       it = seqGroup.find(name);
-                       
-                       if (it != seqGroup.end()) {  
-                               m->openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
-                               outFile << name << '\t' << nameList << endl;
-                               outFile.close();
-                       }else{
-                               wroteExtra = true;
-                               remainingNames << name << '\t' << nameList << endl;
-                       }
-               }
-               bigNameFile.close();
-               
-               for(int i=0;i<numGroups;i++){
-                       string tempNameFile = namefile + "." + toString(i) + ".temp";
-                       if (outputDir == "") { outputDir = m->hasPath(fastafile); }
-                       string tempDistFile = outputDir + m->getRootName(m->getSimpleName((fastafile + "." + toString(i) + ".temp"))) + "dist";
-
-                       //if there are valid distances
-                       ifstream fileHandle;
-                       fileHandle.open(tempDistFile.c_str());
-                       if(fileHandle)  {       
-                               m->gobble(fileHandle);
-                               if (!fileHandle.eof()) {  //check for blank file - this could occur if all dists in group are above cutoff
-                                       map<string, string> temp;
-                                       temp[tempDistFile] = tempNameFile;
-                                       dists.push_back(temp);
-                               }else {
-                                       ifstream in;
-                                       m->openInputFile(tempNameFile, in);
-                               
-                                       while(!in.eof()) { 
-                                               in >> name >> nameList;  m->gobble(in);
-                                               wroteExtra = true;
-                                               remainingNames << name << '\t' << nameList << endl;
-                                       }
-                                       in.close();
-                                       m->mothurRemove(tempNameFile);
-                               }
-                       }
-                       fileHandle.close();
-               }
-               
-               remainingNames.close();
-               if (!wroteExtra) { 
-                       m->mothurRemove(singleton);
-                       singleton = "none";
-               }
-
-               if (m->control_pressed)  {  for (int i = 0; i < dists.size(); i++) { m->mothurRemove((dists[i].begin()->first)); m->mothurRemove((dists[i].begin()->second)); } dists.clear(); }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "createDistanceFilesFromTax");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int SplitMatrix::splitDistanceFileByTax(map<string, int>& seqGroup, int numGroups){
-       try {
-               map<string, int>::iterator it;
-               map<string, int>::iterator it2;
-               
-               ifstream dFile;
-               m->openInputFile(distFile, dFile);
-               ofstream outFile;
-               
-               for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case
-                       m->mothurRemove((distFile + "." + toString(i) + ".temp"));
-               }
-               
-               //for buffering the io to improve speed
-                //allow for 10 dists to be stored, then output.
-               vector<string> outputs;  outputs.resize(numGroups, "");
-               vector<int> numOutputs;  numOutputs.resize(numGroups, 0);       
-               
-               //you can have a group made, but their may be no distances in the file for this group if the taxonomy file and distance file don't match
-               //this can occur if we have converted the phylip to column, since we reduce the size at that step by using the cutoff value
-               vector<bool> validDistances;   validDistances.resize(numGroups, false); 
-               
-               //for each distance
-               while(dFile){
-                       string seqA, seqB;
-                       float dist;
-                       
-                       if (m->control_pressed) { dFile.close(); for (int i = 0; i < numGroups; i++) { m->mothurRemove((distFile + "." + toString(i) + ".temp"));       } }
-                       
-                       dFile >> seqA >> seqB >> dist;  m->gobble(dFile);
-                       
-                       //if both sequences are in the same group then they are within the cutoff
-                       it = seqGroup.find(seqA);
-                       it2 = seqGroup.find(seqB);
-                       
-                       if ((it != seqGroup.end()) && (it2 != seqGroup.end())) { //they are both not singletons 
-                               if (it->second == it2->second) { //they are from the same group so add the distance
-                                       if (numOutputs[it->second] > 30) {
-                                               m->openOutputFileAppend((distFile + "." + toString(it->second) + ".temp"), outFile);
-                                               outFile << outputs[it->second] << seqA << '\t' << seqB << '\t' << dist << endl;
-                                               outFile.close();
-                                               outputs[it->second] = "";
-                                               numOutputs[it->second] = 0;
-                                               validDistances[it->second] = true;
-                                       }else{
-                                               outputs[it->second] += seqA + '\t' + seqB + '\t' + toString(dist)  + '\n';
-                                               numOutputs[it->second]++;
-                                       }
-                               }
-                       }
-               }
-               dFile.close();
-       
-               for (int i = 0; i < numGroups; i++) { //remove old temp files, just in case
-                       m->mothurRemove((namefile + "." + toString(i) + ".temp"));
-                       
-                       //write out any remaining buffers
-                       if (numOutputs[i] > 0) {
-                               m->openOutputFileAppend((distFile + "." + toString(i) + ".temp"), outFile);
-                               outFile << outputs[i];
-                               outFile.close();
-                               outputs[i] = "";
-                               numOutputs[i] = 0;
-                               validDistances[i] = true;
-                       }
-               }
-               
-               ifstream bigNameFile;
-               m->openInputFile(namefile, bigNameFile);
-               
-               singleton = namefile + ".extra.temp";
-               ofstream remainingNames;
-               m->openOutputFile(singleton, remainingNames);
-               
-               bool wroteExtra = false;
-                                               
-               string name, nameList;
-               while(!bigNameFile.eof()){
-                       bigNameFile >> name >> nameList;  m->gobble(bigNameFile);
-                       
-                       //did this sequence get assigned a group
-                       it = seqGroup.find(name);
-                       
-                       if (it != seqGroup.end()) {  
-                               m->openOutputFileAppend((namefile + "." + toString(it->second) + ".temp"), outFile);
-                               outFile << name << '\t' << nameList << endl;
-                               outFile.close();
-                       }else{
-                               wroteExtra = true;
-                               remainingNames << name << '\t' << nameList << endl;
-                       }
-               }
-               bigNameFile.close();
-                               
-               for(int i=0;i<numGroups;i++){
-                       string tempNameFile = namefile + "." + toString(i) + ".temp";
-                       string tempDistFile = distFile + "." + toString(i) + ".temp";
-
-                       //if there are valid distances
-                       if (validDistances[i]) {
-                               map<string, string> temp;
-                               temp[tempDistFile] = tempNameFile;
-                               dists.push_back(temp);
-                       }else{
-                               ifstream in;
-                               m->openInputFile(tempNameFile, in);
-                               
-                               while(!in.eof()) { 
-                                       in >> name >> nameList;  m->gobble(in);
-                                       wroteExtra = true;
-                                       remainingNames << name << '\t' << nameList << endl;
-                               }
-                               in.close();
-                               m->mothurRemove(tempNameFile);
-                       }
-               }
-               
-               remainingNames.close();
-               
-               if (!wroteExtra) { 
-                       m->mothurRemove(singleton);
-                       singleton = "none";
-               }
-
-               if (m->control_pressed)  {  
-                       for (int i = 0; i < dists.size(); i++) { 
-                               m->mothurRemove((dists[i].begin()->first));
-                               m->mothurRemove((dists[i].begin()->second));
-                       }
-                       dists.clear();
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitDistanceFileByTax");
-               exit(1);
-       }
-}
-/***********************************************************************/
-int SplitMatrix::splitDistanceLarge(){
-       try {
-               vector<set<string> > groups;
-               
-               //for buffering the io to improve speed
-                //allow for 30 dists to be stored, then output.
-               vector<string> outputs;
-               vector<int> numOutputs;
-               vector<bool> wroteOutPut;
-               
-               int numGroups = 0;
-
-               ofstream outFile;
-               ifstream dFile;
-               m->openInputFile(distFile, dFile);
-       
-               while(dFile){
-                       string seqA, seqB;
-                       float dist;
-
-                       dFile >> seqA >> seqB >> dist;
-                       
-                       if (m->control_pressed) {   dFile.close();  for(int i=0;i<numGroups;i++){       if(groups[i].size() > 0){  m->mothurRemove((distFile + "." + toString(i) + ".temp")); }  } return 0; }
-                                       
-                       if(dist < cutoff){
-                               //cout << "in cutoff: " << dist << endl;
-                               int groupIDA = -1;
-                               int groupIDB = -1;
-                               int groupID = -1;
-                               
-                               for(int i=0;i<numGroups;i++){
-                                       set<string>::iterator aIt = groups[i].find(seqA);
-                                       set<string>::iterator bIt = groups[i].find(seqB);
-                                       
-                                       if(groupIDA == -1 && aIt != groups[i].end()){//seqA is not already assigned to a group and is in group[i], so assign seqB to group[i]
-                                               groups[i].insert(seqB);
-                                               groupIDA = i;
-                                               groupID = groupIDA;
-
-                                               //cout << "in aIt: " << groupID << endl;
-       //                                      break;
-                                       }
-                                       else if(groupIDB == -1 && bIt != groups[i].end()){//seqB is not already assigned to a group and is in group[i], so assign seqA to group[i]
-                                               groups[i].insert(seqA);
-                                               groupIDB = i;
-                                               groupID = groupIDB;
-
-                                       //      cout << "in bIt: " << groupID << endl;
-       //                                      break;
-                                       }
-                               
-                                       if(groupIDA != -1 && groupIDB != -1){//both ifs above have been executed, so we need to decide who to assign them to
-                                               if(groupIDA < groupIDB){
-                                               //      cout << "A: " << groupIDA << "\t" << groupIDB << endl;
-                                                       groups[groupIDA].insert(groups[groupIDB].begin(), groups[groupIDB].end()); //merge two groups into groupIDA
-                                                       groups[groupIDB].clear(); 
-                                                       groupID = groupIDA;
-                                               }
-                                               else{
-                                               //      cout << "B: " << groupIDA << "\t" << groupIDB << endl;
-                                                       groups[groupIDB].insert(groups[groupIDA].begin(), groups[groupIDA].end()); //merge two groups into groupIDB
-                                                       groups[groupIDA].clear();  
-                                                       groupID = groupIDB;
-                                               }
-                                               break;
-                                       }
-                               }
-                               
-       //windows is gonna gag on the reuse of outFile, will need to make it local...
-                               
-                               if(groupIDA == -1 && groupIDB == -1){ //we need a new group
-                                       set<string> newGroup;
-                                       newGroup.insert(seqA);
-                                       newGroup.insert(seqB);
-                                       groups.push_back(newGroup);
-                                                                       
-                                       string tempOut = seqA + '\t' + seqB + '\t' + toString(dist) + '\n';
-                                       outputs.push_back(tempOut);
-                                       numOutputs.push_back(1);
-                                       wroteOutPut.push_back(false);
-                                       
-                                       numGroups++;
-                               }
-                               else{
-                                       string fileName = distFile + "." + toString(groupID) + ".temp";
-                                                                                       
-                                       //have we reached the max buffer size
-                                       if (numOutputs[groupID] > 60) { //write out sequence
-                                               outFile.open(fileName.c_str(), ios::app);
-                                               outFile << outputs[groupID] << seqA << '\t' << seqB << '\t' << dist << endl;
-                                               outFile.close();
-                                               
-                                               outputs[groupID] = "";
-                                               numOutputs[groupID] = 0;
-                                               wroteOutPut[groupID] = true;
-                                       }else {
-                                               outputs[groupID] +=  seqA + '\t' + seqB + '\t' + toString(dist)  + '\n';
-                                               numOutputs[groupID]++;
-                                       }
-                                       
-                                       if(groupIDA != -1 && groupIDB != -1){ //merge distance files of two groups you merged above
-                                               string row, column, distance;
-                                               if(groupIDA<groupIDB){
-                                                       
-                                                       //merge memory
-                                                       numOutputs[groupID] += numOutputs[groupIDB];
-                                                       outputs[groupID] += outputs[groupIDB];
-                                                       
-                                                       outputs[groupIDB] = "";
-                                                       numOutputs[groupIDB] = 0;
-                                                       
-                                                       //if groupB is written to file it is above buffer size so read and write to new merged file
-                                                       if (wroteOutPut[groupIDB]) {
-                                                               string fileName2 = distFile + "." + toString(groupIDB) + ".temp";
-                                                               ifstream fileB(fileName2.c_str(), ios::ate);
-                                                               
-                                                               outFile.open(fileName.c_str(), ios::app);
-                                                               
-                                                               long size;
-                                                               char* memblock;
-
-                                                               size = fileB.tellg();
-                               
-                                                               fileB.seekg (0, ios::beg);
-                                                               
-                                                               int numRead = size / 1024;
-                                                               int lastRead = size % 1024;
-
-                                                               for (int i = 0; i < numRead; i++) {
-                               
-                                                                       memblock = new char [1024];
-                                                               
-                                                                       fileB.read (memblock, 1024);
-                                                                       
-                                                                       string temp = memblock;
-                                                                       outFile << temp.substr(0, 1024);
-                                                                       
-                                                                       delete memblock;
-                                                               }
-                                                               
-                                                               memblock = new char [lastRead];
-                                                               
-                                                               fileB.read (memblock, lastRead);
-                                                               
-                                                               //not sure why but it will read more than lastRead char...??
-                                                               string temp = memblock;
-                                                               outFile << temp.substr(0, lastRead);
-                                                               delete memblock;
-                                                               
-                                                               fileB.close();
-                                                               m->mothurRemove(fileName2);
-                                                               
-                                                               //write out the merged memory
-                                                               if (numOutputs[groupID] > 60) {
-                                                                       outFile << outputs[groupID];
-                                                                       outputs[groupID] = "";
-                                                                       numOutputs[groupID] = 0;
-                                                               }
-                                                               
-                                                               outFile.close();
-                                                               
-                                                               wroteOutPut[groupID] = true;
-                                                               wroteOutPut[groupIDB] = false;
-                                                       }else{ } //just merge b's memory with a's memory 
-                                               }
-                                               else{
-                                                       numOutputs[groupID] += numOutputs[groupIDA];
-                                                       outputs[groupID] += outputs[groupIDA];
-                                                       
-                                                       outputs[groupIDA] = "";
-                                                       numOutputs[groupIDA] = 0;
-                                                       
-                                                       if (wroteOutPut[groupIDA]) {
-                                                               string fileName2 = distFile + "." + toString(groupIDA) + ".temp";
-                                                               ifstream fileB(fileName2.c_str(), ios::ate);
-                                                               
-                                                               outFile.open(fileName.c_str(), ios::app);
-                                                               
-                                                               long size;
-                                                               char* memblock;
-
-                                                               size = fileB.tellg();
-                                                                                                                       
-                                                               fileB.seekg (0, ios::beg);
-                                                               
-                                                               int numRead = size / 1024;
-                                                               int lastRead = size % 1024;
-
-                                                               for (int i = 0; i < numRead; i++) {
-                               
-                                                                       memblock = new char [1024];
-                                                               
-                                                                       fileB.read (memblock, 1024);
-                                                                       string temp = memblock;
-                                                                       outFile << temp.substr(0, 1024);
-                                                                       
-                                                                       delete memblock;
-                                                               }
-                                                               
-                                                               memblock = new char [lastRead];
-                                                               
-                                                               fileB.read (memblock, lastRead);
-                                                               
-                                                               //not sure why but it will read more than lastRead char...??
-                                                               string temp = memblock;
-                                                               outFile << temp.substr(0, lastRead);
-                                                                       
-                                                               delete memblock;
-                                                               
-                                                               fileB.close();
-                                                               m->mothurRemove(fileName2);
-                                                               
-                                                               //write out the merged memory
-                                                               if (numOutputs[groupID] > 60) {
-                                                                       outFile << outputs[groupID];
-                                                                       outputs[groupID] = "";
-                                                                       numOutputs[groupID] = 0;
-                                                               }
-                                                               
-                                                               outFile.close();
-                                                               
-                                                               wroteOutPut[groupID] = true;
-                                                               wroteOutPut[groupIDA] = false;
-                                                       }else { } //just merge memory
-                                               }                                       
-                                       }
-                               }
-                       }
-                       m->gobble(dFile);
-               }
-               dFile.close();
-               
-               for (int i = 0; i < numGroups; i++) {
-                       if (numOutputs[i] > 0) {
-                               string fileName = distFile + "." + toString(i) + ".temp";
-                               outFile.open(fileName.c_str(), ios::app);
-                               outFile << outputs[i];
-                               outFile.close();
-                       }
-               }
-
-               splitNames(groups);
-                               
-               return 0;                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitDistanceLarge");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-int SplitMatrix::splitNames(vector<set<string> >& groups){
-       try {
-               int numGroups = groups.size();
-       
-               ifstream bigNameFile(namefile.c_str());
-               if(!bigNameFile){
-                       cerr << "Error: We can't open the name file\n";
-                       exit(1);
-               }
-               
-               map<string, string> nameMap;
-               string name, nameList;
-               while(bigNameFile){
-                       bigNameFile >> name >> nameList;
-                       nameMap[name] = nameList;
-                       m->gobble(bigNameFile);
-               }
-               bigNameFile.close();
-                       
-               for(int i=0;i<numGroups;i++){  //parse names file to match distance files
-                       int numSeqsInGroup = groups[i].size();
-                       
-                       if(numSeqsInGroup > 0){
-                               string fileName = namefile + "." + toString(i) + ".temp";
-                               ofstream smallNameFile(fileName.c_str(), ios::ate);
-                               
-                               for(set<string>::iterator gIt=groups[i].begin();gIt!=groups[i].end();gIt++){
-                                       map<string,string>::iterator nIt = nameMap.find(*gIt);
-                                       if (nIt != nameMap.end()) {
-                                               smallNameFile << nIt->first << '\t' << nIt->second << endl;
-                                               nameMap.erase(nIt);
-                                       }else{
-                                               m->mothurOut((*gIt) + " is in your distance file and not in your namefile.  Please correct."); m->mothurOutEndLine(); exit(1);
-                                       }
-                               }
-                               smallNameFile.close();
-                       }
-               }
-               
-               //names of singletons
-               if (nameMap.size() != 0) {
-                       singleton = namefile + ".extra.temp";
-                       ofstream remainingNames(singleton.c_str(), ios::ate);
-                       for(map<string,string>::iterator nIt=nameMap.begin();nIt!=nameMap.end();nIt++){
-                               remainingNames << nIt->first << '\t' << nIt->second << endl;
-                       }
-                       remainingNames.close();
-               }else { singleton = "none"; }
-                       
-               for(int i=0;i<numGroups;i++){
-                       if(groups[i].size() > 0){
-                               string tempNameFile = namefile + "." + toString(i) + ".temp";
-                               string tempDistFile = distFile + "." + toString(i) + ".temp";
-                               
-                               map<string, string> temp;
-                               temp[tempDistFile] = tempNameFile;
-                               dists.push_back(temp);
-                       }
-               }
-               
-               if (m->control_pressed)  {  
-                       for (int i = 0; i < dists.size(); i++) { 
-                               m->mothurRemove((dists[i].begin()->first));
-                               m->mothurRemove((dists[i].begin()->second));
-                       }
-                       dists.clear();
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitNames");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-int SplitMatrix::splitDistanceRAM(){
-       try {
-               vector<set<string> > groups;
-               vector<string> outputs;
-               
-               int numGroups = 0;
-
-               ifstream dFile;
-               m->openInputFile(distFile, dFile);
-
-               while(dFile){
-                       string seqA, seqB;
-                       float dist;
-
-                       dFile >> seqA >> seqB >> dist;
-                       
-                       if (m->control_pressed) {   dFile.close();  for(int i=0;i<numGroups;i++){       if(groups[i].size() > 0){  m->mothurRemove((distFile + "." + toString(i) + ".temp")); }  } return 0; }
-                                       
-                       if(dist < cutoff){
-                               //cout << "in cutoff: " << dist << endl;
-                               int groupIDA = -1;
-                               int groupIDB = -1;
-                               int groupID = -1;
-                               
-                               for(int i=0;i<numGroups;i++){
-                                       set<string>::iterator aIt = groups[i].find(seqA);
-                                       set<string>::iterator bIt = groups[i].find(seqB);
-                                       
-                                       if(groupIDA == -1 && aIt != groups[i].end()){//seqA is not already assigned to a group and is in group[i], so assign seqB to group[i]
-                                               groups[i].insert(seqB);
-                                               groupIDA = i;
-                                               groupID = groupIDA;
-
-                                               //cout << "in aIt: " << groupID << endl;
-       //                                      break;
-                                       }
-                                       else if(groupIDB == -1 && bIt != groups[i].end()){//seqB is not already assigned to a group and is in group[i], so assign seqA to group[i]
-                                               groups[i].insert(seqA);
-                                               groupIDB = i;
-                                               groupID = groupIDB;
-
-                                       //      cout << "in bIt: " << groupID << endl;
-       //                                      break;
-                                       }
-                               
-                                       if(groupIDA != -1 && groupIDB != -1){//both ifs above have been executed, so we need to decide who to assign them to
-                                               if(groupIDA < groupIDB){
-                                               //      cout << "A: " << groupIDA << "\t" << groupIDB << endl;
-                                                       groups[groupIDA].insert(groups[groupIDB].begin(), groups[groupIDB].end()); //merge two groups into groupIDA
-                                                       groups[groupIDB].clear(); 
-                                                       groupID = groupIDA;
-                                               }
-                                               else{
-                                               //      cout << "B: " << groupIDA << "\t" << groupIDB << endl;
-                                                       groups[groupIDB].insert(groups[groupIDA].begin(), groups[groupIDA].end()); //merge two groups into groupIDB
-                                                       groups[groupIDA].clear();  
-                                                       groupID = groupIDB;
-                                               }
-                                               break;
-                                       }
-                               }
-                               
-       //windows is gonna gag on the reuse of outFile, will need to make it local...
-                               
-                               if(groupIDA == -1 && groupIDB == -1){ //we need a new group
-                                       set<string> newGroup;
-                                       newGroup.insert(seqA);
-                                       newGroup.insert(seqB);
-                                       groups.push_back(newGroup);
-                                                                       
-                                       string tempOut = seqA + '\t' + seqB + '\t' + toString(dist) + '\n';
-                                       outputs.push_back(tempOut);
-                                       numGroups++;
-                               }
-                               else{
-                                                                                       
-                                       outputs[groupID] +=  seqA + '\t' + seqB + '\t' + toString(dist)  + '\n';
-                                       
-                                       if(groupIDA != -1 && groupIDB != -1){ //merge distance files of two groups you merged above
-                                               string row, column, distance;
-                                               if(groupIDA<groupIDB){
-                                                       //merge memory
-                                                       outputs[groupID] += outputs[groupIDB];
-                                                       outputs[groupIDB] = "";
-                                               }else{
-                                                       outputs[groupID] += outputs[groupIDA];
-                                                       outputs[groupIDA] = "";
-                                               }                                       
-                                       }
-                               }
-                       }
-                       m->gobble(dFile);
-               }
-               dFile.close();
-               
-               for (int i = 0; i < numGroups; i++) {
-                       if (outputs[i] != "") {
-                               ofstream outFile;
-                               string fileName = distFile + "." + toString(i) + ".temp";
-                               outFile.open(fileName.c_str(), ios::ate);
-                               outFile << outputs[i];
-                               outFile.close();
-                       }
-               }
-
-               splitNames(groups);
-                               
-               return 0;                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "splitDistanceRAM");
-               exit(1);
-       }
-}
-//********************************************************************************************************************
-//sorts biggest to smallest
-inline bool compareFileSizes(map<string, string> left, map<string, string> right){
-       
-       FILE * pFile;
-       long leftsize = 0;
-               
-       //get num bytes in file
-       string filename = left.begin()->first;
-       pFile = fopen (filename.c_str(),"rb");
-       string error = "Error opening " + filename;
-       if (pFile==NULL) perror (error.c_str());
-       else{
-               fseek (pFile, 0, SEEK_END);
-               leftsize=ftell (pFile);
-               fclose (pFile);
-       }
-
-       FILE * pFile2;
-       long rightsize = 0;
-               
-       //get num bytes in file
-       filename = right.begin()->first;
-       pFile2 = fopen (filename.c_str(),"rb");
-       error = "Error opening " + filename;
-       if (pFile2==NULL) perror (error.c_str());
-       else{
-               fseek (pFile2, 0, SEEK_END);
-               rightsize=ftell (pFile2);
-               fclose (pFile2);
-       }
-
-       return (leftsize > rightsize);  
-} 
-/***********************************************************************/
-//returns map of distance files -> namefile sorted by distance file size
-vector< map< string, string> > SplitMatrix::getDistanceFiles(){
-       try {   
-               
-               sort(dists.begin(), dists.end(), compareFileSizes);
-               
-               return dists;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SplitMatrix", "getDistanceFiles");
-               exit(1);
-       }
-}
-/***********************************************************************/
-SplitMatrix::~SplitMatrix(){}
-/***********************************************************************/
-
diff --git a/splitmatrix.h b/splitmatrix.h
deleted file mode 100644 (file)
index 4ff3160..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef SPLITMATRIX_H
-#define SPLITMATRIX_H
-/*
- *  splitmatrix.h
- *  Mothur
- *
- *  Created by westcott on 5/19/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/******************************************************/
-
-class SplitMatrix  {
-       
-       public:
-
-               SplitMatrix(string, string, string, float, string, bool); //column formatted distance file, namesfile, cutoff, method, large
-               SplitMatrix(string, string, string, float, float, string, int, string); //fastafile, namefile, taxFile, taxcutoff, cutoff, method, processors, outputDir
-               
-               ~SplitMatrix();
-               int split();
-               vector< map<string, string> > getDistanceFiles();  //returns map of distance files -> namefile sorted by distance file size
-               string getSingletonNames() { return singleton; } //returns namesfile containing singletons
-       
-       private:
-               MothurOut* m;
-
-               string distFile, namefile, singleton, method, taxFile, fastafile, outputDir;
-               vector< map< string, string> > dists;
-               float cutoff, distCutoff;
-               bool large;
-               int processors;
-                               
-               int splitDistance();
-               int splitClassify();
-               int splitDistanceLarge();
-               int splitDistanceRAM();
-               int splitNames(vector<set<string> >& groups);
-               int splitDistanceFileByTax(map<string, int>&, int);
-               int createDistanceFilesFromTax(map<string, int>&, int);
-};
-
-/******************************************************/
-
-#endif
-
diff --git a/sslvrg.f b/sslvrg.f
deleted file mode 100644 (file)
index 221beaf..0000000
--- a/sslvrg.f
+++ /dev/null
@@ -1,136 +0,0 @@
-C Output from Public domain Ratfor, version 1.0
-      subroutine sslvrg(penalt,dofoff,x,y,w,ssw, n, knot,nk,coef,
-     *     sz,lev, crit,icrit, lambda, xwy, hs0,hs1,hs2,hs3,
-     *     sg0,sg1,sg2,sg3, abd,p1ip,p2ip,ld4,ldnk,info)
-
-C Purpose :
-C       Compute smoothing spline for smoothing parameter lambda
-C       and compute one of three `criteria' (OCV , GCV , "df match").
-C See comments in ./sbart.f from which this is called
-
-      integer n,nk,icrit,ld4,ldnk,info
-      DOUBLE precision penalt,dofoff,x(n),y(n),w(n),ssw,
-     &     knot(nk+4), coef(nk),sz(n),lev(n), crit, lambda,
-     *     xwy(nk), hs0(nk),hs1(nk),hs2(nk),hs3(nk),
-     *     sg0(nk),sg1(nk),sg2(nk),sg3(nk), abd(ld4,nk),
-     &     p1ip(ld4,nk),p2ip(ldnk,nk)
-
-      EXTERNAL bvalue
-      double precision bvalue
-C local variables
-      double precision vnikx(4,1),work(16)
-      integer i,ileft,j,mflag, lenkno, ilo
-      double precision b0,b1,b2,b3,eps, xv,rss,df, sumw
-c
-c      integer interv
-c      external interv
-
-      lenkno = nk+4
-      ileft = 1
-      eps = 1d-11
-         ilo = 1
-
-C compute the coefficients coef() of estimated smooth
-
-      do 1 i=1,nk
-         coef(i) = xwy(i)
-         abd(4,i) = hs0(i)+lambda*sg0(i)
- 1    continue
-
-      do 4 i=1,(nk-1)
-         abd(3,i+1) = hs1(i)+lambda*sg1(i)
- 4    continue
-
-      do 6 i=1,(nk-2)
- 6       abd(2,i+2) = hs2(i)+lambda*sg2(i)
-
-      do 8 i=1,(nk-3)
- 8       abd(1,i+3) = hs3(i)+lambda*sg3(i)
-
-c     factorize banded matrix abd:
-      call dpbfa(abd,ld4,nk,3,info)
-      if(info.ne.0) then
-C        matrix could not be factorized -> ier := info
-         return
-      endif
-c     solve linear system (from factorize abd):
-      call dpbsl(abd,ld4,nk,3,coef)
-
-C     Value of smooth at the data points
-      do 12 i=1,n
-         xv = x(i)
- 12      sz(i) = bvalue(knot,coef,nk,4,xv,0)
-
-C     Compute the criterion function if requested
-
-      if(icrit .eq. 0)then
-         return
-      else
-C --- Ordinary or Generalized CV or "df match" ---
-
-C     Get Leverages First
-         call sinerp(abd,ld4,nk,p1ip,p2ip,ldnk,0)
-         do 16 i=1,n
-            xv = x(i)
-            call interv(knot(1), nk+1, xv, ileft, mflag)
-            if(mflag .eq. -1) then
-               ileft = 4
-               xv = knot(4)+eps
-            else if(mflag .eq. 1) then
-               ileft = nk
-               xv = knot(nk+1) - eps
-            endif
-            j=ileft-3
-C           call bspvd(knot,4,1,xv,ileft,4,vnikx,work)
-            call bsplvd(knot,lenkno,4,xv,ileft,work,vnikx,1)
-            b0=vnikx(1,1)
-            b1=vnikx(2,1)
-            b2=vnikx(3,1)
-            b3=vnikx(4,1)
-            lev(i) = (
-     &              p1ip(4,j)*b0**2   + 2.d0*p1ip(3,j)*b0*b1 +
-     *           2.d0*p1ip(2,j)*b0*b2   + 2.d0*p1ip(1,j)*b0*b3 +
-     *              p1ip(4,j+1)*b1**2 + 2.d0*p1ip(3,j+1)*b1*b2 +
-     *           2.d0*p1ip(2,j+1)*b1*b3 +    p1ip(4,j+2)*b2**2 +
-     &           2.d0*p1ip(3,j+2)*b2*b3 +    p1ip(4,j+3)*b3**2
-     &           )*w(i)**2
- 16      continue
-
-C     Evaluate Criterion
-
-         if(icrit .eq. 1)then
-C     Generalized CV
-            rss = ssw
-            df = 0d0
-            sumw = 0d0
-c      w(i) are sqrt( wt[i] ) weights scaled in ../R/smspline.R such
-c       that sumw =  number of observations with w(i) > 0
-            do 24 i=1,n
-               rss = rss + ((y(i)-sz(i))*w(i))**2
-               df = df + lev(i)
-               sumw = sumw + w(i)**2
- 24         continue
-
-            crit = (rss/sumw)/((1d0-(dofoff + penalt*df)/sumw)**2)
-c            call dblepr("spar", 4, spar, 1)
-c            call dblepr("crit", 4, crit, 1)
-
-         else if(icrit .eq. 2) then
-C     Ordinary CV
-               crit = 0d0
-               do 30 i = 1,n
- 30               crit = crit + (((y(i)-sz(i))*w(i))/(1-lev(i)))**2
-               crit = crit/n
-c            call dblepr("spar", 4, spar, 1)
-c            call dblepr("crit", 4, crit, 1)
-            else
-C     df matching
-            crit = 0d0
-            do 32 i=1,n
- 32            crit = crit+lev(i)
-            crit = 3 + (dofoff-crit)**2
-         endif
-         return
-      endif
-C     Criterion evaluation
-      end
diff --git a/structchi2.cpp b/structchi2.cpp
deleted file mode 100644 (file)
index 00ec097..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *  structchi2.cpp
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "structchi2.h"
-
-/***********************************************************************/
-EstOutput StructChi2::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumA = shared[0]->getNumSeqs();
-               double sumB = shared[1]->getNumSeqs();
-               double totalSum = 0.0;
-               
-               for (int i = 0; i < shared.size(); i++) { totalSum += shared[i]->getNumSeqs();  }
-               
-               vector<int> sumOtus; sumOtus.resize(shared[0]->getNumBins(), 0);
-               //for each otu
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //for each group
-                       for (int j = 0; j < shared.size(); j++) { 
-                               sumOtus[i] += shared[j]->getAbundance(i);
-                       }
-               }
-               
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       double totalTerm = 1 / (float) sumOtus[i];
-                       double Aterm = A / sumA;
-                       double Bterm = B / sumB;
-                       
-                       sum += (totalTerm * ((Aterm-Bterm)*(Aterm-Bterm)));
-               }
-                               
-               data[0] = sqrt((totalSum * sum));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "StructChi2", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/structchi2.h b/structchi2.h
deleted file mode 100644 (file)
index a444dd3..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef STRUCTCHI2_H
-#define STRUCTCHI2_H
-
-/*
- *  structchi2.h
- *  Mothur
- *
- *  Created by westcott on 12/17/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class StructChi2 : public Calculator  {
-       
-public:
-       StructChi2() :  Calculator("structchi2", 1, false, true) {};  //the true means this calculator needs all groups to calculate the pair value
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Structchi2"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
-
diff --git a/structchord.cpp b/structchord.cpp
deleted file mode 100644 (file)
index e85846f..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *  structchord.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "structchord.h"
-
-/***********************************************************************/
-EstOutput StructChord::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumAj2 = 0.0;
-               double sumBj2 = 0.0;
-               
-               //calc the 2 denominators
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       //(Aij) ^ 2
-                       sumAj2 += (Aij * Aij);
-                       sumBj2 += (Bij * Bij);
-               }
-               
-               sumAj2 = sqrt(sumAj2);
-               sumBj2 = sqrt(sumBj2);
-               
-               //calc sum
-               double sum = 0.0;
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       sum += (((Aij / sumAj2) - (Bij / sumBj2)) * ((Aij / sumAj2) - (Bij / sumBj2)));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "StructChord", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/structchord.h b/structchord.h
deleted file mode 100644 (file)
index b92007e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef STRUCTCHORD_H
-#define STRUCTCHORD_H
-
-/*
- *  structchord.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class StructChord : public Calculator  {
-       
-public:
-       StructChord() :  Calculator("structchord", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Structchord"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
diff --git a/structeuclidean.cpp b/structeuclidean.cpp
deleted file mode 100644 (file)
index 1737920..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  structeuclidean.cpp
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "structeuclidean.h"
-
-/***********************************************************************/
-EstOutput StructEuclidean::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sum = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int Aij = shared[0]->getAbundance(i);
-                       int Bij = shared[1]->getAbundance(i);
-                       
-                       //(Aij - Bij) ^ 2
-                       sum += ((Aij - Bij) * (Aij - Bij));
-               }
-               
-               data[0] = sqrt(sum);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "StructEuclidean", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
diff --git a/structeuclidean.h b/structeuclidean.h
deleted file mode 100644 (file)
index 2a7bd5c..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef STRUCTEUCLIDEAN_H
-#define STRUCTEUCLIDEAN_H
-
-/*
- *  structeuclidean.h
- *  Mothur
- *
- *  Created by westcott on 12/14/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class StructEuclidean : public Calculator  {
-       
-public:
-       StructEuclidean() :  Calculator("structeuclidean", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Structeuclidean"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
diff --git a/structkulczynski.cpp b/structkulczynski.cpp
deleted file mode 100644 (file)
index 9518068..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *  structkulczynski.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "structkulczynski.h"
-
-/***********************************************************************/
-EstOutput StructKulczynski::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               double sumA = 0.0;
-               double sumB = 0.0;
-               double sumMin = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       
-                       int A = shared[0]->getAbundance(i);
-                       int B = shared[1]->getAbundance(i);
-                       
-                       sumA += A;
-                       sumB += B;
-                       sumMin += min(A, B);
-               }
-               
-               data[0] = 1.0 - (0.5 * ((sumMin / sumA) + (sumMin / sumB)));
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "StructKulczynski", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
diff --git a/structkulczynski.h b/structkulczynski.h
deleted file mode 100644 (file)
index a0e4b9d..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef STRUCTKULCZYNSKI_H
-#define STRUCTKULCZYNSKI_H
-
-/*
- *  structkulczynski.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class StructKulczynski : public Calculator  {
-       
-public:
-       StructKulczynski() :  Calculator("structkulczynski", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Structkulczynski"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
-
diff --git a/structpearson.cpp b/structpearson.cpp
deleted file mode 100644 (file)
index a21eb99..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *  structpearson.cpp
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "structpearson.h"
-
-/***********************************************************************/
-EstOutput StructPearson::getValues(vector<SharedRAbundVector*> shared) {
-       try {
-               data.resize(1,0);
-               
-               int numOTUS = shared[0]->getNumBins();
-               double averageA = shared[0]->getNumSeqs() /  (float) numOTUS;
-               double averageB = shared[1]->getNumSeqs() / (float) numOTUS;
-               
-               double numTerm = 0.0;
-               double denomTerm1 = 0.0;
-               double denomTerm2 = 0.0;
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) { 
-                       int Aij =  shared[0]->getAbundance(i);
-                       int Bij =  shared[1]->getAbundance(i);
-                       
-                       
-                       numTerm += ((Aij - averageA) * (Bij - averageB));
-                       denomTerm1 += ((Aij - averageA) * (Aij - averageA));
-                       denomTerm2 += ((Bij - averageB) * (Bij - averageB));
-               }
-               
-               denomTerm1 = sqrt(denomTerm1);
-               denomTerm2 = sqrt(denomTerm2);
-               
-               double denom = denomTerm1 * denomTerm2;
-               
-               data[0] = (numTerm / denom);
-               
-               if (isnan(data[0]) || isinf(data[0])) { data[0] = 0; }
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "StructPearson", "getValues");
-               exit(1);
-       }
-}
-/***********************************************************************/
diff --git a/structpearson.h b/structpearson.h
deleted file mode 100644 (file)
index c0cbf9b..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef STRUCTPEARSON_H
-#define STRUCTPEARSON_H
-
-/*
- *  structpearson.h
- *  Mothur
- *
- *  Created by westcott on 12/15/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-
-
-#include "calculator.h"
-
-/***********************************************************************/
-
-class StructPearson : public Calculator  {
-       
-public:
-       StructPearson() :  Calculator("structpearson", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Structpearson"; }
-private:
-       
-};
-
-/***********************************************************************/
-
-#endif
-
-
diff --git a/stxwx.f b/stxwx.f
deleted file mode 100644 (file)
index 5322228..0000000
--- a/stxwx.f
+++ /dev/null
@@ -1,65 +0,0 @@
-C Output from Public domain Ratfor, version 1.0
-      subroutine stxwx(x,z,w,k,xknot,n,y,hs0,hs1,hs2,hs3)
-
-c      implicit none
-      integer k,n
-      DOUBLE precision x(k),z(k),w(k), xknot(n+4),y(n),
-     &     hs0(n),hs1(n),hs2(n),hs3(n)
-C local
-      DOUBLE precision eps,vnikx(4,1),work(16)
-      integer lenxk, i,j, ileft,mflag
-c
-c      integer interv
-c      external interv
-
-      lenxk=n+4
-C     Initialise the output vectors
-      do 1 i=1,n
-         y(i)=0d0
-         hs0(i)=0d0
-         hs1(i)=0d0
-         hs2(i)=0d0
-         hs3(i)=0d0
- 1    continue
-
-C Compute X' W^2 X -> hs0,hs1,hs2,hs3  and X' W^2 Z -> y
-C Note that here the weights w(i) == sqrt(wt[i])  where wt[] where original weights
-      ileft=1
-      eps= .1d-9
-
-      do 100 i=1,k
-         call interv(xknot(1), n+1, x(i), ileft, mflag)
-C        if(mflag==-1) {write(6,'("Error in hess ",i2)')mflag;stop}
-C        if(mflag==-1) {return}
-         if(mflag.eq. 1)then
-            if(x(i).le.(xknot(ileft)+eps))then
-               ileft=ileft-1
-            else
-               return
-            endif
-C        else{write(6,'("Error in hess ",i2)')mflag;stop}}
-         endif
-         call bsplvd (xknot,lenxk,4,x(i),ileft,work,vnikx,1)
-
-         j= ileft-4+1
-         y(j) = y(j)+w(i)**2*z(i)*vnikx(1,1)
-         hs0(j)=hs0(j)+w(i)**2*vnikx(1,1)**2
-         hs1(j)=hs1(j)+w(i)**2*vnikx(1,1)*vnikx(2,1)
-         hs2(j)=hs2(j)+w(i)**2*vnikx(1,1)*vnikx(3,1)
-         hs3(j)=hs3(j)+w(i)**2*vnikx(1,1)*vnikx(4,1)
-         j= ileft-4+2
-         y(j) = y(j)+w(i)**2*z(i)*vnikx(2,1)
-         hs0(j)=hs0(j)+w(i)**2*vnikx(2,1)**2
-         hs1(j)=hs1(j)+w(i)**2*vnikx(2,1)*vnikx(3,1)
-         hs2(j)=hs2(j)+w(i)**2*vnikx(2,1)*vnikx(4,1)
-         j= ileft-4+3
-         y(j) = y(j)+w(i)**2*z(i)*vnikx(3,1)
-         hs0(j)=hs0(j)+w(i)**2*vnikx(3,1)**2
-         hs1(j)=hs1(j)+w(i)**2*vnikx(3,1)*vnikx(4,1)
-         j= ileft-4+4
-         y(j) = y(j)+w(i)**2*z(i)*vnikx(4,1)
-         hs0(j)=hs0(j)+w(i)**2*vnikx(4,1)**2
- 100  continue
-
-      return
-      end
diff --git a/subsample.cpp b/subsample.cpp
deleted file mode 100644 (file)
index b1e78a4..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-//
-//  subsample.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/2/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "subsample.h"
-
-//**********************************************************************************************************************
-Tree* SubSample::getSample(Tree* T, TreeMap* tmap, map<string, string> whole, int size) {
-    try {
-        Tree* newTree = NULL;
-        
-        vector<string> subsampledSeqs = getSample(tmap, size);
-        map<string, string> sampledNameMap = deconvolute(whole, subsampledSeqs); 
-        
-        //remove seqs not in sample from treemap
-        for (int i = 0; i < tmap->namesOfSeqs.size(); i++) {
-            //is that name in the subsample?
-            int count = 0;
-            for (int j = 0; j < subsampledSeqs.size(); j++) {
-                if (tmap->namesOfSeqs[i] == subsampledSeqs[j]) { break; } //found it
-                count++;
-            }
-
-            if (m->control_pressed) { return newTree; }
-            
-            //if you didnt find it, remove it 
-            if (count == subsampledSeqs.size()) { 
-                tmap->removeSeq(tmap->namesOfSeqs[i]);
-                i--; //need this because removeSeq removes name from namesOfSeqs
-            }
-        }
-        
-        //create new tree
-        int numUniques = sampledNameMap.size();
-        if (sampledNameMap.size() == 0) { numUniques = subsampledSeqs.size(); }
-        
-        newTree = new Tree(numUniques, tmap); //numNodes, treemap
-        newTree->getSubTree(T, subsampledSeqs, sampledNameMap);
-        
-        return newTree;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "SubSample", "getSample-Tree");
-        exit(1);
-    }
-}      
-//**********************************************************************************************************************
-//assumes whole maps dupName -> uniqueName
-map<string, string> SubSample::deconvolute(map<string, string> whole, vector<string>& wanted) {
-    try {
-        map<string, string> nameMap;
-        
-        //whole will be empty if user gave no name file, so we don't need to make a new one
-        if (whole.size() == 0) { return nameMap; }
-        
-        vector<string> newWanted;
-        for (int i = 0; i < wanted.size(); i++) {
-            
-            if (m->control_pressed) { break; }
-            
-            string dupName = wanted[i];
-            
-            map<string, string>::iterator itWhole = whole.find(dupName);
-            if (itWhole != whole.end()) {
-                string repName = itWhole->second;
-                
-                //do we already have this rep?
-                map<string, string>::iterator itName = nameMap.find(repName);
-                if (itName != nameMap.end()) { //add this seqs to dups list
-                    (itName->second) += "," + dupName;
-                }else { //first sighting of this seq
-                    nameMap[repName] = dupName;
-                    newWanted.push_back(repName);
-                }
-            }else { m->mothurOut("[ERROR]: "+dupName+" is not in your name file, please correct.\n"); m->control_pressed = true; }
-        }
-        
-        wanted = newWanted;
-        return nameMap;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SubSample", "deconvolute");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-vector<string> SubSample::getSample(TreeMap* tMap, int size) {
-    try {
-        vector<string> sample;
-        
-        vector<string> Groups = tMap->getNamesOfGroups();    
-        for (int i = 0; i < Groups.size(); i++) {
-            
-            if (m->control_pressed) { break; }
-            
-            vector<string> thisGroup; thisGroup.push_back(Groups[i]);
-            vector<string> thisGroupsSeqs = tMap->getNamesSeqs(thisGroup);
-            int thisSize = thisGroupsSeqs.size();
-            
-            if (thisSize >= size) {    
-                
-                random_shuffle(thisGroupsSeqs.begin(), thisGroupsSeqs.end());
-                
-                for (int j = 0; j < size; j++) { sample.push_back(thisGroupsSeqs[j]); }
-            }else {  m->mothurOut("[ERROR]: You have selected a size that is larger than "+Groups[i]+" number of sequences.\n"); m->control_pressed = true; }
-        } 
-        
-        return sample;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "SubSample", "getSample-TreeMap");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int size) {
-       try {
-               
-               //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
-               
-               int numBins = thislookup[0]->getNumBins();
-               for (int i = 0; i < thislookup.size(); i++) {           
-                       int thisSize = thislookup[i]->getNumSeqs();
-                       
-                       if (thisSize != size) {
-                               
-                               string thisgroup = thislookup[i]->getGroup();
-                               
-                               OrderVector order;
-                               for(int p=0;p<numBins;p++){
-                                       for(int j=0;j<thislookup[i]->getAbundance(p);j++){
-                                               order.push_back(p);
-                                       }
-                               }
-                               random_shuffle(order.begin(), order.end());
-                               
-                               SharedRAbundVector* temp = new SharedRAbundVector(numBins);
-                               temp->setLabel(thislookup[i]->getLabel());
-                               temp->setGroup(thislookup[i]->getGroup());
-                               
-                               delete thislookup[i];
-                               thislookup[i] = temp;
-                               
-                               
-                               for (int j = 0; j < size; j++) {
-                                       
-                                       if (m->control_pressed) {  return m->currentBinLabels; }
-                                       
-                                       int bin = order.get(j);
-                                       
-                                       int abund = thislookup[i]->getAbundance(bin);
-                                       thislookup[i]->set(bin, (abund+1), thisgroup);
-                               }       
-                       }
-               }
-               
-               //subsampling may have created some otus with no sequences in them
-               eliminateZeroOTUS(thislookup);
-               
-               if (m->control_pressed) { return m->currentBinLabels; }
-               
-               //save mothurOut's binLabels to restore for next label
-        vector<string> subsampleBinLabels = m->currentBinLabels;
-               m->currentBinLabels = saveBinLabels;
-               
-               return subsampleBinLabels;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSample", "getSample-shared");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int SubSample::eliminateZeroOTUS(vector<SharedRAbundVector*>& thislookup) {
-       try {
-               
-               vector<SharedRAbundVector*> newLookup;
-               for (int i = 0; i < thislookup.size(); i++) {
-                       SharedRAbundVector* temp = new SharedRAbundVector();
-                       temp->setLabel(thislookup[i]->getLabel());
-                       temp->setGroup(thislookup[i]->getGroup());
-                       newLookup.push_back(temp);
-               }
-               
-               //for each bin
-               vector<string> newBinLabels;
-               string snumBins = toString(thislookup[0]->getNumBins());
-               for (int i = 0; i < thislookup[0]->getNumBins(); i++) {
-                       if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                       
-                       //look at each sharedRabund and make sure they are not all zero
-                       bool allZero = true;
-                       for (int j = 0; j < thislookup.size(); j++) {
-                               if (thislookup[j]->getAbundance(i) != 0) { allZero = false;  break;  }
-                       }
-                       
-                       //if they are not all zero add this bin
-                       if (!allZero) {
-                               for (int j = 0; j < thislookup.size(); j++) {
-                                       newLookup[j]->push_back(thislookup[j]->getAbundance(i), thislookup[j]->getGroup());
-                               }
-                               //if there is a bin label use it otherwise make one
-                               string binLabel = "Otu";
-                               string sbinNumber = toString(i+1);
-                               if (sbinNumber.length() < snumBins.length()) { 
-                                       int diff = snumBins.length() - sbinNumber.length();
-                                       for (int h = 0; h < diff; h++) { binLabel += "0"; }
-                               }
-                               binLabel += sbinNumber; 
-                               if (i < m->currentBinLabels.size()) {  binLabel = m->currentBinLabels[i]; }
-                               
-                               newBinLabels.push_back(binLabel);
-                       }
-               }
-               
-               for (int j = 0; j < thislookup.size(); j++) {  delete thislookup[j];  }
-               thislookup.clear();
-               
-               thislookup = newLookup;
-               m->currentBinLabels = newBinLabels;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSample", "eliminateZeroOTUS");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-
-
diff --git a/subsample.h b/subsample.h
deleted file mode 100644 (file)
index aaf5244..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef Mothur_subsample_h
-#define Mothur_subsample_h
-
-//
-//  subsample.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/2/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "mothurout.h"
-#include "sharedrabundvector.h"
-#include "treemap.h"
-#include "tree.h"
-
-//subsampling overwrites the sharedRabunds.  If you need to reuse the original use the getSamplePreserve function.
-
-class SubSample {
-       
-    public:
-    
-        SubSample() { m = MothurOut::getInstance(); }
-        ~SubSample() {}
-    
-        vector<string> getSample(vector<SharedRAbundVector*>&, int); //returns the bin labels for the subsample, mothurOuts binlabels are preserved so you can run this multiple times. Overwrites original vector passed in, if you need to preserve it deep copy first.
-        
-        Tree* getSample(Tree*, TreeMap*, map<string, string>, int); //creates new subsampled tree, destroys treemap so copy if needed.
-    
-    private:
-    
-        MothurOut* m;
-        int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
-    
-        vector<string> getSample(TreeMap*, int); //returns map contains names of seqs in subsample -> group. 
-        map<string, string> deconvolute(map<string, string> wholeSet, vector<string>& subsampleWanted); //returns new nameMap containing only subsampled names, and removes redundants from subsampled wanted because it makes the new nameMap.
-
-
-};
-
-#endif
diff --git a/subsamplecommand.cpp b/subsamplecommand.cpp
deleted file mode 100644 (file)
index 717b1d3..0000000
+++ /dev/null
@@ -1,1489 +0,0 @@
-/*
- *  subsamplecommand.cpp
- *  Mothur
- *
- *  Created by westcott on 10/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "subsamplecommand.h"
-#include "sharedutilities.h"
-#include "deconvolutecommand.h"
-#include "subsample.h"
-
-//**********************************************************************************************************************
-vector<string> SubSampleCommand::setParameters(){      
-       try {           
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(pfasta);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter plist("list", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(plist);
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(pshared);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "none", "FLSSR", "none",false,false); parameters.push_back(psabund);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter ppersample("persample", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppersample);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SubSampleCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The sub.sample command is designed to be used as a way to normalize your data, or create a smaller set from your original set.\n";
-               helpString += "The sub.sample command parameters are fasta, name, list, group, rabund, sabund, shared, groups, size, persample and label.  You must provide a fasta, list, sabund, rabund or shared file as an input file.\n";
-               helpString += "The namefile is only used with the fasta file, not with the listfile, because the list file should contain all sequences.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included. The group names are separated by dashes.\n";
-               helpString += "The label parameter allows you to select what distance levels you would like, and are also separated by dashes.\n";
-               helpString += "The size parameter allows you indicate the size of your subsample.\n";
-               helpString += "The persample parameter allows you indicate you want to select subsample of the same size from each of your groups, default=false. It is only used with the list and fasta files if a groupfile is given.\n";
-               helpString += "persample=false will select a random set of sequences of the size you select, but the number of seqs from each group may differ.\n";
-               helpString += "The size parameter is not set: with shared file size=number of seqs in smallest sample, with all other files if a groupfile is given and persample=true, then size=number of seqs in smallest sample, otherwise size=10% of number of seqs.\n";
-               helpString += "The sub.sample command should be in the following format: sub.sample(list=yourListFile, group=yourGroupFile, groups=yourGroups, label=yourLabels).\n";
-               helpString += "Example sub.sample(list=abrecovery.fn.list, group=abrecovery.groups, groups=B-C, size=20).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and all labels in your inputfile will be used.\n";
-               helpString += "The sub.sample command outputs a .subsample file.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SubSampleCommand::SubSampleCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["shared"] = tempOutNames;
-               outputTypes["list"] = tempOutNames;
-               outputTypes["rabund"] = tempOutNames;
-               outputTypes["sabund"] = tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "GetRelAbundCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SubSampleCommand::SubSampleCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       map<string,string>::iterator it;
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["shared"] = tempOutNames;
-                       outputTypes["list"] = tempOutNames;
-                       outputTypes["rabund"] = tempOutNames;
-                       outputTypes["sabund"] = tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = ""; }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else { m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else { m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else { m->setRabundFile(rabundfile); }
-                       
-                       fastafile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastafile == "not open") { fastafile = ""; abort = true; }  
-                       else if (fastafile == "not found") { fastafile = ""; }
-                       else { m->setFastaFile(fastafile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else { m->setSharedFile(sharedfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }    
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }  
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; pickedGroups = false; }
-                       else { 
-                               pickedGroups = true;
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "size", false);              if (temp == "not found"){       temp = "0";             }
-                       m->mothurConvert(temp, size);  
-                       
-                       temp = validParameter.validFile(parameters, "persample", false);                if (temp == "not found"){       temp = "f";             }
-                       persample = m->isTrue(temp);
-                       
-                       if (groupfile == "") { persample = false; }
-                       
-                       if ((namefile != "") && (fastafile == "")) { m->mothurOut("You may only use a namefile with a fastafile."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile == "") && (listfile == "") && (sabundfile == "") && (rabundfile == "") && (sharedfile == "")) {
-                               m->mothurOut("You must provide a fasta, list, sabund, rabund or shared file as an input file."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if (pickedGroups && ((groupfile == "") && (sharedfile == ""))) { 
-                               m->mothurOut("You cannot pick groups without a valid group file or shared file."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((groupfile != "") && ((fastafile == "") && (listfile == ""))) { 
-                               m->mothurOut("Group file only valid with listfile or fastafile."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((groupfile != "") && ((fastafile != "") && (listfile != ""))) { 
-                               m->mothurOut("A new group file can only be made from the subsample of a listfile or fastafile, not both. Please correct."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if ((fastafile != "") && (namefile == "")) {
-                               vector<string> files; files.push_back(fastafile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "SubSampleCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SubSampleCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (sharedfile != "")   {   getSubSampleShared();       }
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); return 0; } }
-               
-               if (listfile != "")             {   getSubSampleList();         }
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); return 0; } }
-               
-               if (rabundfile != "")   {   getSubSampleRabund();       }
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); return 0; } }
-               
-               if (sabundfile != "")   {   getSubSampleSabund();       }
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); return 0; } }
-               
-               if (fastafile != "")    {   getSubSampleFasta();        }
-               if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]); return 0; } }
-                       
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-               
-               itTypes = outputTypes.find("list");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); }
-               }
-               
-               itTypes = outputTypes.find("shared");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); }
-               }
-               
-               itTypes = outputTypes.find("rabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setRabundFile(current); }
-               }
-               
-               itTypes = outputTypes.find("sabund");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSabundFile(current); }
-               }
-               
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::getSubSampleFasta() {
-       try {
-               
-               if (namefile != "") { readNames(); }    //fills names with all names in namefile.
-               else { getNames(); }//no name file, so get list of names to pick from
-               
-               GroupMap* groupMap;
-               if (groupfile != "") {
-                       
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-                       
-                       //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
-                       vector<string> namesGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, namesGroups);
-                       delete util;
-                       
-                       //file mismatch quit
-                       if (names.size() != groupMap->getNumSeqs()) { 
-                               m->mothurOut("[ERROR]: your fasta file contains " + toString(names.size()) + " sequences, and your groupfile contains " + toString(groupMap->getNumSeqs()) + ", please correct."); 
-                               m->mothurOutEndLine();
-                               delete groupMap;
-                               return 0;
-                       }                       
-               }       
-               
-               if (m->control_pressed) { return 0; }
-               
-               
-               //make sure that if your picked groups size is not too big
-               int thisSize = names.size();
-               if (persample) { 
-                       if (size == 0) { //user has not set size, set size = smallest samples size
-                               size = groupMap->getNumSeqs(Groups[0]);
-                               for (int i = 1; i < Groups.size(); i++) {
-                                       int thisSize = groupMap->getNumSeqs(Groups[i]);
-                                       
-                                       if (thisSize < size) {  size = thisSize;        }
-                               }
-                       }else { //make sure size is not too large
-                               vector<string> newGroups;
-                               for (int i = 0; i < Groups.size(); i++) {
-                                       int thisSize = groupMap->getNumSeqs(Groups[i]);
-                                       
-                                       if (thisSize >= size) { newGroups.push_back(Groups[i]); }
-                                       else {  m->mothurOut("You have selected a size that is larger than " + Groups[i] + " number of sequences, removing " + Groups[i] + "."); m->mothurOutEndLine(); }
-                               }
-                               Groups = newGroups;
-                       }
-                       
-                       m->mothurOut("Sampling " + toString(size) + " from each group."); m->mothurOutEndLine();                        
-               }else {
-                       if (pickedGroups) {
-                               int total = 0;
-                               for(int i = 0; i < Groups.size(); i++) {
-                                       total += groupMap->getNumSeqs(Groups[i]);
-                               }
-                               
-                               if (size == 0) { //user has not set size, set size = 10% samples size
-                                       size = int (total * 0.10);
-                               }
-                               
-                               if (total < size) { 
-                                       if (size != 0) { 
-                                               m->mothurOut("Your size is too large for the number of groups you selected. Adjusting to " + toString(int (total * 0.10)) + "."); m->mothurOutEndLine();
-                                       }
-                                       size = int (total * 0.10);
-                               }
-                               
-                               m->mothurOut("Sampling " + toString(size) + " from " + toString(total) + "."); m->mothurOutEndLine();
-                       }
-                       
-                       if (size == 0) { //user has not set size, set size = 10% samples size
-                               size = int (names.size() * 0.10);
-                       }
-                       
-                       if (size > thisSize) { m->mothurOut("Your fasta file only contains " + toString(thisSize) + " sequences. Setting size to " + toString(thisSize) + "."); m->mothurOutEndLine();
-                               size = thisSize;
-                       }
-                       
-                       if (!pickedGroups) { m->mothurOut("Sampling " + toString(size) + " from " + toString(thisSize) + "."); m->mothurOutEndLine(); }
-
-               }
-               random_shuffle(names.begin(), names.end());
-               
-               set<string> subset; //dont want repeat sequence names added
-               if (persample) {
-                       //initialize counts
-                       map<string, int> groupCounts;
-                       map<string, int>::iterator itGroupCounts;
-                       for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
-                       
-                       for (int j = 0; j < names.size(); j++) {
-                                       
-                               if (m->control_pressed) { return 0; }
-                                                                                               
-                               string group = groupMap->getGroup(names[j]);
-                               if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                               else{
-                                       itGroupCounts = groupCounts.find(group);
-                                       if (itGroupCounts != groupCounts.end()) {
-                                               if (groupCounts[group] < size) {        subset.insert(names[j]);        groupCounts[group]++; }
-                                       }
-                               }                               
-                       }
-               }else {
-                       
-                       //randomly select a subset of those names to include in the subsample
-                       //since names was randomly shuffled just grab the next one
-                       for (int j = 0; j < names.size(); j++) {
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               if (groupfile != "") { //if there is a groupfile given fill in group info
-                                       string group = groupMap->getGroup(names[j]);
-                                       if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                                       
-                                       if (pickedGroups) { //if hte user picked groups, we only want to keep the names of sequences from those groups
-                                               if (m->inUsersGroups(group, Groups)) {
-                                                       subset.insert(names[j]); 
-                                               }
-                                       }else{
-                                               subset.insert(names[j]); 
-                                       }
-                               }else{ //save everyone, group
-                                       subset.insert(names[j]); 
-                               }                                       
-                       
-                               //do we have enough??
-                               if (subset.size() == size) { break; }
-                       }       
-               }
-               
-               if (subset.size() == 0) {  m->mothurOut("The size you selected is too large, skipping fasta file."); m->mothurOutEndLine();  return 0; }
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(fastafile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(fastafile)) + "subsample" + m->getExtension(fastafile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               
-               //read through fasta file outputting only the names on the subsample list
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               string thisname;
-               int count = 0;
-               map<string, vector<string> >::iterator itNameMap;
-               
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); out.close();  return 0; }
-                       
-                       Sequence currSeq(in);
-                       thisname = currSeq.getName();
-                       
-                       if (thisname != "") {
-                               
-                               //does the subset contain a sequence that this sequence represents
-                               itNameMap = nameMap.find(thisname);
-                               if (itNameMap != nameMap.end()) {
-                                       vector<string> nameRepresents = itNameMap->second;
-                               
-                                       for (int i = 0; i < nameRepresents.size(); i++){
-                                               if (subset.count(nameRepresents[i]) != 0) {
-                                                       out << ">" << nameRepresents[i] << endl << currSeq.getAligned() << endl;
-                                                       count++;
-                                               }
-                                       }
-                               }else{
-                                       m->mothurOut("[ERROR]: " + thisname + " is not in your namefile, please correct."); m->mothurOutEndLine();
-                               }
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               out.close();
-               
-               if (count != subset.size()) {
-                       m->mothurOut("[ERROR]: The subset selected contained " + toString(subset.size()) + " sequences, but I only found " + toString(count) + " of those in the fastafile."); m->mothurOutEndLine();
-               }
-               
-               if (namefile != "") {
-                       m->mothurOut("Deconvoluting subsampled fasta file... "); m->mothurOutEndLine();
-                       
-                       //use unique.seqs to create new name and fastafile
-                       string inputString = "fasta=" + outputFileName;
-                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-                       m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); 
-                       m->mothurCalling = true;
-            
-                       Command* uniqueCommand = new DeconvoluteCommand(inputString);
-                       uniqueCommand->execute();
-                       
-                       map<string, vector<string> > filenames = uniqueCommand->getOutputFiles();
-                       
-                       delete uniqueCommand;
-                       m->mothurCalling = false;
-            
-                       outputTypes["name"].push_back(filenames["name"][0]);  outputNames.push_back(filenames["name"][0]);
-                       m->mothurRemove(outputFileName);
-                       outputFileName = filenames["fasta"][0];
-                       
-                       m->mothurOut("/******************************************/"); m->mothurOutEndLine(); 
-                       
-                       m->mothurOut("Done."); m->mothurOutEndLine();
-               }
-               
-               outputTypes["fasta"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               //if a groupfile is provided read through the group file only outputting the names on the subsample list
-               if (groupfile != "") {
-                       
-                       string groupOutputDir = outputDir;
-                       if (outputDir == "") {  groupOutputDir += m->hasPath(groupfile);  }
-                       string groupOutputFileName = groupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "subsample" + m->getExtension(groupfile);
-                       
-                       ofstream outGroup;
-                       m->openOutputFile(groupOutputFileName, outGroup);
-                       outputTypes["group"].push_back(groupOutputFileName);  outputNames.push_back(groupOutputFileName);
-                       
-                       ifstream inGroup;
-                       m->openInputFile(groupfile, inGroup);
-                       string name, group;
-                       
-                       while(!inGroup.eof()){
-                               
-                               if (m->control_pressed) { inGroup.close(); outGroup.close(); return 0; }
-                               
-                               inGroup >> name;        m->gobble(inGroup);                     //read from first column
-                               inGroup >> group;                       //read from second column
-                               
-                               //if this name is in the accnos file
-                               if (subset.count(name) != 0) {
-                                       outGroup << name << '\t' << group << endl;
-                                       subset.erase(name);
-                               }
-                               
-                               m->gobble(inGroup);
-                       }
-                       inGroup.close();
-                       outGroup.close();       
-                       
-                       //sanity check
-                       if (subset.size() != 0) {  
-                               m->mothurOut("Your groupfile does not match your fasta file."); m->mothurOutEndLine();
-                               for (set<string>::iterator it = subset.begin(); it != subset.end(); it++) {
-                                       m->mothurOut("[ERROR]: " + *it + " is missing from your groupfile."); m->mothurOutEndLine();
-                               }
-                       }
-               }
-                       
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getSubSampleFasta");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::getNames() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(fastafile, in);
-               
-               string thisname;
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       Sequence currSeq(in);
-                       thisname = currSeq.getName();
-                       
-                       if (thisname != "") {
-                               vector<string> temp; temp.push_back(thisname);
-                               nameMap[thisname] = temp;
-                               names.push_back(thisname);
-                       }
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getNames");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int SubSampleCommand::readNames() {
-       try {
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               string thisname, repnames;
-               map<string, vector<string> >::iterator it;
-               
-               while(!in.eof()){
-                       
-                       if (m->control_pressed) { in.close(); return 0; }
-                       
-                       in >> thisname;         m->gobble(in);          //read from first column
-                       in >> repnames;                 //read from second column
-                       
-                       it = nameMap.find(thisname);
-                       if (it == nameMap.end()) {
-                               
-                               vector<string> splitRepNames;
-                               m->splitAtComma(repnames, splitRepNames);
-                               
-                               nameMap[thisname] = splitRepNames;      
-                               for (int i = 0; i < splitRepNames.size(); i++) { names.push_back(splitRepNames[i]); }
-                               
-                       }else{  m->mothurOut(thisname + " is already in namesfile. I will use first definition."); m->mothurOutEndLine();  }
-                       
-                       m->gobble(in);
-               }
-               in.close();     
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "readNames");
-               exit(1);
-       }
-}              
-//**********************************************************************************************************************
-int SubSampleCommand::getSubSampleShared() {
-       try {
-               
-               InputData* input = new InputData(sharedfile, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (size == 0) { //user has not set size, set size = smallest samples size
-                       size = lookup[0]->getNumSeqs();
-                       for (int i = 1; i < lookup.size(); i++) {
-                               int thisSize = lookup[i]->getNumSeqs();
-                               
-                               if (thisSize < size) {  size = thisSize;        }
-                       }
-               }else {
-                       m->clearGroups();
-                       Groups.clear();
-                       vector<SharedRAbundVector*> temp;
-                       for (int i = 0; i < lookup.size(); i++) {
-                               if (lookup[i]->getNumSeqs() < size) { 
-                                       m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
-                                       delete lookup[i];
-                               }else { 
-                                       Groups.push_back(lookup[i]->getGroup()); 
-                                       temp.push_back(lookup[i]);
-                               }
-                       } 
-                       lookup = temp;
-                       m->setGroups(Groups);
-               }
-               
-               if (lookup.size() == 0) {  m->mothurOut("The size you selected is too large, skipping shared file."); m->mothurOutEndLine(); delete input; return 0; }
-               
-               m->mothurOut("Sampling " + toString(size) + " from each group."); m->mothurOutEndLine();
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) {  delete input; for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }  return 0;  }
-                       
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               processShared(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                               
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }  
-                               
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               
-                               processShared(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i]; lookup[i] = NULL; }
-                       
-                       //get next line to process
-                       lookup = input->getSharedRAbundVectors();                               
-               }
-               
-               
-               if (m->control_pressed) {   return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) { if (lookup[i] != NULL) { delete lookup[i]; } }  
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-                       
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       
-                       processShared(lookup);
-                       
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }
-               }
-               
-               delete input;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getSubSampleShared");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::processShared(vector<SharedRAbundVector*>& thislookup) {
-       try {
-               
-               //save mothurOut's binLabels to restore for next label
-               vector<string> saveBinLabels = m->currentBinLabels;
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sharedfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sharedfile)) + thislookup[0]->getLabel() + ".subsample" + m->getExtension(sharedfile);
-        
-        SubSample sample;
-        vector<string> subsampledLabels = sample.getSample(thislookup, size);
-        
-        if (m->control_pressed) {  return 0; }
-        
-        ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputTypes["shared"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-        m->currentBinLabels = subsampledLabels;
-        
-               thislookup[0]->printHeaders(out);
-               
-               for (int i = 0; i < thislookup.size(); i++) {
-                       out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
-                       thislookup[i]->print(out);
-               }
-               out.close();
-        
-        
-        //save mothurOut's binLabels to restore for next label
-               m->currentBinLabels = saveBinLabels;
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "processShared");
-               exit(1);
-       }
-}                      
-//**********************************************************************************************************************
-int SubSampleCommand::getSubSampleList() {
-       try {
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(listfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(listfile)) + "subsample" + m->getExtension(listfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputTypes["list"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               InputData* input = new InputData(listfile, "list");
-               ListVector* list = input->getListVector();
-               string lastLabel = list->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               ofstream outGroup;
-               GroupMap* groupMap;
-               if (groupfile != "") {
-                       
-                       groupMap = new GroupMap(groupfile);
-                       groupMap->readMap();
-                       
-                       //takes care of user setting groupNames that are invalid or setting groups=all
-                       SharedUtil* util = new SharedUtil();
-                       vector<string> namesGroups = groupMap->getNamesOfGroups();
-                       util->setGroups(Groups, namesGroups);
-                       delete util;
-                       
-                       //create outputfiles
-                       string groupOutputDir = outputDir;
-                       if (outputDir == "") {  groupOutputDir += m->hasPath(groupfile);  }
-                       string groupOutputFileName = groupOutputDir + m->getRootName(m->getSimpleName(groupfile)) + "subsample" + m->getExtension(groupfile);
-                       
-                       m->openOutputFile(groupOutputFileName, outGroup);
-                       outputTypes["group"].push_back(groupOutputFileName);  outputNames.push_back(groupOutputFileName);
-                       
-                       //file mismatch quit
-                       if (list->getNumSeqs() != groupMap->getNumSeqs()) { 
-                               m->mothurOut("[ERROR]: your list file contains " + toString(list->getNumSeqs()) + " sequences, and your groupfile contains " + toString(groupMap->getNumSeqs()) + ", please correct."); 
-                               m->mothurOutEndLine();
-                               delete groupMap;
-                               delete list;
-                               delete input;
-                               out.close();
-                               outGroup.close();
-                               return 0;
-                       }                       
-               }
-               
-               //make sure that if your picked groups size is not too big
-               if (persample) {
-                       if (size == 0) { //user has not set size, set size = smallest samples size
-                               size = groupMap->getNumSeqs(Groups[0]);
-                               for (int i = 1; i < Groups.size(); i++) {
-                                       int thisSize = groupMap->getNumSeqs(Groups[i]);
-                                       
-                                       if (thisSize < size) {  size = thisSize;        }
-                               }
-                       }else { //make sure size is not too large
-                               vector<string> newGroups;
-                               for (int i = 0; i < Groups.size(); i++) {
-                                       int thisSize = groupMap->getNumSeqs(Groups[i]);
-                                       
-                                       if (thisSize >= size) { newGroups.push_back(Groups[i]); }
-                                       else {  m->mothurOut("You have selected a size that is larger than " + Groups[i] + " number of sequences, removing " + Groups[i] + "."); m->mothurOutEndLine(); }
-                               }
-                               Groups = newGroups;
-                       }
-                       
-                       m->mothurOut("Sampling " + toString(size) + " from each group."); m->mothurOutEndLine();        
-               }else{
-                       if (pickedGroups) {
-                               int total = 0;
-                               for(int i = 0; i < Groups.size(); i++) {
-                                       total += groupMap->getNumSeqs(Groups[i]);
-                               }
-                               
-                               if (size == 0) { //user has not set size, set size = 10% samples size
-                                       size = int (total * 0.10);
-                               }
-                               
-                               if (total < size) { 
-                                       m->mothurOut("Your size is too large for the number of groups you selected. Adjusting to " + toString(int (total * 0.10)) + "."); m->mothurOutEndLine();
-                                       size = int (total * 0.10);
-                               }
-                               
-                               m->mothurOut("Sampling " + toString(size) + " from " + toString(total) + "."); m->mothurOutEndLine();
-                       }else{
-                               
-                               if (size == 0) { //user has not set size, set size = 10% samples size
-                                       size = int (list->getNumSeqs() * 0.10);
-                               }
-                               
-                               int thisSize = list->getNumSeqs();
-                               if (size > thisSize) { m->mothurOut("Your list file only contains " + toString(thisSize) + " sequences. Setting size to " + toString(thisSize) + "."); m->mothurOutEndLine();
-                                       size = thisSize;
-                               }
-                               
-                               m->mothurOut("Sampling " + toString(size) + " from " + toString(list->getNumSeqs()) + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               
-               //fill names
-               for (int i = 0; i < list->getNumBins(); i++) {
-                       string binnames = list->get(i);
-                       
-                       //parse names
-                       string individual = "";
-                       int length = binnames.length();
-                       for(int j=0;j<length;j++){
-                               if(binnames[j] == ','){
-                                       
-                                       if (groupfile != "") { //if there is a groupfile given fill in group info
-                                               string group = groupMap->getGroup(individual);
-                                               if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                                               
-                                               if (pickedGroups) { //if hte user picked groups, we only want to keep the names of sequences from those groups
-                                                       if (m->inUsersGroups(group, Groups)) {
-                                                               names.push_back(individual);
-                                                       }
-                                               }else{
-                                                       names.push_back(individual);
-                                               }
-                                       }else{ //save everyone, group
-                                               names.push_back(individual);
-                                       }
-                                       individual = "";                                
-                               }
-                               else{
-                                       individual += binnames[j];
-                               }
-                       }
-                       //save last name
-                       if (groupfile != "") { //if there is a groupfile given fill in group info
-                               string group = groupMap->getGroup(individual);
-                               if (group == "not found") { m->mothurOut("[ERROR]: " + individual + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                               
-                               if (pickedGroups) { //if hte user picked groups, we only want to keep the names of sequences from those groups
-                                       if (m->inUsersGroups(group, Groups)) {
-                                               names.push_back(individual);
-                                       }
-                               }else{
-                                       names.push_back(individual);
-                               }
-                       }else{ //save everyone, group
-                               names.push_back(individual);
-                       }
-               }
-               
-               random_shuffle(names.begin(), names.end());
-                       
-               //randomly select a subset of those names to include in the subsample
-               set<string> subset; //dont want repeat sequence names added
-               if (persample) {
-                       //initialize counts
-                       map<string, int> groupCounts;
-                       map<string, int>::iterator itGroupCounts;
-                       for (int i = 0; i < Groups.size(); i++) { groupCounts[Groups[i]] = 0; }
-                       
-                       for (int j = 0; j < names.size(); j++) {
-                               
-                               if (m->control_pressed) { return 0; }
-                               
-                               string group = groupMap->getGroup(names[j]);
-                               if (group == "not found") { m->mothurOut("[ERROR]: " + names[j] + " is not in your groupfile. please correct."); m->mothurOutEndLine(); group = "NOTFOUND"; }
-                               else{
-                                       itGroupCounts = groupCounts.find(group);
-                                       if (itGroupCounts != groupCounts.end()) {
-                                               if (groupCounts[group] < size) {        subset.insert(names[j]);        groupCounts[group]++; }
-                                       }
-                               }                               
-                       }
-               }else{
-                       for (int j = 0; j < size; j++) {
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               subset.insert(names[j]); 
-                       }       
-               }
-               
-               if (groupfile != "") { 
-                       //write out new groupfile
-                       for (set<string>::iterator it = subset.begin(); it != subset.end(); it++) {
-                               string group = groupMap->getGroup(*it);
-                               if (group == "not found") { group = "NOTFOUND"; }
-                               
-                               outGroup << *it << '\t' << group << endl;
-                       }
-                       outGroup.close(); delete groupMap; 
-               }
-               
-                                               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((list != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                       if (m->control_pressed) {  delete list; delete input; out.close();  return 0;  }
-                       
-                       if(allLines == 1 || labels.count(list->getLabel()) == 1){                       
-                               
-                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                               
-                               processList(list, out, subset);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(list->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = list->getLabel();
-                               
-                               delete list; 
-                               
-                               list = input->getListVector(lastLabel);
-                               m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                               
-                               processList(list, out, subset);
-                               
-                               processedLabels.insert(list->getLabel());
-                               userLabels.erase(list->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               list->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = list->getLabel();
-                       
-                       delete list; list = NULL;
-                       
-                       //get next line to process
-                       list = input->getListVector();                          
-               }
-               
-               
-               if (m->control_pressed) {  if (list != NULL) { delete list; } delete input; out.close(); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (list != NULL) { delete list; }
-                       
-                       list = input->getListVector(lastLabel);
-                       
-                       m->mothurOut(list->getLabel()); m->mothurOutEndLine();
-                       
-                       processList(list, out, subset);
-                       
-                       delete list; list = NULL;
-               }
-               
-               out.close();  
-               if (list != NULL) { delete list; }
-               delete input;
-                                               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getSubSampleList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::processList(ListVector*& list, ofstream& out, set<string>& subset) {
-       try {
-                               
-               int numBins = list->getNumBins();
-
-               ListVector* temp = new ListVector();
-               temp->setLabel(list->getLabel());
-               
-               for (int i = 0; i < numBins; i++) {
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       string binnames = list->get(i);
-                       
-                       //parse names
-                       string individual = "";
-                       string newNames = "";
-                       int length = binnames.length();
-                       for(int j=0;j<length;j++){
-                               if(binnames[j] == ','){
-                                       if (subset.count(individual) != 0) {  newNames += individual + ",";  }
-                                       individual = "";                                
-                               }else{
-                                       individual += binnames[j];
-                               }
-                       }
-                       if (subset.count(individual) != 0) {  newNames += individual + ",";  }
-                       
-                       
-                       //if there are names in this bin add to new list
-                       if (newNames != "") { 
-                               newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
-                               temp->push_back(newNames);
-                       }
-               }
-               
-               delete list;
-               list = temp;
-               
-               if (m->control_pressed) { return 0; }
-               
-               list->print(out);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "processList");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::getSubSampleRabund() {
-       try {
-               InputData* input = new InputData(rabundfile, "rabund");
-               RAbundVector* rabund = input->getRAbundVector();
-               string lastLabel = rabund->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (size == 0) { //user has not set size, set size = 10%
-                       size = int((rabund->getNumSeqs()) * 0.10);
-               }else if (size > rabund->getNumSeqs()) { m->mothurOut("The size you selected is too large, skipping rabund file."); m->mothurOutEndLine(); delete input; delete rabund; return 0; }
-               
-               m->mothurOut("Sampling " + toString(size) + " from " + toString(rabund->getNumSeqs()) + "."); m->mothurOutEndLine();
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(rabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(rabundfile)) + "subsample" + m->getExtension(rabundfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputTypes["rabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((rabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) {  delete input; delete rabund; out.close(); return 0;  }
-                       
-                       if(allLines == 1 || labels.count(rabund->getLabel()) == 1){                     
-                               
-                               m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                               
-                               processRabund(rabund, out);
-                               
-                               processedLabels.insert(rabund->getLabel());
-                               userLabels.erase(rabund->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(rabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = rabund->getLabel();
-                               
-                               delete rabund; 
-                               
-                               rabund = input->getRAbundVector(lastLabel);
-                               m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                               
-                               processRabund(rabund, out);
-                               
-                               processedLabels.insert(rabund->getLabel());
-                               userLabels.erase(rabund->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               rabund->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = rabund->getLabel();
-                       
-                       //prevent memory leak
-                       delete rabund; rabund = NULL;
-                       
-                       //get next line to process
-                       rabund = input->getRAbundVector();                              
-               }
-               
-               
-               if (m->control_pressed) {  out.close(); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (rabund != NULL) { delete rabund; }
-                       
-                       rabund = input->getRAbundVector(lastLabel);
-                       
-                       m->mothurOut(rabund->getLabel()); m->mothurOutEndLine();
-                       
-                       processRabund(rabund, out);
-                       
-                       delete rabund;
-               }
-               
-               delete input;
-               out.close();  
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getSubSampleRabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::processRabund(RAbundVector*& rabund, ofstream& out) {
-       try {
-               
-               int numBins = rabund->getNumBins();
-               int thisSize = rabund->getNumSeqs();
-                       
-               if (thisSize != size) {
-                               
-                       OrderVector* order = new OrderVector();
-                       for(int p=0;p<numBins;p++){
-                               for(int j=0;j<rabund->get(p);j++){
-                                       order->push_back(p);
-                               }
-                       }
-                       random_shuffle(order->begin(), order->end());
-                       
-                       RAbundVector* temp = new RAbundVector(numBins);
-                       temp->setLabel(rabund->getLabel());
-                       
-                       delete rabund;
-                       rabund = temp;
-                       
-                       for (int j = 0; j < size; j++) {
-                               
-                               if (m->control_pressed) { delete order; return 0; }
-                               
-                               int bin = order->get(j);
-                               
-                               int abund = rabund->get(bin);
-                               rabund->set(bin, (abund+1));
-                       }
-                       
-                       delete order;
-               }
-               
-               if (m->control_pressed) { return 0; }
-               
-               rabund->print(out);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "processRabund");
-               exit(1);
-       }
-}      
-//**********************************************************************************************************************
-int SubSampleCommand::getSubSampleSabund() {
-       try {
-                               
-               InputData* input = new InputData(sabundfile, "sabund");
-               SAbundVector* sabund = input->getSAbundVector();
-               string lastLabel = sabund->getLabel();
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               if (size == 0) { //user has not set size, set size = 10%
-                       size = int((sabund->getNumSeqs()) * 0.10);
-               }else if (size > sabund->getNumSeqs()) { m->mothurOut("The size you selected is too large, skipping sabund file."); m->mothurOutEndLine(); delete input; delete sabund; return 0; }
-               
-               
-               m->mothurOut("Sampling " + toString(size) + " from " + toString(sabund->getNumSeqs()) + "."); m->mothurOutEndLine();
-               
-               string thisOutputDir = outputDir;
-               if (outputDir == "") {  thisOutputDir += m->hasPath(sabundfile);  }
-               string outputFileName = thisOutputDir + m->getRootName(m->getSimpleName(sabundfile)) + "subsample" + m->getExtension(sabundfile);
-               
-               ofstream out;
-               m->openOutputFile(outputFileName, out);
-               outputTypes["sabund"].push_back(outputFileName);  outputNames.push_back(outputFileName);
-               
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) {  delete input; delete sabund; out.close(); return 0;  }
-                       
-                       if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
-                               
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               
-                               processSabund(sabund, out);
-                               
-                               processedLabels.insert(sabund->getLabel());
-                               userLabels.erase(sabund->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = sabund->getLabel();
-                               
-                               delete sabund; 
-                               
-                               sabund = input->getSAbundVector(lastLabel);
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               
-                               processSabund(sabund, out);
-                               
-                               processedLabels.insert(sabund->getLabel());
-                               userLabels.erase(sabund->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               sabund->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = sabund->getLabel();
-                       
-                       //prevent memory leak
-                       delete sabund; sabund = NULL;
-                       
-                       //get next line to process
-                       sabund = input->getSAbundVector();                              
-               }
-               
-               
-               if (m->control_pressed) {  out.close(); return 0;  }
-               
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       if (sabund != NULL) { delete sabund; }
-                       
-                       sabund = input->getSAbundVector(lastLabel);
-                       
-                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                       
-                       processSabund(sabund, out);
-                       
-                       delete sabund;
-               }
-               
-               delete input;
-               out.close();  
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "getSubSampleSabund");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-int SubSampleCommand::processSabund(SAbundVector*& sabund, ofstream& out) {
-       try {
-               
-               RAbundVector* rabund = new RAbundVector();
-               *rabund = sabund->getRAbundVector();
-               
-               int numBins = rabund->getNumBins();
-               int thisSize = rabund->getNumSeqs();
-       
-               if (thisSize != size) {
-                       
-                       OrderVector* order = new OrderVector();
-                       for(int p=0;p<numBins;p++){
-                               for(int j=0;j<rabund->get(p);j++){
-                                       order->push_back(p);
-                               }
-                       }
-                       random_shuffle(order->begin(), order->end());
-                       
-                       RAbundVector* temp = new RAbundVector(numBins);
-                       temp->setLabel(rabund->getLabel());
-                       
-                       delete rabund;
-                       rabund = temp;
-                       
-                       for (int j = 0; j < size; j++) {
-       
-                               if (m->control_pressed) { delete order; return 0; }
-                               
-                               int bin = order->get(j);
-                               
-                               int abund = rabund->get(bin);
-                               rabund->set(bin, (abund+1));
-                       }
-                       
-                       delete order;
-               }
-               
-               if (m->control_pressed) { return 0; }
-
-               delete sabund;
-               sabund = new SAbundVector();
-               *sabund = rabund->getSAbundVector();
-               delete rabund;
-       
-               sabund->print(out);
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SubSampleCommand", "processSabund");
-               exit(1);
-       }
-}                      
-//**********************************************************************************************************************
-
-
-
diff --git a/subsamplecommand.h b/subsamplecommand.h
deleted file mode 100644 (file)
index 7235a7b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-#ifndef SUBSAMPLECOMMAND_H
-#define SUBSAMPLECOMMAND_H
-
-/*
- *  subsamplecommand.h
- *  Mothur
- *
- *  Created by westcott on 10/27/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "sharedrabundvector.h"
-#include "listvector.hpp"
-#include "rabundvector.hpp"
-#include "inputdata.h"
-#include "sequence.hpp"
-
-
-class SubSampleCommand : public Command {
-
-public:
-       SubSampleCommand(string);
-       SubSampleCommand();
-       ~SubSampleCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "sub.sample";  }
-       string getCommandCategory()             { return "General";             }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Sub.sample"; }
-       string getDescription()         { return "get a sampling of sequences from a list, shared, rabund, sabund or fasta file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:       
-       bool abort, pickedGroups, allLines, persample;
-       string listfile, groupfile, sharedfile, rabundfile, sabundfile, fastafile, namefile;
-       set<string> labels; //holds labels to be used
-       string groups, label, outputDir;
-       vector<string> Groups, outputNames;
-       int size;
-       vector<string> names;
-       map<string, vector<string> > nameMap;
-       
-       int getSubSampleShared();
-       int getSubSampleList();
-       int getSubSampleRabund();
-       int getSubSampleSabund();
-       int getSubSampleFasta();
-       int processShared(vector<SharedRAbundVector*>&);
-       int processRabund(RAbundVector*&, ofstream&);
-       int processSabund(SAbundVector*&, ofstream&);
-       int processList(ListVector*&, ofstream&, set<string>&);
-       int getNames();
-       int readNames();
-       
-};
-
-#endif
-
diff --git a/suffixdb.cpp b/suffixdb.cpp
deleted file mode 100644 (file)
index 4fc342d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *  suffixdb.cpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is a child class of the Database abstract datatype.  The class is basically a database of suffix trees and an
- *     encapsulation of the method for finding the most similar tree to an inputted sequence.  the suffixForest objecct
- *     is a vector of SuffixTrees, with each template sequence being represented by a different SuffixTree.  The class also
- *     provides a method to take an unaligned sequence and find the closest sequence in the suffixForest.  The search
- *     method is inspired by the article and Perl source code provided at http://www.ddj.com/web-development/184416093.  I 
- *     would estimate that the time complexity is O(LN) for each search, which is slower than the kmer searching, but 
- *     faster than blast
- *
- */
-
-#include "database.hpp"
-#include "sequence.hpp"
-#include "suffixtree.hpp"
-#include "suffixdb.hpp"
-
-/**************************************************************************************************/
-
-SuffixDB::SuffixDB(int numSeqs) : Database() {
-       suffixForest.resize(numSeqs);
-       count = 0;
-}
-/**************************************************************************************************/
-
-SuffixDB::SuffixDB() : Database() {
-       count = 0;
-}
-
-/**************************************************************************************************/
-//assumes sequences have been added using addSequence
-vector<int> SuffixDB::findClosestSequences(Sequence* candidateSeq, int num){
-       try {
-               vector<int> topMatches;
-               string processedSeq = candidateSeq->convert2ints();             //      the candidate sequence needs to be a string of ints
-               
-               vector<seqMatch> seqMatches;
-               for(int i=0;i<suffixForest.size();i++){                                 //      scan through the forest and see what the minimum
-                       int count = suffixForest[i].countSuffixes(processedSeq);        //      return score is and keep track of the
-                       seqMatch temp(i, count);
-                       seqMatches.push_back(temp);
-               }
-               
-               //sorts putting smallest matches first
-               sort(seqMatches.begin(), seqMatches.end(), compareSeqMatchesReverse);
-               
-               searchScore = seqMatches[0].match;
-               searchScore = 100 * (1. - searchScore / (float)processedSeq.length());
-               
-               //save top matches
-               for (int i = 0; i < num; i++) {
-                       topMatches.push_back(seqMatches[i].seq);
-               }
-
-               //      return the Sequence object that has the minimum score
-               return topMatches;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SuffixDB", "findClosestSequences");
-               exit(1);
-       }       
-}
-/**************************************************************************************************/
-//adding the sequences generates the db
-void SuffixDB::addSequence(Sequence seq) {
-       try {
-               suffixForest[count].loadSequence(seq);          
-               count++;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SuffixDB", "addSequence");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-SuffixDB::~SuffixDB(){                                                                                                         
-       for (int i = (suffixForest.size()-1); i >= 0; i--) {  suffixForest.pop_back();  }
-}
-/**************************************************************************************************/
diff --git a/suffixdb.hpp b/suffixdb.hpp
deleted file mode 100644 (file)
index 3796801..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef SUFFIXDB_HPP
-#define SUFFIXDB_HPP
-
-/*
- *  suffixdb.hpp
- *  
- *
- *  Created by Pat Schloss on 12/16/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is a child class of the Database abstract datatype.  The class is basically a database of suffix trees and an
- *     encapsulation of the method for finding the most similar tree to an inputted sequence.  the suffixForest object
- *     is a vector of SuffixTrees, with each template sequence being represented by a different SuffixTree.  The class also
- *     provides a method to take an unaligned sequence and find the closest sequence in the suffixForest.  The search
- *     method is inspired by the article and Perl source code provided at http://www.ddj.com/web-development/184416093.  I 
- *     would estimate that the time complexity is O(LN) for each search, which is slower than the kmer searching, but 
- *     faster than blast
- *
- */
-
-#include "mothur.h"
-#include "database.hpp"
-#include "suffixtree.hpp"
-
-class SuffixDB : public Database {
-       
-public:
-       SuffixDB(int);
-       SuffixDB();
-       ~SuffixDB();
-       
-       void generateDB() {}; //adding sequences generates the db
-       void addSequence(Sequence);
-       vector<int> findClosestSequences(Sequence*, int);
-
-private:
-       vector<SuffixTree> suffixForest;
-       int count;
-};
-
-#endif
diff --git a/suffixnodes.cpp b/suffixnodes.cpp
deleted file mode 100644 (file)
index 130b2be..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- *  SuffixNodes.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     There are two types of nodes in a suffix tree as I have implemented it.  First, there are the internal nodes that
- *     have children, these are the SuffixBranch objects.  There are also the terminal nodes, which are the suffixBranches.
- *  I divided them into two groups to save on memory.  A SuffixTree object will be a vector of SuffixNodes; therefore,
- *     the values of parentNode, children nodes, and suffix nodes are stored as ints that correspond to indices in the 
- *     vector
- *
- */
-
-#include "suffixnodes.hpp"
-
-
-//********************************************************************************************************************
-
-inline char deCodeSequence(char code){
-       
-       if(code == '0')                 {       return 'a';     }       //      this method allows us to go from the int string to a char string;
-       else if(code == '1')    {       return 'c';     }       //      it's only really useful if we want to print out the tree
-       else if(code == '2')    {       return 'g';     }
-       else if(code == '3')    {       return 't';     }
-       else if(code == '4')    {       return 'n';     }
-       else                                    {       return '$';     }
-       
-}
-
-//********************************************************************************************************************
-
-SuffixNode::SuffixNode(int parent, int start, int end) : 
-               parentNode(parent),                     //      we store the parent node as an int
-               startCharPosition(start),       //      the suffix tree class will hold the sequence that the startCharPosition and 
-               endCharPosition(end)            //      endCharPosition indices correspond to
-               {       /*      do nothing      */              m = MothurOut::getInstance();   }
-
-
-void SuffixNode::setChildren(char, int)                        {       /*      do nothing      */                      }       //      there's no children in a leaf
-int SuffixNode::getNumChildren()                               {       return 0;                                       }       //      ditto
-void SuffixNode::eraseChild(char)                              {       /*      do nothing      */                      }       //      ditto
-int SuffixNode::getChild(char)                                 {       return -1;                                      }       //      ditto
-void SuffixNode::setSuffixNode(int)                            {       /*      do nothing      */                      }       //      there's no suffix node in a leaf
-int SuffixNode::getSuffixNode()                                        {       return -1;                                      }       //      ditto
-int SuffixNode::getParentNode()                                        {       return parentNode;                      }
-void SuffixNode::setParentNode(int number)             {       parentNode = number;            }
-int SuffixNode::getStartCharPos()                              {       return startCharPosition;       }
-void SuffixNode::setStartCharPos(int start)            {       startCharPosition = start;      }
-int SuffixNode::getEndCharPos()                                        {       return endCharPosition;         }       
-
-//********************************************************************************************************************
-
-SuffixLeaf::SuffixLeaf(int parent, int start, int end) : SuffixNode(parent, start, end) {      /*      do nothing      */      }
-
-
-void SuffixLeaf::print(string sequence, int nodeNumber){
-       
-       m->mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" +
-       toString(-1) + "\t" + toString(startCharPosition) + "\t" + toString(endCharPosition) + "\t");
-       
-       m->mothurOut("/");
-       for(int i=startCharPosition;i<=endCharPosition;i++){
-               m->mothurOut(toString(deCodeSequence(sequence[i])));
-       }
-       m->mothurOut("/");  m->mothurOutEndLine();
-}
-
-//********************************************************************************************************************
-
-SuffixBranch::SuffixBranch(int parent, int start, int end) : SuffixNode(parent, start, end), suffixNode(-1){
-               childNodes.assign(6, -1);
-}
-       
-void SuffixBranch::print(string sequence, int nodeNumber){                                             //      this method is different that than
-       m->mothurOut(toString(this) + "\t" + toString(parentNode) + "\t" + toString(nodeNumber) + "\t" +                //      of a leaf because it prints out a
-       toString(suffixNode) + "\t" + toString(startCharPosition) + "\t" + toString(endCharPosition) + "\t");  //       value for the suffix node
-       
-       m->mothurOut("/");
-       for(int i=startCharPosition;i<=endCharPosition;i++){
-               m->mothurOut(toString(deCodeSequence(sequence[i])));
-       }
-       m->mothurOut("/");  m->mothurOutEndLine();
-}
-
-//     we can access the children by subtracting '0' from the the char value from the string, the difference is an int
-//     value and the index we need to access.
-void SuffixBranch::eraseChild(char base)       {       childNodes[base - '0'] = -1;    }       //to erase set the child index to -1
-void SuffixBranch::setChildren(char base, int nodeIndex){      childNodes[base - '0'] = nodeIndex;     }
-void SuffixBranch::setSuffixNode(int nodeIndex){       suffixNode = nodeIndex;         }
-int SuffixBranch::getSuffixNode()                      {       return suffixNode;                              }
-int SuffixBranch::getChild(char base)          {       return childNodes[base - '0'];  }
-       
-//********************************************************************************************************************
diff --git a/suffixnodes.hpp b/suffixnodes.hpp
deleted file mode 100644 (file)
index 6a22c4d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef SUFFIXNODES_H
-#define SUFFIXNODES_H
-
-/*
- *  SuffixNodes.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     There are two types of nodes in a suffix tree as I have implemented it.  First, there are the internal nodes that
- *     have children, these are the SuffixBranch objects.  There are also the terminal nodes, which are the suffixBranches.
- *  I divided them into two groups to save on memory.  A SuffixTree object will be a vector of SuffixNodes; therefore,
- *     the values of parentNode, children nodes, and suffix nodes are stored as ints that correspond to indices in the 
- *     vector
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-//********************************************************************************************************************
-
-class SuffixNode {
-       
-public:
-       SuffixNode(int, int, int);
-       virtual ~SuffixNode() {}
-       virtual void print(string, int) = 0;
-       virtual void setChildren(char, int);
-       virtual int getNumChildren();
-       virtual void eraseChild(char);
-       virtual void setSuffixNode(int);
-       virtual int getSuffixNode();
-       virtual int getChild(char);
-       int getParentNode();
-       void setParentNode(int);
-       int getStartCharPos();
-       void setStartCharPos(int start);
-       int getEndCharPos();
-       
-protected:
-       int parentNode;
-       int startCharPosition;
-       int endCharPosition;
-       MothurOut* m;
-};
-
-//********************************************************************************************************************
-
-class SuffixLeaf : public SuffixNode { //      most of the methods are already set in the parent class
-       
-public:
-       SuffixLeaf(int, int, int);              //      we just need to define a constructor and
-       ~SuffixLeaf() {}
-       void print(string, int);                //      print method
-};
-
-//********************************************************************************************************************
-
-class SuffixBranch : public SuffixNode {
-       
-public:
-       SuffixBranch(int, int, int);
-       ~SuffixBranch() {}
-       void print(string, int);                //      need a special method for printing the node because there are children
-       void eraseChild(char);                  //      need a special method for erasing the children
-       void setChildren(char, int);    //      need a special method for setting children
-       void setSuffixNode(int);                //      need a special method for setting the suffix node
-       int getSuffixNode();                    //      need a special method for returning the suffix node
-       int getChild(char);                             //      need a special method for return children
-       
-private:
-       vector<int> childNodes;                 //      a suffix branch is unique because it has children and a suffixNode.  The 
-       int suffixNode;                                 //      are stored in a vector for super-fast lookup.  If the alphabet were bigger, this
-};                                                                     //      might not be practical.  Since we only have 5 possible letters, it makes sense
-
-//********************************************************************************************************************
-
-#endif
diff --git a/suffixtree.cpp b/suffixtree.cpp
deleted file mode 100644 (file)
index 9cd8351..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- *  suffixtree.cpp
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is my half-assed attempt to implement a suffix tree.  This is a cobbled together algorithm using materials that
- *     I found at http://marknelson.us/1996/08/01/suffix-trees/ and:
- *
- *             Ukkonen E. (1995). On-line construction of suffix trees. Algorithmica 14 (3): 249--260
- *             Gusfield, Dan (1999). Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology. 
- *                     USA: Cambridge University Press
- *
- *     The Ukkonen paper is the seminal paper describing the on-line method of constructing a suffix tree.
- *
- *     I have chosen to store the nodes of the tree as a vector of pointers to SuffixNode objects.  The root is stored at
- *     nodeVector[0].  Each tree also stores the sequence name and the string that corresponds to the actual sequence. 
- *     Finally, this class provides a way of counting the number of suffixes that are needed in one tree to generate a new
- *     sequence (countSuffixes).  This method is used to determine similarity between sequences and was inspired by the
- *     article and Perl source code provided at http://www.ddj.com/web-development/184416093.
- *
- */
-
-#include "sequence.hpp"
-#include "suffixnodes.hpp"
-#include "suffixtree.hpp"
-
-
-//********************************************************************************************************************
-
-inline bool compareParents(SuffixNode* left, SuffixNode* right){//     this is necessary to print the tree and to sort the
-       return (left->getParentNode() < right->getParentNode());        //      nodes in order of their parent
-}
-
-//********************************************************************************************************************
-
-SuffixTree::SuffixTree(){ m = MothurOut::getInstance(); }
-
-//********************************************************************************************************************
-
-SuffixTree::~SuffixTree(){
-       for(int i=0;i<nodeVector.size();i++){   delete nodeVector[i];   }       
-       nodeVector.clear();
-}
-
-//********************************************************************************************************************
-
-void SuffixTree::loadSequence(Sequence seq){
-       nodeCounter = 0;                                                        //      initially there are 0 nodes in the tree
-       activeStartPosition = 0;
-       activeEndPosition = -1;                                         
-       seqName = seq.getName();
-       sequence = seq.convert2ints();
-       sequence += '5';                                                        //      this essentially concatenates a '$' to the end of the sequence to
-       int seqLength = sequence.length();                      //      make it a cononical suffix tree
-       
-       nodeVector.push_back(new SuffixBranch(-1, 0, -1));      //      enter the root of the suffix tree
-       
-       activeNode = root = 0;
-       string hold;
-       for(int i=0;i<seqLength;i++){
-               addPrefix(i);                                                   //      step through the sequence adding each prefix
-       }
-}
-
-//********************************************************************************************************************
-
-string SuffixTree::getSeqName()        {
-       return seqName;         
-}
-
-//********************************************************************************************************************
-
-void SuffixTree::print(){
-       vector<SuffixNode*> hold = nodeVector;
-       sort(hold.begin(), hold.end(), compareParents);
-       m->mothurOut("Address\t\tParent\tNode\tSuffix\tStartC\tEndC\tSuffix"); m->mothurOutEndLine();
-       for(int i=1;i<=nodeCounter;i++){
-               hold[i]->print(sequence, i);
-       }
-}
-
-//********************************************************************************************************************
-
-int SuffixTree::countSuffixes(string compareSequence, int& minValue){  //      here we count the number of suffix parts 
-                                                                                                                       //      we need to rewrite a user supplied sequence.  if the 
-       int numSuffixes = 0;                                                                    //      count exceeds the supplied minValue, bail out.  The
-       int seqLength = compareSequence.length();                               //      time complexity should be O(L)
-       int position = 0;
-       
-       int presentNode = 0;
-       
-       while(position < seqLength){            //      while the position in the query sequence isn't at the end...
-               
-               if(numSuffixes > minValue)      {       return 1000000;         }       //      bail if the count gets too high
-               
-               int newNode = nodeVector[presentNode]->getChild(compareSequence[position]);     //      see if the current node has a
-                                                                                                                               //      child that matches the next character in the query
-               if(newNode == -1){                                                                              
-                       if(presentNode == 0){   position++;             }                       //      if not, go back to the root and increase the count
-                       numSuffixes++;                                                                          //      by one.
-                       presentNode = 0;
-               }
-               else{                                                                                                   //      if there is, move to that node and see how far down
-                       presentNode = newNode;                                                          //      it we can get
-                       
-                       for(int i=nodeVector[newNode]->getStartCharPos(); i<=nodeVector[newNode]->getEndCharPos(); i++){
-                               if(compareSequence[position] == sequence[i]){
-                                       position++;                                                                     //      as long as the query and branch agree, keep going
-                               }
-                               else{
-                                       numSuffixes++;                                                          //      if there is a mismatch, increase the number of 
-                                       presentNode = 0;                                                        //      suffixes and go back to the root
-                                       break;
-                               }
-                       }
-               }
-               //      if we get all the way through the node we'll go to the top of the while loop and find the child node
-               //      that corresponds to what we are interested in           
-       }
-       numSuffixes--;                                                                                          //      the method puts an extra count on numSuffixes
-       
-       if(numSuffixes < minValue)      {       minValue = numSuffixes; }       //      if the count is less than the previous minValue,
-       return numSuffixes;                                                                                     //      change the value and return the number of suffixes
-       
-}
-//********************************************************************************************************************
-
-int SuffixTree::countSuffixes(string compareSequence){ //      here we count the number of suffix parts 
-                                                                                                                       //      we need to rewrite a user supplied sequence.  if the 
-       int numSuffixes = 0;                                                                    //      count exceeds the supplied minValue, bail out.  The
-       int seqLength = compareSequence.length();                               //      time complexity should be O(L)
-       int position = 0;
-       
-       int presentNode = 0;
-       
-       while(position < seqLength){            //      while the position in the query sequence isn't at the end...
-               
-               int newNode = nodeVector[presentNode]->getChild(compareSequence[position]);     //      see if the current node has a
-                                                                                                                               //      child that matches the next character in the query
-               if(newNode == -1){                                                                              
-                       if(presentNode == 0){   position++;             }                       //      if not, go back to the root and increase the count
-                       numSuffixes++;                                                                          //      by one.
-                       presentNode = 0;
-               }
-               else{                                                                                                   //      if there is, move to that node and see how far down
-                       presentNode = newNode;                                                          //      it we can get
-                       
-                       for(int i=nodeVector[newNode]->getStartCharPos(); i<=nodeVector[newNode]->getEndCharPos(); i++){
-                               if(compareSequence[position] == sequence[i]){
-                                       position++;                                                                     //      as long as the query and branch agree, keep going
-                               }
-                               else{
-                                       numSuffixes++;                                                          //      if there is a mismatch, increase the number of 
-                                       presentNode = 0;                                                        //      suffixes and go back to the root
-                                       break;
-                               }
-                       }
-               }
-               //      if we get all the way through the node we'll go to the top of the while loop and find the child node
-               //      that corresponds to what we are interested in           
-       }
-       numSuffixes--;                                                                                          //      the method puts an extra count on numSuffixes
-       
-       return numSuffixes;                                                                                     //      change the value and return the number of suffixes
-}
-//********************************************************************************************************************
-
-void SuffixTree::canonize(){   //      if you have to ask how this works, you don't really want to know and this really
-                                                               //      isn't the place to ask.
-       if ( isExplicit() == 0 ) {      //      if the node has no children...
-               
-               int tempNodeIndex = nodeVector[activeNode]->getChild(sequence[activeStartPosition]);
-               SuffixNode* tempNode = nodeVector[tempNodeIndex];
-               
-               int span = tempNode->getEndCharPos() - tempNode->getStartCharPos();
-               
-               while ( span <= ( activeEndPosition - activeStartPosition ) ) {
-                       
-            activeStartPosition = activeStartPosition + span + 1;
-                       
-                       activeNode = tempNodeIndex;
-                       
-            if ( activeStartPosition <= activeEndPosition ) {
-                               tempNodeIndex = nodeVector[tempNodeIndex]->getChild(sequence[activeStartPosition]);
-                               tempNode = nodeVector[tempNodeIndex];
-                               span = tempNode->getEndCharPos() - tempNode->getStartCharPos();
-            }
-                       
-        }
-    }
-}
-
-//********************************************************************************************************************
-
-int SuffixTree::split(int nodeIndex, int position){    //      leaves stay leaves, etc, to split a leaf we make a new interior 
-                                                                                                       //      node and reconnect everything
-       SuffixNode* node = nodeVector[nodeIndex];                                       //      get the node that needs to be split
-       SuffixNode* parentNode = nodeVector[node->getParentNode()];     //      get it's parent node
-       
-       parentNode->eraseChild(sequence[node->getStartCharPos()]);      //      erase the present node from the registry of its parent
-       
-       nodeCounter++;
-       SuffixNode* newNode = new SuffixBranch(node->getParentNode(), node->getStartCharPos(), node->getStartCharPos() + activeEndPosition - activeStartPosition);      //      create a new node that will link the parent with the old child
-       parentNode->setChildren(sequence[newNode->getStartCharPos()], nodeCounter);//   give the parent the new child
-       nodeVector.push_back(newNode);
-       
-       node->setParentNode(nodeCounter);       //      give the original node the new node as its parent
-       newNode->setChildren(sequence[node->getStartCharPos() + activeEndPosition - activeStartPosition + 1], nodeIndex);
-       //      put the original node in the registry of the new node's children
-       newNode->setSuffixNode(activeNode);//link the new node with the old active node
-       
-       //      recalculate the startCharPosition of the outermost node
-       node->setStartCharPos(node->getStartCharPos() + activeEndPosition - activeStartPosition + 1 );
-       
-       return node->getParentNode();
-}
-
-//********************************************************************************************************************
-
-void SuffixTree::makeSuffixLink(int& previous, int present){
-       
-//     here we link the nodes that are suffixes of one another to rapidly speed through the tree
-       if ( previous > 0 ) {   nodeVector[previous]->setSuffixNode(present);   }
-       else                            {       /*      do nothing                                                              */      }
-       
-    previous = present;
-}
-
-//********************************************************************************************************************
-
-void SuffixTree::addPrefix(int prefixPosition){
-       
-       int lastParentNode = -1;        //      we need to place a new prefix in the suffix tree
-       int parentNode = 0;
-       
-       while(1){
-               
-               parentNode = activeNode;
-               
-               if(isExplicit() == 1){  //      if the node is explicit (has kids), try to follow it down the branch if its there...
-                       if(nodeVector[activeNode]->getChild(sequence[prefixPosition]) != -1){   //      break out and get next prefix...
-                               break;                                                                                          
-                       }
-                       else{                           //      ...otherwise continue, we'll need to make a new node later on...
-                       }
-               }
-               else{                                   //      if it's not explicit (no kids), read through and see if all of the chars agree...
-                       int tempNode = nodeVector[activeNode]->getChild(sequence[activeStartPosition]);
-                       int span = activeEndPosition - activeStartPosition;
-                       
-                       if(sequence[nodeVector[tempNode]->getStartCharPos() + span + 1] == sequence[prefixPosition] ){
-                               break;                  //      if the existing suffix agrees with the new one, grab a new prefix...
-                       }
-                       else{
-                               parentNode = split(tempNode, prefixPosition);   //      ... otherwise we need to split the node
-                       }
-                       
-               }
-               
-               nodeCounter++;  //      we need to generate a new node here if the kid didn't exist, or we split a node
-               SuffixNode* newSuffixLeaf = new SuffixLeaf(parentNode, prefixPosition, sequence.length()-1);
-               nodeVector[parentNode]->setChildren(sequence[prefixPosition], nodeCounter);
-               nodeVector.push_back(newSuffixLeaf);
-               
-               makeSuffixLink( lastParentNode, parentNode );           //      make a suffix link for the parent node
-               
-               if(nodeVector[activeNode]->getParentNode() == -1){      //      move along the start position for the tree
-            activeStartPosition++;
-        } 
-               else {
-            activeNode = nodeVector[activeNode]->getSuffixNode();
-               }
-               canonize();                                                                                     //      frankly, i'm not entirely clear on what canonize does.
-       }
-       
-       makeSuffixLink( lastParentNode, parentNode );
-       activeEndPosition++;                                                                    //      move along the end position for the tree
-       
-       canonize();                                                                                             //      frankly, i'm not entirely clear on what canonize does.
-       
-}
-
-//********************************************************************************************************************
-
diff --git a/suffixtree.hpp b/suffixtree.hpp
deleted file mode 100644 (file)
index d2b69e4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef SUFFIXTREE_H
-#define SUFFIXTREE_H
-
-/*
- *  suffixtree.h
- *  
- *
- *  Created by Pat Schloss on 12/15/08.
- *  Copyright 2008 Patrick D. Schloss. All rights reserved.
- *
- *     This is my half-assed attempt to implement a suffix tree.  This is a cobbled together algorithm using materials that
- *     I found at http://marknelson.us/1996/08/01/suffix-trees/ and:
- *
- *             Ukkonen E. (1995). On-line construction of suffix trees. Algorithmica 14 (3): 249--260
- *             Gusfield, Dan (1999). Algorithms on Strings, Trees and Sequences: Computer Science and Computational Biology. 
- *                     USA: Cambridge University Press
- *
- *     The Ukkonen paper is the seminal paper describing the on-line method of constructing a suffix tree.
- *
- *     I have chosen to store the nodes of the tree as a vector of pointers to SuffixNode objects.  The root is stored at
- *     nodeVector[0].  Each tree also stores the sequence name and the string that corresponds to the actual sequence. 
- *     Finally, this class provides a way of counting the number of suffixes that are needed in one tree to generate a new
- *     sequence (countSuffixes).  This method is used to determine similarity between sequences and was inspired by the
- *     article and Perl source code provided at http://www.ddj.com/web-development/184416093.
- *
- */
-
-#include "mothur.h"
-
-class SuffixNode;
-
-//********************************************************************************************************************
-
-class SuffixTree {
-       
-public:
-       SuffixTree();
-       ~SuffixTree();
-
-       void loadSequence(Sequence);
-       string getSeqName();
-       void print();   
-       int countSuffixes(string, int&);
-       int countSuffixes(string);      
-
-private:       
-       void addPrefix(int);
-       void canonize();
-       int split(int, int);
-       void makeSuffixLink(int&, int);
-       bool isExplicit(){      return activeStartPosition > activeEndPosition; }
-       
-       int activeStartPosition;
-       int activeEndPosition;
-       
-       vector<SuffixNode*> nodeVector;
-       int root;
-       int activeNode;
-       int nodeCounter;
-       string seqName;
-       string sequence;
-       MothurOut* m;
-       
-};
-
-//********************************************************************************************************************
-
-#endif
diff --git a/summarycommand.cpp b/summarycommand.cpp
deleted file mode 100644 (file)
index 83ea8c9..0000000
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- *  summarycommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "summarycommand.h"
-#include "ace.h"
-#include "sobs.h"
-#include "nseqs.h"
-#include "chao1.h"
-#include "bootstrap.h"
-#include "simpson.h"
-#include "simpsoneven.h"
-#include "invsimpson.h"
-#include "npshannon.h"
-#include "shannon.h"
-#include "heip.h"
-#include "smithwilson.h"
-#include "shannoneven.h"
-#include "jackknife.h"
-#include "geom.h"
-#include "logsd.h"
-#include "qstat.h"
-#include "bergerparker.h"
-#include "bstick.h"
-#include "goodscoverage.h"
-#include "coverage.h"
-#include "efron.h"
-#include "boneh.h"
-#include "solow.h"
-#include "shen.h"
-
-//**********************************************************************************************************************
-vector<string> SummaryCommand::setParameters(){        
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter prabund("rabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(prabund);
-               CommandParameter psabund("sabund", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(psabund);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "Multiple", "sobs-chao-nseqs-coverage-ace-jack-shannon-shannoneven-npshannon-heip-smithwilson-simpson-simpsoneven-invsimpson-bootstrap-geometric-qstat-logseries-bergerparker-bstick-goodscoverage-efron-boneh-solow-shen", "sobs-chao-ace-jack-shannon-npshannon-simpson", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter psize("size", "Number", "", "0", "", "", "",false,false); parameters.push_back(psize);
-               CommandParameter pgroupmode("groupmode", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pgroupmode);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SummaryCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The summary.single command parameters are list, sabund, rabund, shared, label, calc, abund and groupmode.  list, sabund, rabund or shared is required unless you have a valid current file.\n";
-               helpString += "The summary.single command should be in the following format: \n";
-               helpString += "summary.single(label=yourLabel, calc=yourEstimators).\n";
-               helpString += "Example summary.single(label=unique-.01-.03, calc=sobs-chao-ace-jack-bootstrap-shannon-npshannon-simpson).\n";
-               helpString += validCalculator.printCalc("summary");
-               helpString += "The default value calc is sobs-chao-ace-jack-shannon-npshannon-simpson\n";
-               helpString += "If you are running summary.single with a shared file and would like your summary results collated in one file, set groupmode=t. (Default=true).\n";
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabels).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-SummaryCommand::SummaryCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "SummaryCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SummaryCommand::SummaryCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") {  help();  abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("rabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["rabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("sabund");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["sabund"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sabundfile = validParameter.validFile(parameters, "sabund", true);
-                       if (sabundfile == "not open") { sabundfile = ""; abort = true; }        
-                       else if (sabundfile == "not found") { sabundfile = ""; }
-                       else {  format = "sabund"; inputfile = sabundfile; m->setSabundFile(sabundfile); }
-                       
-                       rabundfile = validParameter.validFile(parameters, "rabund", true);
-                       if (rabundfile == "not open") { rabundfile = ""; abort = true; }        
-                       else if (rabundfile == "not found") { rabundfile = ""; }
-                       else {  format = "rabund"; inputfile = rabundfile; m->setRabundFile(rabundfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       if ((sharedfile == "") && (listfile == "") && (rabundfile == "") && (sabundfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               rabundfile = m->getRabundFile(); 
-                                               if (rabundfile != "") { inputfile = rabundfile; format = "rabund"; m->mothurOut("Using " + rabundfile + " as input file for the rabund parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       sabundfile = m->getSabundFile(); 
-                                                       if (sabundfile != "") { inputfile = sabundfile; format = "sabund"; m->mothurOut("Using " + sabundfile + " as input file for the sabund parameter."); m->mothurOutEndLine(); }
-                                                       else { 
-                                                               m->mothurOut("No valid current files. You must provide a list, sabund, rabund or shared file before you can use the collect.single command."); m->mothurOutEndLine(); 
-                                                               abort = true;
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sobs-chao-ace-jack-shannon-npshannon-simpson";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sobs-chao-ace-jack-shannon-npshannon-simpson";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, abund); 
-                       
-                       temp = validParameter.validFile(parameters, "size", false);                     if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, size); 
-                       
-                       temp = validParameter.validFile(parameters, "groupmode", false);                if (temp == "not found") { temp = "T"; }
-                       groupMode = m->isTrue(temp);
-                       
-       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "SummaryCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SummaryCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if ((format != "sharedfile")) { inputFileNames.push_back(inputfile);  }
-               else {  inputFileNames = parseSharedFile(sharedfile);  format = "rabund"; }
-               
-               if (m->control_pressed) { return 0; }
-               
-               int numLines = 0;
-               int numCols = 0;
-               
-               for (int p = 0; p < inputFileNames.size(); p++) {
-                       
-                       numLines = 0;
-                       numCols = 0;
-                       
-                       string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])) + "summary";
-                       outputNames.push_back(fileNameRoot); outputTypes["summary"].push_back(fileNameRoot);
-                       
-                       if (inputFileNames.size() > 1) {
-                               m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
-                       }
-                       
-                       sumCalculators.clear();
-                       
-                       ValidCalculators validCalculator;
-                       
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("summary", Estimators[i]) == true) { 
-                                       if(Estimators[i] == "sobs"){
-                                               sumCalculators.push_back(new Sobs());
-                                       }else if(Estimators[i] == "chao"){
-                                               sumCalculators.push_back(new Chao1());
-                                       }else if(Estimators[i] == "coverage"){
-                                               sumCalculators.push_back(new Coverage());
-                                       }else if(Estimators[i] == "geometric"){
-                                               sumCalculators.push_back(new Geom());
-                                       }else if(Estimators[i] == "logseries"){
-                                               sumCalculators.push_back(new LogSD());
-                                       }else if(Estimators[i] == "qstat"){
-                                               sumCalculators.push_back(new QStat());
-                                       }else if(Estimators[i] == "bergerparker"){
-                                               sumCalculators.push_back(new BergerParker());
-                                       }else if(Estimators[i] == "bstick"){
-                                               sumCalculators.push_back(new BStick());
-                                       }else if(Estimators[i] == "ace"){
-                                               if(abund < 5)
-                                                       abund = 10;
-                                               sumCalculators.push_back(new Ace(abund));
-                                       }else if(Estimators[i] == "jack"){
-                                               sumCalculators.push_back(new Jackknife());
-                                       }else if(Estimators[i] == "shannon"){
-                                               sumCalculators.push_back(new Shannon());
-                                       }else if(Estimators[i] == "shannoneven"){
-                                               sumCalculators.push_back(new ShannonEven());
-                                       }else if(Estimators[i] == "npshannon"){
-                                               sumCalculators.push_back(new NPShannon());
-                                       }else if(Estimators[i] == "heip"){
-                                               sumCalculators.push_back(new Heip());
-                                       }else if(Estimators[i] == "smithwilson"){
-                                               sumCalculators.push_back(new SmithWilson());
-                                       }else if(Estimators[i] == "simpson"){
-                                               sumCalculators.push_back(new Simpson());
-                                       }else if(Estimators[i] == "simpsoneven"){
-                                               sumCalculators.push_back(new SimpsonEven());
-                                       }else if(Estimators[i] == "invsimpson"){
-                                               sumCalculators.push_back(new InvSimpson());
-                                       }else if(Estimators[i] == "bootstrap"){
-                                               sumCalculators.push_back(new Bootstrap());
-                                       }else if (Estimators[i] == "nseqs") { 
-                                               sumCalculators.push_back(new NSeqs());
-                                       }else if (Estimators[i] == "goodscoverage") { 
-                                               sumCalculators.push_back(new GoodsCoverage());
-                                       }else if (Estimators[i] == "efron") { 
-                                               sumCalculators.push_back(new Efron(size));
-                                       }else if (Estimators[i] == "boneh") { 
-                                               sumCalculators.push_back(new Boneh(size));
-                                       }else if (Estimators[i] == "solow") { 
-                                               sumCalculators.push_back(new Solow(size));
-                                       }else if (Estimators[i] == "shen") { 
-                                               sumCalculators.push_back(new Shen(size, abund));
-                                       }
-                               }
-                       }
-                       
-                       //if the users entered no valid calculators don't execute command
-                       if (sumCalculators.size() == 0) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } return 0; }
-                       
-                       ofstream outputFileHandle;
-                       m->openOutputFile(fileNameRoot, outputFileHandle);
-                       outputFileHandle << "label";
-               
-                       input = new InputData(inputFileNames[p], format);
-                       sabund = input->getSAbundVector();
-                       string lastLabel = sabund->getLabel();
-               
-                       for(int i=0;i<sumCalculators.size();i++){
-                               if(sumCalculators[i]->getCols() == 1){
-                                       outputFileHandle << '\t' << sumCalculators[i]->getName();
-                                       numCols++;
-                               }
-                               else{
-                                       outputFileHandle << '\t' << sumCalculators[i]->getName() << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";
-                                       numCols += 3;
-                               }
-                       }
-                       outputFileHandle << endl;
-                       
-                       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-                       set<string> processedLabels;
-                       set<string> userLabels = labels;
-                       
-                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
-                       
-                       while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                               
-                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
-                               
-                               if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
-                                       
-                                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                                       
-                                       outputFileHandle << sabund->getLabel();
-                                       for(int i=0;i<sumCalculators.size();i++){
-                                               vector<double> data = sumCalculators[i]->getValues(sabund);
-                                               
-                                               if (m->control_pressed) { outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input;  return 0;  }
-
-                                               outputFileHandle << '\t';
-                                               sumCalculators[i]->print(outputFileHandle);
-                                       }
-                                       outputFileHandle << endl;
-                                       numLines++;
-                               }
-                               
-                               if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = sabund->getLabel();
-                                       
-                                       delete sabund;
-                                       sabund = input->getSAbundVector(lastLabel);
-                                       
-                                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                                       
-                                       outputFileHandle << sabund->getLabel();
-                                       for(int i=0;i<sumCalculators.size();i++){
-                                               vector<double> data = sumCalculators[i]->getValues(sabund);
-                                               
-                                               if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {      m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } delete sabund;  delete input;  return 0;  }
-                                               
-                                               outputFileHandle << '\t';
-                                               sumCalculators[i]->print(outputFileHandle);
-                                       }
-                                       outputFileHandle << endl;
-                                       numLines++;
-                                       
-                                       //restore real lastlabel to save below
-                                       sabund->setLabel(saveLabel);
-                               }               
-                               
-                               lastLabel = sabund->getLabel();                 
-                               
-                               delete sabund;
-                               sabund = input->getSAbundVector();
-                       }
-                       
-                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
-
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-                       
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (sabund != NULL) {   delete sabund;  }
-                               sabund = input->getSAbundVector(lastLabel);
-                               
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               outputFileHandle << sabund->getLabel();
-                               for(int i=0;i<sumCalculators.size();i++){
-                                       vector<double> data = sumCalculators[i]->getValues(sabund);
-                                       
-                                       if (m->control_pressed) {  outputFileHandle.close(); for (int i = 0; i < outputNames.size(); i++) {     m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }  delete sabund;  delete input; return 0;  }
-
-                                       outputFileHandle << '\t';
-                                       sumCalculators[i]->print(outputFileHandle);
-                               }
-                               outputFileHandle << endl;
-                               numLines++;
-                               delete sabund;
-                       }
-                       
-                       outputFileHandle.close();
-                       
-                       if (m->control_pressed) {  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }   delete input;  return 0;  }
-
-                       
-                       delete input;  
-                       for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-               }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }  return 0;  }
-               
-               //create summary file containing all the groups data for each label - this function just combines the info from the files already created.
-               if ((sharedfile != "") && (groupMode)) {   outputNames.push_back(createGroupSummaryFile(numLines, numCols, outputNames));  }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }  return 0;  }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> SummaryCommand::parseSharedFile(string filename) {
-       try {
-               vector<string> filenames;
-               
-               map<string, ofstream*> filehandles;
-               map<string, ofstream*>::iterator it3;
-               
-               input = new InputData(filename, "sharedfile");
-               vector<SharedRAbundVector*> lookup = input->getSharedRAbundVectors();
-               
-               string sharedFileRoot = m->getRootName(filename);
-               
-               //clears file before we start to write to it below
-               for (int i=0; i<lookup.size(); i++) {
-                       m->mothurRemove((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-                       filenames.push_back((sharedFileRoot + lookup[i]->getGroup() + ".rabund"));
-               }
-               
-               ofstream* temp;
-               for (int i=0; i<lookup.size(); i++) {
-                       temp = new ofstream;
-                       filehandles[lookup[i]->getGroup()] = temp;
-                       groups.push_back(lookup[i]->getGroup());
-               }
-
-               while(lookup[0] != NULL) {
-               
-                       for (int i = 0; i < lookup.size(); i++) {
-                               RAbundVector rav = lookup[i]->getRAbundVector();
-                               m->openOutputFileAppend(sharedFileRoot + lookup[i]->getGroup() + ".rabund", *(filehandles[lookup[i]->getGroup()]));
-                               rav.print(*(filehandles[lookup[i]->getGroup()]));
-                               (*(filehandles[lookup[i]->getGroup()])).close();
-                       }
-               
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               //free memory
-               for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
-                       delete it3->second;
-               }
-               
-               delete input;
-
-               return filenames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "parseSharedFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SummaryCommand::createGroupSummaryFile(int numLines, int numCols, vector<string>& outputNames) {
-       try {
-               
-               ofstream out;
-               string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups.summary";
-               
-               //open combined file
-               m->openOutputFile(combineFileName, out);
-               
-               //open each groups summary file
-               string newLabel = "";
-               map<string, vector<string> > files;
-               for (int i=0; i<outputNames.size(); i++) {
-                       vector<string> thisFilesLines;
-                       
-                       ifstream temp;
-                       m->openInputFile(outputNames[i], temp);
-                       
-                       //read through first line - labels
-                       string tempLabel;
-                       if (i == 0) { //we want to save the labels to output below
-                               for (int j = 0; j < numCols+1; j++) {  
-                                       temp >> tempLabel; 
-                                       
-                                       if (j == 1) {  newLabel += "group\t" + tempLabel + '\t';
-                                       }else{  newLabel += tempLabel + '\t';   }
-                               }
-                       }else{  for (int j = 0; j < numCols+1; j++) {  temp >> tempLabel;  }  }
-                       
-                       m->gobble(temp);
-                       
-                       //for each label
-                       for (int k = 0; k < numLines; k++) {
-                               
-                               string thisLine = "";
-                               string tempLabel;
-                                       
-                               for (int j = 0; j < numCols+1; j++) {  
-                                       temp >> tempLabel; 
-                                               
-                                       //save for later
-                                       if (j == 1) { thisLine += groups[i] + "\t" + tempLabel + "\t";  }
-                                       else{  thisLine += tempLabel + "\t";    }
-                               }
-                                       
-                               thisLine += "\n";
-                               
-                               thisFilesLines.push_back(thisLine);
-                                       
-                               m->gobble(temp);
-                       }
-                               
-                       files[outputNames[i]] = thisFilesLines;
-                       
-                       temp.close();
-                       m->mothurRemove(outputNames[i]);
-               }
-               
-               //output label line to new file
-               out << newLabel << endl;
-               
-               //for each label
-               for (int k = 0; k < numLines; k++) {
-               
-                       //grab summary data for each group
-                       for (int i=0; i<outputNames.size(); i++) {
-                               out << files[outputNames[i]][k];
-                       }
-               }       
-               
-               outputNames.clear();
-               
-               out.close();
-               
-               //return combine file name
-               return combineFileName;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryCommand", "createGroupSummaryFile");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
diff --git a/summarycommand.h b/summarycommand.h
deleted file mode 100644 (file)
index 15b7f40..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef SUMMARYCOMMAND_H
-#define SUMMARYCOMMAND_H
-/*
- *  summarycommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "sabundvector.hpp"
-#include "inputdata.h"
-#include "calculator.h"
-#include "validcalculator.h"
-
-class SummaryCommand : public Command {
-
-public:
-       SummaryCommand(string);
-       SummaryCommand();
-       ~SummaryCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "summary.single";                      }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Summary.single"; }
-       string getDescription()         { return "generate summary file that has the calculator value for each line in the OTU data"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       vector<Calculator*> sumCalculators;     
-       InputData* input;
-       SAbundVector* sabund;
-       int abund, size;
-
-       bool abort, allLines, groupMode;
-       set<string> labels; //holds labels to be used
-       string label, calc, outputDir, sharedfile, listfile, rabundfile, sabundfile, format, inputfile;
-       vector<string>  Estimators;
-       vector<string> inputFileNames, outputNames;
-       vector<string> groups;
-       
-       vector<string> parseSharedFile(string);
-       string createGroupSummaryFile(int, int, vector<string>&);
-
-
-};
-#endif
diff --git a/summaryqualcommand.cpp b/summaryqualcommand.cpp
deleted file mode 100644 (file)
index 5c17510..0000000
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- *  summaryqualcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 11/28/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "summaryqualcommand.h"
-
-
-//**********************************************************************************************************************
-vector<string> SummaryQualCommand::setParameters(){    
-       try {
-               CommandParameter pqual("qfile", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pqual);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SummaryQualCommand::getHelpString(){    
-       try {
-               string helpString = "";
-               helpString += "The summary.qual command reads a quality file and an optional name file, and summarizes the quality information.\n";
-               helpString += "The summary.tax command parameters are qfile, name and processors. qfile is required, unless you have a valid current quality file.\n";
-               helpString += "The name parameter allows you to enter a name file associated with your quality file. \n";
-               helpString += "The summary.qual command should be in the following format: \n";
-               helpString += "summary.qual(qfile=yourQualityFile) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. qfile), '=' and parameters (i.e.yourQualityFile).\n";     
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-SummaryQualCommand::SummaryQualCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "SummaryQualCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-SummaryQualCommand::SummaryQualCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //check for required parameters
-                       qualfile = validParameter.validFile(parameters, "qfile", true);
-                       if (qualfile == "not open") { qualfile = ""; abort = true; }
-                       else if (qualfile == "not found") {                             
-                               qualfile = m->getQualFile(); 
-                               if (qualfile != "") { m->mothurOut("Using " + qualfile + " as input file for the qfile parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current quality file and the qfile parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setQualFile(qualfile); }     
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = "";  }   
-                       else { m->setNameFile(namefile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(qualfile); //if user entered a file with a path then preserve it        
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "processors", false);        if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);     
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(qualfile);
-                               parser.getNameFile(files);
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "SummaryQualCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-int SummaryQualCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               int start = time(NULL);
-               int numSeqs = 0;
-               
-               vector<int> position;
-               vector<int> averageQ;
-               vector< vector<int> > scores;
-                               
-               if (m->control_pressed) { return 0; }
-               
-               if (namefile != "") { nameMap = m->readNames(namefile); }
-               
-               vector<unsigned long long> positions; 
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               positions = m->divideFile(qualfile, processors);
-               for (int i = 0; i < (positions.size()-1); i++) {        lines.push_back(linePair(positions[i], positions[(i+1)]));      }
-#else  
-               if (processors == 1) {
-                       lines.push_back(linePair(0, 1000)); 
-               }else {
-                       positions = m->setFilePosFasta(qualfile, numSeqs); 
-            if (positions.size() < processors) { processors = positions.size(); }
-                       
-                       //figure out how many sequences you have to process
-                       int numSeqsPerProcessor = numSeqs / processors;
-                       for (int i = 0; i < processors; i++) {
-                               int startIndex =  i * numSeqsPerProcessor;
-                               if(i == (processors - 1)){      numSeqsPerProcessor = numSeqs - i * numSeqsPerProcessor;        }
-                               lines.push_back(linePair(positions[startIndex], numSeqsPerProcessor));
-                       }
-               }
-#endif
-               
-               
-               if(processors == 1){ numSeqs = driverCreateSummary(position, averageQ, scores, qualfile, lines[0]);  }
-               else{  numSeqs = createProcessesCreateSummary(position, averageQ, scores, qualfile);  }
-               
-               if (m->control_pressed) {  return 0; }
-               
-               //print summary file
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(qualfile)) + "qual.summary";
-               printQual(summaryFile, position, averageQ, scores);
-               
-               if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
-               
-               //output results to screen
-               cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
-               m->mothurOutEndLine();
-               m->mothurOut("Position\tNumSeqs\tAverageQ"); m->mothurOutEndLine();
-               for (int i = 0; i < position.size(); i+=100) {
-                       float average = averageQ[i] / (float) position[i];
-                       cout << i << '\t' << position[i] << '\t' << average;
-                       m->mothurOutJustToLog(toString(i) + "\t" + toString(position[i]) + "\t" + toString(average)); m->mothurOutEndLine();
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to create the summary file for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(summaryFile); m->mothurOutEndLine();       outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile);
-               m->mothurOutEndLine();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-int SummaryQualCommand::driverCreateSummary(vector<int>& position, vector<int>& averageQ, vector< vector<int> >& scores, string filename, linePair filePos) {  
-       try {
-               ifstream in;
-               m->openInputFile(filename, in);
-               
-               in.seekg(filePos.start);
-               
-               bool done = false;
-               int count = 0;
-               
-               while (!done) {
-                       
-                       if (m->control_pressed) { in.close(); return 1; }
-                       
-                       QualityScores current(in); m->gobble(in);
-                       
-                       if (current.getName() != "") {
-                               
-                               int num = 1;
-                               if (namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = nameMap.find(current.getName());
-                                       
-                                       if (it == nameMap.end()) { m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               vector<int> thisScores = current.getQualityScores();
-                               
-                               //resize to num of positions setting number of seqs with that size to 1
-                               if (position.size() < thisScores.size()) { position.resize(thisScores.size(), 0); }
-                               if (averageQ.size() < thisScores.size()) { averageQ.resize(thisScores.size(), 0); }
-                               if (scores.size() < thisScores.size()) { 
-                                       scores.resize(thisScores.size()); 
-                                       for (int i = 0; i < scores.size(); i++) { scores[i].resize(41, 0); }
-                               }
-                               
-                               //increase counts of number of seqs with this position
-                               //average is really the total, we will average in execute
-                               for (int i = 0; i < thisScores.size(); i++) { 
-                                       position[i] += num; 
-                                       averageQ[i] += (thisScores[i] * num); //weighting for namesfile
-                                       if (thisScores[i] > 40) { m->mothurOut("[ERROR]: " + current.getName() + " has a quality scores of " + toString(thisScores[i]) + ", expecting values to be less than 40."); m->mothurOutEndLine(); m->control_pressed = true; }
-                                       else { scores[i][thisScores[i]] += num; }  
-                               }
-                               
-                               count += num;
-                       }
-                       
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       unsigned long long pos = in.tellg();
-                       if ((pos == -1) || (pos >= filePos.end)) { break; }
-#else
-                       if (in.eof()) { break; }
-#endif
-               }
-               
-               in.close();
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "driverCreateSummary");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int SummaryQualCommand::createProcessesCreateSummary(vector<int>& position, vector<int>& averageQ, vector< vector<int> >& scores, string filename) {
-       try {
-               int process = 1;
-               int numSeqs = 0;
-               processIDS.clear();
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               numSeqs = driverCreateSummary(position, averageQ, scores, qualfile, lines[process]);
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = qualfile + toString(getpid()) + ".num.temp";
-                               m->openOutputFile(tempFile, out);
-                               
-                               out << numSeqs << endl;
-                               out << position.size() << endl;
-                               for (int k = 0; k < position.size(); k++)                       {               out << position[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < averageQ.size(); k++)                       {               out << averageQ[k] << '\t'; }  out << endl;
-                               for (int k = 0; k < scores.size(); k++) {               
-                                       for (int j = 0; j < 41; j++) {
-                                               out << scores[k][j] << '\t'; 
-                                       }
-                                       out << endl;
-                               }  
-                               out << endl;
-                               
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //do your part
-               numSeqs = driverCreateSummary(position, averageQ, scores, qualfile, lines[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //parent reads in and combine Filter info
-               for (int i = 0; i < processIDS.size(); i++) {
-                       string tempFilename = qualfile + toString(processIDS[i]) + ".num.temp";
-                       ifstream in;
-                       m->openInputFile(tempFilename, in);
-                       
-                       int temp, tempNum;
-                       in >> tempNum; m->gobble(in); numSeqs += tempNum;
-                       in >> tempNum; m->gobble(in);
-                       
-                       if (position.size() < tempNum) { position.resize(tempNum, 0); }
-                       if (averageQ.size() < tempNum) { averageQ.resize(tempNum, 0); }
-                       if (scores.size() < tempNum) { 
-                               scores.resize(tempNum); 
-                               for (int i = 0; i < scores.size(); i++) { scores[i].resize(41, 0); }
-                       }
-                       
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; position[k] += temp;                        }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {               in >> temp; averageQ[k] += temp;                }               m->gobble(in);
-                       for (int k = 0; k < tempNum; k++)                       {       
-                               for (int j = 0; j < 41; j++) {
-                                       in >> temp; scores[k][j] += temp;
-                                       m->gobble(in);
-                               }       
-                       }
-                       
-                       in.close();
-                       m->mothurRemove(tempFilename);
-               }
-               
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the seqSumQualData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //Taking advantage of shared memory to pass results vectors.
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<seqSumQualData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors];
-               HANDLE  hThreadArray[processors]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors; i++ ){
-                       
-                       // Allocate memory for thread data.
-                       seqSumQualData* tempSum = new seqSumQualData(filename, m, lines[i].start, lines[i].end, namefile, nameMap);
-                       pDataArray.push_back(tempSum);
-                       processIDS.push_back(i);
-        
-                       hThreadArray[i] = CreateThread(NULL, 0, MySeqSumQualThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       numSeqs += pDataArray[i]->count;
-            int tempNum = pDataArray[i]->position.size();
-            if (position.size() < tempNum) { position.resize(tempNum, 0); }
-                       if (averageQ.size() < tempNum) { averageQ.resize(tempNum, 0); }
-                       if (scores.size() < tempNum) { 
-                               scores.resize(tempNum); 
-                               for (int i = 0; i < scores.size(); i++) { scores[i].resize(41, 0); }
-                       }
-            
-            for (int k = 0; k < tempNum; k++)                  {                position[k]    +=  pDataArray[i]->position[k];         }               
-                       for (int k = 0; k < tempNum; k++)                       {                averageQ[k]    +=  pDataArray[i]->averageQ[k];         }               
-                       for (int k = 0; k < tempNum; k++)                       {       for (int j = 0; j < 41; j++) {  scores[k][j] += pDataArray[i]->scores[k][j];   }        }
-
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-#endif         
-               return numSeqs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "createProcessesCreateSummary");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int SummaryQualCommand::printQual(string sumFile, vector<int>& position, vector<int>& averageQ, vector< vector<int> >& scores) {
-       try {
-               ofstream out;
-               m->openOutputFile(sumFile, out);
-               out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-               outputNames.push_back(sumFile); outputTypes["summary"].push_back(sumFile);
-               
-               //print headings
-               out << "Position\tnumSeqs\tAverageQ\t";
-               for (int i = 0; i < 41; i++) { out << "q" << i << '\t'; }
-               out << endl;
-               
-               for (int i = 0; i < position.size(); i++) {
-                       
-                       if (m->control_pressed) { out.close(); return 0; }
-                       
-                       float average = averageQ[i] / (float) position[i];
-                       out << i << '\t' << position[i] << '\t' << average << '\t';
-                       
-                       for (int j = 0; j < 41; j++) {
-                               out << scores[i][j] << '\t';
-                       }
-                       out << endl;
-               }
-               
-               out.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryQualCommand", "printQual");
-               exit(1);
-       }
-}
-
-/**************************************************************************************/
-
-
diff --git a/summaryqualcommand.h b/summaryqualcommand.h
deleted file mode 100644 (file)
index bbd103c..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-#ifndef SUMMARYQUALCOMMAND_H
-#define SUMMARYQUALCOMMAND_H
-
-/*
- *  summaryqualcommand.h
- *  Mothur
- *
- *  Created by westcott on 11/28/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "qualityscores.h"
-
-/**************************************************************************************************/
-
-class SummaryQualCommand : public Command {
-public:
-       SummaryQualCommand(string);
-       SummaryQualCommand();
-       ~SummaryQualCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "summary.qual";                        }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Summary.qual"; }
-       string getDescription()         { return "summarize the quality of a set of sequences"; }
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort;
-       string qualfile, outputDir, namefile;
-       vector<string> outputNames;
-       map<string, int> nameMap;
-       int processors;
-       
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-       
-       vector<linePair> lines;
-       vector<int> processIDS;
-       
-       int createProcessesCreateSummary(vector<int>&, vector<int>&, vector< vector<int> >&, string);
-       int driverCreateSummary(vector<int>&, vector<int>&, vector< vector<int> >&, string, linePair);  
-       int printQual(string, vector<int>&, vector<int>&, vector< vector<int> >&);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct seqSumQualData {
-       vector<int> position;
-       vector<int> averageQ;
-       vector< vector<int> > scores; 
-       string filename, namefile; 
-       unsigned long long start;
-       unsigned long long end;
-       int count;
-       MothurOut* m;
-       map<string, int> nameMap;
-       
-       ~seqSumQualData(){}
-       seqSumQualData(string f, MothurOut* mout, unsigned long long st, unsigned long long en, string n, map<string, int> nam) {
-               filename = f;
-               m = mout;
-               start = st;
-               end = en;
-               namefile = n;
-               nameMap = nam;
-               count = 0;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){ 
-       seqSumQualData* pDataArray;
-       pDataArray = (seqSumQualData*)lpParam;
-       
-       try {
-               ifstream in;
-               pDataArray->m->openInputFile(pDataArray->filename, in);
-               
-               //print header if you are process 0
-               if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
-                       in.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       in.seekg(pDataArray->start-1); pDataArray->m->gobble(in); 
-               }
-               
-               int count = 0;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                               
-                       if (pDataArray->m->control_pressed) { in.close(); pDataArray->count = 1; return 1; }
-                       
-                       QualityScores current(in); pDataArray->m->gobble(in);
-                       
-                       if (current.getName() != "") {
-                       
-                               int num = 1;
-                               if (pDataArray->namefile != "") {
-                                       //make sure this sequence is in the namefile, else error 
-                                       map<string, int>::iterator it = pDataArray->nameMap.find(current.getName());
-                                       
-                                       if (it == pDataArray->nameMap.end()) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
-                                       else { num = it->second; }
-                               }
-                               
-                               vector<int> thisScores = current.getQualityScores();
-                               
-                               //resize to num of positions setting number of seqs with that size to 1
-                               if (pDataArray->position.size() < thisScores.size()) { pDataArray->position.resize(thisScores.size(), 0); }
-                               if (pDataArray->averageQ.size() < thisScores.size()) { pDataArray->averageQ.resize(thisScores.size(), 0); }
-                               if (pDataArray->scores.size() < thisScores.size()) { 
-                                       pDataArray->scores.resize(thisScores.size()); 
-                                       for (int i = 0; i < pDataArray->scores.size(); i++) { pDataArray->scores.at(i).resize(41, 0); }
-                               }
-                               
-                               //increase counts of number of seqs with this position
-                               //average is really the total, we will average in execute
-                               for (int i = 0; i < thisScores.size(); i++) { 
-                                       pDataArray->position.at(i) += num; 
-                                       pDataArray->averageQ.at(i) += (thisScores[i] * num); //weighting for namesfile
-                                       if (thisScores[i] > 40) { pDataArray->m->mothurOut("[ERROR]: " + current.getName() + " has a quality scores of " + toString(thisScores[i]) + ", expecting values to be less than 40."); pDataArray->m->mothurOutEndLine(); pDataArray->m->control_pressed = true; }
-                                       else { pDataArray->scores.at(i)[thisScores[i]] += num; }  
-                               }
-                               
-                               count += num;
-                       }
-               }
-               
-               pDataArray->count = count;
-               in.close();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "SummaryQualCommand", "MySeqSumQualThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-/**************************************************************************************************/
-
-
-#endif
-
diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp
deleted file mode 100644 (file)
index 8c4ea0d..0000000
+++ /dev/null
@@ -1,770 +0,0 @@
-/*
- *  summarysharedcommand.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "summarysharedcommand.h"
-
-//**********************************************************************************************************************
-vector<string> SummarySharedCommand::setParameters(){  
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pshared);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pdistance("distance", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pdistance);
-               CommandParameter pcalc("calc", "Multiple", "sharedchao-sharedsobs-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-whittaker-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-structchi2-hamming-gower-memchi2-memchord-memeuclidean-mempearson", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan", "", "", "",true,false); parameters.push_back(pcalc);
-               CommandParameter pall("all", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pall);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SummarySharedCommand::getHelpString(){  
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The summary.shared command parameters are shared, label, calc, distance, processors and all.  shared is required if there is no current sharedfile.\n";
-               helpString += "The summary.shared command should be in the following format: \n";
-               helpString += "summary.shared(label=yourLabel, calc=yourEstimators, groups=yourGroups).\n";
-               helpString += "Example summary.shared(label=unique-.01-.03, groups=B-C, calc=sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan).\n";
-               helpString +=  validCalculator.printCalc("sharedsummary");
-               helpString += "The default value for calc is sharedsobs-sharedchao-sharedace-jabund-sorensonabund-jclass-sorclass-jest-sorest-thetayc-thetan\n";
-               helpString += "The default value for groups is all the groups in your groupfile.\n";
-               helpString += "The distance parameter allows you to indicate you would like a distance file created for each calculator for each label, default=f.\n";
-               helpString += "The label parameter is used to analyze specific labels in your input.\n";
-               helpString += "The all parameter is used to specify if you want the estimate of all your groups together.  This estimate can only be made for sharedsobs and sharedchao calculators. The default is false.\n";
-               helpString += "If you use sharedchao and run into memory issues, set all to false. \n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. label), '=' and parameters (i.e.yourLabel).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SummarySharedCommand::SummarySharedCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-SummarySharedCommand::SummarySharedCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                               
-               //allow user to run help
-               if(option == "help") {  help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       map<string, string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string, string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                       }
-                       
-                       //get shared file
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { 
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current sharedfile and the shared parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setSharedFile(sharedfile); }
-                       
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(sharedfile);             }
-                       
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                                       
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
-                       else { 
-                                if (calc == "default")  {  calc = "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       string temp = validParameter.validFile(parameters, "all", false);                               if (temp == "not found") { temp = "false"; }
-                       all = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "distance", false);                                 if (temp == "not found") { temp = "false"; }
-                       createPhylip = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       if (abort == false) {
-                       
-                               ValidCalculators validCalculator;
-                               int i;
-                               
-                               for (i=0; i<Estimators.size(); i++) {
-                                       if (validCalculator.isValidCalculator("sharedsummary", Estimators[i]) == true) { 
-                                               if (Estimators[i] == "sharedsobs") { 
-                                                       sumCalculators.push_back(new SharedSobsCS());
-                                               }else if (Estimators[i] == "sharedchao") { 
-                                                       sumCalculators.push_back(new SharedChao1());
-                                               }else if (Estimators[i] == "sharedace") { 
-                                                       sumCalculators.push_back(new SharedAce());
-                                               }else if (Estimators[i] == "jabund") {  
-                                                       sumCalculators.push_back(new JAbund());
-                                               }else if (Estimators[i] == "sorabund") { 
-                                                       sumCalculators.push_back(new SorAbund());
-                                               }else if (Estimators[i] == "jclass") { 
-                                                       sumCalculators.push_back(new Jclass());
-                                               }else if (Estimators[i] == "sorclass") { 
-                                                       sumCalculators.push_back(new SorClass());
-                                               }else if (Estimators[i] == "jest") { 
-                                                       sumCalculators.push_back(new Jest());
-                                               }else if (Estimators[i] == "sorest") { 
-                                                       sumCalculators.push_back(new SorEst());
-                                               }else if (Estimators[i] == "thetayc") { 
-                                                       sumCalculators.push_back(new ThetaYC());
-                                               }else if (Estimators[i] == "thetan") { 
-                                                       sumCalculators.push_back(new ThetaN());
-                                               }else if (Estimators[i] == "kstest") { 
-                                                       sumCalculators.push_back(new KSTest());
-                                               }else if (Estimators[i] == "sharednseqs") { 
-                                                       sumCalculators.push_back(new SharedNSeqs());
-                                               }else if (Estimators[i] == "ochiai") { 
-                                                       sumCalculators.push_back(new Ochiai());
-                                               }else if (Estimators[i] == "anderberg") { 
-                                                       sumCalculators.push_back(new Anderberg());
-                                               }else if (Estimators[i] == "kulczynski") { 
-                                                       sumCalculators.push_back(new Kulczynski());
-                                               }else if (Estimators[i] == "kulczynskicody") { 
-                                                       sumCalculators.push_back(new KulczynskiCody());
-                                               }else if (Estimators[i] == "lennon") { 
-                                                       sumCalculators.push_back(new Lennon());
-                                               }else if (Estimators[i] == "morisitahorn") { 
-                                                       sumCalculators.push_back(new MorHorn());
-                                               }else if (Estimators[i] == "braycurtis") { 
-                                                       sumCalculators.push_back(new BrayCurtis());
-                                               }else if (Estimators[i] == "whittaker") { 
-                                                       sumCalculators.push_back(new Whittaker());
-                                               }else if (Estimators[i] == "odum") { 
-                                                       sumCalculators.push_back(new Odum());
-                                               }else if (Estimators[i] == "canberra") { 
-                                                       sumCalculators.push_back(new Canberra());
-                                               }else if (Estimators[i] == "structeuclidean") { 
-                                                       sumCalculators.push_back(new StructEuclidean());
-                                               }else if (Estimators[i] == "structchord") { 
-                                                       sumCalculators.push_back(new StructChord());
-                                               }else if (Estimators[i] == "hellinger") { 
-                                                       sumCalculators.push_back(new Hellinger());
-                                               }else if (Estimators[i] == "manhattan") { 
-                                                       sumCalculators.push_back(new Manhattan());
-                                               }else if (Estimators[i] == "structpearson") { 
-                                                       sumCalculators.push_back(new StructPearson());
-                                               }else if (Estimators[i] == "soergel") { 
-                                                       sumCalculators.push_back(new Soergel());
-                                               }else if (Estimators[i] == "spearman") { 
-                                                       sumCalculators.push_back(new Spearman());
-                                               }else if (Estimators[i] == "structkulczynski") { 
-                                                       sumCalculators.push_back(new StructKulczynski());
-                                               }else if (Estimators[i] == "speciesprofile") { 
-                                                       sumCalculators.push_back(new SpeciesProfile());
-                                               }else if (Estimators[i] == "hamming") { 
-                                                       sumCalculators.push_back(new Hamming());
-                                               }else if (Estimators[i] == "structchi2") { 
-                                                       sumCalculators.push_back(new StructChi2());
-                                               }else if (Estimators[i] == "gower") { 
-                                                       sumCalculators.push_back(new Gower());
-                                               }else if (Estimators[i] == "memchi2") { 
-                                                       sumCalculators.push_back(new MemChi2());
-                                               }else if (Estimators[i] == "memchord") { 
-                                                       sumCalculators.push_back(new MemChord());
-                                               }else if (Estimators[i] == "memeuclidean") { 
-                                                       sumCalculators.push_back(new MemEuclidean());
-                                               }else if (Estimators[i] == "mempearson") { 
-                                                       sumCalculators.push_back(new MemPearson());
-                                               }
-                                       }
-                               }
-                               
-                               mult = false;
-                       }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "SummarySharedCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int SummarySharedCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               ofstream outputFileHandle, outAll;
-               string outputFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "shared.summary";
-               
-               //if the users entered no valid calculators don't execute command
-               if (sumCalculators.size() == 0) { return 0; }
-               //check if any calcs can do multiples
-               else{
-                       if (all){ 
-                               for (int i = 0; i < sumCalculators.size(); i++) {
-                                       if (sumCalculators[i]->getMultiple() == true) { mult = true; }
-                               }
-                       }
-               }
-                       
-               input = new InputData(sharedfile, "sharedfile");
-               lookup = input->getSharedRAbundVectors();
-               string lastLabel = lookup[0]->getLabel();
-       
-               /******************************************************/
-               //output headings for files
-               /******************************************************/
-               //output estimator names as column headers
-               m->openOutputFile(outputFileName, outputFileHandle);
-               outputFileHandle << "label" <<'\t' << "comparison" << '\t'; 
-               for(int i=0;i<sumCalculators.size();i++){
-                       outputFileHandle << '\t' << sumCalculators[i]->getName();
-                       if (sumCalculators[i]->getCols() == 3) {   outputFileHandle << "\t" << sumCalculators[i]->getName() << "_lci\t" << sumCalculators[i]->getName() << "_hci";  }
-               }
-               outputFileHandle << endl;
-               outputFileHandle.close();
-               
-               //create file and put column headers for multiple groups file
-               string outAllFileName = ((m->getRootName(sharedfile)) + "sharedmultiple.summary");
-               if (mult == true) {
-                       m->openOutputFile(outAllFileName, outAll);
-                       outputNames.push_back(outAllFileName);
-                       
-                       outAll << "label" <<'\t' << "comparison" << '\t'; 
-                       for(int i=0;i<sumCalculators.size();i++){
-                               if (sumCalculators[i]->getMultiple() == true) { 
-                                       outAll << '\t' << sumCalculators[i]->getName();
-                               }
-                       }
-                       outAll << endl;
-                       outAll.close();
-               }
-               
-               if (lookup.size() < 2) { 
-                       m->mothurOut("I cannot run the command without at least 2 valid groups."); 
-                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
-                       
-                       //close files and clean up
-                       m->mothurRemove(outputFileName);
-                       if (mult == true) { m->mothurRemove(outAllFileName);  }
-                       return 0;
-               //if you only have 2 groups you don't need a .sharedmultiple file
-               }else if ((lookup.size() == 2) && (mult == true)) { 
-                       mult = false;
-                       m->mothurRemove(outAllFileName);
-                       outputNames.pop_back();
-               }
-               
-               if (m->control_pressed) {
-                       if (mult) {  m->mothurRemove(outAllFileName);  }
-                       m->mothurRemove(outputFileName); 
-                       delete input;
-                       for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
-                       for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-                       m->clearGroups(); 
-                       return 0;
-               }
-               /******************************************************/
-               
-               
-               /******************************************************/
-               //comparison breakup to be used by different processes later
-               numGroups = m->getNumGroups();
-               lines.resize(processors);
-               for (int i = 0; i < processors; i++) {
-                       lines[i].start = int (sqrt(float(i)/float(processors)) * numGroups);
-                       lines[i].end = int (sqrt(float(i+1)/float(processors)) * numGroups);
-               }               
-               /******************************************************/
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-                       
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) {
-                               if (mult) {  m->mothurRemove(outAllFileName);  }
-                               m->mothurRemove(outputFileName); 
-                               delete input; 
-                               for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
-                               for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-                               m->clearGroups(); 
-                               return 0;
-                       }
-
-               
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup, outputFileName, outAllFileName);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookup[0]->getLabel();
-                                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       process(lookup, outputFileName, outAllFileName);
-                                       
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       lookup[0]->setLabel(saveLabel);
-                       }
-                       
-                       lastLabel = lookup[0]->getLabel();                      
-                               
-                       //get next line to process
-                       //prevent memory leak
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               if (m->control_pressed) {
-                       if (mult) { m->mothurRemove(outAllFileName);  }
-                       m->mothurRemove(outputFileName); 
-                       delete input; 
-                       for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-                       m->clearGroups(); 
-                       return 0;
-               }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                               for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i];       } } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup, outputFileName, outAllFileName);
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-               }
-               
-                               
-               //reset groups parameter
-               m->clearGroups();  
-               
-               for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-               delete input;  
-               
-               if (m->control_pressed) {
-                       m->mothurRemove(outAllFileName);  
-                       m->mothurRemove(outputFileName); 
-                       return 0;
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               m->mothurOut(outputFileName); m->mothurOutEndLine();    
-               if (mult) { m->mothurOut(outAllFileName); m->mothurOutEndLine();        outputTypes["summary"].push_back(outAllFileName); }
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    } outputTypes["summary"].push_back(outputFileName);
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "execute");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-int SummarySharedCommand::process(vector<SharedRAbundVector*> thisLookup, string sumFileName, string sumAllFileName) {
-       try {
-        vector< vector<seqDist> > calcDists;  //vector containing vectors that contains the summary results for each group compare
-        calcDists.resize(sumCalculators.size()); //one for each calc, this will be used to make .dist files
-        
-        
-        if(processors == 1){
-            driver(thisLookup, 0, numGroups, sumFileName+".temp", sumAllFileName+".temp", calcDists);
-            m->appendFiles((sumFileName + ".temp"), sumFileName);
-            m->mothurRemove((sumFileName + ".temp"));
-            if (mult) {
-                m->appendFiles((sumAllFileName + ".temp"), sumAllFileName);
-                m->mothurRemove((sumAllFileName + ".temp"));
-            }
-        }else{
-            
-            int process = 1;
-            vector<int> processIDS;
-            
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-            //loop through and create all the processes you want
-            while (process != processors) {
-                int pid = fork();
-                
-                if (pid > 0) {
-                    processIDS.push_back(pid); 
-                    process++;
-                }else if (pid == 0){
-                    driver(thisLookup, lines[process].start, lines[process].end, sumFileName + toString(getpid()) + ".temp", sumAllFileName + toString(getpid()) + ".temp", calcDists);   
-                    
-                    //only do this if you want a distance file
-                    if (createPhylip) {
-                        string tempdistFileName = m->getRootName(m->getSimpleName(sumFileName)) + toString(getpid()) + ".dist";
-                        ofstream outtemp;
-                        m->openOutputFile(tempdistFileName, outtemp);
-                        
-                        for (int i = 0; i < calcDists.size(); i++) {
-                            outtemp << calcDists[i].size() << endl;
-                            
-                            for (int j = 0; j < calcDists[i].size(); j++) {
-                                outtemp << calcDists[i][j].seq1 << '\t' << calcDists[i][j].seq2 << '\t' << calcDists[i][j].dist << endl;
-                            }
-                        }
-                        outtemp.close();
-                    }
-                    
-                    exit(0);
-                }else { 
-                    m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                    for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                    exit(0);
-                }
-            }
-            
-            //parent do your part
-            driver(thisLookup, lines[0].start, lines[0].end, sumFileName + toString(getpid()) + ".temp", sumAllFileName + toString(getpid()) + ".temp", calcDists);   
-            m->appendFiles((sumFileName + toString(getpid()) + ".temp"), sumFileName);
-            m->mothurRemove((sumFileName + toString(getpid()) + ".temp"));
-            if (mult) { m->appendFiles((sumAllFileName + toString(getpid()) + ".temp"), sumAllFileName); }
-            
-            //force parent to wait until all the processes are done
-            for (int i = 0; i < processIDS.size(); i++) {
-                int temp = processIDS[i];
-                wait(&temp);
-            }
-            
-            for (int i = 0; i < processIDS.size(); i++) {
-                m->appendFiles((sumFileName + toString(processIDS[i]) + ".temp"), sumFileName);
-                m->mothurRemove((sumFileName + toString(processIDS[i]) + ".temp"));
-                if (mult) {    m->mothurRemove((sumAllFileName + toString(processIDS[i]) + ".temp"));  }
-                
-                if (createPhylip) {
-                    string tempdistFileName = m->getRootName(m->getSimpleName(sumFileName)) + toString(processIDS[i]) +  ".dist";
-                    ifstream intemp;
-                    m->openInputFile(tempdistFileName, intemp);
-                    
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = 0;
-                        intemp >> size; m->gobble(intemp);
-                        
-                        for (int j = 0; j < size; j++) {
-                            int seq1 = 0;
-                            int seq2 = 0;
-                            float dist = 1.0;
-                            
-                            intemp >> seq1 >> seq2 >> dist;   m->gobble(intemp);
-                            
-                            seqDist tempDist(seq1, seq2, dist);
-                            calcDists[k].push_back(tempDist);
-                        }
-                    }
-                    intemp.close();
-                    m->mothurRemove(tempdistFileName);
-                }
-            }
-#else
-            //////////////////////////////////////////////////////////////////////////////////////////////////////
-            //Windows version shared memory, so be careful when passing variables through the summarySharedData struct. 
-            //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-            //Taking advantage of shared memory to pass results vectors.
-            //////////////////////////////////////////////////////////////////////////////////////////////////////
-
-            vector<summarySharedData*> pDataArray; 
-            DWORD   dwThreadIdArray[processors-1];
-            HANDLE  hThreadArray[processors-1]; 
-            
-            //Create processor worker threads.
-            for( int i=1; i<processors; i++ ){
-                
-                //make copy of lookup so we don't get access violations
-                vector<SharedRAbundVector*> newLookup;
-                for (int k = 0; k < thisLookup.size(); k++) {
-                    SharedRAbundVector* temp = new SharedRAbundVector();
-                    temp->setLabel(thisLookup[k]->getLabel());
-                    temp->setGroup(thisLookup[k]->getGroup());
-                    newLookup.push_back(temp);
-                }
-                
-                //for each bin
-                for (int k = 0; k < thisLookup[0]->getNumBins(); k++) {
-                    if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                    for (int j = 0; j < thisLookup.size(); j++) { newLookup[j]->push_back(thisLookup[j]->getAbundance(k), thisLookup[j]->getGroup()); }
-                }
-
-                // Allocate memory for thread data.
-                summarySharedData* tempSum = new summarySharedData((sumFileName+toString(i)+".temp"), m, lines[i].start, lines[i].end, Estimators, newLookup);
-                pDataArray.push_back(tempSum);
-                processIDS.push_back(i);
-                
-                hThreadArray[i-1] = CreateThread(NULL, 0, MySummarySharedThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-            }
-            
-            //parent do your part
-            driver(thisLookup, lines[0].start, lines[0].end, sumFileName +"0.temp", sumAllFileName + "0.temp", calcDists);   
-            m->appendFiles((sumFileName + "0.temp"), sumFileName);
-            m->mothurRemove((sumFileName + "0.temp"));
-            if (mult) { m->appendFiles((sumAllFileName + "0.temp"), sumAllFileName); }
-            
-            //Wait until all threads have terminated.
-            WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-            
-            //Close all thread handles and free memory allocations.
-            for(int i=0; i < pDataArray.size(); i++){
-                m->appendFiles((sumFileName + toString(processIDS[i]) + ".temp"), sumFileName);
-                m->mothurRemove((sumFileName + toString(processIDS[i]) + ".temp"));
-                
-                for (int j = 0; j < pDataArray[i]->thisLookup.size(); j++) {  delete pDataArray[i]->thisLookup[j];  } 
-                
-                if (createPhylip) {
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = pDataArray[i]->calcDists[k].size();
-                        for (int j = 0; j < size; j++) {    calcDists[k].push_back(pDataArray[i]->calcDists[k][j]);    }
-                    }
-                }
-              
-                CloseHandle(hThreadArray[i]);
-                delete pDataArray[i];
-            }
-
-#endif
-        }
-              
-        if (createPhylip) {
-            for (int i = 0; i < calcDists.size(); i++) {
-                if (m->control_pressed) { break; }
-                               
-                string distFileName = outputDir + m->getRootName(m->getSimpleName(sumFileName)) + sumCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".dist";
-                outputNames.push_back(distFileName);
-                ofstream outDist;
-                m->openOutputFile(distFileName, outDist);
-                outDist.setf(ios::fixed, ios::floatfield); outDist.setf(ios::showpoint);
-                
-                //initialize matrix
-                vector< vector<float> > matrix; //square matrix to represent the distance
-                matrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                
-                
-                for (int j = 0; j < calcDists[i].size(); j++) {
-                    int row = calcDists[i][j].seq1;
-                    int column = calcDists[i][j].seq2;
-                    float dist = calcDists[i][j].dist;
-                    
-                    matrix[row][column] = dist;
-                    matrix[column][row] = dist;
-                }
-                
-                //output to file
-                outDist << thisLookup.size() << endl;
-                for (int r=0; r<thisLookup.size(); r++) { 
-                    //output name
-                    string name = thisLookup[r]->getGroup();
-                    if (name.length() < 10) { //pad with spaces to make compatible
-                        while (name.length() < 10) {  name += " ";  }
-                    }
-                    outDist << name << '\t';
-                                       
-                    //output distances
-                    for (int l = 0; l < r; l++) {      outDist  << matrix[r][l] << '\t';  }
-                    outDist << endl;
-                }
-                
-                outDist.close();
-            }
-        }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "process");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int SummarySharedCommand::driver(vector<SharedRAbundVector*> thisLookup, int start, int end, string sumFile, string sumAllFile, vector< vector<seqDist> >& calcDists) { 
-       try {
-               
-               //loop through calculators and add to file all for all calcs that can do mutiple groups
-               if (mult == true) {
-                       ofstream outAll;
-                       m->openOutputFile(sumAllFile, outAll);
-                       
-                       //output label
-                       outAll << thisLookup[0]->getLabel() << '\t';
-                       
-                       //output groups names
-                       string outNames = "";
-                       for (int j = 0; j < thisLookup.size(); j++) {
-                               outNames += thisLookup[j]->getGroup() +  "-";
-                       }
-                       outNames = outNames.substr(0, outNames.length()-1); //rip off extra '-';
-                       outAll << outNames << '\t';
-                       
-                       for(int i=0;i<sumCalculators.size();i++){
-                               if (sumCalculators[i]->getMultiple() == true) { 
-                                       sumCalculators[i]->getValues(thisLookup);
-                                       
-                                       if (m->control_pressed) { outAll.close(); return 1; }
-                                       
-                                       outAll << '\t';
-                                       sumCalculators[i]->print(outAll);
-                               }
-                       }
-                       outAll << endl;
-                       outAll.close();
-               }
-               
-               ofstream outputFileHandle;
-               m->openOutputFile(sumFile, outputFileHandle);
-               
-               vector<SharedRAbundVector*> subset;
-               for (int k = start; k < end; k++) { // pass cdd each set of groups to compare
-
-                       for (int l = 0; l < k; l++) {
-                               
-                               outputFileHandle << thisLookup[0]->getLabel() << '\t';
-                               
-                               subset.clear(); //clear out old pair of sharedrabunds
-                               //add new pair of sharedrabunds
-                               subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]); 
-                               
-                               //sort groups to be alphanumeric
-                               if (thisLookup[k]->getGroup() > thisLookup[l]->getGroup()) {
-                                       outputFileHandle << (thisLookup[l]->getGroup() +'\t' + thisLookup[k]->getGroup()) << '\t'; //print out groups
-                               }else{
-                                       outputFileHandle << (thisLookup[k]->getGroup() +'\t' + thisLookup[l]->getGroup()) << '\t'; //print out groups
-                               }
-                               
-                               for(int i=0;i<sumCalculators.size();i++) {
-                                       
-                                       //if this calc needs all groups to calculate the pair load all groups
-                                       if (sumCalculators[i]->getNeedsAll()) { 
-                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                               for (int w = 0; w < thisLookup.size(); w++) {
-                                                       if ((w != k) && (w != l)) { subset.push_back(thisLookup[w]); }
-                                               }
-                                       }
-                                       
-                                       vector<double> tempdata = sumCalculators[i]->getValues(subset); //saves the calculator outputs
-                                       
-                                       if (m->control_pressed) { outputFileHandle.close(); return 1; }
-                                       
-                                       outputFileHandle << '\t';
-                                       sumCalculators[i]->print(outputFileHandle);
-                                       
-                                       seqDist temp(l, k, tempdata[0]);
-                                       calcDists[i].push_back(temp);
-                               }
-                               outputFileHandle << endl;
-                       }
-               }
-               
-               outputFileHandle.close();
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummarySharedCommand", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
diff --git a/summarysharedcommand.h b/summarysharedcommand.h
deleted file mode 100644 (file)
index fbfea7b..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-#ifndef SUMMARYSHAREDCOMMAND_H
-#define SUMMARYSHAREDCOMMAND_H
-/*
- *  summarysharedcommand.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/2/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-
-#include "command.hpp"
-#include "sharedrabundvector.h"
-#include "inputdata.h"
-#include "calculator.h"
-#include "validcalculator.h"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "sharednseqs.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedkstest.h"
-#include "whittaker.h"
-#include "sharedochiai.h"
-#include "sharedanderbergs.h"
-#include "sharedkulczynski.h"
-#include "sharedkulczynskicody.h"
-#include "sharedlennon.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-#include "sharedjackknife.h"
-#include "whittaker.h"
-#include "odum.h"
-#include "canberra.h"
-#include "structeuclidean.h"
-#include "structchord.h"
-#include "hellinger.h"
-#include "manhattan.h"
-#include "structpearson.h"
-#include "soergel.h"
-#include "spearman.h"
-#include "structkulczynski.h"
-#include "structchi2.h"
-#include "speciesprofile.h"
-#include "hamming.h"
-#include "gower.h"
-#include "memchi2.h"
-#include "memchord.h"
-#include "memeuclidean.h"
-#include "mempearson.h"
-
-class SummarySharedCommand : public Command {
-
-public:
-       SummarySharedCommand(string);
-       SummarySharedCommand();
-       ~SummarySharedCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "summary.shared";                      }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Summary.shared"; }
-       string getDescription()         { return "generate a summary file containing calculator values for each line in the OTU data and for all possible comparisons between groups"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-       
-private:
-       struct linePair {
-               int start;
-               int end;
-       };
-       vector<linePair> lines;
-       vector<Calculator*> sumCalculators;     
-       InputData* input;
-       
-       bool abort, allLines, mult, all, createPhylip;
-       set<string> labels; //holds labels to be used
-       string label, calc, groups, sharedfile;
-       vector<string>  Estimators, Groups, outputNames;
-       vector<SharedRAbundVector*> lookup;
-       string format, outputDir;
-       int numGroups, processors;
-       int process(vector<SharedRAbundVector*>, string, string);
-       int driver(vector<SharedRAbundVector*>, int, int, string, string, vector< vector<seqDist> >&);
-
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-//main process handling the calcs that can do more than 2 groups
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct summarySharedData {
-    vector<SharedRAbundVector*> thisLookup;
-    vector< vector<seqDist> > calcDists;
-    vector<string>  Estimators;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       string sumFile;
-       
-       summarySharedData(){}
-       summarySharedData(string sf, MothurOut* mout, unsigned long long st, unsigned long long en, vector<string> est, vector<SharedRAbundVector*> lu) {
-               sumFile = sf;
-               m = mout;
-               start = st;
-               end = en;
-        Estimators = est;
-        thisLookup = lu;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MySummarySharedThreadFunction(LPVOID lpParam){ 
-       summarySharedData* pDataArray;
-       pDataArray = (summarySharedData*)lpParam;
-       
-       try {
-        
-        vector<Calculator*> sumCalculators;
-        ValidCalculators validCalculator;
-        for (int i=0; i<pDataArray->Estimators.size(); i++) {
-            if (validCalculator.isValidCalculator("sharedsummary", pDataArray->Estimators[i]) == true) { 
-                if (pDataArray->Estimators[i] == "sharedsobs") { 
-                    sumCalculators.push_back(new SharedSobsCS());
-                }else if (pDataArray->Estimators[i] == "sharedchao") { 
-                    sumCalculators.push_back(new SharedChao1());
-                }else if (pDataArray->Estimators[i] == "sharedace") { 
-                    sumCalculators.push_back(new SharedAce());
-                }else if (pDataArray->Estimators[i] == "jabund") {     
-                    sumCalculators.push_back(new JAbund());
-                }else if (pDataArray->Estimators[i] == "sorabund") { 
-                    sumCalculators.push_back(new SorAbund());
-                }else if (pDataArray->Estimators[i] == "jclass") { 
-                    sumCalculators.push_back(new Jclass());
-                }else if (pDataArray->Estimators[i] == "sorclass") { 
-                    sumCalculators.push_back(new SorClass());
-                }else if (pDataArray->Estimators[i] == "jest") { 
-                    sumCalculators.push_back(new Jest());
-                }else if (pDataArray->Estimators[i] == "sorest") { 
-                    sumCalculators.push_back(new SorEst());
-                }else if (pDataArray->Estimators[i] == "thetayc") { 
-                    sumCalculators.push_back(new ThetaYC());
-                }else if (pDataArray->Estimators[i] == "thetan") { 
-                    sumCalculators.push_back(new ThetaN());
-                }else if (pDataArray->Estimators[i] == "kstest") { 
-                    sumCalculators.push_back(new KSTest());
-                }else if (pDataArray->Estimators[i] == "sharednseqs") { 
-                    sumCalculators.push_back(new SharedNSeqs());
-                }else if (pDataArray->Estimators[i] == "ochiai") { 
-                    sumCalculators.push_back(new Ochiai());
-                }else if (pDataArray->Estimators[i] == "anderberg") { 
-                    sumCalculators.push_back(new Anderberg());
-                }else if (pDataArray->Estimators[i] == "kulczynski") { 
-                    sumCalculators.push_back(new Kulczynski());
-                }else if (pDataArray->Estimators[i] == "kulczynskicody") { 
-                    sumCalculators.push_back(new KulczynskiCody());
-                }else if (pDataArray->Estimators[i] == "lennon") { 
-                    sumCalculators.push_back(new Lennon());
-                }else if (pDataArray->Estimators[i] == "morisitahorn") { 
-                    sumCalculators.push_back(new MorHorn());
-                }else if (pDataArray->Estimators[i] == "braycurtis") { 
-                    sumCalculators.push_back(new BrayCurtis());
-                }else if (pDataArray->Estimators[i] == "whittaker") { 
-                    sumCalculators.push_back(new Whittaker());
-                }else if (pDataArray->Estimators[i] == "odum") { 
-                    sumCalculators.push_back(new Odum());
-                }else if (pDataArray->Estimators[i] == "canberra") { 
-                    sumCalculators.push_back(new Canberra());
-                }else if (pDataArray->Estimators[i] == "structeuclidean") { 
-                    sumCalculators.push_back(new StructEuclidean());
-                }else if (pDataArray->Estimators[i] == "structchord") { 
-                    sumCalculators.push_back(new StructChord());
-                }else if (pDataArray->Estimators[i] == "hellinger") { 
-                    sumCalculators.push_back(new Hellinger());
-                }else if (pDataArray->Estimators[i] == "manhattan") { 
-                    sumCalculators.push_back(new Manhattan());
-                }else if (pDataArray->Estimators[i] == "structpearson") { 
-                    sumCalculators.push_back(new StructPearson());
-                }else if (pDataArray->Estimators[i] == "soergel") { 
-                    sumCalculators.push_back(new Soergel());
-                }else if (pDataArray->Estimators[i] == "spearman") { 
-                    sumCalculators.push_back(new Spearman());
-                }else if (pDataArray->Estimators[i] == "structkulczynski") { 
-                    sumCalculators.push_back(new StructKulczynski());
-                }else if (pDataArray->Estimators[i] == "speciesprofile") { 
-                    sumCalculators.push_back(new SpeciesProfile());
-                }else if (pDataArray->Estimators[i] == "hamming") { 
-                    sumCalculators.push_back(new Hamming());
-                }else if (pDataArray->Estimators[i] == "structchi2") { 
-                    sumCalculators.push_back(new StructChi2());
-                }else if (pDataArray->Estimators[i] == "gower") { 
-                    sumCalculators.push_back(new Gower());
-                }else if (pDataArray->Estimators[i] == "memchi2") { 
-                    sumCalculators.push_back(new MemChi2());
-                }else if (pDataArray->Estimators[i] == "memchord") { 
-                    sumCalculators.push_back(new MemChord());
-                }else if (pDataArray->Estimators[i] == "memeuclidean") { 
-                    sumCalculators.push_back(new MemEuclidean());
-                }else if (pDataArray->Estimators[i] == "mempearson") { 
-                    sumCalculators.push_back(new MemPearson());
-                }
-            }
-        }
-        
-        pDataArray->calcDists.resize(sumCalculators.size());
-        
-               ofstream outputFileHandle;
-               pDataArray->m->openOutputFile(pDataArray->sumFile, outputFileHandle);
-               
-               vector<SharedRAbundVector*> subset;
-               for (int k = pDataArray->start; k < pDataArray->end; k++) { // pass cdd each set of groups to compare
-            
-                       for (int l = 0; l < k; l++) {
-                               
-                               outputFileHandle << pDataArray->thisLookup[0]->getLabel() << '\t';
-                               
-                               subset.clear(); //clear out old pair of sharedrabunds
-                               //add new pair of sharedrabunds
-                               subset.push_back(pDataArray->thisLookup[k]); subset.push_back(pDataArray->thisLookup[l]); 
-                               
-                               //sort groups to be alphanumeric
-                               if (pDataArray->thisLookup[k]->getGroup() > pDataArray->thisLookup[l]->getGroup()) {
-                                       outputFileHandle << (pDataArray->thisLookup[l]->getGroup() +'\t' + pDataArray->thisLookup[k]->getGroup()) << '\t'; //print out groups
-                               }else{
-                                       outputFileHandle << (pDataArray->thisLookup[k]->getGroup() +'\t' + pDataArray->thisLookup[l]->getGroup()) << '\t'; //print out groups
-                               }
-                               
-                               for(int i=0;i<sumCalculators.size();i++) {
-                                       
-                                       //if this calc needs all groups to calculate the pair load all groups
-                                       if (sumCalculators[i]->getNeedsAll()) { 
-                                               //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                               for (int w = 0; w < pDataArray->thisLookup.size(); w++) {
-                                                       if ((w != k) && (w != l)) { subset.push_back(pDataArray->thisLookup[w]); }
-                                               }
-                                       }
-                                       
-                                       vector<double> tempdata = sumCalculators[i]->getValues(subset); //saves the calculator outputs
-                                       
-                                       if (pDataArray->m->control_pressed) { for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; } outputFileHandle.close(); return 1; }
-                                       
-                                       outputFileHandle << '\t';
-                                       sumCalculators[i]->print(outputFileHandle);
-                                       
-                                       seqDist temp(l, k, tempdata[0]);
-                                       pDataArray->calcDists[i].push_back(temp);
-                               }
-                               outputFileHandle << endl;
-                       }
-               }
-               
-               outputFileHandle.close();
-        for(int i=0;i<sumCalculators.size();i++){  delete sumCalculators[i]; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "SummarySharedCommand", "MySummarySharedThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-#endif
diff --git a/summarytaxcommand.cpp b/summarytaxcommand.cpp
deleted file mode 100644 (file)
index ffa3041..0000000
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- *  summarytaxcommand.cpp
- *  Mothur
- *
- *  Created by westcott on 9/23/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "summarytaxcommand.h"
-#include "phylosummary.h"
-
-//**********************************************************************************************************************
-vector<string> SummaryTaxCommand::setParameters(){     
-       try {
-               CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptaxonomy);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter preftaxonomy("reftaxonomy", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(preftaxonomy);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string SummaryTaxCommand::getHelpString(){     
-       try {
-               string helpString = "";
-               helpString += "The summary.tax command reads a taxonomy file and an optional name file, and summarizes the taxonomy information.\n";
-               helpString += "The summary.tax command parameters are taxonomy, group and name. taxonomy is required, unless you have a valid current taxonomy file.\n";
-               helpString += "The name parameter allows you to enter a name file associated with your taxonomy file. \n";
-               helpString += "The group parameter allows you add a group file so you can have the summary totals broken up by group.\n";
-               helpString += "The reftaxonomy parameter allows you give the name of the reference taxonomy file used when you classified your sequences. It is not required, but providing it will keep the rankIDs in the summary file static.\n";
-               helpString += "The summary.tax command should be in the following format: \n";
-               helpString += "summary.tax(taxonomy=yourTaxonomyFile) \n";
-               helpString += "Note: No spaces between parameter labels (i.e. taxonomy), '=' and parameters (i.e.yourTaxonomyFile).\n"; 
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-SummaryTaxCommand::SummaryTaxCommand(){        
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["summary"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "SummaryTaxCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-SummaryTaxCommand::SummaryTaxCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("taxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["taxonomy"] = inputDir + it->second;         }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("reftaxonomy");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["reftaxonomy"] = inputDir + it->second;              }
-                               }
-                               
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["summary"] = tempOutNames;
-                       
-                       //check for required parameters
-                       taxfile = validParameter.validFile(parameters, "taxonomy", true);
-                       if (taxfile == "not open") { abort = true; }
-                       else if (taxfile == "not found") {                              
-                               taxfile = m->getTaxonomyFile(); 
-                               if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else { m->setTaxonomyFile(taxfile); }  
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = "";  }   
-                       else { m->setNameFile(namefile); }
-                       
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { groupfile = ""; abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       refTaxonomy = validParameter.validFile(parameters, "reftaxonomy", true);
-                       if (refTaxonomy == "not found") { refTaxonomy = ""; m->mothurOut("reftaxonomy is not required, but if given will keep the rankIDs in the summary file static."); m->mothurOutEndLine(); }
-                       else if (refTaxonomy == "not open") { refTaxonomy = ""; abort = true; }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(taxfile); //if user entered a file with a path then preserve it 
-                       }
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(taxfile);
-                               parser.getNameFile(files);
-                       }
-                       
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "SummaryTaxCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int SummaryTaxCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               int start = time(NULL);
-               
-               PhyloSummary* taxaSum;
-               if (refTaxonomy != "") {
-                       taxaSum = new PhyloSummary(refTaxonomy, groupfile);
-               }else {
-                       taxaSum = new PhyloSummary(groupfile);
-               }
-               
-               if (m->control_pressed) { delete taxaSum; return 0; }
-               
-               int numSeqs = 0;
-               if (namefile == "") { numSeqs = taxaSum->summarize(taxfile);  }
-               else {
-                       map<string, vector<string> > nameMap;
-                       map<string, vector<string> >::iterator itNames;
-                       m->readNames(namefile, nameMap);
-                       
-                       if (m->control_pressed) { delete taxaSum; return 0; }
-                       
-                       ifstream in;
-                       m->openInputFile(taxfile, in);
-                       
-                       //read in users taxonomy file and add sequences to tree
-                       string name, taxon;
-                       
-                       while(!in.eof()){
-                               in >> name >> taxon; m->gobble(in);
-                               
-                               itNames = nameMap.find(name);
-                               
-                               if (itNames == nameMap.end()) { 
-                                       m->mothurOut("[ERROR]: " + name + " is not in your name file please correct."); m->mothurOutEndLine(); exit(1);
-                               }else{
-                                       for (int i = 0; i < itNames->second.size(); i++) { 
-                                               numSeqs++;
-                                               taxaSum->addSeqToTree(itNames->second[i], taxon);  //add it as many times as there are identical seqs
-                                       }
-                                       itNames->second.clear();
-                                       nameMap.erase(itNames->first);
-                               }
-                       }
-                       in.close();
-               }
-               
-               if (m->control_pressed) {  delete taxaSum; return 0; }
-               
-               //print summary file
-               ofstream outTaxTree;
-               string summaryFile = outputDir + m->getRootName(m->getSimpleName(taxfile)) + "tax.summary";
-               m->openOutputFile(summaryFile, outTaxTree);
-               taxaSum->print(outTaxTree);
-               outTaxTree.close();
-               
-               delete taxaSum;
-               
-               if (m->control_pressed) {  m->mothurRemove(summaryFile); return 0; }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to create the summary file for " + toString(numSeqs) + " sequences."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Name: "); m->mothurOutEndLine();
-               m->mothurOut(summaryFile); m->mothurOutEndLine();       outputNames.push_back(summaryFile); outputTypes["summary"].push_back(summaryFile);
-               m->mothurOutEndLine();
-                                       
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SummaryTaxCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************/
-
-
diff --git a/summarytaxcommand.h b/summarytaxcommand.h
deleted file mode 100644 (file)
index b5bdab1..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef SUMMARYTAXCOMMAND_H
-#define SUMMARYTAXCOMMAND_H
-
-/*
- *  summarytaxcommand.h
- *  Mothur
- *
- *  Created by westcott on 9/23/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-/**************************************************************************************************/
-
-class SummaryTaxCommand : public Command {
-       public:
-               SummaryTaxCommand(string);
-               SummaryTaxCommand();
-               ~SummaryTaxCommand(){}
-               
-               vector<string> setParameters();
-               string getCommandName()                 { return "summary.tax";                 }
-               string getCommandCategory()             { return "Phylotype Analysis";          }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/Summary.tax"; }
-               string getDescription()         { return "summarize the taxonomies of a set of sequences"; }
-               
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-               
-       private:
-               bool abort;
-               string taxfile, outputDir, namefile, groupfile, refTaxonomy;
-               vector<string> outputNames;
-               map<string, int> nameMap;
-};
-
-/**************************************************************************************************/
-
-
-#endif
diff --git a/systemcommand.cpp b/systemcommand.cpp
deleted file mode 100644 (file)
index c07deff..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- *  systemcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "systemcommand.h"
-
-//**********************************************************************************************************************
-vector<string> SystemCommand::setParameters(){ 
-       try {
-               CommandParameter pcommand("command", "String", "", "", "", "", "",false,false); parameters.push_back(pcommand);
-                               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SystemCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-SystemCommand::SystemCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser.getParameters();
-                       map<string, string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string commandOption = validParameter.validFile(parameters, "command", false);                  
-                       if (commandOption == "not found") { commandOption = ""; }
-                       else { command = commandOption; }
-                       
-                       if ((option == "") && (commandOption == "")) { m->mothurOut("You must enter a command to run."); m->mothurOutEndLine(); abort = true; }
-                       else if (commandOption == "") { 
-                               //check for outputdir and inputdir parameters
-                               int commaPos = option.find_first_of(',');
-                               
-                               //if there is a comma then grab string up to that pos
-                               if (commaPos != option.npos) {
-                                       option = option.substr(0, commaPos);
-                               }
-                       
-                               command = option;
-                       }
-               }       
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SystemCommand", "SystemCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-string SystemCommand::getHelpString(){
-       try {
-               string helpString = "";
-               helpString += "The system command allows you to execute a system command from within mothur.\n";
-               helpString += "The system has no parameters.\n";
-               helpString += "The system command should be in the following format: system(yourCommand).\n";
-               helpString += "Example system(clear).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "SystemCommand", "help");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-int SystemCommand::execute(){
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               //if command contains a redirect don't add the redirect
-               bool usedRedirect = false;
-               if ((command.find('>')) == string::npos) {
-                       command += " > ./commandScreen.output 2>&1";
-                       usedRedirect = true;
-               }
-               
-               system(command.c_str());
-               
-               if (usedRedirect) {
-                       ifstream in;
-                       string filename = "./commandScreen.output";
-                       m->openInputFile(filename, in, "no error");
-                       
-                       string output = "";
-                       while(char c = in.get()){
-                               if(in.eof())            {       break;                  }
-                               else                            {       output += c;    }
-                       }
-                       in.close();
-                       
-                       m->mothurOut(output); m->mothurOutEndLine();
-                       m->mothurRemove(filename);
-               }
-               
-               return 0;               
-       }
-
-       catch(exception& e) {
-               m->errorOut(e, "SystemCommand", "execute");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/systemcommand.h b/systemcommand.h
deleted file mode 100644 (file)
index 6a4b884..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef SYSTEMCOMMAND_H
-#define SYSTEMCOMMAND_H
-
-/*
- *  systemcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 7/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-
-
-class SystemCommand : public Command {
-       
-       public:
-       
-               SystemCommand(string);  
-               SystemCommand() { setParameters(); abort = true; calledHelp = true; }
-               ~SystemCommand(){}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "system";              }
-               string getCommandCategory()             { return "General";             }
-               string getHelpString(); 
-               string getCitation() { return "http://www.mothur.org/wiki/System"; }
-               string getDescription()         { return "execute system commands from within mothur"; }
-
-               int execute(); 
-               void help() { m->mothurOut(getHelpString()); }  
-       
-       private:
-               string command;
-               bool abort;
-               vector<string> outputNames;
-               
-               
-};
-
-#endif
-
diff --git a/taxonomyequalizer.cpp b/taxonomyequalizer.cpp
deleted file mode 100644 (file)
index c050726..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- *  taxonomyequalizer.cpp
- *  Mothur
- *
- *  Created by westcott on 11/20/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "taxonomyequalizer.h"
-
-/**************************************************************************************************/
-TaxEqualizer::TaxEqualizer(string tfile, int c, string o) : cutoff(c), outputDir(o) {
-       try {
-               m = MothurOut::getInstance();
-               containsConfidence = false;
-               
-               ifstream inTax;
-               m->openInputFile(tfile, inTax);
-       
-               highestLevel = getHighestLevel(inTax);
-               
-               if (!m->control_pressed) { 
-                       
-                       //if the user has specified a cutoff and it's smaller than the highest level
-                       if ((cutoff != -1) && (cutoff < highestLevel)) { 
-                               highestLevel = cutoff;
-                       }else if (cutoff > highestLevel) {
-                               m->mothurOut("The highest level taxonomy you have is " + toString(highestLevel) + " and your cutoff is " + toString(cutoff) + ". I will set the cutoff to " + toString(highestLevel));
-                               m->mothurOutEndLine();
-                       }
-                       
-                       inTax.close(); 
-                       ifstream in; 
-                       m->openInputFile(tfile, in);
-                       
-                       ofstream out;
-                       equalizedFile = outputDir + m->getRootName(m->getSimpleName(tfile)) + "equalized.taxonomy";
-                       m->openOutputFile(equalizedFile, out);
-                       
-       
-                       string name, tax;
-                       while (in) {
-                       
-                               if (m->control_pressed) {  break; }
-                               
-                               in >> name >> tax;   m->gobble(in);
-                               
-                               if (containsConfidence) {  m->removeConfidences(tax);   }
-                               
-                               //is this a taxonomy that needs to be extended?
-                               if (seqLevels[name] < highestLevel) {
-                                       extendTaxonomy(name, tax, highestLevel);
-                               }else if (seqLevels[name] > highestLevel) { //this can happen if the user enters a cutoff
-                                       truncateTaxonomy(name, tax, highestLevel);
-                               }
-                               
-                               out << name << '\t' << tax << endl;
-                       }
-                       
-                       in.close();
-                       out.close();
-                       
-                       if (m->control_pressed) { m->mothurRemove(equalizedFile);  }
-               }else { inTax.close(); }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TaxEqualizer", "TaxEqualizer");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int TaxEqualizer::getHighestLevel(ifstream& in) {
-       try {
-               
-               int level = 0;
-               string name, tax;
-               
-               while (in) {
-                       in >> name >> tax;   m->gobble(in);
-               
-                       //count levels in this taxonomy
-                       int thisLevel = 0;
-                       for (int i = 0; i < tax.length(); i++) {
-                               if (tax[i] == ';') {  thisLevel++;      }
-                       }
-               
-                       //save sequences level
-                       seqLevels[name] = thisLevel;
-       
-                       //is this the longest taxonomy?
-                       if (thisLevel > level) {  
-                               level = thisLevel;  
-                               testTax = tax; //testTax is used to figure out if this file has confidences we need to strip out
-                       } 
-               }
-               
-               int pos = testTax.find_first_of('(');
-
-               //if there are '(' then there are confidences we need to take out
-               if (pos != -1) {  containsConfidence = true;  }
-       
-               return level;
-                                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TaxEqualizer", "getHighestLevel");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void TaxEqualizer::extendTaxonomy(string name, string& tax, int desiredLevel) {
-       try {
-                       
-               //get last taxon
-               tax = tax.substr(0, tax.length()-1);  //take off final ";"
-               int pos = tax.find_last_of(';');
-               string lastTaxon = tax.substr(pos+1);  
-               lastTaxon += ";"; //add back on delimiting char
-               tax += ";";
-               
-               int currentLevel = seqLevels[name];
-               
-               //added last taxon until you get desired level
-               for (int i = currentLevel; i < desiredLevel; i++) {
-                       tax += lastTaxon;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TaxEqualizer", "extendTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void TaxEqualizer::truncateTaxonomy(string name, string& tax, int desiredLevel) {
-       try {
-                       
-               int currentLevel = seqLevels[name];
-               tax = tax.substr(0, tax.length()-1);  //take off final ";"
-               
-               //remove a taxon until you get to desired level
-               for (int i = currentLevel; i > desiredLevel; i--) {
-                       tax = tax.substr(0,  tax.find_last_of(';'));
-               }
-               
-               tax += ";";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TaxEqualizer", "truncateTaxonomy");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
diff --git a/taxonomyequalizer.h b/taxonomyequalizer.h
deleted file mode 100644 (file)
index 191267c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef TAXONOMYEQUALIZER_H
-#define TAXONOMYEQUALIZER_H
-
-
-/*
- *  taxonomyequalizer.h
- *  Mothur
- *
- *  Created by westcott on 11/20/09.
- *  Copyright 2009 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-//reads in taxonomy file and makes all the taxonomies the same length 
-//by appending the last taxon to a given taxonomy as many times as needed to 
-//make it as long as the longest taxonomy in the file 
-
-/**************************************************************************************************/
-
-class TaxEqualizer  {
-       
-public:
-       TaxEqualizer(string, int, string);
-       ~TaxEqualizer() {};
-       
-       string getEqualizedTaxFile()    {       return equalizedFile;   }
-       int getHighestLevel()                   {       return highestLevel;    }
-       
-       
-private:
-       string equalizedFile, testTax, outputDir;
-       bool containsConfidence;
-       int cutoff, highestLevel;
-       map<string, int> seqLevels;  //maps name to level of taxonomy
-       
-       int getHighestLevel(ifstream&);  //scans taxonomy file to find taxonomy with highest level
-       void extendTaxonomy(string, string&, int);  //name, taxonomy, desired level
-       void truncateTaxonomy(string, string&, int);  //name, taxonomy, desired level
-       MothurOut* m;
-       
-};
-
-/**************************************************************************************************/
-
-
-#endif
-
-
diff --git a/tree.cpp b/tree.cpp
deleted file mode 100644 (file)
index d9b4a9c..0000000
--- a/tree.cpp
+++ /dev/null
@@ -1,1337 +0,0 @@
-/*
- *  tree.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "tree.h"
-
-/*****************************************************************/
-Tree::Tree(int num, TreeMap* t) : tmap(t) {
-       try {
-               m = MothurOut::getInstance();
-               
-               numLeaves = num;  
-               numNodes = 2*numLeaves - 1;
-        
-               tree.resize(numNodes);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "Tree - numNodes");
-               exit(1);
-       }
-}
-/*****************************************************************/
-Tree::Tree(string g) { //do not use tree generated by this its just to extract the treenames, its a chicken before the egg thing that needs to be revisited.
-       try {
-               m = MothurOut::getInstance();
-               parseTreeFile();  m->runParse = false;  
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "Tree - just parse");
-               exit(1);
-       }
-}
-/*****************************************************************/
-Tree::Tree(TreeMap* t) : tmap(t) {
-       try {
-               m = MothurOut::getInstance();
-               
-               if (m->runParse == true) {  parseTreeFile();  m->runParse = false;  }
-//for(int i = 0; i <   globaldata->Treenames.size(); i++) { cout << i << '\t' << globaldata->Treenames[i] << endl;  }  
-               numLeaves = m->Treenames.size();
-               numNodes = 2*numLeaves - 1;
-               
-               tree.resize(numNodes);
-                       
-               //initialize groupNodeInfo
-               for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
-                       groupNodeInfo[(tmap->getNamesOfGroups())[i]].resize(0);
-               }
-               
-               //initialize tree with correct number of nodes, name and group info.
-               for (int i = 0; i < numNodes; i++) {
-                       //initialize leaf nodes
-                       if (i <= (numLeaves-1)) {
-                               tree[i].setName(m->Treenames[i]);
-                               
-                               //save group info
-                               string group = tmap->getGroup(m->Treenames[i]);
-                               
-                               vector<string> tempGroups; tempGroups.push_back(group);
-                               tree[i].setGroup(tempGroups);
-                               groupNodeInfo[group].push_back(i); 
-                               
-                               //set pcount and pGroup for groupname to 1.
-                               tree[i].pcount[group] = 1;
-                               tree[i].pGroups[group] = 1;
-                               
-                               //Treemap knows name, group and index to speed up search
-                               tmap->setIndex(m->Treenames[i], i);
-       
-                       //intialize non leaf nodes
-                       }else if (i > (numLeaves-1)) {
-                               tree[i].setName("");
-                               vector<string> tempGroups;
-                               tree[i].setGroup(tempGroups);
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "Tree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-Tree::Tree(TreeMap* t, vector< vector<double> >& sims) : tmap(t) {
-       try {
-               m = MothurOut::getInstance();
-               
-               if (m->runParse == true) {  parseTreeFile();  m->runParse = false;  }
-               numLeaves = m->Treenames.size();
-               numNodes = 2*numLeaves - 1;
-               
-               tree.resize(numNodes);
-        
-               //initialize groupNodeInfo
-               for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
-                       groupNodeInfo[(tmap->getNamesOfGroups())[i]].resize(0);
-               }
-               
-               //initialize tree with correct number of nodes, name and group info.
-               for (int i = 0; i < numNodes; i++) {
-                       //initialize leaf nodes
-                       if (i <= (numLeaves-1)) {
-                               tree[i].setName(m->Treenames[i]);
-                               
-                               //save group info
-                               string group = tmap->getGroup(m->Treenames[i]);
-                               
-                               vector<string> tempGroups; tempGroups.push_back(group);
-                               tree[i].setGroup(tempGroups);
-                               groupNodeInfo[group].push_back(i); 
-                               
-                               //set pcount and pGroup for groupname to 1.
-                               tree[i].pcount[group] = 1;
-                               tree[i].pGroups[group] = 1;
-                               
-                               //Treemap knows name, group and index to speed up search
-                               tmap->setIndex(m->Treenames[i], i);
-                
-                //intialize non leaf nodes
-                       }else if (i > (numLeaves-1)) {
-                               tree[i].setName("");
-                               vector<string> tempGroups;
-                               tree[i].setGroup(tempGroups);
-                       }
-               }
-        
-        //build tree from matrix
-        //initialize indexes
-        map<int, int> indexes;  //maps row in simMatrix to vector index in the tree
-        for (int g = 0; g < numLeaves; g++) {  indexes[g] = g; }
-               
-               //do merges and create tree structure by setting parents and children
-               //there are numGroups - 1 merges to do
-               for (int i = 0; i < (numLeaves - 1); i++) {
-                       float largest = -1000.0;
-                       
-                       if (m->control_pressed) { break; }
-                       
-                       int row, column;
-                       //find largest value in sims matrix by searching lower triangle
-                       for (int j = 1; j < sims.size(); j++) {
-                               for (int k = 0; k < j; k++) {
-                                       if (sims[j][k] > largest) {  largest = sims[j][k]; row = j; column = k;  }
-                               }
-                       }
-            
-                       //set non-leaf node info and update leaves to know their parents
-                       //non-leaf
-                       tree[numLeaves + i].setChildren(indexes[row], indexes[column]);
-                       
-                       //parents
-                       tree[indexes[row]].setParent(numLeaves + i);
-                       tree[indexes[column]].setParent(numLeaves + i);
-                       
-                       //blength = distance / 2;
-                       float blength = ((1.0 - largest) / 2);
-                       
-                       //branchlengths
-                       tree[indexes[row]].setBranchLength(blength - tree[indexes[row]].getLengthToLeaves());
-                       tree[indexes[column]].setBranchLength(blength - tree[indexes[column]].getLengthToLeaves());
-                       
-                       //set your length to leaves to your childs length plus branchlength
-                       tree[numLeaves + i].setLengthToLeaves(tree[indexes[row]].getLengthToLeaves() + tree[indexes[row]].getBranchLength());
-                       
-                       
-                       //update index 
-                       indexes[row] = numLeaves+i;
-                       indexes[column] = numLeaves+i;
-                       
-                       //remove highest value that caused the merge.
-                       sims[row][column] = -1000.0;
-                       sims[column][row] = -1000.0;
-                       
-                       //merge values in simsMatrix
-                       for (int n = 0; n < sims.size(); n++)   {
-                               //row becomes merge of 2 groups
-                               sims[row][n] = (sims[row][n] + sims[column][n]) / 2;
-                               sims[n][row] = sims[row][n];
-                               //delete column
-                               sims[column][n] = -1000.0;
-                               sims[n][column] = -1000.0;
-                       }
-               }
-               
-               //adjust tree to make sure root to tip length is .5
-               int root = findRoot();
-               tree[root].setBranchLength((0.5 - tree[root].getLengthToLeaves()));
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "Tree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-Tree::~Tree() {}
-/*****************************************************************/
-void Tree::addNamesToCounts(map<string, string> nameMap) {
-       try {
-               //ex. seq1      seq2,seq3,se4
-               //              seq1 = pasture
-               //              seq2 = forest
-               //              seq4 = pasture
-               //              seq3 = ocean
-               
-               //before this function seq1.pcount = pasture -> 1
-               //after                            seq1.pcount = pasture -> 2, forest -> 1, ocean -> 1
-               
-               //before this function seq1.pgroups = pasture -> 1
-               //after                            seq1.pgroups = pasture -> 1 since that is the dominant group
-
-                               
-               //go through each leaf and update its pcounts and pgroups
-               
-               //float A = clock();
-
-               for (int i = 0; i < numLeaves; i++) {
-
-                       string name = tree[i].getName();
-               
-                       map<string, string>::iterator itNames = nameMap.find(name);
-               
-                       if (itNames == nameMap.end()) { m->mothurOut(name + " is not in your name file, please correct."); m->mothurOutEndLine(); exit(1);  }
-                       else {
-                               vector<string> dupNames;
-                               m->splitAtComma(nameMap[name], dupNames);
-                               
-                               map<string, int>::iterator itCounts;
-                               int maxPars = 1;
-                               set<string> groupsAddedForThisNode;
-                               for (int j = 0; j < dupNames.size(); j++) {
-                                       
-                                       string group = tmap->getGroup(dupNames[j]);
-                                       
-                                       if (dupNames[j] != name) {//you already added yourself in the constructor
-                               
-                                               if (groupsAddedForThisNode.count(group) == 0)  {  groupNodeInfo[group].push_back(i);  groupsAddedForThisNode.insert(group);  } //if you have not already added this node for this group, then add it
-                                               
-                                               //update pcounts
-                                               itCounts = tree[i].pcount.find(group);
-                                               if (itCounts == tree[i].pcount.end()) { //new group, add it
-                                                       tree[i].pcount[group] = 1;
-                                               }else {
-                                                       tree[i].pcount[group]++;
-                                               }
-                                                       
-                                               //update pgroups
-                                               itCounts = tree[i].pGroups.find(group);
-                                               if (itCounts == tree[i].pGroups.end()) { //new group, add it
-                                                       tree[i].pGroups[group] = 1;
-                                               }else{
-                                                       tree[i].pGroups[group]++;
-                                               }
-                                               
-                                               //keep highest group
-                                               if(tree[i].pGroups[group] > maxPars){
-                                                       maxPars = tree[i].pGroups[group];
-                                               }
-                                       }else {  groupsAddedForThisNode.insert(group);  } //add it so you don't add it to groupNodeInfo again
-                               }//end for
-                               
-                               if (maxPars > 1) { //then we have some more dominant groups
-                                       //erase all the groups that are less than maxPars because you found a more dominant group.
-                                       for(it=tree[i].pGroups.begin();it!=tree[i].pGroups.end();){
-                                               if(it->second < maxPars){
-                                                       tree[i].pGroups.erase(it++);
-                                               }else { it++; }
-                                       }
-                                       //set one remaining groups to 1
-                                       for(it=tree[i].pGroups.begin();it!=tree[i].pGroups.end();it++){
-                                               tree[i].pGroups[it->first] = 1;
-                                       }
-                               }//end if
-                               
-                               //update groups to reflect all the groups this node represents
-                               vector<string> nodeGroups;
-                               map<string, int>::iterator itGroups;
-                               for (itGroups = tree[i].pcount.begin(); itGroups != tree[i].pcount.end(); itGroups++) {
-                                       nodeGroups.push_back(itGroups->first);
-                               }
-                               tree[i].setGroup(nodeGroups);
-                               
-                       }//end else
-               }//end for              
-               
-               //float B = clock();
-               //cout << "addNamesToCounts\t" << (B - A) / CLOCKS_PER_SEC << endl;     
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "addNamesToCounts");
-               exit(1);
-       }
-}
-/*****************************************************************/
-int Tree::getIndex(string searchName) {
-       try {
-               //Treemap knows name, group and index to speed up search
-               // getIndex function will return the vector index or -1 if seq is not found.
-               int index = tmap->getIndex(searchName);
-               return index;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "getIndex");
-               exit(1);
-       }
-}
-/*****************************************************************/
-
-void Tree::setIndex(string searchName, int index) {
-       try {
-               //set index in treemap
-               tmap->setIndex(searchName, index);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "setIndex");
-               exit(1);
-       }
-}
-/*****************************************************************/
-int Tree::assembleTree(map<string, string> nameMap) {
-       try {
-               //save for later
-        names = nameMap;
-
-               //if user has given a names file we want to include that info in the pgroups and pcount info.
-               if(nameMap.size() != 0) {  addNamesToCounts(nameMap);  }
-               
-               //build the pGroups in non leaf nodes to be used in the parsimony calcs.
-               for (int i = numLeaves; i < numNodes; i++) {
-                       if (m->control_pressed) { return 1; }
-
-                       tree[i].pGroups = (mergeGroups(i));
-                       tree[i].pcount = (mergeGcounts(i));
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "assembleTree");
-               exit(1);
-       }
-}
-/*****************************************************************
-int Tree::assembleTree(string n) {
-       try {
-               
-               //build the pGroups in non leaf nodes to be used in the parsimony calcs.
-               for (int i = numLeaves; i < numNodes; i++) {
-                       if (m->control_pressed) { return 1; }
-
-                       tree[i].pGroups = (mergeGroups(i));
-                       tree[i].pcount = (mergeGcounts(i));
-               }
-               //float B = clock();
-               //cout << "assembleTree\t" << (B-A) / CLOCKS_PER_SEC << endl;
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "assembleTree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-//assumes leaf node names are in groups and no names file - used by indicator command
-void Tree::getSubTree(Tree* Ctree, vector<string> Groups) {
-       try {
-        
-        //copy Tree since we are going to destroy it
-        Tree* copy = new Tree(tmap);
-        copy->getCopy(Ctree);
-        map<string, string> empty;
-        copy->assembleTree(empty);
-        
-               //we want to select some of the leaf nodes to create the output tree
-               //go through the input Tree starting at parents of leaves
-               for (int i = 0; i < numNodes; i++) {
-                       
-                       //initialize leaf nodes
-                       if (i <= (numLeaves-1)) {
-                               tree[i].setName(Groups[i]);
-                               
-                               //save group info
-                               string group = tmap->getGroup(Groups[i]);
-                               vector<string> tempGroups; tempGroups.push_back(group);
-                               tree[i].setGroup(tempGroups);
-                               groupNodeInfo[group].push_back(i); 
-                               
-                               //set pcount and pGroup for groupname to 1.
-                               tree[i].pcount[group] = 1;
-                               tree[i].pGroups[group] = 1;
-                               
-                               //Treemap knows name, group and index to speed up search
-                               tmap->setIndex(Groups[i], i);
-                               
-                               //intialize non leaf nodes
-                       }else if (i > (numLeaves-1)) {
-                               tree[i].setName("");
-                               vector<string> tempGroups;
-                               tree[i].setGroup(tempGroups);
-                       }
-               }
-               
-               set<int> removedLeaves;
-               for (int i = 0; i < copy->getNumLeaves(); i++) {
-                       
-                       if (removedLeaves.count(i) == 0) {
-                       
-                       //am I in the group
-                       int parent = copy->tree[i].getParent();
-                       
-                       if (parent != -1) {
-                               
-                               if (m->inUsersGroups(copy->tree[i].getName(), Groups)) {
-                                       //find my siblings name
-                                       int parentRC = copy->tree[parent].getRChild();
-                                       int parentLC = copy->tree[parent].getLChild();
-                                       
-                                       //if I am the right child, then my sib is the left child
-                                       int sibIndex = parentRC;
-                                       if (parentRC == i) { sibIndex = parentLC; }
-                                       
-                                       string sibsName = copy->tree[sibIndex].getName();
-                                       
-                                       //if yes, is my sibling
-                                       if ((m->inUsersGroups(sibsName, Groups)) || (sibsName == "")) {
-                                               //we both are okay no trimming required
-                                       }else{
-                                               //i am, my sib is not, so remove sib by setting my parent to my grandparent
-                                               int grandparent = copy->tree[parent].getParent();
-                                               int grandparentLC = copy->tree[grandparent].getLChild();
-                                               int grandparentRC = copy->tree[grandparent].getRChild();
-                                               
-                                               //whichever of my granparents children was my parent now equals me
-                                               if (grandparentLC == parent) { grandparentLC = i; }
-                                               else { grandparentRC = i; }
-                                               
-                                               copy->tree[i].setParent(grandparent);
-                                               copy->tree[i].setBranchLength((copy->tree[i].getBranchLength()+copy->tree[parent].getBranchLength()));
-                                               if (grandparent != -1) {
-                                                       copy->tree[grandparent].setChildren(grandparentLC, grandparentRC);
-                                               }
-                                               removedLeaves.insert(sibIndex);
-                                       }
-                               }else{
-                                       //find my siblings name
-                                       int parentRC = copy->tree[parent].getRChild();
-                                       int parentLC = copy->tree[parent].getLChild();
-                                       
-                                       //if I am the right child, then my sib is the left child
-                                       int sibIndex = parentRC;
-                                       if (parentRC == i) { sibIndex = parentLC; }
-                                       
-                                       string sibsName = copy->tree[sibIndex].getName();
-                                       
-                                       //if no is my sibling
-                                       if ((m->inUsersGroups(sibsName, Groups)) || (sibsName == "")) {
-                                               //i am not, but my sib is
-                                               int grandparent = copy->tree[parent].getParent();
-                                               int grandparentLC = copy->tree[grandparent].getLChild();
-                                               int grandparentRC = copy->tree[grandparent].getRChild();
-                                               
-                                               //whichever of my granparents children was my parent now equals my sib
-                                               if (grandparentLC == parent) { grandparentLC = sibIndex; }
-                                               else { grandparentRC = sibIndex; }
-                                               
-                                               copy->tree[sibIndex].setParent(grandparent);
-                                               copy->tree[sibIndex].setBranchLength((copy->tree[sibIndex].getBranchLength()+copy->tree[parent].getBranchLength()));
-                                               if (grandparent != -1) {
-                                                       copy->tree[grandparent].setChildren(grandparentLC, grandparentRC);
-                                               }
-                                               removedLeaves.insert(i);
-                                       }else{
-                                               //neither of us are, so we want to eliminate ourselves and our parent
-                                               //so set our parents sib to our great-grandparent
-                                               int parent = copy->tree[i].getParent();
-                                               int grandparent = copy->tree[parent].getParent();
-                                               int parentsSibIndex;
-                                               if (grandparent != -1) {
-                                                       int greatgrandparent = copy->tree[grandparent].getParent();
-                                                       int greatgrandparentLC, greatgrandparentRC;
-                                                       if (greatgrandparent != -1) {
-                                                               greatgrandparentLC = copy->tree[greatgrandparent].getLChild();
-                                                               greatgrandparentRC = copy->tree[greatgrandparent].getRChild();
-                                                       }
-                                                       
-                                                       int grandparentLC = copy->tree[grandparent].getLChild();
-                                                       int grandparentRC = copy->tree[grandparent].getRChild();
-                                                       
-                                                       parentsSibIndex = grandparentLC;
-                                                       if (grandparentLC == parent) { parentsSibIndex = grandparentRC; }
-
-                                                       //whichever of my greatgrandparents children was my grandparent
-                                                       if (greatgrandparentLC == grandparent) { greatgrandparentLC = parentsSibIndex; }
-                                                       else { greatgrandparentRC = parentsSibIndex; }
-                                                       
-                                                       copy->tree[parentsSibIndex].setParent(greatgrandparent);
-                                                       copy->tree[parentsSibIndex].setBranchLength((copy->tree[parentsSibIndex].getBranchLength()+copy->tree[grandparent].getBranchLength()));
-                                                       if (greatgrandparent != -1) {
-                                                               copy->tree[greatgrandparent].setChildren(greatgrandparentLC, greatgrandparentRC);
-                                                       }
-                                               }else{
-                                                       copy->tree[parent].setParent(-1);
-                                                       //cout << "issues with making subtree" << endl;
-                                               }
-                                               removedLeaves.insert(sibIndex);
-                                               removedLeaves.insert(i);
-                                       }
-                               }
-                       }
-                       }
-               }
-               
-               int root = 0;
-               for (int i = 0; i < copy->getNumNodes(); i++) {
-                       //you found the root
-                       if (copy->tree[i].getParent() == -1) { root = i; break; }
-               }
-        
-               int nextSpot = numLeaves;
-               populateNewTree(copy->tree, root, nextSpot);
-        
-        delete copy;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "getSubTree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-//assumes nameMap contains unique names as key or is empty. 
-//assumes numLeaves defined in tree constructor equals size of seqsToInclude and seqsToInclude only contains unique seqs.
-int Tree::getSubTree(Tree* copy, vector<string> seqsToInclude, map<string, string> nameMap) {
-       try {
-        
-        if (numLeaves != seqsToInclude.size()) { m->mothurOut("[ERROR]: numLeaves does not equal numUniques, cannot create subtree.\n"); m->control_pressed = true; return 0; }
-        
-        getSubTree(copy, seqsToInclude);
-        if (nameMap.size() != 0) {  addNamesToCounts(nameMap);  }
-        
-        //build the pGroups in non leaf nodes to be used in the parsimony calcs.
-               for (int i = numLeaves; i < numNodes; i++) {
-                       if (m->control_pressed) { return 1; }
-            
-                       tree[i].pGroups = (mergeGroups(i));
-                       tree[i].pcount = (mergeGcounts(i));
-               }
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "getSubTree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-int Tree::populateNewTree(vector<Node>& oldtree, int node, int& index) {
-       try {
-               
-               if (oldtree[node].getLChild() != -1) {
-                       int rc = populateNewTree(oldtree, oldtree[node].getLChild(), index);
-                       int lc = populateNewTree(oldtree, oldtree[node].getRChild(), index);
-
-                       tree[index].setChildren(lc, rc);
-                       tree[rc].setParent(index);
-                       tree[lc].setParent(index);
-                       
-                       tree[index].setBranchLength(oldtree[node].getBranchLength());
-                       tree[rc].setBranchLength(oldtree[oldtree[node].getLChild()].getBranchLength());
-                       tree[lc].setBranchLength(oldtree[oldtree[node].getRChild()].getBranchLength());
-                       
-                       return (index++);
-               }else { //you are a leaf
-                       int indexInNewTree = tmap->getIndex(oldtree[node].getName());
-                       return indexInNewTree;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "populateNewTree");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::getCopy(Tree* copy) {
-       try {
-       
-               //for each node in the tree copy its info
-               for (int i = 0; i < numNodes; i++) {
-                       //copy name
-                       tree[i].setName(copy->tree[i].getName());
-               
-                       //copy group
-                       tree[i].setGroup(copy->tree[i].getGroup());
-                       
-                       //copy branch length
-                       tree[i].setBranchLength(copy->tree[i].getBranchLength());
-               
-                       //copy parent
-                       tree[i].setParent(copy->tree[i].getParent());
-               
-                       //copy children
-                       tree[i].setChildren(copy->tree[i].getLChild(), copy->tree[i].getRChild());
-               
-                       //copy index in node and tmap
-                       tree[i].setIndex(copy->tree[i].getIndex());
-                       setIndex(copy->tree[i].getName(), getIndex(copy->tree[i].getName()));
-                       
-                       //copy pGroups
-                       tree[i].pGroups = copy->tree[i].pGroups;
-               
-                       //copy pcount
-                       tree[i].pcount = copy->tree[i].pcount;
-               }
-               
-               groupNodeInfo = copy->groupNodeInfo;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "getCopy");
-               exit(1);
-       }
-}
-/*****************************************************************/
-//returns a map with a groupname and the number of times that group was seen in the children
-//for instance if your children are white and black then it would return a map with 2 entries
-// p[white] = 1 and p[black] = 1.  Now go up a level and merge that with a node who has p[white] = 1
-//and you get p[white] = 2, p[black] = 1, but you erase the p[black] because you have a p value higher than 1.
-
-map<string, int> Tree::mergeGroups(int i) {
-       try {
-               int lc = tree[i].getLChild();
-               int rc = tree[i].getRChild();
-
-               //set parsimony groups to left child
-               map<string,int> parsimony = tree[lc].pGroups;
-               
-               int maxPars = 1;
-
-               //look at right child groups and update maxPars if right child has something higher for that group.
-               for(it=tree[rc].pGroups.begin();it!=tree[rc].pGroups.end();it++){
-                       it2 = parsimony.find(it->first);
-                       if (it2 != parsimony.end()) {
-                               parsimony[it->first]++;
-                       }else {
-                               parsimony[it->first] = 1;
-                       }
-                       
-                       if(parsimony[it->first] > maxPars){
-                               maxPars = parsimony[it->first];
-                       }
-               }
-       
-               // this is true if right child had a greater parsimony for a certain group
-               if(maxPars > 1){
-                       //erase all the groups that are only 1 because you found something with 2.
-                       for(it=parsimony.begin();it!=parsimony.end();){
-                               if(it->second == 1){
-                                       parsimony.erase(it++);
-                               }else { it++; }
-                       }
-                       //set one remaining groups to 1
-                       //so with our above example p[white] = 2 would be left and it would become p[white] = 1
-                       for(it=parsimony.begin();it!=parsimony.end();it++){
-                               parsimony[it->first] = 1;
-                       }
-               
-               }
-       
-               return parsimony;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "mergeGroups");
-               exit(1);
-       }
-}
-/*****************************************************************/
-//returns a map with a groupname and the number of times that group was seen in the children
-//for instance if your children are white and black then it would return a map with 2 entries
-// p[white] = 1 and p[black] = 1.  Now go up a level and merge that with a node who has p[white] = 1
-//and you get p[white] = 2, p[black] = 1, but you erase the p[black] because you have a p value higher than 1.
-
-map<string, int> Tree::mergeUserGroups(int i, vector<string> g) {
-       try {
-       
-               int lc = tree[i].getLChild();
-               int rc = tree[i].getRChild();
-               
-               //loop through nodes groups removing the ones the user doesn't want
-               for(it=tree[lc].pGroups.begin();it!=tree[lc].pGroups.end();){
-                               if (m->inUsersGroups(it->first, g) != true) {
-                                       tree[lc].pGroups.erase(it++);
-                               }else { it++; }
-               }
-
-               //loop through nodes groups removing the ones the user doesn't want
-               for(it=tree[rc].pGroups.begin();it!=tree[rc].pGroups.end();){
-                               if (m->inUsersGroups(it->first, g) != true) {
-                                       tree[rc].pGroups.erase(it++);
-                               }else { it++; }
-               }
-
-               //set parsimony groups to left child
-               map<string,int> parsimony = tree[lc].pGroups;
-               
-               int maxPars = 1;
-
-               //look at right child groups and update maxPars if right child has something higher for that group.
-               for(it=tree[rc].pGroups.begin();it!=tree[rc].pGroups.end();it++){
-                       it2 = parsimony.find(it->first);
-                       if (it2 != parsimony.end()) {
-                               parsimony[it->first]++;
-                       }else {
-                               parsimony[it->first] = 1;
-                       }
-                       
-                       if(parsimony[it->first] > maxPars){
-                               maxPars = parsimony[it->first];
-                       }
-               }
-                       
-               // this is true if right child had a greater parsimony for a certain group
-               if(maxPars > 1){
-                       //erase all the groups that are only 1 because you found something with 2.
-                       for(it=parsimony.begin();it!=parsimony.end();){
-                               if(it->second == 1){
-                                       parsimony.erase(it++);
-                               }else { it++; }
-                       }
-
-                       for(it=parsimony.begin();it!=parsimony.end();it++){
-                               parsimony[it->first] = 1;
-                       }
-               }               
-               
-               return parsimony;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "mergeUserGroups");
-               exit(1);
-       }
-}
-
-
-/**************************************************************************************************/
-
-map<string,int> Tree::mergeGcounts(int position) {
-       try{
-               map<string,int>::iterator pos;
-       
-               int lc = tree[position].getLChild();
-               int rc = tree[position].getRChild();
-       
-               map<string,int> sum = tree[lc].pcount;
-    
-               for(it=tree[rc].pcount.begin();it!=tree[rc].pcount.end();it++){
-                       sum[it->first] += it->second;
-               }
-               return sum;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "mergeGcounts");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Tree::randomLabels(vector<string> g) {
-       try {
-       
-               //initialize groupNodeInfo
-               for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
-                       groupNodeInfo[(tmap->getNamesOfGroups())[i]].resize(0);
-               }
-               
-               for(int i = 0; i < numLeaves; i++){
-                       int z;
-                       //get random index to switch with
-                       z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));        
-                       
-                       //you only want to randomize the nodes that are from a group the user wants analyzed, so
-                       //if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them.
-                       bool treez, treei;
-               
-                       treez = m->inUsersGroups(tree[z].getGroup(), g);
-                       treei = m->inUsersGroups(tree[i].getGroup(), g);
-                       
-                       if ((treez == true) && (treei == true)) {
-                               //switches node i and node z's info.
-                               map<string,int> lib_hold = tree[z].pGroups;
-                               tree[z].pGroups = (tree[i].pGroups);
-                               tree[i].pGroups = (lib_hold);
-                               
-                               vector<string> zgroup = tree[z].getGroup();
-                               tree[z].setGroup(tree[i].getGroup());
-                               tree[i].setGroup(zgroup);
-                               
-                               string zname = tree[z].getName();
-                               tree[z].setName(tree[i].getName());
-                               tree[i].setName(zname);
-                               
-                               map<string,int> gcount_hold = tree[z].pcount;
-                               tree[z].pcount = (tree[i].pcount);
-                               tree[i].pcount = (gcount_hold);
-                       }
-                       
-                       for (int k = 0; k < (tree[i].getGroup()).size(); k++) {  groupNodeInfo[(tree[i].getGroup())[k]].push_back(i); }
-                       for (int k = 0; k < (tree[z].getGroup()).size(); k++) {  groupNodeInfo[(tree[z].getGroup())[k]].push_back(z); }
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "randomLabels");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-void Tree::randomBlengths()  {
-       try {
-               for(int i=numNodes-1;i>=0;i--){
-                       int z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));    
-               
-                       float bl_hold = tree[z].getBranchLength();
-                       tree[z].setBranchLength(tree[i].getBranchLength());
-                       tree[i].setBranchLength(bl_hold);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "randomBlengths");
-               exit(1);
-       }
-}
-/*************************************************************************************************/
-void Tree::assembleRandomUnifracTree(vector<string> g) {
-       randomLabels(g);
-    map<string, string> empty;
-       assembleTree(empty);
-}
-/*************************************************************************************************/
-void Tree::assembleRandomUnifracTree(string groupA, string groupB) {
-       vector<string> temp; temp.push_back(groupA); temp.push_back(groupB);
-       randomLabels(temp);
-    map<string, string> empty;
-       assembleTree(empty);
-}
-
-/*************************************************************************************************/
-//for now it's just random topology but may become random labels as well later that why this is such a simple function now...
-void Tree::assembleRandomTree() {
-       randomTopology();
-    map<string, string> empty;
-       assembleTree(empty);
-}
-/**************************************************************************************************/
-
-void Tree::randomTopology() {
-       try {
-               for(int i=0;i<numNodes;i++){
-                       tree[i].setParent(-1);
-               }
-               for(int i=numLeaves;i<numNodes;i++){
-                       tree[i].setChildren(-1, -1); 
-               }
-    
-               for(int i=numLeaves;i<numNodes;i++){
-                       int escape =0;
-                       int rnd_index1, rnd_index2;
-                       while(escape == 0){
-                               rnd_index1 = (int)(((double)rand() / (double) RAND_MAX)*i);
-                               if(tree[rnd_index1].getParent() == -1){escape = 1;}
-                       }
-               
-                       escape = 0;
-                       while(escape == 0){
-                               rnd_index2 = (int)(((double)rand() / (double) RAND_MAX)*i);
-                               if(rnd_index2 != rnd_index1 && tree[rnd_index2].getParent() == -1){
-                                       escape = 1;
-                               }               
-                       }
-       
-                       tree[i].setChildren(rnd_index1,rnd_index2);
-                       tree[i].setParent(-1);
-                       tree[rnd_index1].setParent(i);
-                       tree[rnd_index2].setParent(i);
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "randomTopology");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::print(ostream& out) {
-       try {
-               int root = findRoot();
-               printBranch(root, out, "branch");
-               out << ";" << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "print");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::print(ostream& out, map<string, string> nameMap) {
-       try {
-               int root = findRoot();
-               printBranch(root, out, nameMap);
-               out << ";" << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "print");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::print(ostream& out, string mode) {
-       try {
-               int root = findRoot();
-               printBranch(root, out, mode);
-               out << ";" << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "print");
-               exit(1);
-       }
-}
-/*****************************************************************/
-// This prints out the tree in Newick form.
-void Tree::createNewickFile(string f) {
-       try {
-               int root = findRoot();
-       
-               filename = f;
-
-               m->openOutputFile(filename, out);
-               
-               printBranch(root, out, "branch");
-               
-               // you are at the end of the tree
-               out << ";" << endl;
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "createNewickFile");
-               exit(1);
-       }
-}
-
-/*****************************************************************/
-//This function finds the index of the root node.
-
-int Tree::findRoot() {
-       try {
-               for (int i = 0; i < numNodes; i++) {
-                       //you found the root
-                       if (tree[i].getParent() == -1) { return i; }
-                       //cout << "i = " << i << endl;
-                       //cout << "i's parent = " << tree[i].getParent() << endl;  
-               }
-               return -1;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "findRoot");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::printBranch(int node, ostream& out, map<string, string> names) {
-try {
-
-// you are not a leaf
-               if (tree[node].getLChild() != -1) {
-                       out << "(";
-                       printBranch(tree[node].getLChild(), out, names);
-                       out << ",";
-                       printBranch(tree[node].getRChild(), out, names);
-                       out << ")";
-                       
-            //if there is a branch length then print it
-            if (tree[node].getBranchLength() != -1) {
-                out << ":" << tree[node].getBranchLength();
-            }
-                       
-               }else { //you are a leaf
-            map<string, string>::iterator itNames = names.find(tree[node].getName());
-            
-            string outputString = "";
-            if (itNames != names.end()) { 
-                
-                vector<string> dupNames;
-                m->splitAtComma((itNames->second), dupNames);
-                
-                if (dupNames.size() == 1) {
-                    outputString += tree[node].getName();
-                    if (tree[node].getBranchLength() != -1) {
-                        outputString += ":" + toString(tree[node].getBranchLength());
-                    }
-                }else {
-                    outputString += "(";
-                    
-                    for (int u = 0; u < dupNames.size()-1; u++) {
-                        outputString += dupNames[u];
-                        
-                        if (tree[node].getBranchLength() != -1) {
-                            outputString += ":" + toString(0.0);
-                        }
-                        outputString += ",";
-                    }
-                    
-                    outputString += dupNames[dupNames.size()-1];
-                    if (tree[node].getBranchLength() != -1) {
-                        outputString += ":" + toString(0.0);
-                    }
-                    
-                    outputString += ")";
-                    if (tree[node].getBranchLength() != -1) {
-                        outputString += ":" + toString(tree[node].getBranchLength());
-                    }
-                }
-            }else { 
-                outputString = tree[node].getName();
-                //if there is a branch length then print it
-                if (tree[node].getBranchLength() != -1) {
-                    outputString += ":" + toString(tree[node].getBranchLength());
-                }
-                
-                m->mothurOut("[ERROR]: " + tree[node].getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); 
-            }
-                
-            out << outputString;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "printBranch");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::printBranch(int node, ostream& out, string mode) {
-    try {
-        
-        // you are not a leaf
-               if (tree[node].getLChild() != -1) {
-                       out << "(";
-                       printBranch(tree[node].getLChild(), out, mode);
-                       out << ",";
-                       printBranch(tree[node].getRChild(), out, mode);
-                       out << ")";
-                       if (mode == "branch") {
-                               //if there is a branch length then print it
-                               if (tree[node].getBranchLength() != -1) {
-                                       out << ":" << tree[node].getBranchLength();
-                               }
-                       }else if (mode == "boot") {
-                               //if there is a label then print it
-                               if (tree[node].getLabel() != -1) {
-                                       out << tree[node].getLabel();
-                               }
-                       }else if (mode == "both") {
-                               if (tree[node].getLabel() != -1) {
-                                       out << tree[node].getLabel();
-                               }
-                               //if there is a branch length then print it
-                               if (tree[node].getBranchLength() != -1) {
-                                       out << ":" << tree[node].getBranchLength();
-                               }
-                       }
-               }else { //you are a leaf
-                       string leafGroup = tmap->getGroup(tree[node].getName());
-                       
-                       if (mode == "branch") {
-                               out << leafGroup; 
-                               //if there is a branch length then print it
-                               if (tree[node].getBranchLength() != -1) {
-                                       out << ":" << tree[node].getBranchLength();
-                               }
-                       }else if (mode == "boot") {
-                               out << leafGroup; 
-                               //if there is a label then print it
-                               if (tree[node].getLabel() != -1) {
-                                       out << tree[node].getLabel();
-                               }
-                       }else if (mode == "both") {
-                               out << tree[node].getName();
-                               if (tree[node].getLabel() != -1) {
-                                       out << tree[node].getLabel();
-                               }
-                               //if there is a branch length then print it
-                               if (tree[node].getBranchLength() != -1) {
-                                       out << ":" << tree[node].getBranchLength();
-                               }
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "printBranch");
-               exit(1);
-       }
-}
-/*****************************************************************/
-void Tree::printBranch(int node, ostream& out, string mode, vector<Node>& theseNodes) {
-       try {
-               
-               // you are not a leaf
-               if (theseNodes[node].getLChild() != -1) {
-                       out << "(";
-                       printBranch(theseNodes[node].getLChild(), out, mode);
-                       out << ",";
-                       printBranch(theseNodes[node].getRChild(), out, mode);
-                       out << ")";
-                       if (mode == "branch") {
-                               //if there is a branch length then print it
-                               if (theseNodes[node].getBranchLength() != -1) {
-                                       out << ":" << theseNodes[node].getBranchLength();
-                               }
-                       }else if (mode == "boot") {
-                               //if there is a label then print it
-                               if (theseNodes[node].getLabel() != -1) {
-                                       out << theseNodes[node].getLabel();
-                               }
-                       }else if (mode == "both") {
-                               if (theseNodes[node].getLabel() != -1) {
-                                       out << theseNodes[node].getLabel();
-                               }
-                               //if there is a branch length then print it
-                               if (theseNodes[node].getBranchLength() != -1) {
-                                       out << ":" << theseNodes[node].getBranchLength();
-                               }
-                       }
-               }else { //you are a leaf
-                       string leafGroup = tmap->getGroup(theseNodes[node].getName());
-                       
-                       if (mode == "branch") {
-                               out << leafGroup; 
-                               //if there is a branch length then print it
-                               if (theseNodes[node].getBranchLength() != -1) {
-                                       out << ":" << theseNodes[node].getBranchLength();
-                               }
-                       }else if (mode == "boot") {
-                               out << leafGroup; 
-                               //if there is a label then print it
-                               if (theseNodes[node].getLabel() != -1) {
-                                       out << theseNodes[node].getLabel();
-                               }
-                       }else if (mode == "both") {
-                               out << theseNodes[node].getName();
-                               if (theseNodes[node].getLabel() != -1) {
-                                       out << theseNodes[node].getLabel();
-                               }
-                               //if there is a branch length then print it
-                               if (theseNodes[node].getBranchLength() != -1) {
-                                       out << ":" << theseNodes[node].getBranchLength();
-                               }
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "printBranch");
-               exit(1);
-       }
-}
-/*****************************************************************/
-
-void Tree::printTree() {
-       
-       for(int i=0;i<numNodes;i++){
-               cout << i << '\t';
-               tree[i].printNode();
-       }
-       
-}
-
-/*****************************************************************/
-//this code is a mess and should be rethought...-slw
-void Tree::parseTreeFile() {
-       
-       //only takes names from the first tree and assumes that all trees use the same names.
-       try {
-               string filename = m->getTreeFile();
-               ifstream filehandle;
-               m->openInputFile(filename, filehandle);
-               int c, comment;
-               comment = 0;
-               int done = 1;
-               
-               //ifyou are not a nexus file 
-               if((c = filehandle.peek()) != '#') {  
-                       while((c = filehandle.peek()) != ';') { 
-                               while ((c = filehandle.peek()) != ';') {
-                                       // get past comments
-                                       if(c == '[') {
-                                               comment = 1;
-                                       }
-                                       if(c == ']'){
-                                               comment = 0;
-                                       }
-                                       if((c == '(') && (comment != 1)){ break; }
-                                       filehandle.get();
-                               }
-
-                               done = readTreeString(filehandle); 
-                               if (done == 0) { break; }
-                       }
-               //ifyou are a nexus file
-               }else if((c = filehandle.peek()) == '#') {
-                       string holder = "";
-                                       
-                       // get past comments
-                       while(holder != "translate" && holder != "Translate"){  
-                               if(holder == "[" || holder == "[!"){
-                                       comment = 1;
-                               }
-                               if(holder == "]"){
-                                       comment = 0;
-                               }
-                               filehandle >> holder; 
-
-                               //if there is no translate then you must read tree string otherwise use translate to get names
-                               if((holder == "tree") && (comment != 1)){       
-                                       //pass over the "tree rep.6878900 = "
-                                       while (((c = filehandle.get()) != '(') && ((c = filehandle.peek()) != EOF)) {;}
-
-                                       if(c == EOF) { break; }
-                                       filehandle.putback(c);  //put back first ( of tree.
-                                       done = readTreeString(filehandle);
-       
-                                       break;
-                               }
-                       
-                               if (done == 0) { break;  }
-                       }
-                       
-                       //use nexus translation rather than parsing tree to save time
-                       if((holder == "translate") || (holder == "Translate")) {
-
-                               string number, name, h;
-                               h = ""; // so it enters the loop the first time
-                               while((h != ";") && (number != ";")) { 
-                                       filehandle >> number;
-                                       filehandle >> name;
-       
-                                       //c = , until done with translation then c = ;
-                                       h = name.substr(name.length()-1, name.length()); 
-                                       name.erase(name.end()-1);  //erase the comma
-                                       m->Treenames.push_back(number);
-                               }
-                               if(number == ";") { m->Treenames.pop_back(); }  //in case ';' from translation is on next line instead of next to last name
-                       }
-               }
-               filehandle.close();
-               
-               //for (int i = 0; i < globaldata->Treenames.size(); i++) {
-//cout << globaldata->Treenames[i] << endl; }
-//cout << globaldata->Treenames.size() << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "parseTreeFile");
-               exit(1);
-       }
-}
-/*******************************************************/
-
-/*******************************************************/
-int Tree::readTreeString(ifstream& filehandle) {
-       try {
-               int c;
-               string name;  //, k
-               
-               while((c = filehandle.peek()) != ';') { 
-//k = c;
-//cout << " at beginning of while " <<  k << endl;                     
-                       if(c == ')')  {    
-                               //to pass over labels in trees
-                               c=filehandle.get();
-                               while((c!=',') && (c != -1) && (c!= ':') && (c!=';')){ c=filehandle.get(); }
-                               filehandle.putback(c);
-                       }
-                       if(c == ';') { return 0; }
-                       if(c == -1) { return 0; }
-                       //if you are a name
-                       if((c != '(') && (c != ')') && (c != ',') && (c != ':') && (c != '\n') && (c != '\t') && (c != 32)) { //32 is space
-                               name = "";
-                               c = filehandle.get();
-                       //k = c;
-//cout << k << endl;
-                               while ((c != '(') && (c != ')') && (c != ',') && (c != ':') && (c != '\n') && (c != 32) && (c != '\t')) {                       
-                                       name += c;
-                                       c = filehandle.get();
-                       //k = c;
-//cout << " in name while " << k << endl;
-                               }
-                               
-//cout << "name = " << name << endl;
-                               m->Treenames.push_back(name);
-                               filehandle.putback(c);
-//k = c;
-//cout << " after putback" <<  k << endl;
-                       } 
-                       
-                       if(c  == ':') { //read until you reach the end of the branch length
-                               while ((c != '(') && (c != ')') && (c != ',') && (c != ';') && (c != '\n') && (c != '\t') && (c != 32)) {
-                                       c = filehandle.get();
-       //k = c;
-       //cout << " in branch while " << k << endl;
-                               }
-                               filehandle.putback(c);
-                       }
-               
-                       c = filehandle.get();
-//k = c;
-       //cout << " here after get " << k << endl;
-                       if(c == ';') { return 0; }
-                       if(c == ')') { filehandle.putback(c); }
-       //k = c;
-//cout << k << endl;
-
-               }
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Tree", "readTreeString");
-               exit(1);
-       }
-}      
-
-/*******************************************************/
-
-/*******************************************************/
-
diff --git a/tree.h b/tree.h
deleted file mode 100644 (file)
index 0660e8a..0000000
--- a/tree.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef TREE_H
-#define TREE_H
-
-/*
- *  tree.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/22/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treenode.h"
-#include "treemap.h"
-/* This class represents the treefile. */
-
-class Tree {
-public: 
-       Tree(string);  //do not use tree generated by this constructor its just to extract the treenames, its a chicken before the egg thing that needs to be revisited.
-       Tree(int, TreeMap*); 
-       Tree(TreeMap*);         //to generate a tree from a file
-    Tree(TreeMap*, vector< vector<double> >&); //create tree from sim matrix
-       ~Tree();
-       
-    TreeMap* getTreeMap() { return tmap; }
-       void getCopy(Tree*);  //makes tree a copy of the one passed in.
-       void getSubTree(Tree*, vector<string>);  //makes tree a that contains only the names passed in.
-    int getSubTree(Tree* originalToCopy, vector<string> seqToInclude, map<string, string> nameMap);  //used with (int, TreeMap) constructor. SeqsToInclude contains subsample wanted - assumes these are unique seqs and size of vector=numLeaves passed into constructor. nameMap is unique -> redundantList can be empty if no namesfile was provided. 
-    
-       void assembleRandomTree();
-       void assembleRandomUnifracTree(vector<string>);
-       void assembleRandomUnifracTree(string, string);
-    
-       void createNewickFile(string);
-       int getIndex(string);
-       void setIndex(string, int);
-       int getNumNodes() { return numNodes; }
-       int getNumLeaves(){     return numLeaves; }
-       map<string, int> mergeUserGroups(int, vector<string>);  //returns a map with a groupname and the number of times that group was seen in the children
-       void printTree();
-       void print(ostream&);
-       void print(ostream&, string);
-    void print(ostream&, map<string, string>);
-       int findRoot();  //return index of root node
-       
-       //this function takes the leaf info and populates the non leaf nodes
-       int assembleTree(map<string, string>);  
-       
-       vector<Node> tree;              //the first n nodes are the leaves, where n is the number of sequences.
-       map< string, vector<int> > groupNodeInfo;       //maps group to indexes of leaf nodes with that group, different groups may contain same node because of names file.
-                       
-private:
-       TreeMap* tmap;
-       int numNodes, numLeaves;
-       ofstream out;
-       string filename;
-       
-    map<string, string> names;
-       map<string, int>::iterator it, it2;
-       map<string, int> mergeGroups(int);  //returns a map with a groupname and the number of times that group was seen in the children
-       map<string,int> mergeGcounts(int);
-       
-       void addNamesToCounts(map<string, string>);
-       void randomTopology();
-       void randomBlengths();
-       void randomLabels(vector<string>);
-       //void randomLabels(string, string);
-       void printBranch(int, ostream&, map<string, string>);  //recursively print out tree
-    void printBranch(int, ostream&, string);
-       void parseTreeFile();   //parses through tree file to find names of nodes and number of them
-                                                       //this is required in case user has sequences in the names file that are
-                                                       //not included in the tree. 
-                                                       //only takes names from the first tree in the tree file and assumes that all trees use the same names.
-       int readTreeString(ifstream&);
-       int populateNewTree(vector<Node>&, int, int&);
-       void printBranch(int, ostream&, string, vector<Node>&);
-               
-       MothurOut* m;
-               
-};
-
-#endif
diff --git a/treecalculator.h b/treecalculator.h
deleted file mode 100644 (file)
index 06abdb8..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef TREECALCULATOR_H
-#define TREECALCULATOR_H
-
-/*
- *  treecalculator.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "tree.h"
-#include "mothurout.h"
-
-/* The tree calculator class is the parent class for tree calculators in mothur. */ 
-
-typedef vector<double> EstOutput;
-
-/***********************************************************************/
-
-class TreeCalculator {
-
-public:
-       TreeCalculator(){ m = MothurOut::getInstance(); }
-       TreeCalculator(string n) : name(n) {};
-       
-       virtual ~TreeCalculator(){};
-       virtual EstOutput getValues(Tree*) { return data; }     
-       virtual EstOutput getValues(Tree*, int, string) { return data; }        
-       virtual EstOutput getValues(Tree*, string, string) { return data; }
-       virtual EstOutput getValues(Tree*, string, string, vector<double>&) { return data; }
-       
-       virtual string getName()                {       return name;    }
-               
-protected:
-       EstOutput data;
-       string name;
-       MothurOut* m;
-
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp
deleted file mode 100644 (file)
index c26199d..0000000
+++ /dev/null
@@ -1,1041 +0,0 @@
-/*
- *  treegroupscommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treegroupscommand.h"
-#include "subsample.h"
-#include "consensus.h"
-
-//**********************************************************************************************************************
-vector<string> TreeGroupCommand::setParameters(){      
-       try {
-               CommandParameter pshared("shared", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pshared);
-               CommandParameter pphylip("phylip", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "none",false,false); parameters.push_back(pphylip);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "ColumnName",false,false); parameters.push_back(pname);
-               CommandParameter pcolumn("column", "InputTypes", "", "", "PhylipColumnShared", "PhylipColumnShared", "ColumnName",false,false); parameters.push_back(pcolumn);  
-        CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pcutoff("cutoff", "Number", "", "10", "", "", "",false,false); parameters.push_back(pcutoff);
-               CommandParameter pprecision("precision", "Number", "", "100", "", "", "",false,false); parameters.push_back(pprecision);                
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter pcalc("calc", "Multiple", "sharedsobs-sharedchao-sharedace-jabund-sorabund-jclass-sorclass-jest-sorest-thetayc-thetan-kstest-sharednseqs-ochiai-anderberg-kulczynski-kulczynskicody-lennon-morisitahorn-braycurtis-whittaker-odum-canberra-structeuclidean-structchord-hellinger-manhattan-structpearson-soergel-spearman-structkulczynski-speciesprofile-hamming-structchi2-gower-memchi2-memchord-memeuclidean-mempearson", "jclass-thetayc", "", "", "",true,false); parameters.push_back(pcalc);
-               
-        CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-//CommandParameter poutput("output", "Multiple", "lt-square", "lt", "", "", "",false,false); parameters.push_back(poutput);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string TreeGroupCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               ValidCalculators validCalculator;
-               helpString += "The tree.shared command creates a .tre to represent the similiarity between groups or sequences.\n";
-               helpString += "The tree.shared command parameters are shared, groups, calc, phylip, column, name, cutoff, precision, processors, subsample, iters and label.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included used.\n";
-               helpString += "The group names are separated by dashes. The label allow you to select what distance levels you would like trees created for, and are also separated by dashes.\n";
-               helpString += "The phylip or column parameter are required if you do not provide a sharedfile, and only one may be used.  If you use a column file the name filename is required. \n";
-               helpString += "If you do not provide a cutoff value 10.00 is assumed. If you do not provide a precision value then 100 is assumed.\n";
-               helpString += "The tree.shared command should be in the following format: tree.shared(groups=yourGroups, calc=yourCalcs, label=yourLabels).\n";
-        helpString += "The iters parameter allows you to choose the number of times you would like to run the subsample.\n";
-        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group. The subsample parameter may only be used with a shared file.\n";
-               helpString += "Example tree.shared(groups=A-B-C, calc=jabund-sorabund).\n";
-               helpString += "The default value for groups is all the groups in your groupfile.\n";
-               helpString += "The default value for calc is jclass-thetayc.\n";
-               helpString += "The tree.shared command outputs a .tre file for each calculator you specify at each distance you choose.\n";
-               helpString += validCalculator.printCalc("treegroup");
-               helpString += "Or the tree.shared command can be in the following format: tree.shared(phylip=yourPhylipFile).\n";
-               helpString += "Example tree.shared(phylip=abrecovery.dist).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-TreeGroupCommand::TreeGroupCommand(){  
-       try {
-               abort = true; calledHelp = true;
-               setParameters();
-               //initialize outputTypes
-               vector<string> tempOutNames;
-               outputTypes["tree"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-TreeGroupCommand::TreeGroupCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string, string> parameters = parser. getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string, string>::iterator it;
-               
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["tree"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("phylip");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["phylip"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("column");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["column"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       phylipfile = validParameter.validFile(parameters, "phylip", true);
-                       if (phylipfile == "not open") { phylipfile = ""; abort = true; }
-                       else if (phylipfile == "not found") { phylipfile = ""; }        
-                       else {  inputfile = phylipfile;  format = "phylip"; m->setPhylipFile(phylipfile);       }
-                       
-                       columnfile = validParameter.validFile(parameters, "column", true);
-                       if (columnfile == "not open") { columnfile = ""; abort = true; }        
-                       else if (columnfile == "not found") { columnfile = ""; }
-                       else {  inputfile = columnfile; format = "column";      m->setColumnFile(columnfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  inputfile = sharedfile; format = "sharedfile";  m->setSharedFile(sharedfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { abort = true; }   
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       if ((phylipfile == "") && (columnfile == "") && (sharedfile == "")) { 
-                               //is there are current file available for either of these?
-                               //give priority to shared, then column, then phylip
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") {  inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       columnfile = m->getColumnFile(); 
-                                       if (columnfile != "") { inputfile = columnfile; format = "column";  m->mothurOut("Using " + columnfile + " as input file for the column parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               phylipfile = m->getPhylipFile(); 
-                                               if (phylipfile != "") { inputfile = phylipfile;  format = "phylip";  m->mothurOut("Using " + phylipfile + " as input file for the phylip parameter."); m->mothurOutEndLine(); }
-                                               else { 
-                                                       m->mothurOut("No valid current files. You must provide a shared, phylip or column file."); m->mothurOutEndLine(); 
-                                                       abort = true;
-                                               }
-                                       }
-                               }
-                       }
-                       else if ((phylipfile != "") && (columnfile != "")) { m->mothurOut("When running the tree.shared command with a distance file you may not use both the column and the phylip parameters."); m->mothurOutEndLine(); abort = true; }
-                       
-                       if (columnfile != "") {
-                               if (namefile == "") { 
-                                       namefile = m->getNameFile(); 
-                                       if (namefile != "") {  m->mothurOut("Using " + namefile + " as input file for the name parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("You need to provide a namefile if you are going to use the column format."); m->mothurOutEndLine(); 
-                                               abort = true; 
-                                       }       
-                               }
-                       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                               
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { calc = "jclass-thetayc";  }
-                       else { 
-                                if (calc == "default")  {  calc = "jclass-thetayc";  }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-
-                       string temp;
-                       temp = validParameter.validFile(parameters, "precision", false);                        if (temp == "not found") { temp = "100"; }
-                       m->mothurConvert(temp, precision); 
-                       
-                       temp = validParameter.validFile(parameters, "cutoff", false);                   if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, cutoff); 
-                       cutoff += (5 / (precision * 10.0));
-                       
-            temp = validParameter.validFile(parameters, "processors", false);  if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-            
-            temp = validParameter.validFile(parameters, "iters", false);                       if (temp == "not found") { temp = "1000"; }
-                       m->mothurConvert(temp, iters); 
-            
-            temp = validParameter.validFile(parameters, "subsample", false);           if (temp == "not found") { temp = "F"; }
-                       if (m->isNumeric1(temp)) { m->mothurConvert(temp, subsampleSize); subsample = true; }
-            else {  
-                if (m->isTrue(temp)) { subsample = true; subsampleSize = -1; }  //we will set it to smallest group later 
-                else { subsample = false; }
-            }
-            
-            if (subsample == false) { iters = 1; }
-            
-            if (subsample && (format != "sharedfile")) { m->mothurOut("[ERROR]: the subsample parameter can only be used with a shared file.\n"); abort=true; }
-            
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(inputfile); //if user entered a file with a path then preserve it       
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "TreeGroupCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-TreeGroupCommand::~TreeGroupCommand(){
-       if (abort == false) {
-               if (format == "sharedfile") {  delete input; }
-               else { delete readMatrix;  delete matrix; delete list; }
-               delete tmap;  
-       }
-       
-}
-
-//**********************************************************************************************************************
-
-int TreeGroupCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               if (format == "sharedfile") {
-                       
-                       ValidCalculators validCalculator;
-               
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("treegroup", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "sharedsobs") { 
-                                               treeCalculators.push_back(new SharedSobsCS());
-                                       }else if (Estimators[i] == "sharedchao") { 
-                                               treeCalculators.push_back(new SharedChao1());
-                                       }else if (Estimators[i] == "sharedace") { 
-                                               treeCalculators.push_back(new SharedAce());
-                                       }else if (Estimators[i] == "jabund") {  
-                                               treeCalculators.push_back(new JAbund());
-                                       }else if (Estimators[i] == "sorabund") { 
-                                               treeCalculators.push_back(new SorAbund());
-                                       }else if (Estimators[i] == "jclass") { 
-                                               treeCalculators.push_back(new Jclass());
-                                       }else if (Estimators[i] == "sorclass") { 
-                                               treeCalculators.push_back(new SorClass());
-                                       }else if (Estimators[i] == "jest") { 
-                                               treeCalculators.push_back(new Jest());
-                                       }else if (Estimators[i] == "sorest") { 
-                                               treeCalculators.push_back(new SorEst());
-                                       }else if (Estimators[i] == "thetayc") { 
-                                               treeCalculators.push_back(new ThetaYC());
-                                       }else if (Estimators[i] == "thetan") { 
-                                               treeCalculators.push_back(new ThetaN());
-                                       }else if (Estimators[i] == "kstest") { 
-                                               treeCalculators.push_back(new KSTest());
-                                       }else if (Estimators[i] == "sharednseqs") { 
-                                               treeCalculators.push_back(new SharedNSeqs());
-                                       }else if (Estimators[i] == "ochiai") { 
-                                               treeCalculators.push_back(new Ochiai());
-                                       }else if (Estimators[i] == "anderberg") { 
-                                               treeCalculators.push_back(new Anderberg());
-                                       }else if (Estimators[i] == "kulczynski") { 
-                                               treeCalculators.push_back(new Kulczynski());
-                                       }else if (Estimators[i] == "kulczynskicody") { 
-                                               treeCalculators.push_back(new KulczynskiCody());
-                                       }else if (Estimators[i] == "lennon") { 
-                                               treeCalculators.push_back(new Lennon());
-                                       }else if (Estimators[i] == "morisitahorn") { 
-                                               treeCalculators.push_back(new MorHorn());
-                                       }else if (Estimators[i] == "braycurtis") { 
-                                               treeCalculators.push_back(new BrayCurtis());
-                                       }else if (Estimators[i] == "whittaker") { 
-                                               treeCalculators.push_back(new Whittaker());
-                                       }else if (Estimators[i] == "odum") { 
-                                               treeCalculators.push_back(new Odum());
-                                       }else if (Estimators[i] == "canberra") { 
-                                               treeCalculators.push_back(new Canberra());
-                                       }else if (Estimators[i] == "structeuclidean") { 
-                                               treeCalculators.push_back(new StructEuclidean());
-                                       }else if (Estimators[i] == "structchord") { 
-                                               treeCalculators.push_back(new StructChord());
-                                       }else if (Estimators[i] == "hellinger") { 
-                                               treeCalculators.push_back(new Hellinger());
-                                       }else if (Estimators[i] == "manhattan") { 
-                                               treeCalculators.push_back(new Manhattan());
-                                       }else if (Estimators[i] == "structpearson") { 
-                                               treeCalculators.push_back(new StructPearson());
-                                       }else if (Estimators[i] == "soergel") { 
-                                               treeCalculators.push_back(new Soergel());
-                                       }else if (Estimators[i] == "spearman") { 
-                                               treeCalculators.push_back(new Spearman());
-                                       }else if (Estimators[i] == "structkulczynski") { 
-                                               treeCalculators.push_back(new StructKulczynski());
-                                       }else if (Estimators[i] == "speciesprofile") { 
-                                               treeCalculators.push_back(new SpeciesProfile());
-                                       }else if (Estimators[i] == "hamming") { 
-                                               treeCalculators.push_back(new Hamming());
-                                       }else if (Estimators[i] == "structchi2") { 
-                                               treeCalculators.push_back(new StructChi2());
-                                       }else if (Estimators[i] == "gower") { 
-                                               treeCalculators.push_back(new Gower());
-                                       }else if (Estimators[i] == "memchi2") { 
-                                               treeCalculators.push_back(new MemChi2());
-                                       }else if (Estimators[i] == "memchord") { 
-                                               treeCalculators.push_back(new MemChord());
-                                       }else if (Estimators[i] == "memeuclidean") { 
-                                               treeCalculators.push_back(new MemEuclidean());
-                                       }else if (Estimators[i] == "mempearson") { 
-                                               treeCalculators.push_back(new MemPearson());
-                                       }
-                               }
-                       }
-                       
-                       //if the users entered no valid calculators don't execute command
-                       if (treeCalculators.size() == 0) { m->mothurOut("You have given no valid calculators."); m->mothurOutEndLine(); return 0; }
-                       
-                       input = new InputData(sharedfile, "sharedfile");
-                       lookup = input->getSharedRAbundVectors();
-                       lastLabel = lookup[0]->getLabel();
-                       
-                       if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); return 0; }
-                       
-                       //used in tree constructor 
-                       m->runParse = false;
-                       
-                       //create treemap class from groupmap for tree class to use
-                       tmap = new TreeMap();
-                       tmap->makeSim(m->getAllGroups());
-                       
-                       //clear globaldatas old tree names if any
-                       m->Treenames.clear();
-                       
-                       //fills globaldatas tree names
-                       m->Treenames = m->getGroups();
-               
-                       if (m->control_pressed) { return 0; }
-                       
-                       //create tree file
-                       makeSimsShared();
-                       
-                       if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-               }else{
-                       //read in dist file
-                       filename = inputfile;
-               
-                       if (format == "column") { readMatrix = new ReadColumnMatrix(filename); }        
-                       else if (format == "phylip") { readMatrix = new ReadPhylipMatrix(filename); }
-                               
-                       readMatrix->setCutoff(cutoff);
-       
-                       if(namefile != ""){     
-                               nameMap = new NameAssignment(namefile);
-                               nameMap->readMap();
-                       }
-                       else{
-                               nameMap = NULL;
-                       }
-       
-                       readMatrix->read(nameMap);
-                       list = readMatrix->getListVector();
-                       matrix = readMatrix->getMatrix();
-
-                       //make treemap
-                       tmap = new TreeMap();
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       tmap->makeSim(list);
-                       
-                       vector<string> namesGroups = tmap->getNamesOfGroups();
-                       m->setGroups(namesGroups);
-               
-                       //clear globaldatas old tree names if any
-                       m->Treenames.clear();
-               
-                       //fills globaldatas tree names
-                       m->Treenames = m->getGroups();
-                       
-                       //used in tree constructor 
-                       m->runParse = false;
-                       
-                       if (m->control_pressed) { return 0; }
-                       
-                       vector< vector<double> > matrix = makeSimsDist();
-                       
-                       if (m->control_pressed) { return 0; }
-
-                       //create a new filename
-                       string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "tre";    
-                       outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile);
-                               
-                       Tree* newTree = createTree(matrix);
-            
-            if (newTree != NULL) {  writeTree(outputFile, newTree); delete newTree; }
-                       
-                       if (m->control_pressed) { return 0; }
-
-                       m->mothurOut("Tree complete. "); m->mothurOutEndLine();
-                       
-               }
-                               
-               //reset groups parameter
-               m->clearGroups(); 
-               
-               //set tree file as new current treefile
-               string current = "";
-               itTypes = outputTypes.find("tree");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTreeFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-Tree* TreeGroupCommand::createTree(vector< vector<double> >& simMatrix){
-       try {
-               //create tree
-               t = new Tree(tmap, simMatrix);
-        
-        if (m->control_pressed) { delete t; t = NULL; return t; }
-               
-        //assemble tree
-        map<string, string> empty;
-               t->assembleTree(empty);
-
-               return t;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "createTree");
-               exit(1);
-       }
-}
-/***********************************************************/
-int TreeGroupCommand::writeTree(string out, Tree* T) {
-       try {
-               
-        //print newick file
-               t->createNewickFile(out);
-               
-        if (m->control_pressed) { m->mothurRemove(out); outputNames.pop_back(); return 1; }
-        
-        return 0;
-        
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "printSims");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-void TreeGroupCommand::printSims(ostream& out, vector< vector<double> >& simMatrix) {
-       try {
-               
-        for (int m = 0; m < simMatrix.size(); m++)     {
-                       //out << lookup[m]->getGroup() << '\t';
-                       for (int n = 0; n < simMatrix.size(); n++)      {
-                               out << simMatrix[m][n] << '\t'; 
-                       }
-                       out << endl;
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "printSims");
-               exit(1);
-       }
-}
-/***********************************************************/
-vector< vector<double> > TreeGroupCommand::makeSimsDist() {
-       try {
-               numGroups = list->size();
-               
-               //initialize simMatrix
-               vector< vector<double> > simMatrix;
-               simMatrix.resize(numGroups);
-               for (int k = 0; k < simMatrix.size(); k++)      {
-                       for (int j = 0; j < simMatrix.size(); j++)      {
-                               simMatrix[k].push_back(0.0);
-                       }
-               }
-               
-               //go through sparse matrix and fill sims
-               //go through each cell in the sparsematrix
-               for(MatData currentCell = matrix->begin(); currentCell != matrix->end(); currentCell++){
-                       //similairity = -(distance-1)
-                       simMatrix[currentCell->row][currentCell->column] = -(currentCell->dist -1.0);   
-                       simMatrix[currentCell->column][currentCell->row] = -(currentCell->dist -1.0);   
-                       
-                       if (m->control_pressed) { return simMatrix; }
-                       
-               }
-
-               return simMatrix;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "makeSimsDist");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-int TreeGroupCommand::makeSimsShared() {
-       try {
-        
-        if (subsample) { 
-            if (subsampleSize == -1) { //user has not set size, set size = smallest samples size
-                subsampleSize = lookup[0]->getNumSeqs();
-                for (int i = 1; i < lookup.size(); i++) {
-                    int thisSize = lookup[i]->getNumSeqs();
-                    
-                    if (thisSize < subsampleSize) {    subsampleSize = thisSize;       }
-                }
-            }else {
-                m->clearGroups();
-                Groups.clear();
-                vector<SharedRAbundVector*> temp;
-                for (int i = 0; i < lookup.size(); i++) {
-                    if (lookup[i]->getNumSeqs() < subsampleSize) { 
-                        m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
-                        delete lookup[i];
-                    }else { 
-                        Groups.push_back(lookup[i]->getGroup()); 
-                        temp.push_back(lookup[i]);
-                    }
-                } 
-                lookup = temp;
-                m->setGroups(Groups);
-            }
-            
-            if (lookup.size() < 2) { m->mothurOut("You have not provided enough valid groups.  I cannot run the command."); m->mothurOutEndLine(); m->control_pressed = true; return 0; }
-        }
-        
-        numGroups = lookup.size();
-               lines.resize(processors);
-               for (int i = 0; i < processors; i++) {
-                       lines[i].start = int (sqrt(float(i)/float(processors)) * numGroups);
-                       lines[i].end = int (sqrt(float(i+1)/float(processors)) * numGroups);
-               }       
-        
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-               
-               //as long as you are not at the end of the file or done wih the lines you want
-               while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } for(int i = 0 ; i < treeCalculators.size(); i++) {  delete treeCalculators[i]; } return 1; }
-               
-                       if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                               
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                       }
-                       
-                       if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                               string saveLabel = lookup[0]->getLabel();
-                       
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors(lastLabel);
-
-                               m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                               process(lookup);
-                                       
-                               processedLabels.insert(lookup[0]->getLabel());
-                               userLabels.erase(lookup[0]->getLabel());
-                               
-                               //restore real lastlabel to save below
-                               lookup[0]->setLabel(saveLabel);
-                       }
-
-                       lastLabel = lookup[0]->getLabel();                      
-                       
-                       //get next line to process
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       lookup = input->getSharedRAbundVectors();
-               }
-               
-               if (m->control_pressed) { for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } for(int i = 0 ; i < treeCalculators.size(); i++) {  delete treeCalculators[i]; } return 1; }
-
-               //output error messages about any remaining user labels
-               set<string>::iterator it;
-               bool needToRun = false;
-               for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                       m->mothurOut("Your file does not include the label " + *it); 
-                       if (processedLabels.count(lastLabel) != 1) {
-                               m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                               needToRun = true;
-                       }else {
-                               m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                       }
-               }
-               
-               //run last label if you need to
-               if (needToRun == true)  {
-                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {             delete lookup[i]; }             } 
-                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                       process(lookup);
-                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  }         
-               }
-               
-               for(int i = 0 ; i < treeCalculators.size(); i++) {  delete treeCalculators[i]; }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "makeSimsShared");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-int TreeGroupCommand::process(vector<SharedRAbundVector*> thisLookup) {
-       try{
-               vector< vector< vector<seqDist> > > calcDistsTotals;  //each iter, one for each calc, then each groupCombos dists. this will be used to make .dist files
-        vector< vector<seqDist>  > calcDists; calcDists.resize(treeCalculators.size());                
-        
-        for (int thisIter = 0; thisIter < iters; thisIter++) {
-            
-            vector<SharedRAbundVector*> thisItersLookup = thisLookup;
-            
-            if (subsample) {
-                SubSample sample;
-                vector<string> tempLabels; //dont need since we arent printing the sampled sharedRabunds
-                
-                //make copy of lookup so we don't get access violations
-                vector<SharedRAbundVector*> newLookup;
-                for (int k = 0; k < thisItersLookup.size(); k++) {
-                    SharedRAbundVector* temp = new SharedRAbundVector();
-                    temp->setLabel(thisItersLookup[k]->getLabel());
-                    temp->setGroup(thisItersLookup[k]->getGroup());
-                    newLookup.push_back(temp);
-                }
-                
-                //for each bin
-                for (int k = 0; k < thisItersLookup[0]->getNumBins(); k++) {
-                    if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                    for (int j = 0; j < thisItersLookup.size(); j++) { newLookup[j]->push_back(thisItersLookup[j]->getAbundance(k), thisItersLookup[j]->getGroup()); }
-                }
-                
-                tempLabels = sample.getSample(newLookup, subsampleSize);
-                thisItersLookup = newLookup;
-            }
-            
-            if(processors == 1){
-                driver(thisItersLookup, 0, numGroups, calcDists);
-            }else{
-                int process = 1;
-                vector<int> processIDS;
-                
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                //loop through and create all the processes you want
-                while (process != processors) {
-                    int pid = fork();
-                    
-                    if (pid > 0) {
-                        processIDS.push_back(pid); 
-                        process++;
-                    }else if (pid == 0){
-                        
-                        driver(thisItersLookup, lines[process].start, lines[process].end, calcDists);   
-                        
-                        string tempdistFileName = m->getRootName(m->getSimpleName(sharedfile)) + toString(getpid()) + ".dist";
-                        ofstream outtemp;
-                        m->openOutputFile(tempdistFileName, outtemp);
-                        
-                        for (int i = 0; i < calcDists.size(); i++) {
-                            outtemp << calcDists[i].size() << endl;
-                            
-                            for (int j = 0; j < calcDists[i].size(); j++) {
-                                outtemp << calcDists[i][j].seq1 << '\t' << calcDists[i][j].seq2 << '\t' << calcDists[i][j].dist << endl;
-                            }
-                        }
-                        outtemp.close();
-                        
-                        exit(0);
-                    }else { 
-                        m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                        for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                        exit(0);
-                    }
-                }
-                
-                //parent do your part
-                driver(thisItersLookup, lines[0].start, lines[0].end, calcDists);   
-                
-                //force parent to wait until all the processes are done
-                for (int i = 0; i < processIDS.size(); i++) {
-                    int temp = processIDS[i];
-                    wait(&temp);
-                }
-                
-                for (int i = 0; i < processIDS.size(); i++) {
-                    string tempdistFileName = m->getRootName(m->getSimpleName(sharedfile)) + toString(processIDS[i]) +  ".dist";
-                    ifstream intemp;
-                    m->openInputFile(tempdistFileName, intemp);
-                    
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = 0;
-                        intemp >> size; m->gobble(intemp);
-                        
-                        for (int j = 0; j < size; j++) {
-                            int seq1 = 0;
-                            int seq2 = 0;
-                            float dist = 1.0;
-                            
-                            intemp >> seq1 >> seq2 >> dist;   m->gobble(intemp);
-                            
-                            seqDist tempDist(seq1, seq2, dist);
-                            calcDists[k].push_back(tempDist);
-                        }
-                    }
-                    intemp.close();
-                    m->mothurRemove(tempdistFileName);
-                }
-#else
-                //////////////////////////////////////////////////////////////////////////////////////////////////////
-                //Windows version shared memory, so be careful when passing variables through the treeSharedData struct. 
-                //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-                //Taking advantage of shared memory to pass results vectors.
-                //////////////////////////////////////////////////////////////////////////////////////////////////////
-                
-                vector<treeSharedData*> pDataArray; 
-                DWORD   dwThreadIdArray[processors-1];
-                HANDLE  hThreadArray[processors-1]; 
-                
-                //Create processor worker threads.
-                for( int i=1; i<processors; i++ ){
-                    
-                    //make copy of lookup so we don't get access violations
-                    vector<SharedRAbundVector*> newLookup;
-                    for (int k = 0; k < thisItersLookup.size(); k++) {
-                        SharedRAbundVector* temp = new SharedRAbundVector();
-                        temp->setLabel(thisItersLookup[k]->getLabel());
-                        temp->setGroup(thisItersLookup[k]->getGroup());
-                        newLookup.push_back(temp);
-                    }
-                    
-                    //for each bin
-                    for (int k = 0; k < thisItersLookup[0]->getNumBins(); k++) {
-                        if (m->control_pressed) { for (int j = 0; j < newLookup.size(); j++) {  delete newLookup[j];  } return 0; }
-                        for (int j = 0; j < thisItersLookup.size(); j++) { newLookup[j]->push_back(thisItersLookup[j]->getAbundance(k), thisItersLookup[j]->getGroup()); }
-                    }
-                    
-                    // Allocate memory for thread data.
-                    treeSharedData* tempSum = new treeSharedData(m, lines[i].start, lines[i].end, Estimators, newLookup);
-                    pDataArray.push_back(tempSum);
-                    processIDS.push_back(i);
-                    
-                    hThreadArray[i-1] = CreateThread(NULL, 0, MyTreeSharedThreadFunction, pDataArray[i-1], 0, &dwThreadIdArray[i-1]);   
-                }
-                
-                //parent do your part
-                driver(thisItersLookup, lines[0].start, lines[0].end, calcDists);   
-                
-                //Wait until all threads have terminated.
-                WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-                
-                //Close all thread handles and free memory allocations.
-                for(int i=0; i < pDataArray.size(); i++){
-                    for (int j = 0; j < pDataArray[i]->thisLookup.size(); j++) {  delete pDataArray[i]->thisLookup[j];  } 
-                    
-                    for (int k = 0; k < calcDists.size(); k++) {
-                        int size = pDataArray[i]->calcDists[k].size();
-                        for (int j = 0; j < size; j++) {    calcDists[k].push_back(pDataArray[i]->calcDists[k][j]);    }
-                    }
-                    
-                    CloseHandle(hThreadArray[i]);
-                    delete pDataArray[i];
-                }
-                
-#endif
-            }
-            
-            calcDistsTotals.push_back(calcDists);
-            
-            if (subsample) {  
-                
-                //clean up memory
-                for (int i = 0; i < thisItersLookup.size(); i++) { delete thisItersLookup[i]; }
-                thisItersLookup.clear();
-                for (int i = 0; i < calcDists.size(); i++) {  calcDists[i].clear(); }
-            }
-               }
-               
-        if (iters != 1) {
-            //we need to find the average distance and standard deviation for each groups distance
-            
-            vector< vector<seqDist>  > calcAverages; calcAverages.resize(treeCalculators.size()); 
-            for (int i = 0; i < calcAverages.size(); i++) {  //initialize sums to zero.
-                calcAverages[i].resize(calcDistsTotals[0][i].size());
-                
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    calcAverages[i][j].seq1 = calcDists[i][j].seq1;
-                    calcAverages[i][j].seq2 = calcDists[i][j].seq2;
-                    calcAverages[i][j].dist = 0.0;
-                }
-            }
-            
-            for (int thisIter = 0; thisIter < iters; thisIter++) { //sum all groups dists for each calculator
-                for (int i = 0; i < calcAverages.size(); i++) {  //initialize sums to zero.
-                    for (int j = 0; j < calcAverages[i].size(); j++) {
-                        calcAverages[i][j].dist += calcDistsTotals[thisIter][i][j].dist;
-                    }
-                }
-            }
-            
-            for (int i = 0; i < calcAverages.size(); i++) {  //finds average.
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    calcAverages[i][j].dist /= (float) iters;
-                }
-            }
-            
-            //create average tree for each calc
-            for (int i = 0; i < calcDists.size(); i++) {
-                vector< vector<double> > matrix; //square matrix to represent the distance
-                matrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                
-                for (int j = 0; j < calcAverages[i].size(); j++) {
-                    int row = calcAverages[i][j].seq1;
-                    int column = calcAverages[i][j].seq2;
-                    float dist = calcAverages[i][j].dist;
-                    
-                    matrix[row][column] = dist;
-                    matrix[column][row] = dist;
-                }
-                
-                //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".ave.tre";                            
-                outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
-                
-                //creates tree from similarity matrix and write out file
-                Tree* newTree = createTree(matrix);
-                if (newTree != NULL) { writeTree(outputFile, newTree); }                
-            }
-            
-            //create all trees for each calc and find their consensus tree
-            for (int i = 0; i < calcDists.size(); i++) {
-                if (m->control_pressed) { break; }
-                
-                //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".all.tre";                            
-                outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
-                
-                ofstream outAll;
-                m->openOutputFile(outputFile, outAll);
-                
-                vector<Tree*> trees; 
-                for (int myIter = 0; myIter < iters; myIter++) {
-                    
-                    if(m->control_pressed) { break; }
-                    
-                    //initialize matrix
-                    vector< vector<double> > matrix; //square matrix to represent the distance
-                    matrix.resize(thisLookup.size());
-                    for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                    
-                    for (int j = 0; j < calcDistsTotals[myIter][i].size(); j++) {
-                        int row = calcDistsTotals[myIter][i][j].seq1;
-                        int column = calcDistsTotals[myIter][i][j].seq2;
-                        double dist = calcDistsTotals[myIter][i][j].dist;
-                        
-                        matrix[row][column] = dist;
-                        matrix[column][row] = dist;
-                    }
-                    
-                    //creates tree from similarity matrix and write out file
-                    Tree* newTree = createTree(matrix);
-                    if (newTree != NULL) { 
-                        newTree->print(outAll);
-                        trees.push_back(newTree);
-                    }
-                }
-                outAll.close();
-                if (m->control_pressed) { for (int k = 0; k < trees.size(); k++) { delete trees[k]; } }
-                
-                Consensus consensus;
-                //clear old tree names if any
-                m->Treenames.clear(); m->Treenames = m->getGroups(); //may have changed if subsample eliminated groups
-                Tree* conTree = consensus.getTree(trees);
-                
-                //create a new filename
-                string conFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".cons.tre";                              
-                outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
-                ofstream outTree;
-                m->openOutputFile(conFile, outTree);
-                
-                if (conTree != NULL) { conTree->print(outTree, "boot"); delete conTree; }
-            }
-
-        }else {
-            
-            for (int i = 0; i < calcDists.size(); i++) {
-                if (m->control_pressed) { break; }
-                
-                //initialize matrix
-                vector< vector<double> > matrix; //square matrix to represent the distance
-                matrix.resize(thisLookup.size());
-                for (int k = 0; k < thisLookup.size(); k++) {  matrix[k].resize(thisLookup.size(), 0.0); }
-                
-                for (int j = 0; j < calcDists[i].size(); j++) {
-                    int row = calcDists[i][j].seq1;
-                    int column = calcDists[i][j].seq2;
-                    double dist = calcDists[i][j].dist;
-                    
-                    matrix[row][column] = dist;
-                    matrix[column][row] = dist;
-                }
-                
-                //create a new filename
-                string outputFile = outputDir + m->getRootName(m->getSimpleName(inputfile)) + treeCalculators[i]->getName() + "." + thisLookup[0]->getLabel() + ".tre";                                
-                outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
-                
-                //creates tree from similarity matrix and write out file
-                Tree* newTree = createTree(matrix);
-                if (newTree != NULL) { writeTree(outputFile, newTree); delete newTree; }
-            }
-        }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "process");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int TreeGroupCommand::driver(vector<SharedRAbundVector*> thisLookup, int start, int end, vector< vector<seqDist> >& calcDists) { 
-       try {
-               vector<SharedRAbundVector*> subset;
-               for (int k = start; k < end; k++) { // pass cdd each set of groups to compare
-                       
-                       for (int l = 0; l < k; l++) {
-                               
-                               if (k != l) { //we dont need to similiarity of a groups to itself
-                                       subset.clear(); //clear out old pair of sharedrabunds
-                                       //add new pair of sharedrabunds
-                                       subset.push_back(thisLookup[k]); subset.push_back(thisLookup[l]); 
-                                       
-                                       for(int i=0;i<treeCalculators.size();i++) {
-                                               
-                                               //if this calc needs all groups to calculate the pair load all groups
-                                               if (treeCalculators[i]->getNeedsAll()) { 
-                                                       //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                       for (int w = 0; w < thisLookup.size(); w++) {
-                                                               if ((w != k) && (w != l)) { subset.push_back(thisLookup[w]); }
-                                                       }
-                                               }
-                                               
-                                               vector<double> tempdata = treeCalculators[i]->getValues(subset); //saves the calculator outputs
-                                               
-                                               if (m->control_pressed) { return 1; }
-                                               
-                                               seqDist temp(l, k, -(tempdata[0]-1.0));
-                                               calcDists[i].push_back(temp);
-                                       }
-                               }
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeGroupCommand", "driver");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-       
-
diff --git a/treegroupscommand.h b/treegroupscommand.h
deleted file mode 100644 (file)
index d3c1b3e..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-#ifndef TREEGROUPCOMMAND_H
-#define TREEGROUPCOMMAND_H
-
-/*
- *  treegroupscommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 4/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "inputdata.h"
-#include "groupmap.h"
-#include "validcalculator.h"
-#include "tree.h"
-#include "treemap.h"
-#include "readmatrix.hpp"
-#include "readcolumn.h"
-#include "readphylip.h"
-#include "sparsematrix.hpp"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "sharednseqs.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedkstest.h"
-#include "whittaker.h"
-#include "sharedochiai.h"
-#include "sharedanderbergs.h"
-#include "sharedkulczynski.h"
-#include "sharedkulczynskicody.h"
-#include "sharedlennon.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-#include "sharedjackknife.h"
-#include "whittaker.h"
-#include "odum.h"
-#include "canberra.h"
-#include "structeuclidean.h"
-#include "structchord.h"
-#include "hellinger.h"
-#include "manhattan.h"
-#include "structpearson.h"
-#include "soergel.h"
-#include "spearman.h"
-#include "structkulczynski.h"
-#include "structchi2.h"
-#include "speciesprofile.h"
-#include "hamming.h"
-#include "gower.h"
-#include "memchi2.h"
-#include "memchord.h"
-#include "memeuclidean.h"
-#include "mempearson.h"
-
-
-
-/* This command create a tree file for each similarity calculator at distance level, using various calculators to find the similiarity between groups. 
-       The user can select the lines or labels they wish to use as well as the groups they would like included.
-       They can also use as many or as few calculators as they wish. */
-       
-
-typedef list<PCell>::iterator MatData;
-
-class TreeGroupCommand : public Command {
-       
-public:
-       TreeGroupCommand(string);       
-       TreeGroupCommand();
-       ~TreeGroupCommand();
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "tree.shared";                         }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Tree.shared"; }
-       string getDescription()         { return "generate a tree file that describes the dissimilarity among groups"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-    
-    struct linePair {
-               int start;
-               int end;
-       };
-       vector<linePair> lines;
-    
-       Tree* createTree(vector< vector<double> >&);
-       void printSims(ostream&, vector< vector<double> >&);
-       int makeSimsShared();
-       vector< vector<double> > makeSimsDist();
-    int writeTree(string, Tree*);
-    int driver(vector<SharedRAbundVector*>, int, int, vector< vector<seqDist> >&);
-       
-       ReadMatrix* readMatrix;
-       SparseMatrix* matrix;
-       NameAssignment* nameMap;
-       ListVector* list;
-       TreeMap* tmap;
-       Tree* t;
-    InputData* input;
-       vector<Calculator*> treeCalculators;
-       vector<SharedRAbundVector*> lookup;
-       string lastLabel;
-       string format, groupNames, filename, sharedfile, inputfile;
-       int numGroups, subsampleSize, iters, processors;
-       ofstream out;
-       float precision, cutoff;
-
-       bool abort, allLines, subsample;
-       set<string> labels; //holds labels to be used
-       string phylipfile, columnfile, namefile, calc, groups, label, outputDir;
-       vector<string>  Estimators, Groups, outputNames; //holds estimators to be used
-       
-       //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-       int process(vector<SharedRAbundVector*>);
-       
-       
-
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct treeSharedData {
-    vector<SharedRAbundVector*> thisLookup;
-    vector< vector<seqDist> > calcDists;
-    vector<string>  Estimators;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       
-       treeSharedData(){}
-       treeSharedData(MothurOut* mout, unsigned long long st, unsigned long long en, vector<string> est, vector<SharedRAbundVector*> lu) {
-               m = mout;
-               start = st;
-               end = en;
-        Estimators = est;
-        thisLookup = lu;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyTreeSharedThreadFunction(LPVOID lpParam){ 
-       treeSharedData* pDataArray;
-       pDataArray = (treeSharedData*)lpParam;
-       
-       try {
-        
-        vector<Calculator*> treeCalculators;
-        ValidCalculators validCalculator;
-        for (int i=0; i<pDataArray->Estimators.size(); i++) {
-            if (validCalculator.isValidCalculator("matrix", pDataArray->Estimators[i]) == true) { 
-                if (pDataArray->Estimators[i] == "sharedsobs") { 
-                    treeCalculators.push_back(new SharedSobsCS());
-                }else if (pDataArray->Estimators[i] == "sharedchao") { 
-                    treeCalculators.push_back(new SharedChao1());
-                }else if (pDataArray->Estimators[i] == "sharedace") { 
-                    treeCalculators.push_back(new SharedAce());
-                }else if (pDataArray->Estimators[i] == "jabund") {     
-                    treeCalculators.push_back(new JAbund());
-                }else if (pDataArray->Estimators[i] == "sorabund") { 
-                    treeCalculators.push_back(new SorAbund());
-                }else if (pDataArray->Estimators[i] == "jclass") { 
-                    treeCalculators.push_back(new Jclass());
-                }else if (pDataArray->Estimators[i] == "sorclass") { 
-                    treeCalculators.push_back(new SorClass());
-                }else if (pDataArray->Estimators[i] == "jest") { 
-                    treeCalculators.push_back(new Jest());
-                }else if (pDataArray->Estimators[i] == "sorest") { 
-                    treeCalculators.push_back(new SorEst());
-                }else if (pDataArray->Estimators[i] == "thetayc") { 
-                    treeCalculators.push_back(new ThetaYC());
-                }else if (pDataArray->Estimators[i] == "thetan") { 
-                    treeCalculators.push_back(new ThetaN());
-                }else if (pDataArray->Estimators[i] == "kstest") { 
-                    treeCalculators.push_back(new KSTest());
-                }else if (pDataArray->Estimators[i] == "sharednseqs") { 
-                    treeCalculators.push_back(new SharedNSeqs());
-                }else if (pDataArray->Estimators[i] == "ochiai") { 
-                    treeCalculators.push_back(new Ochiai());
-                }else if (pDataArray->Estimators[i] == "anderberg") { 
-                    treeCalculators.push_back(new Anderberg());
-                }else if (pDataArray->Estimators[i] == "kulczynski") { 
-                    treeCalculators.push_back(new Kulczynski());
-                }else if (pDataArray->Estimators[i] == "kulczynskicody") { 
-                    treeCalculators.push_back(new KulczynskiCody());
-                }else if (pDataArray->Estimators[i] == "lennon") { 
-                    treeCalculators.push_back(new Lennon());
-                }else if (pDataArray->Estimators[i] == "morisitahorn") { 
-                    treeCalculators.push_back(new MorHorn());
-                }else if (pDataArray->Estimators[i] == "braycurtis") { 
-                    treeCalculators.push_back(new BrayCurtis());
-                }else if (pDataArray->Estimators[i] == "whittaker") { 
-                    treeCalculators.push_back(new Whittaker());
-                }else if (pDataArray->Estimators[i] == "odum") { 
-                    treeCalculators.push_back(new Odum());
-                }else if (pDataArray->Estimators[i] == "canberra") { 
-                    treeCalculators.push_back(new Canberra());
-                }else if (pDataArray->Estimators[i] == "structeuclidean") { 
-                    treeCalculators.push_back(new StructEuclidean());
-                }else if (pDataArray->Estimators[i] == "structchord") { 
-                    treeCalculators.push_back(new StructChord());
-                }else if (pDataArray->Estimators[i] == "hellinger") { 
-                    treeCalculators.push_back(new Hellinger());
-                }else if (pDataArray->Estimators[i] == "manhattan") { 
-                    treeCalculators.push_back(new Manhattan());
-                }else if (pDataArray->Estimators[i] == "structpearson") { 
-                    treeCalculators.push_back(new StructPearson());
-                }else if (pDataArray->Estimators[i] == "soergel") { 
-                    treeCalculators.push_back(new Soergel());
-                }else if (pDataArray->Estimators[i] == "spearman") { 
-                    treeCalculators.push_back(new Spearman());
-                }else if (pDataArray->Estimators[i] == "structkulczynski") { 
-                    treeCalculators.push_back(new StructKulczynski());
-                }else if (pDataArray->Estimators[i] == "speciesprofile") { 
-                    treeCalculators.push_back(new SpeciesProfile());
-                }else if (pDataArray->Estimators[i] == "hamming") { 
-                    treeCalculators.push_back(new Hamming());
-                }else if (pDataArray->Estimators[i] == "structchi2") { 
-                    treeCalculators.push_back(new StructChi2());
-                }else if (pDataArray->Estimators[i] == "gower") { 
-                    treeCalculators.push_back(new Gower());
-                }else if (pDataArray->Estimators[i] == "memchi2") { 
-                    treeCalculators.push_back(new MemChi2());
-                }else if (pDataArray->Estimators[i] == "memchord") { 
-                    treeCalculators.push_back(new MemChord());
-                }else if (pDataArray->Estimators[i] == "memeuclidean") { 
-                    treeCalculators.push_back(new MemEuclidean());
-                }else if (pDataArray->Estimators[i] == "mempearson") { 
-                    treeCalculators.push_back(new MemPearson());
-                }
-            }
-        }
-        
-        pDataArray->calcDists.resize(treeCalculators.size());
-        
-               vector<SharedRAbundVector*> subset;
-               for (int k = pDataArray->start; k < pDataArray->end; k++) { // pass cdd each set of groups to compare
-                       
-                       for (int l = 0; l < k; l++) {
-                               
-                               if (k != l) { //we dont need to similiarity of a groups to itself
-                                       subset.clear(); //clear out old pair of sharedrabunds
-                                       //add new pair of sharedrabunds
-                                       subset.push_back(pDataArray->thisLookup[k]); subset.push_back(pDataArray->thisLookup[l]); 
-                                       
-                                       for(int i=0;i<treeCalculators.size();i++) {
-                                               
-                                               //if this calc needs all groups to calculate the pair load all groups
-                                               if (treeCalculators[i]->getNeedsAll()) { 
-                                                       //load subset with rest of lookup for those calcs that need everyone to calc for a pair
-                                                       for (int w = 0; w < pDataArray->thisLookup.size(); w++) {
-                                                               if ((w != k) && (w != l)) { subset.push_back(pDataArray->thisLookup[w]); }
-                                                       }
-                                               }
-                                               
-                                               vector<double> tempdata = treeCalculators[i]->getValues(subset); //saves the calculator outputs
-                                               
-                                               if (pDataArray->m->control_pressed) { return 1; }
-                                               
-                                               seqDist temp(l, k, -(tempdata[0]-1.0));
-                                               pDataArray->calcDists[i].push_back(temp);
-                                       }
-                               }
-                       }
-               }
-        
-        for(int i=0;i<treeCalculators.size();i++){  delete treeCalculators[i]; }
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "TreeGroupsCommand", "MyTreeSharedThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-       
-#endif
-
-
diff --git a/treemap.cpp b/treemap.cpp
deleted file mode 100644 (file)
index c228162..0000000
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- *  treemap.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treemap.h"
-
-/************************************************************/
-
- TreeMap::TreeMap(string filename) {
-       m = MothurOut::getInstance();
-       groupFileName = filename;
-       m->openInputFile(filename, fileHandle);
-}
-
-/************************************************************/
- TreeMap::~TreeMap(){}
-/************************************************************/
-int TreeMap::readMap(string gf) {
-    
-    groupFileName = gf;
-       m->openInputFile(gf, fileHandle);
-    
-    string seqName, seqGroup;
-    int error = 0;
-    
-    while(fileHandle){
-        fileHandle >> seqName;       m->gobble(fileHandle);    //read from first column
-        fileHandle >> seqGroup;                        //read from second column
-        
-        if (m->control_pressed) {  fileHandle.close();  return 1; }
-        
-        setNamesOfGroups(seqGroup);
-        
-        map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
-        if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-        else {
-            namesOfSeqs.push_back(seqName);
-            treemap[seqName].groupname = seqGroup;     //store data in map
-            
-            it2 = seqsPerGroup.find(seqGroup);
-            if (it2 == seqsPerGroup.end()) { //if it's a new group
-                seqsPerGroup[seqGroup] = 1;
-            }else {//it's a group we already have
-                seqsPerGroup[seqGroup]++;
-            }                          
-        }
-        
-        m->gobble(fileHandle);
-    }
-    fileHandle.close();
-    
-    return error;
-}
-
-/************************************************************/
-int TreeMap::readMap() {
-               string seqName, seqGroup;
-               int error = 0;
-               
-               while(fileHandle){
-                       fileHandle >> seqName;           m->gobble(fileHandle); //read from first column
-                       fileHandle >> seqGroup;                 //read from second column
-                       
-                       if (m->control_pressed) {  fileHandle.close();  return 1; }
-                       
-                       setNamesOfGroups(seqGroup);
-                                       
-                       map<string, GroupIndex>::iterator itCheck = treemap.find(seqName);
-                       if (itCheck != treemap.end()) { error = 1; m->mothurOut("[WARNING]: Your groupfile contains more than 1 sequence named " + seqName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine();  }
-                       else {
-                               namesOfSeqs.push_back(seqName);
-                               treemap[seqName].groupname = seqGroup;  //store data in map
-                               
-                               it2 = seqsPerGroup.find(seqGroup);
-                               if (it2 == seqsPerGroup.end()) { //if it's a new group
-                                       seqsPerGroup[seqGroup] = 1;
-                               }else {//it's a group we already have
-                                       seqsPerGroup[seqGroup]++;
-                               }                               
-                       }
-                       
-                       m->gobble(fileHandle);
-               }
-               fileHandle.close();
-       
-
-               return error;
-}
-/************************************************************/
-void TreeMap::addSeq(string seqName, string seqGroup) {
-       
-               namesOfSeqs.push_back(seqName);
-               setNamesOfGroups(seqGroup);
-                                       
-               treemap[seqName].groupname = seqGroup;  //store data in map
-                       
-               it2 = seqsPerGroup.find(seqGroup);
-               if (it2 == seqsPerGroup.end()) { //if it's a new group
-                       seqsPerGroup[seqGroup] = 1;
-               }else {//it's a group we already have
-                       seqsPerGroup[seqGroup]++;
-               }
-}
-/************************************************************/
-void TreeMap::removeSeq(string seqName) {
-       
-       //erase name from namesOfSeqs
-       for (int i = 0; i < namesOfSeqs.size(); i++) {
-               if (namesOfSeqs[i] == seqName)  {
-                       namesOfSeqs.erase(namesOfSeqs.begin()+i);
-                       break;
-               }
-       }
-       
-       //decrement sequences in this group
-       string group = treemap[seqName].groupname;
-       seqsPerGroup[group]--;
-       
-       //remove seq from treemap
-       it = treemap.find(seqName);
-       treemap.erase(it);
-}
-/************************************************************/
-
-int TreeMap::getNumGroups() {
-                       
-       return namesOfGroups.size();    
-               
-}
-/************************************************************/
-
-int TreeMap::getNumSeqs() {
-                       
-       return namesOfSeqs.size();      
-               
-}
-
-/************************************************************/
-
-string TreeMap::getGroup(string sequenceName) {
-                       
-       it = treemap.find(sequenceName);
-       if (it != treemap.end()) { //sequence name was in group file
-               return it->second.groupname;    
-       }else {
-               return "not found";
-       }
-               
-}
-/************************************************************/
-void TreeMap::setIndex(string seq, int index) {
-       it = treemap.find(seq);
-       if (it != treemap.end()) { //sequence name was in group file
-               treemap[seq].vectorIndex = index;       
-       }else {
-               treemap[seq].vectorIndex = index;
-               treemap[seq].groupname = "not found";
-       }
-}
-/************************************************************/
-int TreeMap::getIndex(string seq) {
-       
-       it = treemap.find(seq);
-       // if it is a valid sequence name then return index
-       if (it != treemap.end()) { return treemap[seq].vectorIndex; }
-       // if not return error code
-       else { return -1; }
-       
-}
-/************************************************************/
-
-void TreeMap::setNamesOfGroups(string seqGroup) {
-                       int i, count;
-                       count = 0;
-                       for (i=0; i<namesOfGroups.size(); i++) {
-                               if (namesOfGroups[i] != seqGroup) {
-                                       count++; //you have not found this group
-                               }else {
-                                       break; //you already have it
-                               }
-                       }
-                       if (count == namesOfGroups.size()) {
-                               namesOfGroups.push_back(seqGroup); //new group
-                       }
-}
-/************************************************************/
-bool TreeMap::isValidGroup(string groupname) {
-       try {
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       if (groupname == namesOfGroups[i]) { return true; }
-               }
-               
-               return false;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "isValidGroup");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-void TreeMap::print(ostream& output){
-       try {
-               
-               for(it = treemap.begin(); it != treemap.end(); it++){
-                       output << it->first << '\t' << it->second.groupname << '\t' << it->second.vectorIndex << endl;
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "print");
-               exit(1);
-       }
-}
-
-/************************************************************/
-void TreeMap::makeSim(vector<string> ThisnamesOfGroups) {
-       try {
-               //set names of groups
-               namesOfGroups = ThisnamesOfGroups;
-               
-               //set names of seqs to names of groups
-               namesOfSeqs = ThisnamesOfGroups;
-               
-               // make map where key and value are both the group name since that what the tree.shared command wants
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       treemap[namesOfGroups[i]].groupname = namesOfGroups[i];
-                       seqsPerGroup[namesOfGroups[i]] = 1;
-               }
-               
-               numGroups = namesOfGroups.size();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "makeSim");
-               exit(1);
-       }
-}
-/************************************************************/
-void TreeMap::makeSim(ListVector* list) {
-       try {
-               //set names of groups
-               namesOfGroups.clear();
-               for(int i = 0; i < list->size(); i++) {
-                       namesOfGroups.push_back(list->get(i));
-               }
-               
-               //set names of seqs to names of groups
-               namesOfSeqs = namesOfGroups;
-               
-               // make map where key and value are both the group name since that what the tree.shared command wants
-               for (int i = 0; i < namesOfGroups.size(); i++) {
-                       treemap[namesOfGroups[i]].groupname = namesOfGroups[i];
-                       seqsPerGroup[namesOfGroups[i]] = 1;
-               }
-               
-               numGroups = namesOfGroups.size();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "makeSim");
-               exit(1);
-       }
-}
-/************************************************************/
-int TreeMap::getCopy(TreeMap& copy){
-       try {
-         
-        namesOfGroups = copy.getNamesOfGroups();
-               numGroups = copy.getNumGroups();
-        namesOfSeqs = copy.namesOfSeqs;
-        seqsPerGroup = copy.seqsPerGroup;
-        treemap = copy.treemap;
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "getCopy");
-               exit(1);
-       }
-}
-/************************************************************/
-vector<string> TreeMap::getNamesSeqs(){
-       try {
-        
-               vector<string> names;
-               
-        for(it = treemap.begin(); it != treemap.end(); it++){
-            names.push_back(it->first);
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "getNamesSeqs");
-               exit(1);
-       }
-}
-/************************************************************/
-vector<string> TreeMap::getNamesSeqs(vector<string> picked){
-       try {
-               
-               vector<string> names;
-               
-               for(it = treemap.begin(); it != treemap.end(); it++){
-                       //if you are belong to one the the groups in the picked vector add you
-                       if (m->inUsersGroups(it->second.groupname, picked)) {
-                               names.push_back(it->first);
-                       }
-               }
-               
-               return names;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeMap", "getNamesSeqs");
-               exit(1);
-       }
-}
-
-/************************************************************/
-
diff --git a/treemap.h b/treemap.h
deleted file mode 100644 (file)
index 57822e0..0000000
--- a/treemap.h
+++ /dev/null
@@ -1,69 +0,0 @@
-#ifndef TREEMAP_H
-#define TREEMAP_H
-/*
- *  treemap.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/26/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "listvector.hpp"
-
-/* This class is used by the read.tree command to build the tree container. */
-
-struct GroupIndex {
-       string  groupname;
-       int             vectorIndex;
-};
-
-class TreeMap {
-public:
-       TreeMap() { m = MothurOut::getInstance(); }
-       TreeMap(string);
-       ~TreeMap();
-    
-       int readMap();
-    int readMap(string);
-       int getNumGroups();
-       int getNumSeqs();
-       void setIndex(string, int);  //sequencename, index
-       int getIndex(string);           //returns vector index of sequence
-       bool isValidGroup(string);  //return true if string is a valid group
-       void removeSeq(string);  //removes a sequence, this is to accomadate trees that do not contain all the seqs in your groupfile
-       string getGroup(string);
-       void addSeq(string, string);
-       void addGroup(string s) { setNamesOfGroups(s); }
-       vector<string> getNamesOfGroups() {
-               sort(namesOfGroups.begin(), namesOfGroups.end());
-               return namesOfGroups;
-       }
-    
-    void print(ostream&);
-       void makeSim(vector<string>);  //takes groupmap info and fills treemap for use by tree.shared command.
-       void makeSim(ListVector*);  //takes listvector info and fills treemap for use by tree.shared command.   
-    vector<string> getNamesSeqs();
-       vector<string> getNamesSeqs(vector<string>); //get names of seqs belonging to a group or set of groups
-    int getCopy(TreeMap&);
-    
-    vector<string> namesOfSeqs;
-    map<string,int> seqsPerGroup;      //groupname, number of seqs in that group.
-       map<string, GroupIndex> treemap; //sequence name and <groupname, vector index>
-
-    
-private:
-       vector<string> namesOfGroups;
-       ifstream fileHandle;
-       string groupFileName;
-       int numGroups;
-       map<string, GroupIndex>::iterator it;
-       map<string, int>::iterator it2;
-       void setNamesOfGroups(string); 
-       MothurOut* m;
-       
-       
-};
-
-#endif
diff --git a/treenode.cpp b/treenode.cpp
deleted file mode 100644 (file)
index 0131f59..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *  treenode.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treenode.h"
-
-
-/****************************************************************/     
-Node::Node() {
-       m = MothurOut::getInstance();
-       //initialize node
-       name = "";
-       branchLength = -1;
-       parent = -1;
-       lchild = -1;
-       rchild = -1;
-       length2leaf = 0.0;
-       label = -1;
-       
-}
-/****************************************************************/
-void Node::setName(string Name) {  name = Name; }
-/****************************************************************/
-void Node::setGroup(vector<string> groups)  { group =groups; }
-/****************************************************************/
-void Node::setBranchLength(float l) { branchLength = l; }
-/****************************************************************/
-void Node::setLabel(float l) { label = l; }
-/****************************************************************/
-void Node::setLengthToLeaves(float l) { length2leaf = l; }
-/****************************************************************/
-void Node::setParent(int p)  { parent = p; }
-/****************************************************************/
-void Node::setIndex(int i)  { vectorIndex = i; }
-/****************************************************************/
-void Node::setChildren(int lc, int rc) { lchild = lc; rchild = rc; }   //leftchild, rightchild
-/****************************************************************/
-string Node::getName() { return name; }
-/****************************************************************/
-vector<string> Node::getGroup() { return group; }
-/****************************************************************/
-float Node::getBranchLength() { return branchLength; }
-/****************************************************************/
-float Node::getLabel() { return label; }
-/****************************************************************/
-float Node::getLengthToLeaves() { return length2leaf; }
-/****************************************************************/
-int Node::getParent() { return parent; }
-/****************************************************************/
-int Node::getLChild() { return lchild; }
-/****************************************************************/
-int Node::getRChild() { return rchild; }
-/****************************************************************/
-int Node::getIndex() { return vectorIndex; }
-/****************************************************************/
-//to be used by printTree in the Tree class to print the leaf info                     
-void Node::printNode() {
-       try{
-               m->mothurOut(name + " " + toString(parent) + " " + toString(lchild) + " " + toString(rchild) + " ");
-               
-               /*for (int i = 0; i < group.size(); i++) {  m->mothurOut( group[i] + " "); }
-               
-               //there is a branch length
-               if (branchLength != -1) { 
-                       m->mothurOut(" " + toString(branchLength)); 
-               }
-               m->mothurOut(" |");
-               
-               map<string, int>::iterator it;
-               for(it=pGroups.begin();it!=pGroups.end();it++){
-                       m->mothurOut(" " + it->first + ":" + toString(it->second));
-               }
-               m->mothurOut(" |");
-               for(it=pcount.begin();it!=pcount.end();it++){
-                       m->mothurOut(" " + it->first + ":" + toString(it->second));
-               }*/
-               m->mothurOutEndLine();
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Node", "printNode");
-               exit(1);
-       }
-}
-/****************************************************************/     
diff --git a/treenode.h b/treenode.h
deleted file mode 100644 (file)
index 029cee9..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef TREENODE_H
-#define TREENODE_H
-
-/*
- *  treenode.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 1/23/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-/* This class represents a node on a tree. */
-
-
-class Node  {
-       public:
-               Node();  //pass it the sequence name
-               ~Node() { pGroups.clear(); pcount.clear(); };
-               
-               void setName(string);
-               void setGroup(vector<string>);  
-               void setBranchLength(float);
-               void setLabel(float);
-               void setParent(int);
-               void setChildren(int, int);             //leftchild, rightchild
-               void setIndex(int);
-               void setLengthToLeaves(float);
-               
-               string getName();
-               vector<string> getGroup();  
-               float getBranchLength();
-               float getLengthToLeaves();
-               float getLabel();
-               int getParent();
-               int getLChild();
-               int getRChild();
-               int getIndex();
-               void printNode();   //prints out the name and the branch length
-               
-               
-               //pGroup is the parsimony group info.  i.e. for a leaf node it would contain 1 enter pGroup["groupname"] = 1;
-               //but for a branch node it may contain several entries so if the nodes children are from different groups it
-               //would have at least two entries pgroup["groupnameOfLeftChild"] = 1, pgroup["groupnameOfRightChild"] = 1.
-               //pCount is the nodes descendant group infomation.  i.e. pCount["black"] = 20 would mean that 20 of the nodes 
-               //descendant are from group black.
-
-               map<string, int> pGroups; //leaf nodes will only have 1 group, but branch nodes may have multiple groups.
-               map<string, int> pcount;        
-                       
-       private:
-               string                  name;
-               vector<string>  group; 
-               float                   branchLength, length2leaf, label;
-               int                             parent;
-               int                             lchild;
-               int                             rchild;
-               int                             vectorIndex;
-               MothurOut* m;
-};             
-
-#endif
diff --git a/treereader.cpp b/treereader.cpp
deleted file mode 100644 (file)
index b385d21..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-//
-//  treereader.cpp
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/11/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "treereader.h"
-#include "readtree.h"
-
-/***********************************************************************/
-
-TreeReader::TreeReader(string tf) : treefile(tf)  { 
-    try {
-        m = MothurOut::getInstance();
-        namefile = "";
-        groupfile = "";
-        readTrees();
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TreeReader", "TreeReader");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-TreeReader::TreeReader(string tf, string gf) : treefile(tf),  groupfile(gf)  { 
-    try {
-        m = MothurOut::getInstance();
-        namefile = "";
-        readTrees();
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TreeReader", "TreeReader");
-               exit(1);
-       }
-}
-/***********************************************************************/
-TreeReader::TreeReader(string tf, string gf, string nf) : treefile(tf),  groupfile(gf), namefile(nf)  { 
-    try {
-        m = MothurOut::getInstance();
-        readTrees();
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TreeReader", "TreeReader");
-               exit(1);
-       }
-}
-/***********************************************************************/
-bool TreeReader::readTrees()  { 
-    try {
-        
-        tmap = new TreeMap();
-        if (groupfile != "") {      tmap->readMap(groupfile);        }
-               else{ //fake out by putting everyone in one group
-                       Tree* tree = new Tree(treefile); delete tree;  //extracts names from tree to make faked out groupmap
-                       for (int i = 0; i < m->Treenames.size(); i++) { tmap->addSeq(m->Treenames[i], "Group1"); }
-               }
-               
-        int numUniquesInName = 0;
-               if (namefile != "") { numUniquesInName = readNamesFile(); }
-               
-               ReadTree* read = new ReadNewickTree(treefile);
-               int readOk = read->read(tmap); 
-               
-               if (readOk != 0) { m->mothurOut("Read Terminated."); m->mothurOutEndLine();  delete read; m->control_pressed=true; return 0; }
-               
-               read->AssembleTrees(names);
-               trees = read->getTrees();
-               delete read;
-        
-               //make sure all files match
-               //if you provide a namefile we will use the numNames in the namefile as long as the number of unique match the tree names size.
-               int numNamesInTree;
-               if (namefile != "")  {  
-                       if (numUniquesInName == m->Treenames.size()) {  numNamesInTree = nameMap.size();  }
-                       else {   numNamesInTree = m->Treenames.size();  }
-               }else {  numNamesInTree = m->Treenames.size();  }
-               
-               
-               //output any names that are in group file but not in tree
-               if (numNamesInTree < tmap->getNumSeqs()) {
-                       for (int i = 0; i < tmap->namesOfSeqs.size(); i++) {
-                               //is that name in the tree?
-                               int count = 0;
-                               for (int j = 0; j < m->Treenames.size(); j++) {
-                                       if (tmap->namesOfSeqs[i] == m->Treenames[j]) { break; } //found it
-                                       count++;
-                               }
-                               
-                               if (m->control_pressed) { for (int i = 0; i < trees.size(); i++) { delete trees[i]; } return 0; }
-                               
-                               //then you did not find it so report it 
-                               if (count == m->Treenames.size()) { 
-                                       //if it is in your namefile then don't remove
-                                       map<string, string>::iterator it = nameMap.find(tmap->namesOfSeqs[i]);
-                                       
-                                       if (it == nameMap.end()) {
-                                               m->mothurOut(tmap->namesOfSeqs[i] + " is in your groupfile and not in your tree. It will be disregarded."); m->mothurOutEndLine();
-                                               tmap->removeSeq(tmap->namesOfSeqs[i]);
-                                               i--; //need this because removeSeq removes name from namesOfSeqs
-                                       }
-                               }
-                       }
-               }
-        
-        return true;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TreeReader", "readTrees");
-               exit(1);
-       }
-}
-/*****************************************************************/
-int TreeReader::readNamesFile() {
-       try {
-               nameMap.clear();
-        names.clear();
-               int numUniquesInName = 0;
-               
-               ifstream in;
-               m->openInputFile(namefile, in);
-               
-               string first, second;
-               map<string, string>::iterator itNames;
-               
-               while(!in.eof()) {
-                       in >> first >> second; m->gobble(in);
-                       
-                       numUniquesInName++;
-                       
-                       itNames = nameMap.find(first);
-                       if (itNames == nameMap.end()) {  
-                               names[first] = second; 
-                               
-                               //we need a list of names in your namefile to use above when removing extra seqs above so we don't remove them
-                               vector<string> dupNames;
-                               m->splitAtComma(second, dupNames);
-                               
-                               for (int i = 0; i < dupNames.size(); i++) {     
-                                       nameMap[dupNames[i]] = first; 
-                                       if ((groupfile == "") && (i != 0)) { tmap->addSeq(dupNames[i], "Group1"); } 
-                               }
-                       }else {  m->mothurOut(first + " has already been seen in namefile, disregarding names file."); m->mothurOutEndLine(); in.close(); nameMap.clear(); names.clear(); namefile = ""; return 1; }                    
-               }
-               in.close();
-               
-               return numUniquesInName;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TreeReader", "readNamesFile");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-
diff --git a/treereader.h b/treereader.h
deleted file mode 100644 (file)
index fb9c791..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef Mothur_treereader_h
-#define Mothur_treereader_h
-
-//
-//  treereader.h
-//  Mothur
-//
-//  Created by Sarah Westcott on 4/11/12.
-//  Copyright (c) 2012 Schloss Lab. All rights reserved.
-//
-
-#include "mothurout.h"
-#include "tree.h"
-
-class TreeReader {
-    
-public:
-    
-    TreeReader(string tf);
-       TreeReader(string tf, string gf);
-    TreeReader(string tf, string gf, string nf);
-       ~TreeReader() {}        
-    
-    vector<Tree*> getTrees()            { return trees;     }
-    map<string, string> getNames()      { return nameMap;   } //dups -> unique
-    map<string, string> getNameMap()    { return names;     } //unique -> dups list
-    
-    
-private:
-    MothurOut* m;
-       vector<Tree*> trees;
-    TreeMap* tmap;
-    map<string, string> nameMap; //dupName -> uniqueName
-    map<string, string> names;
-    
-    string treefile, groupfile, namefile;
-    
-    bool readTrees();
-    int readNamesFile();
-};
-
-
-
-#endif
diff --git a/trialSwap2.cpp b/trialSwap2.cpp
deleted file mode 100644 (file)
index 2d25e83..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-#include "trialswap2.h"
-
-
-//The sum_of_squares, havel_hakimi and calc_c_score algorithms have been adapted from I. Miklos and J. Podani. 2004. Randomization of presence-absence matrices: comments and new algorithms. Ecology 85:86-92.
-
-
-double TrialSwap2::calc_c_score (vector<vector<int> > &co_matrix, vector<int> rowtotal, int ncols, int nrows)
-{
-    try {
-        double cscore = 0.0;
-        double maxD;
-        double D;
-        double normcscore = 0.0;
-        int nonzeros = 0;
-        //int ncols = co_matrix[0].size(); int nrows = rowtotal.size();
-        vector<vector<double> > s; s.resize(nrows);
-        for (int i = 0; i < nrows; i++) { s[i].resize(nrows,0.0); }//only fill half the matrix
-        
-        
-        for(int i=0;i<nrows-1;i++)
-        {
-            
-            for(int j=i+1;j<nrows;j++)
-            {
-                if (m->control_pressed) { return 0; }
-                for(int k=0;k<ncols;k++)
-                {
-                    if((co_matrix[i][k]==1)&&(co_matrix[j][k]==1)) //if both are 1s ie co-occurrence
-                        s[i][j]++; //s counts co-occurrences
-                }
-                
-                //rowtotal[i] = A, rowtotal[j] = B, ncols = P, s[i][j] = J
-                cscore += (rowtotal[i]-s[i][j])*(rowtotal[j]-s[i][j]);///(nrows*(nrows-1)/2);
-                D = (rowtotal[i]-s[i][j])*(rowtotal[j]-s[i][j]);
-                
-                if(ncols < (rowtotal[i] + rowtotal[j]))
-                {
-                    maxD = (ncols-rowtotal[i])*(ncols-rowtotal[j]);
-                }
-                else
-                {
-                    maxD = rowtotal[i] * rowtotal[j];
-                }
-                
-                if(maxD != 0)
-                {
-                    normcscore += D/maxD;
-                    nonzeros++;
-                }
-            }
-        }
-        
-        cscore = cscore/(double)(nrows*(nrows-1)/2);
-        //cout << "normalized c score: " << normcscore/nonzeros << endl;
-        
-        return cscore;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_c_score");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-int TrialSwap2::calc_checker (vector<vector<int> > &co_matrix, vector<int> rowtotal, int ncols, int nrows)
-{
-    try {
-        int cunits=0;
-        //int s[nrows][ncols];
-        //int ncols = co_matrix[0].size(); int nrows = rowtotal.size();
-        vector<vector<int> > s; s.resize(nrows);
-        for (int i = 0; i < nrows; i++) { s[i].resize(nrows,0); }//only fill half the matrix
-        
-        for(int i=0;i<nrows-1;i++)
-        {
-            for(int j=i+1;j<nrows;j++)
-            {
-                if (m->control_pressed) { return 0; }
-                //s[i][j]=0;
-                for(int k=0;k<ncols;k++)
-                {
-                    //cout << s[i][j] << endl;
-                    //iterates through the row and counts co-occurrences. The total number of co-occurrences for each row pair is kept in matrix s at location s[i][j].
-                    if((co_matrix[i][k]==1)&&(co_matrix[j][k]==1)) //if both are 1s ie co-occurrence
-                        s[i][j]++; //s counts co-occurrences
-                    
-                }
-                //cout << "rowtotal: " << rowtotal[i] << endl;
-                //cout << "co-occurrences: " << s[i][j] << endl;
-                //cunits+=(rowtotal[i]-s[i][j])*(rowtotal[j]-s[i][j]);
-                if (s[i][j] == 0)
-                {
-                    cunits+=1;
-                }
-                //cunits+=s[i][j];
-            }
-        }
-        
-        return cunits;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_checker");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-double TrialSwap2::calc_vratio (int nrows, int ncols, vector<int> rowtotal, vector<int> columntotal)
-{
-    try {
-        //int nrows = rowtotal.size();
-        //int ncols = columntotal.size();
-        int sumCol = accumulate(columntotal.begin(), columntotal.end(), 0 );
-        // int sumRow = accumulate(rowtotal.begin(), rowtotal.end(), 0 );
-        
-        double colAvg = (double) sumCol / (double) ncols;
-        // double rowAvg = (double) sumRow / (double) nrows;
-        
-        double p = 0.0;
-        
-        // double totalRowVar = 0.0;
-        double rowVar = 0.0;
-        double colVar = 0.0;
-        
-        for(int i=0;i<nrows;i++)
-        {
-            if (m->control_pressed) { return 0; }
-            p = (double) rowtotal[i]/(double) ncols;
-            rowVar += p * (1.0-p);
-        }
-        
-        for(int i=0;i<ncols;i++)
-        {
-            if (m->control_pressed) { return 0; }
-            colVar += pow(((double) columntotal[i]-colAvg),2);
-        }
-        
-        colVar = (1.0/(double)ncols) * colVar;
-        
-        return colVar/rowVar;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_vratio");
-        exit(1);
-    }
-    
-}
-/**************************************************************************************************/
-int TrialSwap2::calc_combo (int nrows, int ncols, vector<vector<int> > &nullmatrix)
-{
-    try {
-        //need to transpose so we can compare rows (row-major order)
-        int tmpnrows = nrows;
-        vector<vector<int> > tmpmatrix;
-        
-        vector<int> tmprow;
-        if(!tmpmatrix.empty())
-            tmpmatrix.clear();
-        for (int i=0;i<ncols;i++)
-        {
-            for (int j=0;j<nrows;j++)
-            {
-                tmprow.push_back(nullmatrix[j][i]);
-            }
-            
-            tmpmatrix.push_back(tmprow);
-            tmprow.clear();
-        }
-        
-        int unique = 0;
-        int match = 0;
-        for(int j=0;j<ncols;j++)
-        {
-            match = 0;
-            for(int i=j+1;i<=ncols;i++)
-            {
-                //comparing matrix rows
-                if( (tmpmatrix[j] == tmpmatrix[i]))
-                {
-                    match++;
-                    break;
-                }
-            }
-            
-            //on the last iteration of a previously matched row it will add itself because it doesn't match any following rows, so that combination is counted
-            if (match == 0)
-                unique++;
-        }
-        return unique;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_combo");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-int TrialSwap2::swap_checkerboards (vector<vector<int> > &co_matrix, int ncols, int nrows)
-{
-    try {
-        //do 100 runs to make sure enough swaps are happening. This does NOT mean that there will be 1000 swaps, but that is the theoretical max.
-        for(int a=0;a<1000;a++){
-            int i, j, k, l;
-            i = m->getRandomIndex(nrows-1);
-            while((j = m->getRandomIndex(nrows-1) ) == i ) {;if (m->control_pressed) { return 0; }}
-            k = m->getRandomIndex(ncols-1);
-            while((l = m->getRandomIndex(ncols-1)) == k ) {;if (m->control_pressed) { return 0; }}
-
-            if((co_matrix[i][k]*co_matrix[j][l]==1 && co_matrix[i][l]+co_matrix[j][k]==0)||(co_matrix[i][k]+co_matrix[j][l]==0 && co_matrix[i][l]*co_matrix[j][k]==1)) //checking for checkerboard value and swap
-            {
-                co_matrix[i][k]=1-co_matrix[i][k];
-                co_matrix[i][l]=1-co_matrix[i][l];
-                co_matrix[j][k]=1-co_matrix[j][k];
-                co_matrix[j][l]=1-co_matrix[j][l];
-
-            }
-        }
-        
-        return 0;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "swap_checkerboards");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-double TrialSwap2::calc_pvalue_greaterthan (vector<double> scorevec, double initialscore)
-{
-    try {
-        int runs = scorevec.size();
-        double p = 0.0;
-        for( int i=0;i<runs;i++)
-        {
-            if (m->control_pressed) { return 0; }
-            if(scorevec[i]>=initialscore)
-                p++;
-        }
-        return p/(double)runs;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_pvalue_greaterthan");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-double TrialSwap2::calc_pvalue_lessthan (vector<double> scorevec, double initialscore)
-{
-    try {
-        int runs = scorevec.size();
-        double p = 0.0;
-        for( int i=0;i<runs;i++)
-        {
-            if (m->control_pressed) { return 0; }
-            if(scorevec[i]<=initialscore)
-                p++;
-        }
-        return p/(double)runs;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "calc_pvalue_lessthan");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-double TrialSwap2::t_test (double initialscore, int runs, double nullMean, vector<double> scorevec)
-{
-    try {
-        double t;
-        double sampleSD;
-        double sum = 0;
-        
-        for(int i=0;i<runs;i++)
-        {
-            if (m->control_pressed) { return 0; }
-            sum += pow((scorevec[i] - nullMean),2);
-            //cout << "scorevec[" << i << "]" << scorevec[i] << endl;
-        }
-        
-        m->mothurOut("nullMean: " + toString(nullMean)); m->mothurOutEndLine();
-        
-        m->mothurOut("sum: " + toString(sum)); m->mothurOutEndLine();
-        
-        sampleSD = sqrt( (1/runs) * sum );
-        
-        m->mothurOut("samplSD: " + toString(sampleSD)); m->mothurOutEndLine();
-        
-        t = (nullMean - initialscore) / (sampleSD / sqrt(runs));
-        
-        return t;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "t_test");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-int TrialSwap2::print_matrix(vector<vector<int> > &matrix, int nrows, int ncols)
-{
-    try {
-        m->mothurOut("matrix:"); m->mothurOutEndLine();
-        
-        for (int i = 0; i < nrows; i++)
-        {
-            if (m->control_pressed) { return 0; }
-            for (int j = 0; j < ncols; j++)
-            {
-                m->mothurOut(toString(matrix[i][j]));
-            }
-            m->mothurOutEndLine();
-        }
-        return 0;
-    }
-    catch(exception& e) {
-        m->errorOut(e, "TrialSwap2", "print_matrix");
-        exit(1);
-    }
-}
-/**************************************************************************************************/
-
-
-
-
-
diff --git a/trialswap2.h b/trialswap2.h
deleted file mode 100644 (file)
index 924938b..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef TRIALSWAP2
-#define TRIALSWAP2
-
-/*
- *  trialswap2.h
- *  Mothur
- *
- *  Created by Kathryn Iverson on June 27, 2011.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothurout.h"
-
-
-class TrialSwap2 {
-    
-public:
-    TrialSwap2(){ m = MothurOut::getInstance(); };
-    ~TrialSwap2(){};
-    
-    double calc_pvalue_lessthan (vector<double>, double);
-    double calc_pvalue_greaterthan (vector<double>, double);
-    int swap_checkerboards (vector<vector<int> > &, int, int);
-    int calc_combo (int, int, vector<vector<int> > &);
-    double calc_vratio (int, int, vector<int>, vector<int>);
-    int calc_checker (vector<vector<int> > &, vector<int>, int, int);
-    double calc_c_score (vector<vector<int> > &, vector<int>, int, int);
-    
-    
-private:
-    MothurOut* m;
-    
-    double t_test (double, int, double, vector<double>);
-    int print_matrix(vector<vector<int> > &, int, int);
-    
-    
-    
-};
-#endif
-
-
diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp
deleted file mode 100644 (file)
index 0557c71..0000000
+++ /dev/null
@@ -1,935 +0,0 @@
-/*
- *  trimflowscommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "trimflowscommand.h"
-#include "needlemanoverlap.hpp"
-
-
-//**********************************************************************************************************************
-vector<string> TrimFlowsCommand::setParameters(){      
-       try {
-               CommandParameter pflow("flow", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pflow);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pmaxflows("maxflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pmaxflows);
-               CommandParameter pminflows("minflows", "Number", "", "450", "", "", "",false,false); parameters.push_back(pminflows);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter psignal("signal", "Number", "", "0.50", "", "", "",false,false); parameters.push_back(psignal);
-               CommandParameter pnoise("noise", "Number", "", "0.70", "", "", "",false,false); parameters.push_back(pnoise);
-               CommandParameter pallfiles("allfiles", "Boolean", "", "t", "", "", "",false,false); parameters.push_back(pallfiles);
-               CommandParameter porder("order", "String", "", "", "", "", "",false,false); parameters.push_back(porder);
-               CommandParameter pfasta("fasta", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pfasta);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string TrimFlowsCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The trim.flows command reads a flowgram file and creates .....\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Trim.flows.\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-
-TrimFlowsCommand::TrimFlowsCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["flow"] = tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "TrimFlowsCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-TrimFlowsCommand::TrimFlowsCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;   
-               comboStarts = 0;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                                               
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["flow"] = tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("flow");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["flow"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("oligos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
-                               }
-                               
-                       }
-                       
-                       
-                       //check for required parameters
-                       flowFileName = validParameter.validFile(parameters, "flow", true);
-                       if (flowFileName == "not found") { 
-                               flowFileName = m->getFlowFile(); 
-                               if (flowFileName != "") {  m->mothurOut("Using " + flowFileName + " as input file for the flow parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       m->mothurOut("No valid current flow file. You must provide a flow file."); m->mothurOutEndLine(); 
-                                       abort = true;
-                               } 
-                       }else if (flowFileName == "not open") { flowFileName = ""; abort = true; }      
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(flowFileName); //if user entered a file with a path then preserve it    
-                       }
-                       
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "450"; }
-                       m->mothurConvert(temp, minFlows);  
-
-                       temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "450"; }
-                       m->mothurConvert(temp, maxFlows);  
-                       
-                       
-                       temp = validParameter.validFile(parameters, "oligos", true);
-                       if (temp == "not found")        {       oligoFileName = "";             }
-                       else if(temp == "not open")     {       abort = true;                   } 
-                       else                                            {       oligoFileName = temp;   m->setOligosFile(oligoFileName); }
-                       
-                       temp = validParameter.validFile(parameters, "fasta", false);            if (temp == "not found"){       fasta = 0;              }
-                       else if(m->isTrue(temp))        {       fasta = 1;      }
-                       
-                       temp = validParameter.validFile(parameters, "maxhomop", false);         if (temp == "not found"){       temp = "9";             }
-                       m->mothurConvert(temp, maxHomoP);  
-
-                       temp = validParameter.validFile(parameters, "signal", false);           if (temp == "not found"){       temp = "0.50";  }
-                       m->mothurConvert(temp, signal);  
-
-                       temp = validParameter.validFile(parameters, "noise", false);            if (temp == "not found"){       temp = "0.70";  }
-                       m->mothurConvert(temp, noise);  
-       
-                       temp = validParameter.validFile(parameters, "bdiffs", false);           if (temp == "not found"){       temp = "0";             }
-                       m->mothurConvert(temp, bdiffs);
-                       
-                       temp = validParameter.validFile(parameters, "pdiffs", false);           if (temp == "not found"){       temp = "0";             }
-                       m->mothurConvert(temp, pdiffs);
-                       
-            temp = validParameter.validFile(parameters, "ldiffs", false);              if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, ldiffs);
-            
-            temp = validParameter.validFile(parameters, "sdiffs", false);              if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, sdiffs);
-                       
-                       temp = validParameter.validFile(parameters, "tdiffs", false);           if (temp == "not found") { int tempTotal = pdiffs + bdiffs + ldiffs + sdiffs;  temp = toString(tempTotal); }
-                       m->mothurConvert(temp, tdiffs);
-                       
-                       if(tdiffs == 0){        tdiffs = bdiffs + pdiffs + ldiffs + sdiffs;     }
-
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-       
-                       flowOrder = validParameter.validFile(parameters, "order", false);
-                       if (flowOrder == "not found"){ flowOrder = "TACG";              }
-                       else if(flowOrder.length() != 4){
-                               m->mothurOut("The value of the order option must be four bases long\n");
-                       }
-
-                       if(oligoFileName == "") {       allFiles = 0;           }
-                       else                                    {       allFiles = 1;           }
-
-                       numFPrimers = 0;
-                       numRPrimers = 0;
-            numLinkers = 0;
-            numSpacers = 0;
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "TrimFlowsCommand");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int TrimFlowsCommand::execute(){
-       try{
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-
-               string trimFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "trim.flow";
-               outputNames.push_back(trimFlowFileName); outputTypes["flow"].push_back(trimFlowFileName);
-               
-               string scrapFlowFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "scrap.flow";
-               outputNames.push_back(scrapFlowFileName); outputTypes["flow"].push_back(scrapFlowFileName);
-
-               string fastaFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.fasta";
-               if(fasta){
-                       outputNames.push_back(fastaFileName); outputTypes["fasta"].push_back(fastaFileName);
-               }
-               
-               vector<unsigned long long> flowFilePos;
-       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               flowFilePos = getFlowFileBreaks();
-               for (int i = 0; i < (flowFilePos.size()-1); i++) {
-                       lines.push_back(new linePair(flowFilePos[i], flowFilePos[(i+1)]));
-               }       
-       #else
-               ifstream in; m->openInputFile(flowFileName, in); in >> numFlows; in.close();
-       ///////////////////////////////////////// until I fix multiple processors for windows //////////////////        
-               processors = 1;
-       ///////////////////////////////////////// until I fix multiple processors for windows //////////////////                
-               if (processors == 1) {
-                       lines.push_back(new linePair(0, 1000));
-               }else {
-                       int numFlowLines;
-                       flowFilePos = m->setFilePosEachLine(flowFileName, numFlowLines);
-                       flowFilePos.erase(flowFilePos.begin() + 1); numFlowLines--;
-                       
-                       //figure out how many sequences you have to process
-                       int numSeqsPerProcessor = numFlowLines / processors;
-                       cout << numSeqsPerProcessor << '\t' << numFlowLines << endl;
-                       for (int i = 0; i < processors; i++) {
-                               int startIndex =  i * numSeqsPerProcessor;
-                               if(i == (processors - 1)){      numSeqsPerProcessor = numFlowLines - i * numSeqsPerProcessor;   }
-                               lines.push_back(new linePair(flowFilePos[startIndex], numSeqsPerProcessor));
-                               cout << flowFilePos[startIndex] << '\t' << numSeqsPerProcessor << endl;
-                       }
-               }
-       #endif
-               
-               vector<vector<string> > barcodePrimerComboFileNames;
-               if(oligoFileName != ""){
-                       getOligos(barcodePrimerComboFileNames); 
-               }
-               
-               if(processors == 1){
-                       driverCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames, lines[0]);
-               }else{
-                       createProcessesCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames); 
-               }       
-               
-               if (m->control_pressed) {  return 0; }                  
-               
-               string flowFilesFileName;
-               ofstream output;
-               
-               if(allFiles){
-                       set<string> namesAlreadyProcessed;
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.files";
-                       m->openOutputFile(flowFilesFileName, output);
-
-                       for(int i=0;i<barcodePrimerComboFileNames.size();i++){
-                               for(int j=0;j<barcodePrimerComboFileNames[0].size();j++){
-                                       if (namesAlreadyProcessed.count(barcodePrimerComboFileNames[i][j]) == 0) {
-                                               FILE * pFile;
-                                               unsigned long long size;
-                                               
-                                               //get num bytes in file
-                                               pFile = fopen (barcodePrimerComboFileNames[i][j].c_str(),"rb");
-                                               if (pFile==NULL) perror ("Error opening file");
-                                               else{
-                                                       fseek (pFile, 0, SEEK_END);
-                                                       size=ftell(pFile);
-                                                       fclose (pFile);
-                                               }
-                                               
-                                               if(size < 10){
-                                                       m->mothurRemove(barcodePrimerComboFileNames[i][j]);
-                                               }
-                                               else{
-                                                       output << m->getFullPathName(barcodePrimerComboFileNames[i][j]) << endl;
-                                                       outputNames.push_back(barcodePrimerComboFileNames[i][j]);
-                                                       outputTypes["flow"].push_back(barcodePrimerComboFileNames[i][j]);
-                                               }
-                                               namesAlreadyProcessed.insert(barcodePrimerComboFileNames[i][j]);
-                                       }
-                               }
-                       }
-                       output.close();
-               }
-               else{
-                       flowFilesFileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + "flow.files";
-                       m->openOutputFile(flowFilesFileName, output);
-                       
-                       output << m->getFullPathName(trimFlowFileName) << endl;
-                       
-                       output.close();
-               }
-               outputTypes["flow.files"].push_back(flowFilesFileName);
-               outputNames.push_back(flowFilesFileName);
-               
-//             set fasta file as new current fastafile
-//             string current = "";
-//             itTypes = outputTypes.find("fasta");
-//             if (itTypes != outputTypes.end()) {
-//                     if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-//             }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "execute");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileName, string scrapFlowFileName, string fastaFileName, vector<vector<string> > thisBarcodePrimerComboFileNames, linePair* line){
-       
-       try {
-               ofstream trimFlowFile;
-               m->openOutputFile(trimFlowFileName, trimFlowFile);
-               trimFlowFile.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
-
-               ofstream scrapFlowFile;
-               m->openOutputFile(scrapFlowFileName, scrapFlowFile);
-               scrapFlowFile.setf(ios::fixed, ios::floatfield); scrapFlowFile.setf(ios::showpoint);
-               
-               ofstream fastaFile;
-               if(fasta){      m->openOutputFile(fastaFileName, fastaFile);    }
-               
-               ifstream flowFile;
-               m->openInputFile(flowFileName, flowFile);
-               
-               flowFile.seekg(line->start);
-               
-               if(line->start == 0){
-                       flowFile >> numFlows; m->gobble(flowFile);
-                       scrapFlowFile << maxFlows << endl;
-                       trimFlowFile << maxFlows << endl;
-                       if(allFiles){
-                               for(int i=0;i<thisBarcodePrimerComboFileNames.size();i++){
-                                       for(int j=0;j<thisBarcodePrimerComboFileNames[0].size();j++){
-                                               ofstream temp;
-                                               m->openOutputFile(thisBarcodePrimerComboFileNames[i][j], temp);
-                                               temp << maxFlows << endl;
-                                               temp.close();
-                                       }
-                               }                       
-                       }
-               }
-               
-               FlowData flowData(numFlows, signal, noise, maxHomoP, flowOrder);
-               //cout << " driver flowdata address " <<  &flowData  << &flowFile << endl;      
-               int count = 0;
-               bool moreSeqs = 1;
-               
-               TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimer, linker, spacer);
-               
-               while(moreSeqs) {
-                               
-                       if (m->control_pressed) { break; }
-                       
-                       int success = 1;
-                       int currentSeqDiffs = 0;
-                       string trashCode = "";
-                       
-                       flowData.getNext(flowFile); 
-                       //cout << "driver good bit " << flowFile.good() << endl;        
-                       flowData.capFlows(maxFlows);    
-                       
-                       Sequence currSeq = flowData.getSequence();
-                       
-                       if(!flowData.hasMinFlows(minFlows)){    //screen to see if sequence is of a minimum number of flows
-                               success = 0;
-                               trashCode += 'l';
-                       }
-                       
-                       int primerIndex = 0;
-                       int barcodeIndex = 0;
-                       
-            if(numLinkers != 0){
-                success = trimOligos.stripLinker(currSeq);
-                if(success > ldiffs)           {       trashCode += 'k';       }
-                else{ currentSeqDiffs += success;  }
-                
-            }
-            
-                       if(barcodes.size() != 0){
-                               success = trimOligos.stripBarcode(currSeq, barcodeIndex);
-                               if(success > bdiffs)            {       trashCode += 'b';       }
-                               else{ currentSeqDiffs += success;  }
-                       }
-                       
-            if(numSpacers != 0){
-                success = trimOligos.stripSpacer(currSeq);
-                if(success > sdiffs)           {       trashCode += 's';       }
-                else{ currentSeqDiffs += success;  }
-                
-            }
-            
-                       if(numFPrimers != 0){
-                               success = trimOligos.stripForward(currSeq, primerIndex);
-                               if(success > pdiffs)            {       trashCode += 'f';       }
-                               else{ currentSeqDiffs += success;  }
-                       }
-                       
-                       if (currentSeqDiffs > tdiffs)   {       trashCode += 't';   }
-                       
-                       if(numRPrimers != 0){
-                               success = trimOligos.stripReverse(currSeq);
-                               if(!success)                            {       trashCode += 'r';       }
-                       }
-                       
-                       if(trashCode.length() == 0){
-                                                       
-                               flowData.printFlows(trimFlowFile);
-                       
-                               if(fasta)       {       currSeq.printSequence(fastaFile);       }
-                               
-                               if(allFiles){
-                                       ofstream output;
-                                       m->openOutputFileAppend(thisBarcodePrimerComboFileNames[barcodeIndex][primerIndex], output);
-                                       output.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
-                                       
-                                       flowData.printFlows(output);
-                                       output.close();
-                               }                               
-                       }
-                       else{
-                               flowData.printFlows(scrapFlowFile, trashCode);
-                       }
-                               
-                       count++;
-                       //cout << "driver" << '\t' << currSeq.getName() << endl;                        
-                       //report progress
-                       if((count) % 10000 == 0){       m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       unsigned long long pos = flowFile.tellg();
-
-                       if ((pos == -1) || (pos >= line->end)) { break; }
-#else
-                       if (flowFile.eof()) { break; }
-#endif
-                       
-               }
-               //report progress
-               if((count) % 10000 != 0){       m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               
-               trimFlowFile.close();
-               scrapFlowFile.close();
-               flowFile.close();
-               if(fasta){      fastaFile.close();      }
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "driverCreateTrim");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-void TrimFlowsCommand::getOligos(vector<vector<string> >& outFlowFileNames){
-       try {
-               ifstream oligosFile;
-               m->openInputFile(oligoFileName, oligosFile);
-               
-               string type, oligo, group;
-
-               int indexPrimer = 0;
-               int indexBarcode = 0;
-               
-               while(!oligosFile.eof()){
-               
-                       oligosFile >> type; m->gobble(oligosFile);      //get the first column value of the row - is it a comment or a feature we are interested in?
-
-                       if(type[0] == '#'){     //igore the line because there's a comment
-                               while (!oligosFile.eof())       {       char c = oligosFile.get(); if (c == 10 || c == 13){     break;  }       } // get rest of line if there's any crap there
-                       }
-                       else{                           //there's a feature we're interested in
-
-                               for(int i=0;i<type.length();i++){       type[i] = toupper(type[i]);  }                                  //make type case insensitive
-
-                               oligosFile >> oligo;    //get the DNA sequence for the feature
-
-                               for(int i=0;i<oligo.length();i++){      //make type case insensitive and change any U's to T's
-                                       oligo[i] = toupper(oligo[i]);
-                                       if(oligo[i] == 'U')     {       oligo[i] = 'T'; }
-                               }
-
-                               if(type == "FORWARD"){  //if the feature is a forward primer...
-                                       group = "";
-
-                                       while (!oligosFile.eof())       {       // get rest of line in case there is a primer name = will have the name of the primer
-                                               char c = oligosFile.get(); 
-                                               if (c == 10 || c == 13){        break;  }
-                                               else if (c == 32 || c == 9){;} //space or tab
-                                               else {  group += c;  }
-                                       } 
-
-                                       //have we seen this primer already?
-                                       map<string, int>::iterator itPrimer = primers.find(oligo);
-                                       if (itPrimer != primers.end()) { m->mothurOut("primer " + oligo + " is in your oligos file already."); m->mothurOutEndLine();  }
-
-                                       primers[oligo]=indexPrimer; indexPrimer++;
-                                       primerNameVector.push_back(group);
-
-                               }
-                               else if(type == "REVERSE"){
-                                       string oligoRC = reverseOligo(oligo);
-                                       revPrimer.push_back(oligoRC);
-                               }
-                               else if(type == "BARCODE"){
-                                       oligosFile >> group;
-
-                                       //check for repeat barcodes
-                                       map<string, int>::iterator itBar = barcodes.find(oligo);
-                                       if (itBar != barcodes.end()) { m->mothurOut("barcode " + oligo + " is in your oligos file already."); m->mothurOutEndLine();  }
-
-                                       barcodes[oligo]=indexBarcode; indexBarcode++;
-                                       barcodeNameVector.push_back(group);
-                               }else if(type == "LINKER"){
-                                       linker.push_back(oligo);
-                               }else if(type == "SPACER"){
-                                       spacer.push_back(oligo);
-                               }
-                               else{
-                                       m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine();  
-                               }
-                       }
-
-                       m->gobble(oligosFile);
-               }
-               oligosFile.close();
-               
-               if(barcodeNameVector.size() == 0 && primerNameVector[0] == ""){ allFiles = 0;   }
-               
-               //add in potential combos
-               if(barcodeNameVector.size() == 0){
-                       barcodes[""] = 0;
-                       barcodeNameVector.push_back("");                        
-               }
-               
-               if(primerNameVector.size() == 0){
-                       primers[""] = 0;
-                       primerNameVector.push_back("");                 
-               }
-               
-               
-               outFlowFileNames.resize(barcodeNameVector.size());
-               for(int i=0;i<outFlowFileNames.size();i++){
-                       outFlowFileNames[i].assign(primerNameVector.size(), "");
-               }
-               
-               if(allFiles){
-
-                       for(map<string, int>::iterator itBar = barcodes.begin();itBar != barcodes.end();itBar++){
-                               for(map<string, int>::iterator itPrimer = primers.begin();itPrimer != primers.end(); itPrimer++){
-
-                                       string primerName = primerNameVector[itPrimer->second];
-                                       string barcodeName = barcodeNameVector[itBar->second];
-                                                                               
-                                       string comboGroupName = "";
-                                       string fileName = "";
-                                       
-                                       if(primerName == ""){
-                                               comboGroupName = barcodeNameVector[itBar->second];
-                                               fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow";
-                                       }
-                                       else{
-                                               if(barcodeName == ""){
-                                                       comboGroupName = primerNameVector[itPrimer->second];
-                                               }
-                                               else{
-                                                       comboGroupName = barcodeNameVector[itBar->second] + "." + primerNameVector[itPrimer->second];
-                                               }
-                                               fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow";
-                                       }
-                                       
-                                       outFlowFileNames[itBar->second][itPrimer->second] = fileName;
-                                       
-                                       ofstream temp;
-                                       m->openOutputFile(fileName, temp);
-                                       temp.close();
-                               }
-                       }
-               }
-               
-               numFPrimers = primers.size();
-               numRPrimers = revPrimer.size();
-        numLinkers = linker.size();
-        numSpacers = spacer.size();
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "getOligos");
-               exit(1);
-       }
-}
-//********************************************************************/
-string TrimFlowsCommand::reverseOligo(string oligo){
-       try {
-        string reverse = "";
-        
-        for(int i=oligo.length()-1;i>=0;i--){
-            
-            if(oligo[i] == 'A')                {       reverse += 'T'; }
-            else if(oligo[i] == 'T'){  reverse += 'A'; }
-            else if(oligo[i] == 'U'){  reverse += 'A'; }
-            
-            else if(oligo[i] == 'G'){  reverse += 'C'; }
-            else if(oligo[i] == 'C'){  reverse += 'G'; }
-            
-            else if(oligo[i] == 'R'){  reverse += 'Y'; }
-            else if(oligo[i] == 'Y'){  reverse += 'R'; }
-            
-            else if(oligo[i] == 'M'){  reverse += 'K'; }
-            else if(oligo[i] == 'K'){  reverse += 'M'; }
-            
-            else if(oligo[i] == 'W'){  reverse += 'W'; }
-            else if(oligo[i] == 'S'){  reverse += 'S'; }
-            
-            else if(oligo[i] == 'B'){  reverse += 'V'; }
-            else if(oligo[i] == 'V'){  reverse += 'B'; }
-            
-            else if(oligo[i] == 'D'){  reverse += 'H'; }
-            else if(oligo[i] == 'H'){  reverse += 'D'; }
-            
-            else                                               {       reverse += 'N'; }
-        }
-        
-        
-        return reverse;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "reverseOligo");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-vector<unsigned long long> TrimFlowsCommand::getFlowFileBreaks() {
-
-       try{
-                       
-               vector<unsigned long long> filePos;
-               filePos.push_back(0);
-                                       
-               FILE * pFile;
-               unsigned long long size;
-               
-               //get num bytes in file
-               pFile = fopen (flowFileName.c_str(),"rb");
-               if (pFile==NULL) perror ("Error opening file");
-               else{
-                       fseek (pFile, 0, SEEK_END);
-                       size=ftell (pFile);
-                       fclose (pFile);
-               }
-                               
-               //estimate file breaks
-               unsigned long long chunkSize = 0;
-               chunkSize = size / processors;
-
-               //file too small to divide by processors
-               if (chunkSize == 0)  {  processors = 1; filePos.push_back(size); return filePos;        }
-               
-               //for each process seekg to closest file break and search for next '>' char. make that the filebreak
-               for (int i = 0; i < processors; i++) {
-                       unsigned long long spot = (i+1) * chunkSize;
-                       
-                       ifstream in;
-                       m->openInputFile(flowFileName, in);
-                       in.seekg(spot);
-                       
-                       string dummy = m->getline(in);
-                       
-                       //there was not another sequence before the end of the file
-                       unsigned long long sanityPos = in.tellg();
-                       
-//                     if (sanityPos == -1) {  break;  }
-//                     else {  filePos.push_back(newSpot);  }
-                       if (sanityPos == -1) {  break;  }
-                       else {  filePos.push_back(sanityPos);  }
-                       
-                       in.close();
-               }
-               
-               //save end pos
-               filePos.push_back(size);
-               
-               //sanity check filePos
-               for (int i = 0; i < (filePos.size()-1); i++) {
-                       if (filePos[(i+1)] <= filePos[i]) {  filePos.erase(filePos.begin()+(i+1)); i--; }
-               }
-
-               ifstream in;
-               m->openInputFile(flowFileName, in);
-               in >> numFlows;
-               m->gobble(in);
-               //unsigned long long spot = in.tellg();
-               //filePos[0] = spot;
-               in.close();
-               
-               processors = (filePos.size() - 1);
-               
-               return filePos; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "getFlowFileBreaks");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trimFlowFileName, string scrapFlowFileName, string fastaFileName, vector<vector<string> > barcodePrimerComboFileNames){
-
-       try {
-               processIDS.clear();
-               int exitCommand = 1;
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               
-                               vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
-                               if(allFiles){
-                                       for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
-                                               for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
-                                                       tempBarcodePrimerComboFileNames[i][j] += toString(getpid()) + ".temp";
-                                                       ofstream temp;
-                                                       m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
-                                                       temp.close();
-                                                       
-                                               }
-                                       }
-                               }
-                               driverCreateTrim(flowFileName,
-                                                                (trimFlowFileName + toString(getpid()) + ".temp"),
-                                                                (scrapFlowFileName + toString(getpid()) + ".temp"),
-                                                                (fastaFileName + toString(getpid()) + ".temp"),
-                                                                tempBarcodePrimerComboFileNames, lines[process]);
-
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent do my part
-               ofstream temp;
-               m->openOutputFile(trimFlowFileName, temp);
-               temp.close();
-
-               m->openOutputFile(scrapFlowFileName, temp);
-               temp.close();
-               
-               if(fasta){
-                       m->openOutputFile(fastaFileName, temp);
-                       temp.close();
-               }
-               
-               driverCreateTrim(flowFileName, trimFlowFileName, scrapFlowFileName, fastaFileName, barcodePrimerComboFileNames, lines[0]);
-
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-#else
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the trimFlowData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<trimFlowData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++ ){
-                       // Allocate memory for thread data.
-                       string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
-                       
-                       vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
-                       if(allFiles){
-                               for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
-                                       for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
-                                               tempBarcodePrimerComboFileNames[i][j] += extension;
-                                               ofstream temp;
-                                               m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
-                                               temp.close();
-                                               
-                                       }
-                               }
-                       }
-                       
-                       trimFlowData* tempflow = new trimFlowData(flowFileName, (trimFlowFileName + extension), (scrapFlowFileName + extension), fastaFileName, flowOrder, tempBarcodePrimerComboFileNames, barcodes, primers, revPrimer, fasta, allFiles, lines[i]->start, lines[i]->end, m, signal, noise, numFlows, maxFlows, minFlows, maxHomoP, tdiffs, bdiffs, pdiffs, i);
-                       pDataArray.push_back(tempflow);
-                       
-                       //MyTrimFlowThreadFunction is in header. It must be global or static to work with the threads.
-                       //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
-                       hThreadArray[i] = CreateThread(NULL, 0, MyTrimFlowThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-               
-               //using the main process as a worker saves time and memory
-               ofstream temp;
-               m->openOutputFile(trimFlowFileName, temp);
-               temp.close();
-               
-               m->openOutputFile(scrapFlowFileName, temp);
-               temp.close();
-               
-               if(fasta){
-                       m->openOutputFile(fastaFileName, temp);
-                       temp.close();
-               }
-               
-               vector<vector<string> > tempBarcodePrimerComboFileNames = barcodePrimerComboFileNames;
-               if(allFiles){
-                       for(int i=0;i<tempBarcodePrimerComboFileNames.size();i++){
-                               for(int j=0;j<tempBarcodePrimerComboFileNames[0].size();j++){
-                                       tempBarcodePrimerComboFileNames[i][j] += toString(processors-1) + ".temp";
-                                       ofstream temp;
-                                       m->openOutputFile(tempBarcodePrimerComboFileNames[i][j], temp);
-                                       temp.close();
-                                       
-                               }
-                       }
-               }
-               
-               //do my part - do last piece because windows is looking for eof
-               int num = driverCreateTrim(flowFileName, (trimFlowFileName  + toString(processors-1) + ".temp"), (scrapFlowFileName  + toString(processors-1) + ".temp"), (fastaFileName + toString(processors-1) + ".temp"), tempBarcodePrimerComboFileNames, lines[processors-1]);
-               processIDS.push_back((processors-1)); 
-               
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       num += pDataArray[i]->count;
-                       CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-               
-               
-#endif 
-               //append files
-               m->mothurOutEndLine();
-               for(int i=0;i<processIDS.size();i++){
-                       
-                       m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine();
-                       
-                       m->appendFiles((trimFlowFileName + toString(processIDS[i]) + ".temp"), trimFlowFileName);
-                       m->mothurRemove((trimFlowFileName + toString(processIDS[i]) + ".temp"));
-//                     m->mothurOut("\tDone with trim.flow file"); m->mothurOutEndLine();
-
-                       m->appendFiles((scrapFlowFileName + toString(processIDS[i]) + ".temp"), scrapFlowFileName);
-                       m->mothurRemove((scrapFlowFileName + toString(processIDS[i]) + ".temp"));
-//                     m->mothurOut("\tDone with scrap.flow file"); m->mothurOutEndLine();
-
-                       if(fasta){
-                               m->appendFiles((fastaFileName + toString(processIDS[i]) + ".temp"), fastaFileName);
-                               m->mothurRemove((fastaFileName + toString(processIDS[i]) + ".temp"));
-//                             m->mothurOut("\tDone with flow.fasta file"); m->mothurOutEndLine();
-                       }
-                       if(allFiles){                                           
-                               for (int j = 0; j < barcodePrimerComboFileNames.size(); j++) {
-                                       for (int k = 0; k < barcodePrimerComboFileNames[0].size(); k++) {
-                                               m->appendFiles((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"), barcodePrimerComboFileNames[j][k]);
-                                               m->mothurRemove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"));
-                                       }
-                               }
-                       }
-               }
-               
-               return exitCommand;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimFlowsCommand", "createProcessesCreateTrim");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
diff --git a/trimflowscommand.h b/trimflowscommand.h
deleted file mode 100644 (file)
index 2594815..0000000
+++ /dev/null
@@ -1,264 +0,0 @@
-#ifndef TRIMFLOWSCOMMAND_H
-#define TRIMFLOWSCOMMAND_H
-
-/*
- *  trimflowscommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 12/22/10.
- *  Copyright 2010 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "sequence.hpp"
-#include "flowdata.h"
-#include "groupmap.h"
-#include "trimoligos.h"
-
-class TrimFlowsCommand : public Command {
-public:
-       TrimFlowsCommand(string);
-       TrimFlowsCommand();
-       ~TrimFlowsCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "trim.flows";  }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Trim.flows"; }
-       string getDescription()         { return "trim.flows"; }
-
-       
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       bool abort;
-
-       struct linePair {
-               unsigned long long start;
-               unsigned long long end;
-               linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-       };
-       int comboStarts;
-       vector<int> processIDS;   //processid
-       vector<linePair*> lines;
-
-       vector<unsigned long long> getFlowFileBreaks();
-       int createProcessesCreateTrim(string, string, string, string, vector<vector<string> >); 
-       int driverCreateTrim(string, string, string, string, vector<vector<string> >, linePair*);
-    string reverseOligo(string);
-    
-       vector<string> outputNames;
-       set<string> filesToRemove;
-       
-       void getOligos(vector<vector<string> >&);               //a rewrite of what is in trimseqscommand.h
-       
-       bool allFiles;
-       int processors;
-       int numFPrimers, numRPrimers;
-       int maxFlows, minFlows, minLength, maxLength, maxHomoP, tdiffs, bdiffs, pdiffs, sdiffs, ldiffs, numLinkers, numSpacers;
-       int numFlows;
-       float signal, noise;
-       bool fasta;
-       string flowOrder;       
-       
-       string flowFileName, oligoFileName, outputDir;
-
-
-       map<string, int> barcodes;
-       map<string, int> primers;
-       vector<string> revPrimer;
-    vector<string> linker;
-    vector<string> spacer;
-
-       vector<string> primerNameVector;        //needed here?
-       vector<string> barcodeNameVector;       //needed here?
-
-       map<string, int> combos;                        //needed here?
-       map<string, int> groupToIndex;          //needed here?
-       
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct trimFlowData {
-       string flowFileName; 
-       string trimFlowFileName; 
-       string scrapFlowFileName;
-       string fastaFileName;
-       string flowOrder;
-       vector<vector<string> > barcodePrimerComboFileNames;
-       map<string, int> barcodes;
-       map<string, int> primers;
-       vector<string> revPrimer;
-       bool fasta, allFiles;
-       unsigned long long start;
-       unsigned long long end;
-       MothurOut* m;
-       float signal, noise;
-       int numFlows, maxFlows, minFlows, maxHomoP, tdiffs, bdiffs, pdiffs, threadID, count;
-       
-       trimFlowData(){}
-       trimFlowData(string ff, string tf, string sf, string f, string fo, vector<vector<string> > bfn, map<string, int> bar, map<string, int> pri, vector<string> rev, bool fa, bool al, unsigned long long st, unsigned long long en, MothurOut* mout, float sig, float n, int numF, int maxF, int minF, int maxH, int td, int bd, int pd, int tid) {
-               flowFileName = ff;
-               trimFlowFileName = tf;
-               scrapFlowFileName = sf;
-               fastaFileName = f;
-               flowOrder = fo;
-               barcodePrimerComboFileNames = bfn;
-               barcodes = bar;
-               primers = pri;
-               revPrimer = rev;
-               fasta = fa;
-               allFiles = al;
-               start = st;
-               end = en;
-               m = mout;
-               signal = sig;
-               noise = n;
-               numFlows = numF;
-               maxFlows = maxF;
-               minFlows = minF;
-               maxHomoP = maxH;
-               tdiffs = td;
-               bdiffs = bd;
-               pdiffs = pd;
-               threadID = tid;
-       }
-};
-
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyTrimFlowThreadFunction(LPVOID lpParam){ 
-       trimFlowData* pDataArray;
-       pDataArray = (trimFlowData*)lpParam;
-       
-       try {
-               ofstream trimFlowFile;
-               pDataArray->m->openOutputFile(pDataArray->trimFlowFileName, trimFlowFile);
-               trimFlowFile.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
-               
-               ofstream scrapFlowFile;
-               pDataArray->m->openOutputFile(pDataArray->scrapFlowFileName, scrapFlowFile);
-               scrapFlowFile.setf(ios::fixed, ios::floatfield); scrapFlowFile.setf(ios::showpoint);
-               
-               ofstream fastaFile;
-               if(pDataArray->fasta){  pDataArray->m->openOutputFile(pDataArray->fastaFileName, fastaFile);    }
-               
-               ifstream flowFile;
-               pDataArray->m->openInputFile(pDataArray->flowFileName, flowFile);
-               
-               flowFile.seekg(pDataArray->start);
-               
-               if(pDataArray->start == 0){
-                       flowFile >> pDataArray->numFlows; pDataArray->m->gobble(flowFile);
-                       scrapFlowFile << pDataArray->maxFlows << endl;
-                       trimFlowFile << pDataArray->maxFlows << endl;
-                       if(pDataArray->allFiles){
-                               for(int i=0;i<pDataArray->barcodePrimerComboFileNames.size();i++){
-                                       for(int j=0;j<pDataArray->barcodePrimerComboFileNames[0].size();j++){
-                                               ofstream temp;
-                                               pDataArray->m->openOutputFile(pDataArray->barcodePrimerComboFileNames[i][j], temp);
-                                               temp << pDataArray->maxFlows << endl;
-                                               temp.close();
-                                       }
-                               }                       
-                       }
-               }
-               
-               FlowData flowData(pDataArray->numFlows, pDataArray->signal, pDataArray->noise, pDataArray->maxHomoP, pDataArray->flowOrder);
-               cout << " thread flowdata address " <<  &flowData  << '\t' << &flowFile << endl;
-               TrimOligos trimOligos(pDataArray->pdiffs, pDataArray->bdiffs, pDataArray->primers, pDataArray->barcodes, pDataArray->revPrimer);
-               
-               pDataArray->count = pDataArray->end;
-               cout << pDataArray->threadID << '\t' << pDataArray->count << endl;
-               int count = 0;
-               for(int i = 0; i < pDataArray->end; i++){ //end is the number of sequences to process
-                       
-                       if (pDataArray->m->control_pressed) {  break; }
-                       cout << pDataArray->threadID << '\t' << count << endl;
-                       int success = 1;
-                       int currentSeqDiffs = 0;
-                       string trashCode = "";
-                               
-                       flowData.getNext(flowFile);
-                       cout << "thread good bit " << flowFile.good() << endl;
-                       flowData.capFlows(pDataArray->maxFlows);        
-                       
-                       Sequence currSeq = flowData.getSequence();
-                       if(!flowData.hasMinFlows(pDataArray->minFlows)){        //screen to see if sequence is of a minimum number of flows
-                               success = 0;
-                               trashCode += 'l';
-                       }
-                       
-                       int primerIndex = 0;
-                       int barcodeIndex = 0;
-                       
-                       if(pDataArray->barcodes.size() != 0){
-                               success = trimOligos.stripBarcode(currSeq, barcodeIndex);
-                               if(success > pDataArray->bdiffs)                {       trashCode += 'b';       }
-                               else{ currentSeqDiffs += success;  }
-                       }
-                       
-                       if(pDataArray->primers.size() != 0){
-                               success = trimOligos.stripForward(currSeq, primerIndex);
-                               if(success > pDataArray->pdiffs)                {       trashCode += 'f';       }
-                               else{ currentSeqDiffs += success;  }
-                       }
-                       
-                       if (currentSeqDiffs > pDataArray->tdiffs)       {       trashCode += 't';   }
-                       
-                       if(pDataArray->revPrimer.size() != 0){
-                               success = trimOligos.stripReverse(currSeq);
-                               if(!success)                            {       trashCode += 'r';       }
-                       }
-                       
-                       if(trashCode.length() == 0){
-                               
-                               flowData.printFlows(trimFlowFile);
-                               
-                               if(pDataArray->fasta)   {       currSeq.printSequence(fastaFile);       }
-                               
-                               if(pDataArray->allFiles){
-                                       ofstream output;
-                                       pDataArray->m->openOutputFileAppend(pDataArray->barcodePrimerComboFileNames[barcodeIndex][primerIndex], output);
-                                       output.setf(ios::fixed, ios::floatfield); trimFlowFile.setf(ios::showpoint);
-                                       
-                                       flowData.printFlows(output);
-                                       output.close();
-                               }                               
-                       }
-                       else{
-                               flowData.printFlows(scrapFlowFile, trashCode);
-                       }
-                       
-                       count++;
-                               cout << pDataArray->threadID << '\t' << currSeq.getName() << endl;              
-                       //report progress
-                       if((count) % 10000 == 0){       pDataArray->m->mothurOut(toString(count)); pDataArray->m->mothurOutEndLine();           }
-                       
-               }
-               //report progress
-               if((count) % 10000 != 0){       pDataArray->m->mothurOut(toString(count)); pDataArray->m->mothurOutEndLine();           }
-               
-               trimFlowFile.close();
-               scrapFlowFile.close();
-               flowFile.close();
-               if(pDataArray->fasta){  fastaFile.close();      }
-               
-       }
-       catch(exception& e) {
-               pDataArray->m->errorOut(e, "TrimFlowsCommand", "MyTrimFlowsThreadFunction");
-               exit(1);
-       }
-} 
-#endif
-
-
-#endif
diff --git a/trimoligos.cpp b/trimoligos.cpp
deleted file mode 100644 (file)
index 8c523ce..0000000
+++ /dev/null
@@ -1,1080 +0,0 @@
-/*
- *  trimoligos.cpp
- *  Mothur
- *
- *  Created by westcott on 9/1/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "trimoligos.h"
-#include "alignment.hpp"
-#include "needlemanoverlap.hpp"
-
-
-/********************************************************************/
-//strip, pdiffs, bdiffs, primers, barcodes, revPrimers
-TrimOligos::TrimOligos(int p, int b, int l, int s, map<string, int> pr, map<string, int> br, vector<string> r, vector<string> lk, vector<string> sp){
-       try {
-               m = MothurOut::getInstance();
-               
-               pdiffs = p;
-               bdiffs = b;
-        ldiffs = l;
-        sdiffs = s;
-               
-               barcodes = br;
-               primers = pr;
-               revPrimer = r;
-        linker = lk;
-        spacer = sp;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "TrimOligos");
-               exit(1);
-       }
-}
-/********************************************************************/
-//strip, pdiffs, bdiffs, primers, barcodes, revPrimers
-TrimOligos::TrimOligos(int p, int b, map<string, int> pr, map<string, int> br, vector<string> r){
-       try {
-               m = MothurOut::getInstance();
-               
-               pdiffs = p;
-               bdiffs = b;
-               
-               barcodes = br;
-               primers = pr;
-               revPrimer = r;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "TrimOligos");
-               exit(1);
-       }
-}
-/********************************************************************/
-TrimOligos::~TrimOligos() {}
-//*******************************************************************/
-int TrimOligos::stripBarcode(Sequence& seq, QualityScores& qual, int& group){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               int success = bdiffs + 1;       //guilty until proven innocent
-               
-               //can you find the barcode
-               for(map<string,int>::iterator it=barcodes.begin();it!=barcodes.end();it++){
-                       string oligo = it->first;
-                       if(rawSequence.length() < oligo.length()){      //let's just assume that the barcodes are the same length
-                               success = bdiffs + 10;                                  //if the sequence is shorter than the barcode then bail out
-                               break;  
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               group = it->second;
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(oligo.length(), -1);
-                               }
-                               
-                               success = 0;
-                               break;
-                       }
-               }
-               
-               //if you found the barcode or if you don't want to allow for diffs
-               if ((bdiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (barcodes.size() > 0) {
-                               map<string,int>::iterator it; 
-                               
-                               for(it=barcodes.begin();it!=barcodes.end();it++){
-                                       if(it->first.length() > maxLength){
-                                               maxLength = it->first.length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+bdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minGroup = -1;
-                       int minPos = 0;
-                       
-                       for(map<string,int>::iterator it=barcodes.begin();it!=barcodes.end();it++){
-                               string oligo = it->first;
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = bdiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+bdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minGroup = it->second;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > bdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = bdiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               group = minGroup;
-                               seq.setUnaligned(rawSequence.substr(minPos));
-    
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(minPos, -1);
-                               }
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-               
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripBarcode");
-               exit(1);
-       }
-       
-}
-//*******************************************************************/
-int TrimOligos::stripBarcode(Sequence& seq, int& group){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               int success = bdiffs + 1;       //guilty until proven innocent
-               
-               //can you find the barcode
-               for(map<string,int>::iterator it=barcodes.begin();it!=barcodes.end();it++){
-                       string oligo = it->first;
-                       if(rawSequence.length() < oligo.length()){      //let's just assume that the barcodes are the same length
-                               success = bdiffs + 10;                                  //if the sequence is shorter than the barcode then bail out
-                               break;  
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               group = it->second;
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               
-                               success = 0;
-                               break;
-                       }
-               }
-               
-               //if you found the barcode or if you don't want to allow for diffs
-               if ((bdiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (barcodes.size() > 0) {
-                               map<string,int>::iterator it=barcodes.begin();
-                               
-                               for(map<string,int>::iterator it=barcodes.begin();it!=barcodes.end();it++){
-                                       if(it->first.length() > maxLength){
-                                               maxLength = it->first.length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+bdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minGroup = -1;
-                       int minPos = 0;
-                       
-                       for(map<string,int>::iterator it=barcodes.begin();it!=barcodes.end();it++){
-                               string oligo = it->first;
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = bdiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+bdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minGroup = it->second;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > bdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = bdiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               group = minGroup;
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-               
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripBarcode");
-               exit(1);
-       }
-       
-}
-//********************************************************************/
-int TrimOligos::stripForward(Sequence& seq, int& group){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               int success = pdiffs + 1;       //guilty until proven innocent
-               
-               //can you find the primer
-               for(map<string,int>::iterator it=primers.begin();it!=primers.end();it++){
-                       string oligo = it->first;
-                       if(rawSequence.length() < oligo.length()){      //let's just assume that the primers are the same length
-                               success = pdiffs + 10;                                  //if the sequence is shorter than the barcode then bail out
-                               break;  
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               group = it->second;
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               success = 0;
-                               break;
-                       }
-               }
-               
-               //if you found the barcode or if you don't want to allow for diffs
-               if ((pdiffs == 0) || (success == 0)) {  return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (primers.size() > 0) {
-                               map<string,int>::iterator it; 
-                               
-                               for(it=primers.begin();it!=primers.end();it++){
-                                       if(it->first.length() > maxLength){
-                                               maxLength = it->first.length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+pdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minGroup = -1;
-                       int minPos = 0;
-                       
-                       for(map<string,int>::iterator it=primers.begin();it!=primers.end();it++){
-                               string oligo = it->first;
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   
-                                       success = pdiffs + 100;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+pdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minGroup = it->second;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > pdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = pdiffs + 10;  }       //can't tell the difference between multiple primers
-                       else{                                                                                                   //use the best match
-                               group = minGroup;
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-               
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripForward");
-               exit(1);
-       }
-}
-//*******************************************************************/
-int TrimOligos::stripForward(Sequence& seq, QualityScores& qual, int& group, bool keepForward){
-       try {
-               string rawSequence = seq.getUnaligned();
-               int success = pdiffs + 1;       //guilty until proven innocent
-               
-               //can you find the primer
-               for(map<string,int>::iterator it=primers.begin();it!=primers.end();it++){
-                       string oligo = it->first;
-                       if(rawSequence.length() < oligo.length()){      //let's just assume that the primers are the same length
-                               success = pdiffs + 10;                                  //if the sequence is shorter than the barcode then bail out
-                               break;  
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               group = it->second;
-                               if (!keepForward) { seq.setUnaligned(rawSequence.substr(oligo.length())); }
-                               if(qual.getName() != ""){
-                                       if (!keepForward) {  qual.trimQScores(oligo.length(), -1); }
-                               }
-                               success = 0;
-                               break;
-                       }
-               }
-               
-               //if you found the barcode or if you don't want to allow for diffs
-               if ((pdiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (primers.size() > 0) {
-                               map<string,int>::iterator it; 
-                               
-                               for(it=primers.begin();it!=primers.end();it++){
-                                       if(it->first.length() > maxLength){
-                                               maxLength = it->first.length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+pdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minGroup = -1;
-                       int minPos = 0;
-                       
-                       for(map<string,int>::iterator it=primers.begin();it!=primers.end();it++){
-                               string oligo = it->first;
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   
-                                       success = pdiffs + 100;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+pdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minGroup = it->second;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > pdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = pdiffs + 10;  }       //can't tell the difference between multiple primers
-                       else{                                                                                                   //use the best match
-                               group = minGroup;
-                               if (!keepForward) { seq.setUnaligned(rawSequence.substr(minPos)); }
-                               if(qual.getName() != ""){
-                                       if (!keepForward) { qual.trimQScores(minPos, -1); }
-                               }
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-               
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripForward");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool TrimOligos::stripReverse(Sequence& seq, QualityScores& qual){
-       try {
-               string rawSequence = seq.getUnaligned();
-               bool success = 0;       //guilty until proven innocent
-               
-               for(int i=0;i<revPrimer.size();i++){
-                       string oligo = revPrimer[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = 0;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(rawSequence.length()-oligo.length(),oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(0,rawSequence.length()-oligo.length()));
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(-1, rawSequence.length()-oligo.length());
-                               }
-                               success = 1;
-                               break;
-                       }
-               }       
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripReverse");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool TrimOligos::stripReverse(Sequence& seq){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               bool success = 0;       //guilty until proven innocent
-               
-               for(int i=0;i<revPrimer.size();i++){
-                       string oligo = revPrimer[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = 0;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(rawSequence.length()-oligo.length(),oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(0,rawSequence.length()-oligo.length()));
-                               success = 1;
-                               break;
-                       }
-               }       
-               
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripReverse");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool TrimOligos::stripLinker(Sequence& seq, QualityScores& qual){
-       try {
-               string rawSequence = seq.getUnaligned();
-               bool success = ldiffs + 1;      //guilty until proven innocent
-               
-               for(int i=0;i<linker.size();i++){
-                       string oligo = linker[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = ldiffs + 10;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(oligo.length(), -1);
-                               }
-                               success = 0;
-                               break;
-                       }
-               }
-        
-        //if you found the linker or if you don't want to allow for diffs
-               if ((ldiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (linker.size() > 0) {
-                               for(int i = 0; i < linker.size(); i++){
-                                       if(linker[i].length() > maxLength){
-                                               maxLength = linker[i].length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+ldiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minPos = 0;
-                       
-                       for(int i = 0; i < linker.size(); i++){
-                               string oligo = linker[i];
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = ldiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+ldiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > ldiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = ldiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(minPos, -1);
-                               }
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-
-       
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripLinker");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool TrimOligos::stripLinker(Sequence& seq){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               bool success = ldiffs +1;       //guilty until proven innocent
-               
-               for(int i=0;i<linker.size();i++){
-                       string oligo = linker[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = ldiffs +10;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               success = 0;
-                               break;
-                       }
-               }       
-               
-        //if you found the linker or if you don't want to allow for diffs
-               if ((ldiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (linker.size() > 0) {
-                               for(int i = 0; i < linker.size(); i++){
-                                       if(linker[i].length() > maxLength){
-                                               maxLength = linker[i].length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+ldiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minPos = 0;
-                       
-                       for(int i = 0; i < linker.size(); i++){
-                               string oligo = linker[i];
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = ldiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+ldiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > ldiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = ldiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripLinker");
-               exit(1);
-       }
-}
-
-//******************************************************************/
-bool TrimOligos::stripSpacer(Sequence& seq, QualityScores& qual){
-       try {
-               string rawSequence = seq.getUnaligned();
-               bool success = sdiffs+1;        //guilty until proven innocent
-               
-               for(int i=0;i<spacer.size();i++){
-                       string oligo = spacer[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = sdiffs+10;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(oligo.length(), -1);
-                               }
-                               success = 0;
-                               break;
-                       }
-               }
-        
-        //if you found the spacer or if you don't want to allow for diffs
-               if ((sdiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (spacer.size() > 0) {
-                               for(int i = 0; i < spacer.size(); i++){
-                                       if(spacer[i].length() > maxLength){
-                                               maxLength = spacer[i].length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+sdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minPos = 0;
-                       
-                       for(int i = 0; i < spacer.size(); i++){
-                               string oligo = spacer[i];
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = sdiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+sdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > sdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = sdiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               
-                               if(qual.getName() != ""){
-                                       qual.trimQScores(minPos, -1);
-                               }
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-        
-
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripSpacer");
-               exit(1);
-       }
-}
-//******************************************************************/
-bool TrimOligos::stripSpacer(Sequence& seq){
-       try {
-               
-               string rawSequence = seq.getUnaligned();
-               bool success = sdiffs+1;        //guilty until proven innocent
-               
-               for(int i=0;i<spacer.size();i++){
-                       string oligo = spacer[i];
-                       
-                       if(rawSequence.length() < oligo.length()){
-                               success = sdiffs+10;
-                               break;
-                       }
-                       
-                       if(compareDNASeq(oligo, rawSequence.substr(0,oligo.length()))){
-                               seq.setUnaligned(rawSequence.substr(oligo.length()));
-                               success = 0;
-                               break;
-                       }
-               }       
-               
-        //if you found the spacer or if you don't want to allow for diffs
-               if ((sdiffs == 0) || (success == 0)) { return success;  }
-               
-               else { //try aligning and see if you can find it
-                       
-                       int maxLength = 0;
-                       
-                       Alignment* alignment;
-                       if (spacer.size() > 0) {
-                               for(int i = 0; i < spacer.size(); i++){
-                                       if(spacer[i].length() > maxLength){
-                                               maxLength = spacer[i].length();
-                                       }
-                               }
-                               alignment = new NeedlemanOverlap(-1.0, 1.0, -1.0, (maxLength+sdiffs+1));  
-                               
-                       }else{ alignment = NULL; } 
-                       
-                       //can you find the barcode
-                       int minDiff = 1e6;
-                       int minCount = 1;
-                       int minPos = 0;
-                       
-                       for(int i = 0; i < spacer.size(); i++){
-                               string oligo = spacer[i];
-                               //                              int length = oligo.length();
-                               
-                               if(rawSequence.length() < maxLength){   //let's just assume that the barcodes are the same length
-                                       success = sdiffs + 10;
-                                       break;
-                               }
-                               
-                               //use needleman to align first barcode.length()+numdiffs of sequence to each barcode
-                               alignment->align(oligo, rawSequence.substr(0,oligo.length()+sdiffs));
-                               oligo = alignment->getSeqAAln();
-                               string temp = alignment->getSeqBAln();
-                               
-                               int alnLength = oligo.length();
-                               
-                               for(int i=oligo.length()-1;i>=0;i--){
-                                       if(oligo[i] != '-'){    alnLength = i+1;        break;  }
-                               }
-                               oligo = oligo.substr(0,alnLength);
-                               temp = temp.substr(0,alnLength);
-                               
-                               int numDiff = countDiffs(oligo, temp);
-                               
-                               if(numDiff < minDiff){
-                                       minDiff = numDiff;
-                                       minCount = 1;
-                                       minPos = 0;
-                                       for(int i=0;i<alnLength;i++){
-                                               if(temp[i] != '-'){
-                                                       minPos++;
-                                               }
-                                       }
-                               }
-                               else if(numDiff == minDiff){
-                                       minCount++;
-                               }
-                               
-                       }
-                       
-                       if(minDiff > sdiffs)    {       success = minDiff;              }       //no good matches
-                       else if(minCount > 1)   {       success = sdiffs + 100; }       //can't tell the difference between multiple barcodes
-                       else{                                                                                                   //use the best match
-                               seq.setUnaligned(rawSequence.substr(minPos));
-                               success = minDiff;
-                       }
-                       
-                       if (alignment != NULL) {  delete alignment;  }
-                       
-               }
-
-               return success;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "stripSpacer");
-               exit(1);
-       }
-}
-
-//******************************************************************/
-bool TrimOligos::compareDNASeq(string oligo, string seq){
-       try {
-               bool success = 1;
-               int length = oligo.length();
-               
-               for(int i=0;i<length;i++){
-                       
-                       if(oligo[i] != seq[i]){
-                               if(oligo[i] == 'A' || oligo[i] == 'T' || oligo[i] == 'G' || oligo[i] == 'C')    {       success = 0;    }
-                               else if((oligo[i] == 'N' || oligo[i] == 'I') && (seq[i] == 'N'))                                {       success = 0;    }
-                               else if(oligo[i] == 'R' && (seq[i] != 'A' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'Y' && (seq[i] != 'C' && seq[i] != 'T'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'M' && (seq[i] != 'C' && seq[i] != 'A'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'K' && (seq[i] != 'T' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'W' && (seq[i] != 'T' && seq[i] != 'A'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'S' && (seq[i] != 'C' && seq[i] != 'G'))                                    {       success = 0;    }
-                               else if(oligo[i] == 'B' && (seq[i] != 'C' && seq[i] != 'T' && seq[i] != 'G'))   {       success = 0;    }
-                               else if(oligo[i] == 'D' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'G'))   {       success = 0;    }
-                               else if(oligo[i] == 'H' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'C'))   {       success = 0;    }
-                               else if(oligo[i] == 'V' && (seq[i] != 'A' && seq[i] != 'C' && seq[i] != 'G'))   {       success = 0;    }                       
-                               
-                               if(success == 0)        {       break;   }
-                       }
-                       else{
-                               success = 1;
-                       }
-               }
-               
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "compareDNASeq");
-               exit(1);
-       }
-       
-}
-//********************************************************************/
-int TrimOligos::countDiffs(string oligo, string seq){
-       try {
-               
-               int length = oligo.length();
-               int countDiffs = 0;
-               
-               for(int i=0;i<length;i++){
-                       
-                       if(oligo[i] != seq[i]){
-                               if(oligo[i] == 'A' || oligo[i] == 'T' || oligo[i] == 'G' || oligo[i] == 'C' || oligo[i] == '-' || oligo[i] == '.')      {       countDiffs++;   }
-                               else if((oligo[i] == 'N' || oligo[i] == 'I') && (seq[i] == 'N'))                                {       countDiffs++;   }
-                               else if(oligo[i] == 'R' && (seq[i] != 'A' && seq[i] != 'G'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'Y' && (seq[i] != 'C' && seq[i] != 'T'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'M' && (seq[i] != 'C' && seq[i] != 'A'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'K' && (seq[i] != 'T' && seq[i] != 'G'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'W' && (seq[i] != 'T' && seq[i] != 'A'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'S' && (seq[i] != 'C' && seq[i] != 'G'))                                    {       countDiffs++;   }
-                               else if(oligo[i] == 'B' && (seq[i] != 'C' && seq[i] != 'T' && seq[i] != 'G'))   {       countDiffs++;   }
-                               else if(oligo[i] == 'D' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'G'))   {       countDiffs++;   }
-                               else if(oligo[i] == 'H' && (seq[i] != 'A' && seq[i] != 'T' && seq[i] != 'C'))   {       countDiffs++;   }
-                               else if(oligo[i] == 'V' && (seq[i] != 'A' && seq[i] != 'C' && seq[i] != 'G'))   {       countDiffs++;   }       
-                       }
-                       
-               }
-               
-               return countDiffs;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimOligos", "countDiffs");
-               exit(1);
-       }
-}
-/********************************************************************/
-
-
-
diff --git a/trimoligos.h b/trimoligos.h
deleted file mode 100644 (file)
index e3ea7d5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef TRIMOLIGOS_H
-#define TRIMOLIGOS_H
-
-/*
- *  trimoligos.h
- *  Mothur
- *
- *  Created by westcott on 9/1/11.
- *  Copyright 2011 Schloss Lab. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-#include "sequence.hpp"
-#include "qualityscores.h"
-
-
-class TrimOligos {
-       
-       public:
-        TrimOligos(int,int, map<string, int>, map<string, int>, vector<string>); //pdiffs, bdiffs, primers, barcodes, revPrimers
-               TrimOligos(int,int, int, int, map<string, int>, map<string, int>, vector<string>, vector<string>, vector<string>); //pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimers, linker, spacer
-               ~TrimOligos();
-       
-               int stripBarcode(Sequence&, int&);      
-               int stripBarcode(Sequence&, QualityScores&, int&);
-       
-               int stripForward(Sequence&, int&);
-               int stripForward(Sequence&, QualityScores&, int&, bool);
-       
-               bool stripReverse(Sequence&);
-               bool stripReverse(Sequence&, QualityScores&);
-    
-        bool stripLinker(Sequence&);
-        bool stripLinker(Sequence&, QualityScores&);
-    
-        bool stripSpacer(Sequence&);
-        bool stripSpacer(Sequence&, QualityScores&);
-                               
-       
-       private:
-               int pdiffs, bdiffs, ldiffs, sdiffs;
-       
-               map<string, int> barcodes;
-               map<string, int> primers;
-               vector<string> revPrimer;
-        vector<string> linker;
-        vector<string> spacer;
-       
-               MothurOut* m;
-       
-               bool compareDNASeq(string, string);                             
-               int countDiffs(string, string);                 
-};
-
-#endif
-
diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp
deleted file mode 100644 (file)
index 9f8fafb..0000000
+++ /dev/null
@@ -1,1543 +0,0 @@
-/*
- *  trimseqscommand.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 6/6/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "trimseqscommand.h"
-#include "needlemanoverlap.hpp"
-#include "trimoligos.h"
-
-//**********************************************************************************************************************
-vector<string> TrimSeqsCommand::setParameters(){       
-       try {
-               CommandParameter pfasta("fasta", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pfasta);
-               CommandParameter poligos("oligos", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(poligos);
-               CommandParameter pqfile("qfile", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pqfile);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pflip("flip", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pflip);
-               CommandParameter pmaxambig("maxambig", "Number", "", "-1", "", "", "",false,false); parameters.push_back(pmaxambig);
-               CommandParameter pmaxhomop("maxhomop", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxhomop);
-               CommandParameter pminlength("minlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pminlength);
-               CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxlength);
-               CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs);
-               CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs);
-        CommandParameter pldiffs("ldiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pldiffs);
-               CommandParameter psdiffs("sdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(psdiffs);
-        CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter pallfiles("allfiles", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pallfiles);
-               CommandParameter pkeepforward("keepforward", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pkeepforward);
-               CommandParameter pqtrim("qtrim", "Boolean", "", "T", "", "", "",false,false); parameters.push_back(pqtrim);
-               CommandParameter pqthreshold("qthreshold", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqthreshold);
-               CommandParameter pqaverage("qaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqaverage);
-               CommandParameter prollaverage("rollaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(prollaverage);
-               CommandParameter pqwindowaverage("qwindowaverage", "Number", "", "0", "", "", "",false,false); parameters.push_back(pqwindowaverage);
-               CommandParameter pqstepsize("qstepsize", "Number", "", "1", "", "", "",false,false); parameters.push_back(pqstepsize);
-               CommandParameter pqwindowsize("qwindowsize", "Number", "", "50", "", "", "",false,false); parameters.push_back(pqwindowsize);
-               CommandParameter pkeepfirst("keepfirst", "Number", "", "0", "", "", "",false,false); parameters.push_back(pkeepfirst);
-               CommandParameter premovelast("removelast", "Number", "", "0", "", "", "",false,false); parameters.push_back(premovelast);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-                       
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string TrimSeqsCommand::getHelpString(){       
-       try {
-               string helpString = "";
-               helpString += "The trim.seqs command reads a fastaFile and creates 2 new fasta files, .trim.fasta and scrap.fasta, as well as group files if you provide and oligos file.\n";
-               helpString += "The .trim.fasta contains sequences that meet your requirements, and the .scrap.fasta contains those which don't.\n";
-               helpString += "The trim.seqs command parameters are fasta, name, flip, oligos, maxambig, maxhomop, minlength, maxlength, qfile, qthreshold, qaverage, diffs, qtrim, keepfirst, removelast and allfiles.\n";
-               helpString += "The fasta parameter is required.\n";
-               helpString += "The flip parameter will output the reverse compliment of your trimmed sequence. The default is false.\n";
-               helpString += "The oligos parameter allows you to provide an oligos file.\n";
-               helpString += "The name parameter allows you to provide a names file with your fasta file.\n";
-               helpString += "The maxambig parameter allows you to set the maximum number of ambigious bases allowed. The default is -1.\n";
-               helpString += "The maxhomop parameter allows you to set a maximum homopolymer length. \n";
-               helpString += "The minlength parameter allows you to set and minimum sequence length. \n";
-               helpString += "The maxlength parameter allows you to set and maximum sequence length. \n";
-               helpString += "The tdiffs parameter is used to specify the total number of differences allowed in the sequence. The default is pdiffs + bdiffs + sdiffs + ldiffs.\n";
-               helpString += "The bdiffs parameter is used to specify the number of differences allowed in the barcode. The default is 0.\n";
-               helpString += "The pdiffs parameter is used to specify the number of differences allowed in the primer. The default is 0.\n";
-        helpString += "The ldiffs parameter is used to specify the number of differences allowed in the linker. The default is 0.\n";
-               helpString += "The sdiffs parameter is used to specify the number of differences allowed in the spacer. The default is 0.\n";
-               helpString += "The qfile parameter allows you to provide a quality file.\n";
-               helpString += "The qthreshold parameter allows you to set a minimum quality score allowed. \n";
-               helpString += "The qaverage parameter allows you to set a minimum average quality score allowed. \n";
-               helpString += "The qwindowsize parameter allows you to set a number of bases in a window. Default=50.\n";
-               helpString += "The qwindowaverage parameter allows you to set a minimum average quality score allowed over a window. \n";
-               helpString += "The rollaverage parameter allows you to set a minimum rolling average quality score allowed over a window. \n";
-               helpString += "The qstepsize parameter allows you to set a number of bases to move the window over. Default=1.\n";
-               helpString += "The allfiles parameter will create separate group and fasta file for each grouping. The default is F.\n";
-               helpString += "The keepforward parameter allows you to indicate whether you want the forward primer removed or not. The default is F, meaning remove the forward primer.\n";
-               helpString += "The qtrim parameter will trim sequence from the point that they fall below the qthreshold and put it in the .trim file if set to true. The default is T.\n";
-               helpString += "The keepfirst parameter trims the sequence to the first keepfirst number of bases after the barcode or primers are removed, before the sequence is checked to see if it meets the other requirements. \n";
-               helpString += "The removelast removes the last removelast number of bases after the barcode or primers are removed, before the sequence is checked to see if it meets the other requirements.\n";
-               helpString += "The trim.seqs command should be in the following format: \n";
-               helpString += "trim.seqs(fasta=yourFastaFile, flip=yourFlip, oligos=yourOligos, maxambig=yourMaxambig,  \n";
-               helpString += "maxhomop=yourMaxhomop, minlength=youMinlength, maxlength=yourMaxlength)  \n";    
-               helpString += "Example trim.seqs(fasta=abrecovery.fasta, flip=..., oligos=..., maxambig=..., maxhomop=..., minlength=..., maxlength=...).\n";
-               helpString += "Note: No spaces between parameter labels (i.e. fasta), '=' and parameters (i.e.yourFasta).\n";
-               helpString += "For more details please check out the wiki http://www.mothur.org/wiki/Trim.seqs .\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-
-//**********************************************************************************************************************
-
-TrimSeqsCommand::TrimSeqsCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["fasta"] = tempOutNames;
-               outputTypes["qfile"] = tempOutNames;
-               outputTypes["group"] = tempOutNames;
-               outputTypes["name"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-TrimSeqsCommand::TrimSeqsCommand(string option)  {
-       try {
-               
-               abort = false; calledHelp = false;   
-               comboStarts = 0;
-               
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       
-                       ValidParameters validParameter;
-                       map<string,string>::iterator it;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["fasta"] = tempOutNames;
-                       outputTypes["qfile"] = tempOutNames;
-                       outputTypes["group"] = tempOutNames;
-                       outputTypes["name"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("fasta");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["fasta"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("oligos");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["oligos"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("qfile");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["qfile"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                               
-                       }
-
-                       
-                       //check for required parameters
-                       fastaFile = validParameter.validFile(parameters, "fasta", true);
-                       if (fastaFile == "not found") {                                 
-                               fastaFile = m->getFastaFile(); 
-                               if (fastaFile != "") { m->mothurOut("Using " + fastaFile + " as input file for the fasta parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current fastafile and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; }
-                       }else if (fastaFile == "not open") { abort = true; }    
-                       else { m->setFastaFile(fastaFile); }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  
-                               outputDir = ""; 
-                               outputDir += m->hasPath(fastaFile); //if user entered a file with a path then preserve it       
-                       }
-               
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       string temp;
-                       temp = validParameter.validFile(parameters, "flip", false);
-                       if (temp == "not found")    {   flip = 0;       }
-                       else {  flip = m->isTrue(temp);         }
-               
-                       temp = validParameter.validFile(parameters, "oligos", true);
-                       if (temp == "not found"){       oligoFile = "";         }
-                       else if(temp == "not open"){    abort = true;   } 
-                       else                                    {       oligoFile = temp; m->setOligosFile(oligoFile);          }
-                       
-                       
-                       temp = validParameter.validFile(parameters, "maxambig", false);         if (temp == "not found") { temp = "-1"; }
-                       m->mothurConvert(temp, maxAmbig);  
-
-                       temp = validParameter.validFile(parameters, "maxhomop", false);         if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, maxHomoP);  
-
-                       temp = validParameter.validFile(parameters, "minlength", false);        if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, minLength); 
-                       
-                       temp = validParameter.validFile(parameters, "maxlength", false);        if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, maxLength);
-                       
-                       temp = validParameter.validFile(parameters, "bdiffs", false);           if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, bdiffs);
-                       
-                       temp = validParameter.validFile(parameters, "pdiffs", false);           if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, pdiffs);
-            
-            temp = validParameter.validFile(parameters, "ldiffs", false);              if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, ldiffs);
-            
-            temp = validParameter.validFile(parameters, "sdiffs", false);              if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, sdiffs);
-                       
-                       temp = validParameter.validFile(parameters, "tdiffs", false);           if (temp == "not found") { int tempTotal = pdiffs + bdiffs + ldiffs + sdiffs;  temp = toString(tempTotal); }
-                       m->mothurConvert(temp, tdiffs);
-                       
-                       if(tdiffs == 0){        tdiffs = bdiffs + pdiffs + ldiffs + sdiffs;     }
-                       
-                       temp = validParameter.validFile(parameters, "qfile", true);     
-                       if (temp == "not found")        {       qFileName = "";         }
-                       else if(temp == "not open")     {       abort = true;           }
-                       else                                            {       qFileName = temp;       m->setQualFile(qFileName); }
-                       
-                       temp = validParameter.validFile(parameters, "name", true);      
-                       if (temp == "not found")        {       nameFile = "";          }
-                       else if(temp == "not open")     {       nameFile = "";  abort = true;           }
-                       else                                            {       nameFile = temp;        m->setNameFile(nameFile); }
-                       
-                       temp = validParameter.validFile(parameters, "qthreshold", false);       if (temp == "not found") { temp = "0"; }
-                       m->mothurConvert(temp, qThreshold);
-                       
-                       temp = validParameter.validFile(parameters, "qtrim", false);            if (temp == "not found") { temp = "t"; }
-                       qtrim = m->isTrue(temp);
-
-                       temp = validParameter.validFile(parameters, "rollaverage", false);      if (temp == "not found") { temp = "0"; }
-                       convert(temp, qRollAverage);
-
-                       temp = validParameter.validFile(parameters, "qwindowaverage", false);if (temp == "not found") { temp = "0"; }
-                       convert(temp, qWindowAverage);
-
-                       temp = validParameter.validFile(parameters, "qwindowsize", false);      if (temp == "not found") { temp = "50"; }
-                       convert(temp, qWindowSize);
-
-                       temp = validParameter.validFile(parameters, "qstepsize", false);        if (temp == "not found") { temp = "1"; }
-                       convert(temp, qWindowStep);
-
-                       temp = validParameter.validFile(parameters, "qaverage", false);         if (temp == "not found") { temp = "0"; }
-                       convert(temp, qAverage);
-
-                       temp = validParameter.validFile(parameters, "keepfirst", false);        if (temp == "not found") { temp = "0"; }
-                       convert(temp, keepFirst);
-
-                       temp = validParameter.validFile(parameters, "removelast", false);       if (temp == "not found") { temp = "0"; }
-                       convert(temp, removeLast);
-                       
-                       temp = validParameter.validFile(parameters, "allfiles", false);         if (temp == "not found") { temp = "F"; }
-                       allFiles = m->isTrue(temp);
-            
-            temp = validParameter.validFile(parameters, "keepforward", false);         if (temp == "not found") { temp = "F"; }
-                       keepforward = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-                       
-                       if(allFiles && (oligoFile == "")){
-                               m->mothurOut("You selected allfiles, but didn't enter an oligos.  Ignoring the allfiles request."); m->mothurOutEndLine();
-                       }
-                       if((qAverage != 0 && qThreshold != 0) && qFileName == ""){
-                               m->mothurOut("You didn't provide a quality file name, quality criteria will be ignored."); m->mothurOutEndLine();
-                               qAverage=0;
-                               qThreshold=0;
-                       }
-                       if(!flip && oligoFile=="" && !maxLength && !minLength && (maxAmbig==-1) && !maxHomoP && qFileName == ""){               
-                               m->mothurOut("You didn't set any options... quiting command."); m->mothurOutEndLine();
-                               abort = true;
-                       }
-                       
-                       if (nameFile == "") {
-                               vector<string> files; files.push_back(fastaFile);
-                               parser.getNameFile(files);
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "TrimSeqsCommand");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-int TrimSeqsCommand::execute(){
-       try{
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               numFPrimers = 0;  //this needs to be initialized
-               numRPrimers = 0;
-        numSpacers = 0;
-        numLinkers = 0;
-               createGroup = false;
-               vector<vector<string> > fastaFileNames;
-               vector<vector<string> > qualFileNames;
-               vector<vector<string> > nameFileNames;
-               
-               string trimSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.fasta";
-               outputNames.push_back(trimSeqFile); outputTypes["fasta"].push_back(trimSeqFile);
-               
-               string scrapSeqFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.fasta";
-               outputNames.push_back(scrapSeqFile); outputTypes["fasta"].push_back(scrapSeqFile);
-               
-               string trimQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "trim.qual";
-               string scrapQualFile = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "scrap.qual";
-               
-               if (qFileName != "") {
-                       outputNames.push_back(trimQualFile);
-                       outputNames.push_back(scrapQualFile);
-                       outputTypes["qfile"].push_back(trimQualFile);
-                       outputTypes["qfile"].push_back(scrapQualFile); 
-               }
-               
-               string trimNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "trim.names";
-               string scrapNameFile = outputDir + m->getRootName(m->getSimpleName(nameFile)) + "scrap.names";
-               
-               if (nameFile != "") {
-                       m->readNames(nameFile, nameMap);
-                       outputNames.push_back(trimNameFile);
-                       outputNames.push_back(scrapNameFile);
-                       outputTypes["name"].push_back(trimNameFile);
-                       outputTypes["name"].push_back(scrapNameFile); 
-               }
-               
-               if (m->control_pressed) { return 0; }
-               
-               string outputGroupFileName;
-               if(oligoFile != ""){
-                       createGroup = getOligos(fastaFileNames, qualFileNames, nameFileNames);
-                       if (createGroup) {
-                               outputGroupFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + "groups";
-                               outputNames.push_back(outputGroupFileName); outputTypes["group"].push_back(outputGroupFileName);
-                       }
-               }
-       
-        //fills lines and qlines
-               setLines(fastaFile, qFileName);
-               
-        if(processors == 1){
-            driverCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, trimNameFile, scrapNameFile, outputGroupFileName, fastaFileNames, qualFileNames, nameFileNames, lines[0], qLines[0]);
-        }else{
-            createProcessesCreateTrim(fastaFile, qFileName, trimSeqFile, scrapSeqFile, trimQualFile, scrapQualFile, trimNameFile, scrapNameFile, outputGroupFileName, fastaFileNames, qualFileNames, nameFileNames); 
-        }      
-               
-               
-               if (m->control_pressed) {  return 0; }                  
-       
-               if(allFiles){
-                       map<string, string> uniqueFastaNames;// so we don't add the same groupfile multiple times
-                       map<string, string>::iterator it;
-                       set<string> namesToRemove;
-                       for(int i=0;i<fastaFileNames.size();i++){
-                               for(int j=0;j<fastaFileNames[0].size();j++){
-                                       if (fastaFileNames[i][j] != "") {
-                                               if (namesToRemove.count(fastaFileNames[i][j]) == 0) {
-                                                       if(m->isBlank(fastaFileNames[i][j])){
-                                                               m->mothurRemove(fastaFileNames[i][j]);
-                                                               namesToRemove.insert(fastaFileNames[i][j]);
-                                                       
-                                                               if(qFileName != ""){
-                                                                       m->mothurRemove(qualFileNames[i][j]);
-                                                                       namesToRemove.insert(qualFileNames[i][j]);
-                                                               }
-                                                               
-                                                               if(nameFile != ""){
-                                                                       m->mothurRemove(nameFileNames[i][j]);
-                                                                       namesToRemove.insert(nameFileNames[i][j]);
-                                                               }
-                                                       }else{  
-                                                               it = uniqueFastaNames.find(fastaFileNames[i][j]);
-                                                               if (it == uniqueFastaNames.end()) {     
-                                                                       uniqueFastaNames[fastaFileNames[i][j]] = barcodeNameVector[i];  
-                                                               }       
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       //remove names for outputFileNames, just cleans up the output
-                       vector<string> outputNames2;
-                       for(int i = 0; i < outputNames.size(); i++) { if (namesToRemove.count(outputNames[i]) == 0) { outputNames2.push_back(outputNames[i]); } }
-                       outputNames = outputNames2;
-                       
-                       for (it = uniqueFastaNames.begin(); it != uniqueFastaNames.end(); it++) {
-                               ifstream in;
-                               m->openInputFile(it->first, in);
-                               
-                               ofstream out;
-                               string thisGroupName = outputDir + m->getRootName(m->getSimpleName(it->first)) + "groups";
-                               outputNames.push_back(thisGroupName); outputTypes["group"].push_back(thisGroupName);
-                               m->openOutputFile(thisGroupName, out);
-                               
-                               while (!in.eof()){
-                                       if (m->control_pressed) { break; }
-                                       
-                                       Sequence currSeq(in); m->gobble(in);
-                                       out << currSeq.getName() << '\t' << it->second << endl;
-                    
-                    if (nameFile != "") {
-                        map<string, string>::iterator itName = nameMap.find(currSeq.getName());
-                        if (itName != nameMap.end()) { 
-                            vector<string> thisSeqsNames; 
-                            m->splitAtChar(itName->second, thisSeqsNames, ',');
-                            for (int k = 1; k < thisSeqsNames.size(); k++) { //start at 1 to skip self
-                                out << thisSeqsNames[k] << '\t' << it->second << endl;
-                            }
-                        }else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }                                                  
-                    }
-                               }
-                               in.close();
-                               out.close();
-                       }
-               }
-               
-               if (m->control_pressed) {       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0;    }
-
-               //output group counts
-               m->mothurOutEndLine();
-               int total = 0;
-               if (groupCounts.size() != 0) {  m->mothurOut("Group count: \n");  }
-               for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
-                        total += it->second; m->mothurOut(it->first + "\t" + toString(it->second)); m->mothurOutEndLine(); 
-               }
-               if (total != 0) { m->mothurOut("Total of all groups is " + toString(total)); m->mothurOutEndLine(); }
-               
-               if (m->control_pressed) {       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); } return 0;    }
-
-               //set fasta file as new current fastafile
-               string current = "";
-               itTypes = outputTypes.find("fasta");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); }
-               }
-               
-               itTypes = outputTypes.find("name");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); }
-               }
-               
-               itTypes = outputTypes.find("qfile");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); }
-               }
-               
-               itTypes = outputTypes.find("group");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); }
-               }
-
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;       
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "execute");
-               exit(1);
-       }
-}
-               
-/**************************************************************************************/
-
-int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string trimFileName, string scrapFileName, string trimQFileName, string scrapQFileName, string trimNFileName, string scrapNFileName, string groupFileName, vector<vector<string> > fastaFileNames, vector<vector<string> > qualFileNames, vector<vector<string> > nameFileNames, linePair line, linePair qline) {     
-               
-       try {
-               
-               ofstream trimFASTAFile;
-               m->openOutputFile(trimFileName, trimFASTAFile);
-               
-               ofstream scrapFASTAFile;
-               m->openOutputFile(scrapFileName, scrapFASTAFile);
-               
-               ofstream trimQualFile;
-               ofstream scrapQualFile;
-               if(qFileName != ""){
-                       m->openOutputFile(trimQFileName, trimQualFile);
-                       m->openOutputFile(scrapQFileName, scrapQualFile);
-               }
-               
-               ofstream trimNameFile;
-               ofstream scrapNameFile;
-               if(nameFile != ""){
-                       m->openOutputFile(trimNFileName, trimNameFile);
-                       m->openOutputFile(scrapNFileName, scrapNameFile);
-               }
-               
-               
-               ofstream outGroupsFile;
-               if (createGroup){       m->openOutputFile(groupFileName, outGroupsFile);   }
-               if(allFiles){
-                       for (int i = 0; i < fastaFileNames.size(); i++) { //clears old file
-                               for (int j = 0; j < fastaFileNames[i].size(); j++) { //clears old file
-                                       if (fastaFileNames[i][j] != "") {
-                                               ofstream temp;
-                                               m->openOutputFile(fastaFileNames[i][j], temp);                  temp.close();
-                                               if(qFileName != ""){
-                                                       m->openOutputFile(qualFileNames[i][j], temp);                   temp.close();
-                                               }
-                                               
-                                               if(nameFile != ""){
-                                                       m->openOutputFile(nameFileNames[i][j], temp);                   temp.close();
-                                               }
-                                       }
-                               }
-                       }
-               }
-               
-               ifstream inFASTA;
-               m->openInputFile(filename, inFASTA);
-               inFASTA.seekg(line.start);
-               
-               ifstream qFile;
-               if(qFileName != "")     {
-                       m->openInputFile(qFileName, qFile);
-                       qFile.seekg(qline.start);  
-               }
-               
-               int count = 0;
-               bool moreSeqs = 1;
-               TrimOligos trimOligos(pdiffs, bdiffs, ldiffs, sdiffs, primers, barcodes, revPrimer, linker, spacer);
-       
-               while (moreSeqs) {
-                               
-                       if (m->control_pressed) { 
-                               inFASTA.close(); trimFASTAFile.close(); scrapFASTAFile.close();
-                               if (createGroup) {       outGroupsFile.close();   }
-
-                               if(qFileName != ""){
-                                       qFile.close();
-                               }
-                               for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]); }
-
-                               return 0;
-                       }
-                       
-                       int success = 1;
-                       string trashCode = "";
-                       int currentSeqsDiffs = 0;
-
-                       Sequence currSeq(inFASTA); m->gobble(inFASTA);
-                       //cout << currSeq.getName() << '\t' << currSeq.getUnaligned().length() << endl;
-                       QualityScores currQual;
-                       if(qFileName != ""){
-                               currQual = QualityScores(qFile);  m->gobble(qFile);
-                       }
-                       
-                       string origSeq = currSeq.getUnaligned();
-                       if (origSeq != "") {
-                               
-                               int barcodeIndex = 0;
-                               int primerIndex = 0;
-                               
-                if(numLinkers != 0){
-                                       success = trimOligos.stripLinker(currSeq, currQual);
-                                       if(success > ldiffs)            {       trashCode += 'k';       }
-                                       else{ currentSeqsDiffs += success;  }
-
-                               }
-                
-                               if(barcodes.size() != 0){
-                                       success = trimOligos.stripBarcode(currSeq, currQual, barcodeIndex);
-                                       if(success > bdiffs)            {       trashCode += 'b';       }
-                                       else{ currentSeqsDiffs += success;  }
-                               }
-                               
-                if(numSpacers != 0){
-                                       success = trimOligos.stripSpacer(currSeq, currQual);
-                                       if(success > sdiffs)            {       trashCode += 's';       }
-                                       else{ currentSeqsDiffs += success;  }
-
-                               }
-                
-                               if(numFPrimers != 0){
-                                       success = trimOligos.stripForward(currSeq, currQual, primerIndex, keepforward);
-                                       if(success > pdiffs)            {       trashCode += 'f';       }
-                                       else{ currentSeqsDiffs += success;  }
-                               }
-                               
-                               if (currentSeqsDiffs > tdiffs)  {       trashCode += 't';   }
-                               
-                               if(numRPrimers != 0){
-                                       success = trimOligos.stripReverse(currSeq, currQual);
-                                       if(!success)                            {       trashCode += 'r';       }
-                               }
-
-                               if(keepFirst != 0){
-                                       success = keepFirstTrim(currSeq, currQual);
-                               }
-                               
-                               if(removeLast != 0){
-                                       success = removeLastTrim(currSeq, currQual);
-                                       if(!success)                            {       trashCode += 'l';       }
-                               }
-
-                               
-                               if(qFileName != ""){
-                                       int origLength = currSeq.getNumBases();
-                                       
-                                       if(qThreshold != 0)                     {       success = currQual.stripQualThreshold(currSeq, qThreshold);                     }
-                                       else if(qAverage != 0)          {       success = currQual.cullQualAverage(currSeq, qAverage);                          }
-                                       else if(qRollAverage != 0)      {       success = currQual.stripQualRollingAverage(currSeq, qRollAverage);      }
-                                       else if(qWindowAverage != 0){   success = currQual.stripQualWindowAverage(currSeq, qWindowStep, qWindowSize, qWindowAverage);   }
-                                       else                                            {       success = 1;                            }
-                                       
-                                       //you don't want to trim, if it fails above then scrap it
-                                       if ((!qtrim) && (origLength != currSeq.getNumBases())) {  success = 0; }
-                                       
-                                       if(!success)                            {       trashCode += 'q';       }
-                               }                               
-               
-                               if(minLength > 0 || maxLength > 0){
-                                       success = cullLength(currSeq);
-                                       if(!success)                            {       trashCode += 'l';       }
-                               }
-                               if(maxHomoP > 0){
-                                       success = cullHomoP(currSeq);
-                                       if(!success)                            {       trashCode += 'h';       }
-                               }
-                               if(maxAmbig != -1){
-                                       success = cullAmbigs(currSeq);
-                                       if(!success)                            {       trashCode += 'n';       }
-                               }
-                               
-                               if(flip){               // should go last                       
-                                       currSeq.reverseComplement();
-                                       if(qFileName != ""){
-                                               currQual.flipQScores(); 
-                                       }
-                               }
-                               
-                               if(trashCode.length() == 0){
-                                       currSeq.setAligned(currSeq.getUnaligned());
-                                       currSeq.printSequence(trimFASTAFile);
-                                       
-                                       if(qFileName != ""){
-                                               currQual.printQScores(trimQualFile);
-                                       }
-                                       
-                                       if(nameFile != ""){
-                                               map<string, string>::iterator itName = nameMap.find(currSeq.getName());
-                                               if (itName != nameMap.end()) {  trimNameFile << itName->first << '\t' << itName->second << endl; }
-                                               else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
-                                       }
-                                       
-                                       if (createGroup) {
-                                               if(barcodes.size() != 0){
-                                                       string thisGroup = barcodeNameVector[barcodeIndex];
-                                                       if (primers.size() != 0) { 
-                                                               if (primerNameVector[primerIndex] != "") { 
-                                                                       if(thisGroup != "") {
-                                                                               thisGroup += "." + primerNameVector[primerIndex]; 
-                                                                       }else {
-                                                                               thisGroup = primerNameVector[primerIndex]; 
-                                                                       }
-                                                               } 
-                                                       }
-                                                       
-                                                       outGroupsFile << currSeq.getName() << '\t' << thisGroup << endl;
-                                                       
-                                                       if (nameFile != "") {
-                                                               map<string, string>::iterator itName = nameMap.find(currSeq.getName());
-                                                               if (itName != nameMap.end()) { 
-                                                                       vector<string> thisSeqsNames; 
-                                                                       m->splitAtChar(itName->second, thisSeqsNames, ',');
-                                                                       for (int k = 1; k < thisSeqsNames.size(); k++) { //start at 1 to skip self
-                                                                               outGroupsFile << thisSeqsNames[k] << '\t' << thisGroup << endl;
-                                                                       }
-                                                               }else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }                                                   
-                                                       }
-                                                       
-                                                       map<string, int>::iterator it = groupCounts.find(thisGroup);
-                                                       if (it == groupCounts.end()) {  groupCounts[thisGroup] = 1; }
-                                                       else { groupCounts[it->first]++; }
-                                                               
-                                               }
-                                       }
-                                       
-                                       if(allFiles){
-                                               ofstream output;
-                                               m->openOutputFileAppend(fastaFileNames[barcodeIndex][primerIndex], output);
-                                               currSeq.printSequence(output);
-                                               output.close();
-                                               
-                                               if(qFileName != ""){
-                                                       m->openOutputFileAppend(qualFileNames[barcodeIndex][primerIndex], output);
-                                                       currQual.printQScores(output);
-                                                       output.close();                                                 
-                                               }
-                                               
-                                               if(nameFile != ""){
-                                                       map<string, string>::iterator itName = nameMap.find(currSeq.getName());
-                                                       if (itName != nameMap.end()) { 
-                                                               m->openOutputFileAppend(nameFileNames[barcodeIndex][primerIndex], output);
-                                                               output << itName->first << '\t' << itName->second << endl; 
-                                                               output.close();
-                                                       }else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
-                                               }
-                                       }
-                               }
-                               else{
-                                       if(nameFile != ""){ //needs to be before the currSeq name is changed
-                                               map<string, string>::iterator itName = nameMap.find(currSeq.getName());
-                                               if (itName != nameMap.end()) {  scrapNameFile << itName->first << '\t' << itName->second << endl; }
-                                               else { m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); m->mothurOutEndLine(); }
-                                       }
-                                       currSeq.setName(currSeq.getName() + '|' + trashCode);
-                                       currSeq.setUnaligned(origSeq);
-                                       currSeq.setAligned(origSeq);
-                                       currSeq.printSequence(scrapFASTAFile);
-                                       if(qFileName != ""){
-                                               currQual.printQScores(scrapQualFile);
-                                       }
-                               }
-                               count++;
-                       }
-                       
-                       #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               unsigned long long pos = inFASTA.tellg();
-                               if ((pos == -1) || (pos >= line.end)) { break; }
-                       
-                       #else
-                               if (inFASTA.eof()) { break; }
-                       #endif
-                       
-                       //report progress
-                       if((count) % 1000 == 0){        m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-                       
-               }
-               //report progress
-               if((count) % 1000 != 0){        m->mothurOut(toString(count)); m->mothurOutEndLine();           }
-               
-               
-               inFASTA.close();
-               trimFASTAFile.close();
-               scrapFASTAFile.close();
-               if (createGroup) {       outGroupsFile.close();   }
-               if(qFileName != "")     {       qFile.close();  scrapQualFile.close(); trimQualFile.close();    }
-               if(nameFile != "")      {       scrapNameFile.close(); trimNameFile.close();    }
-               
-               return count;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "driverCreateTrim");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName, string trimFASTAFileName, string scrapFASTAFileName, string trimQualFileName, string scrapQualFileName, string trimNameFileName, string scrapNameFileName, string groupFile, vector<vector<string> > fastaFileNames, vector<vector<string> > qualFileNames, vector<vector<string> > nameFileNames) {
-       try {
-        
-        int process = 1;
-               int exitCommand = 1;
-               processIDS.clear();
-               
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               
-                               vector<vector<string> > tempFASTAFileNames = fastaFileNames;
-                               vector<vector<string> > tempPrimerQualFileNames = qualFileNames;
-                               vector<vector<string> > tempNameFileNames = nameFileNames;
-
-                               if(allFiles){
-                                       ofstream temp;
-
-                                       for(int i=0;i<tempFASTAFileNames.size();i++){
-                                               for(int j=0;j<tempFASTAFileNames[i].size();j++){
-                                                       if (tempFASTAFileNames[i][j] != "") {
-                                                               tempFASTAFileNames[i][j] += toString(getpid()) + ".temp";
-                                                               m->openOutputFile(tempFASTAFileNames[i][j], temp);                      temp.close();
-
-                                                               if(qFileName != ""){
-                                                                       tempPrimerQualFileNames[i][j] += toString(getpid()) + ".temp";
-                                                                       m->openOutputFile(tempPrimerQualFileNames[i][j], temp);         temp.close();
-                                                               }
-                                                               if(nameFile != ""){
-                                                                       tempNameFileNames[i][j] += toString(getpid()) + ".temp";
-                                                                       m->openOutputFile(tempNameFileNames[i][j], temp);               temp.close();
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                                                       
-                               driverCreateTrim(filename,
-                                                                qFileName,
-                                                                (trimFASTAFileName + toString(getpid()) + ".temp"),
-                                                                (scrapFASTAFileName + toString(getpid()) + ".temp"),
-                                                                (trimQualFileName + toString(getpid()) + ".temp"),
-                                                                (scrapQualFileName + toString(getpid()) + ".temp"),
-                                                                (trimNameFileName + toString(getpid()) + ".temp"),
-                                                                (scrapNameFileName + toString(getpid()) + ".temp"),
-                                                                (groupFile + toString(getpid()) + ".temp"),
-                                                                tempFASTAFileNames,
-                                                                tempPrimerQualFileNames,
-                                                                tempNameFileNames,
-                                                                lines[process],
-                                                                qLines[process]);
-                               
-                               //pass groupCounts to parent
-                               if(createGroup){
-                                       ofstream out;
-                                       string tempFile = filename + toString(getpid()) + ".num.temp";
-                                       m->openOutputFile(tempFile, out);
-                                       
-                                       out << groupCounts.size() << endl;
-                                       
-                                       for (map<string, int>::iterator it = groupCounts.begin(); it != groupCounts.end(); it++) {
-                                               out << it->first << '\t' << it->second << endl;
-                                       }
-                                       out.close();
-                               }
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               //parent do my part
-               ofstream temp;
-               m->openOutputFile(trimFASTAFileName, temp);             temp.close();
-               m->openOutputFile(scrapFASTAFileName, temp);    temp.close();
-               if(qFileName != ""){
-                       m->openOutputFile(trimQualFileName, temp);              temp.close();
-                       m->openOutputFile(scrapQualFileName, temp);             temp.close();
-               }
-               if (nameFile != "") {
-                       m->openOutputFile(trimNameFileName, temp);              temp.close();
-                       m->openOutputFile(scrapNameFileName, temp);             temp.close();
-               }
-
-               driverCreateTrim(filename, qFileName, trimFASTAFileName, scrapFASTAFileName, trimQualFileName, scrapQualFileName, trimNameFileName, scrapNameFileName, groupFile, fastaFileNames, qualFileNames, nameFileNames, lines[0], qLines[0]);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<processIDS.size();i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-#else
-        //////////////////////////////////////////////////////////////////////////////////////////////////////
-               //Windows version shared memory, so be careful when passing variables through the trimData struct. 
-               //Above fork() will clone, so memory is separate, but that's not the case with windows, 
-               //////////////////////////////////////////////////////////////////////////////////////////////////////
-               
-               vector<trimData*> pDataArray; 
-               DWORD   dwThreadIdArray[processors-1];
-               HANDLE  hThreadArray[processors-1]; 
-               
-               //Create processor worker threads.
-               for( int i=0; i<processors-1; i++){
-                       
-            string extension = "";
-                       if (i != 0) { extension = toString(i) + ".temp"; processIDS.push_back(i); }
-            vector<vector<string> > tempFASTAFileNames = fastaFileNames;
-            vector<vector<string> > tempPrimerQualFileNames = qualFileNames;
-            vector<vector<string> > tempNameFileNames = nameFileNames;
-            
-            if(allFiles){
-                ofstream temp;
-                
-                for(int i=0;i<tempFASTAFileNames.size();i++){
-                    for(int j=0;j<tempFASTAFileNames[i].size();j++){
-                        if (tempFASTAFileNames[i][j] != "") {
-                            tempFASTAFileNames[i][j] += extension;
-                            m->openOutputFile(tempFASTAFileNames[i][j], temp);                 temp.close();
-                            
-                            if(qFileName != ""){
-                                tempPrimerQualFileNames[i][j] += extension;
-                                m->openOutputFile(tempPrimerQualFileNames[i][j], temp);                temp.close();
-                            }
-                            if(nameFile != ""){
-                                tempNameFileNames[i][j] += extension;
-                                m->openOutputFile(tempNameFileNames[i][j], temp);              temp.close();
-                            }
-                        }
-                    }
-                }
-            }
-
-            
-                       trimData* tempTrim = new trimData(filename,
-                                              qFileName, nameFile,
-                                              (trimFASTAFileName+extension),
-                                              (scrapFASTAFileName+extension),
-                                              (trimQualFileName+extension),
-                                              (scrapQualFileName+extension),
-                                              (trimNameFileName+extension),
-                                              (scrapNameFileName+extension),
-                                              (groupFile+extension),
-                                              tempFASTAFileNames,
-                                              tempPrimerQualFileNames,
-                                              tempNameFileNames,
-                                              lines[i].start, lines[i].end, qLines[i].start, qLines[i].end, m,
-                                              pdiffs, bdiffs, ldiffs, sdiffs, tdiffs, primers, barcodes, revPrimer, linker, spacer, 
-                                             primerNameVector, barcodeNameVector, createGroup, allFiles, keepforward, keepFirst, removeLast,
-                                              qWindowStep, qWindowSize, qWindowAverage, qtrim, qThreshold, qAverage, qRollAverage,
-                                             minLength, maxAmbig, maxHomoP, maxLength, flip, nameMap);
-                       pDataArray.push_back(tempTrim);
-            
-                       hThreadArray[i] = CreateThread(NULL, 0, MyTrimThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);   
-               }
-        
-        //parent do my part
-               ofstream temp;
-               m->openOutputFile(trimFASTAFileName, temp);             temp.close();
-               m->openOutputFile(scrapFASTAFileName, temp);    temp.close();
-               if(qFileName != ""){
-                       m->openOutputFile(trimQualFileName, temp);              temp.close();
-                       m->openOutputFile(scrapQualFileName, temp);             temp.close();
-               }
-               if (nameFile != "") {
-                       m->openOutputFile(trimNameFileName, temp);              temp.close();
-                       m->openOutputFile(scrapNameFileName, temp);             temp.close();
-               }
-        
-               driverCreateTrim(filename, qFileName, (trimFASTAFileName + toString(processors-1) + ".temp"), (scrapFASTAFileName + toString(processors-1) + ".temp"), (trimQualFileName + toString(processors-1) + ".temp"), (scrapQualFileName + toString(processors-1) + ".temp"), (trimNameFileName + toString(processors-1) + ".temp"), (scrapNameFileName + toString(processors-1) + ".temp"), (groupFile + toString(processors-1) + ".temp"), fastaFileNames, qualFileNames, nameFileNames, lines[processors-1], qLines[processors-1]);
-        processIDS.push_back(processors-1);
-
-        
-               //Wait until all threads have terminated.
-               WaitForMultipleObjects(processors-1, hThreadArray, TRUE, INFINITE);
-               
-               //Close all thread handles and free memory allocations.
-               for(int i=0; i < pDataArray.size(); i++){
-                       for (map<string, int>::iterator it = pDataArray[i]->groupCounts.begin(); it != pDataArray[i]->groupCounts.end(); it++) {
-                map<string, int>::iterator it2 = groupCounts.find(it->first);
-                if (it2 == groupCounts.end()) {        groupCounts[it->first] = it->second; }
-                else { groupCounts[it->first] += it->second; }
-            }
-            CloseHandle(hThreadArray[i]);
-                       delete pDataArray[i];
-               }
-        
-#endif         
-        
-        
-        //append files
-               for(int i=0;i<processIDS.size();i++){
-                       
-                       m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine();
-                       
-                       m->appendFiles((trimFASTAFileName + toString(processIDS[i]) + ".temp"), trimFASTAFileName);
-                       m->mothurRemove((trimFASTAFileName + toString(processIDS[i]) + ".temp"));
-                       m->appendFiles((scrapFASTAFileName + toString(processIDS[i]) + ".temp"), scrapFASTAFileName);
-                       m->mothurRemove((scrapFASTAFileName + toString(processIDS[i]) + ".temp"));
-                       
-                       if(qFileName != ""){
-                               m->appendFiles((trimQualFileName + toString(processIDS[i]) + ".temp"), trimQualFileName);
-                               m->mothurRemove((trimQualFileName + toString(processIDS[i]) + ".temp"));
-                               m->appendFiles((scrapQualFileName + toString(processIDS[i]) + ".temp"), scrapQualFileName);
-                               m->mothurRemove((scrapQualFileName + toString(processIDS[i]) + ".temp"));
-                       }
-                       
-                       if(nameFile != ""){
-                               m->appendFiles((trimNameFileName + toString(processIDS[i]) + ".temp"), trimNameFileName);
-                               m->mothurRemove((trimNameFileName + toString(processIDS[i]) + ".temp"));
-                               m->appendFiles((scrapNameFileName + toString(processIDS[i]) + ".temp"), scrapNameFileName);
-                               m->mothurRemove((scrapNameFileName + toString(processIDS[i]) + ".temp"));
-                       }
-                       
-                       if(createGroup){
-                               m->appendFiles((groupFile + toString(processIDS[i]) + ".temp"), groupFile);
-                               m->mothurRemove((groupFile + toString(processIDS[i]) + ".temp"));
-                       }
-                       
-                       
-                       if(allFiles){
-                               for(int j=0;j<fastaFileNames.size();j++){
-                                       for(int k=0;k<fastaFileNames[j].size();k++){
-                                               if (fastaFileNames[j][k] != "") {
-                                                       m->appendFiles((fastaFileNames[j][k] + toString(processIDS[i]) + ".temp"), fastaFileNames[j][k]);
-                                                       m->mothurRemove((fastaFileNames[j][k] + toString(processIDS[i]) + ".temp"));
-                                                       
-                                                       if(qFileName != ""){
-                                                               m->appendFiles((qualFileNames[j][k] + toString(processIDS[i]) + ".temp"), qualFileNames[j][k]);
-                                                               m->mothurRemove((qualFileNames[j][k] + toString(processIDS[i]) + ".temp"));
-                                                       }
-                                                       
-                                                       if(nameFile != ""){
-                                                               m->appendFiles((nameFileNames[j][k] + toString(processIDS[i]) + ".temp"), nameFileNames[j][k]);
-                                                               m->mothurRemove((nameFileNames[j][k] + toString(processIDS[i]) + ".temp"));
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-                       
-            #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(createGroup){
-                               ifstream in;
-                               string tempFile =  filename + toString(processIDS[i]) + ".num.temp";
-                               m->openInputFile(tempFile, in);
-                               int tempNum;
-                               string group;
-                               
-                               in >> tempNum; m->gobble(in);
-                               
-                               if (tempNum != 0) {
-                                       while (!in.eof()) { 
-                                               in >> group >> tempNum; m->gobble(in);
-                        
-                                               map<string, int>::iterator it = groupCounts.find(group);
-                                               if (it == groupCounts.end()) {  groupCounts[group] = tempNum; }
-                                               else { groupCounts[it->first] += tempNum; }
-                                       }
-                               }
-                               in.close(); m->mothurRemove(tempFile);
-                       }
-            #endif
-               }
-
-        return exitCommand;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "createProcessesCreateTrim");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-
-int TrimSeqsCommand::setLines(string filename, string qfilename) {
-       try {
-        
-        vector<unsigned long long> fastaFilePos;
-               vector<unsigned long long> qfileFilePos;
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               //set file positions for fasta file
-               fastaFilePos = m->divideFile(filename, processors);
-               
-               //get name of first sequence in each chunk
-               map<string, int> firstSeqNames;
-               for (int i = 0; i < (fastaFilePos.size()-1); i++) {
-                       ifstream in;
-                       m->openInputFile(filename, in);
-                       in.seekg(fastaFilePos[i]);
-               
-                       Sequence temp(in); 
-                       firstSeqNames[temp.getName()] = i;
-               
-                       in.close();
-               }
-               
-               if(qfilename != "")     {
-            //seach for filePos of each first name in the qfile and save in qfileFilePos
-            ifstream inQual;
-            m->openInputFile(qfilename, inQual);
-            
-            string input;
-            while(!inQual.eof()){      
-                input = m->getline(inQual);
-                
-                if (input.length() != 0) {
-                    if(input[0] == '>'){ //this is a sequence name line
-                        istringstream nameStream(input);
-                        
-                        string sname = "";  nameStream >> sname;
-                        sname = sname.substr(1);
-                        
-                        map<string, int>::iterator it = firstSeqNames.find(sname);
-                        
-                        if(it != firstSeqNames.end()) { //this is the start of a new chunk
-                            unsigned long long pos = inQual.tellg(); 
-                            qfileFilePos.push_back(pos - input.length() - 1);  
-                            firstSeqNames.erase(it);
-                        }
-                    }
-                }
-                
-                if (firstSeqNames.size() == 0) { break; }
-            }
-            inQual.close();
-            
-            
-            if (firstSeqNames.size() != 0) { 
-                for (map<string, int>::iterator it = firstSeqNames.begin(); it != firstSeqNames.end(); it++) {
-                    m->mothurOut(it->first + " is in your fasta file and not in your quality file, not using quality file."); m->mothurOutEndLine();
-                }
-                qFileName = "";
-                return processors;
-            }
-            
-            //get last file position of qfile
-            FILE * pFile;
-            unsigned long long size;
-            
-            //get num bytes in file
-            pFile = fopen (qfilename.c_str(),"rb");
-            if (pFile==NULL) perror ("Error opening file");
-            else{
-                fseek (pFile, 0, SEEK_END);
-                size=ftell (pFile);
-                fclose (pFile);
-            }
-            
-            qfileFilePos.push_back(size);
-        }
-        
-        for (int i = 0; i < (fastaFilePos.size()-1); i++) {
-                       lines.push_back(linePair(fastaFilePos[i], fastaFilePos[(i+1)]));
-                       if (qfilename != "") {  qLines.push_back(linePair(qfileFilePos[i], qfileFilePos[(i+1)]));  }
-               }       
-               if(qfilename == "")     {       qLines = lines; } //files with duds
-               
-               return processors;
-               
-               #else
-            
-        if (processors == 1) { //save time
-                       //fastaFilePos.push_back(0); qfileFilePos.push_back(0);
-                       //fastaFilePos.push_back(1000); qfileFilePos.push_back(1000);
-            lines.push_back(linePair(0, 1000));
-            if (qfilename != "") {  qLines.push_back(linePair(0, 1000)); }
-        }else{
-            int numFastaSeqs = 0;
-            fastaFilePos = m->setFilePosFasta(filename, numFastaSeqs); 
-            if (fastaFilePos.size() < processors) { processors = fastaFilePos.size(); }
-        
-            if (qfilename != "") { 
-                int numQualSeqs = 0;
-                qfileFilePos = m->setFilePosFasta(qfilename, numQualSeqs); 
-                
-                if (numFastaSeqs != numQualSeqs) {
-                    m->mothurOut("[ERROR]: You have " + toString(numFastaSeqs) + " sequences in your fasta file, but " + toString(numQualSeqs) + " sequences in your quality file."); m->mothurOutEndLine(); m->control_pressed = true; 
-                }
-            }
-        
-            //figure out how many sequences you have to process
-            int numSeqsPerProcessor = numFastaSeqs / processors;
-            for (int i = 0; i < processors; i++) {
-                int startIndex =  i * numSeqsPerProcessor;
-                if(i == (processors - 1)){     numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor;   }
-                lines.push_back(linePair(fastaFilePos[startIndex], numSeqsPerProcessor));
-                cout << fastaFilePos[startIndex] << '\t' << numSeqsPerProcessor << endl;
-                if (qfilename != "") {  qLines.push_back(linePair(qfileFilePos[startIndex], numSeqsPerProcessor)); }
-            }
-        }
-            if(qfilename == "")        {       qLines = lines; } //files with duds
-                       return 1;
-               
-               #endif
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "setLines");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::getOligos(vector<vector<string> >& fastaFileNames, vector<vector<string> >& qualFileNames, vector<vector<string> >& nameFileNames){
-       try {
-               ifstream inOligos;
-               m->openInputFile(oligoFile, inOligos);
-               
-               ofstream test;
-               
-               string type, oligo, group;
-
-               int indexPrimer = 0;
-               int indexBarcode = 0;
-               
-               while(!inOligos.eof()){
-
-                       inOligos >> type; 
-                                       
-                       if(type[0] == '#'){
-                               while (!inOligos.eof()) {       char c = inOligos.get();  if (c == 10 || c == 13){      break;  }       } // get rest of line if there's any crap there
-                               m->gobble(inOligos);
-                       }
-                       else{
-                               m->gobble(inOligos);
-                               //make type case insensitive
-                               for(int i=0;i<type.length();i++){       type[i] = toupper(type[i]);  }
-                               
-                               inOligos >> oligo;
-                               
-                               for(int i=0;i<oligo.length();i++){
-                                       oligo[i] = toupper(oligo[i]);
-                                       if(oligo[i] == 'U')     {       oligo[i] = 'T'; }
-                               }
-                               
-                               if(type == "FORWARD"){
-                                       group = "";
-                                       
-                                       // get rest of line in case there is a primer name
-                                       while (!inOligos.eof()) {       
-                                               char c = inOligos.get(); 
-                                               if (c == 10 || c == 13){        break;  }
-                                               else if (c == 32 || c == 9){;} //space or tab
-                                               else {  group += c;  }
-                                       } 
-                                       
-                                       //check for repeat barcodes
-                                       map<string, int>::iterator itPrime = primers.find(oligo);
-                                       if (itPrime != primers.end()) { m->mothurOut("primer " + oligo + " is in your oligos file already."); m->mothurOutEndLine();  }
-                                       
-                                       primers[oligo]=indexPrimer; indexPrimer++;              
-                                       primerNameVector.push_back(group);
-                               }
-                               else if(type == "REVERSE"){
-                                       //Sequence oligoRC("reverse", oligo);
-                                       //oligoRC.reverseComplement();
-                    string oligoRC = reverseOligo(oligo);
-                                       revPrimer.push_back(oligoRC);
-                               }
-                               else if(type == "BARCODE"){
-                                       inOligos >> group;
-                                       
-                                       //check for repeat barcodes
-                                       map<string, int>::iterator itBar = barcodes.find(oligo);
-                                       if (itBar != barcodes.end()) { m->mothurOut("barcode " + oligo + " is in your oligos file already."); m->mothurOutEndLine();  }
-                                               
-                                       barcodes[oligo]=indexBarcode; indexBarcode++;
-                                       barcodeNameVector.push_back(group);
-                               }else if(type == "LINKER"){
-                                       linker.push_back(oligo);
-                               }else if(type == "SPACER"){
-                                       spacer.push_back(oligo);
-                               }
-                               else{   m->mothurOut(type + " is not recognized as a valid type. Choices are forward, reverse, and barcode. Ignoring " + oligo + "."); m->mothurOutEndLine();  }
-                       }
-                       m->gobble(inOligos);
-               }       
-               inOligos.close();
-               
-               if(barcodeNameVector.size() == 0 && primerNameVector[0] == ""){ allFiles = 0;   }
-               
-               //add in potential combos
-               if(barcodeNameVector.size() == 0){
-                       barcodes[""] = 0;
-                       barcodeNameVector.push_back("");                        
-               }
-               
-               if(primerNameVector.size() == 0){
-                       primers[""] = 0;
-                       primerNameVector.push_back("");                 
-               }
-               
-               fastaFileNames.resize(barcodeNameVector.size());
-               for(int i=0;i<fastaFileNames.size();i++){
-                       fastaFileNames[i].assign(primerNameVector.size(), "");
-               }
-               if(qFileName != "")     {       qualFileNames = fastaFileNames; }
-               if(nameFile != "")      {       nameFileNames = fastaFileNames; }
-               
-               if(allFiles){
-                       set<string> uniqueNames; //used to cleanup outputFileNames
-                       for(map<string, int>::iterator itBar = barcodes.begin();itBar != barcodes.end();itBar++){
-                               for(map<string, int>::iterator itPrimer = primers.begin();itPrimer != primers.end(); itPrimer++){
-                                       
-                                       string primerName = primerNameVector[itPrimer->second];
-                                       string barcodeName = barcodeNameVector[itBar->second];
-                                       
-                                       string comboGroupName = "";
-                                       string fastaFileName = "";
-                                       string qualFileName = "";
-                                       string nameFileName = "";
-                                       
-                                       if(primerName == ""){
-                                               comboGroupName = barcodeNameVector[itBar->second];
-                                       }
-                                       else{
-                                               if(barcodeName == ""){
-                                                       comboGroupName = primerNameVector[itPrimer->second];
-                                               }
-                                               else{
-                                                       comboGroupName = barcodeNameVector[itBar->second] + "." + primerNameVector[itPrimer->second];
-                                               }
-                                       }
-                                       
-                                       
-                                       ofstream temp;
-                                       fastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFile)) + comboGroupName + ".fasta";
-                                       if (uniqueNames.count(fastaFileName) == 0) {
-                                               outputNames.push_back(fastaFileName);
-                                               outputTypes["fasta"].push_back(fastaFileName);
-                                               uniqueNames.insert(fastaFileName);
-                                       }
-                                       
-                                       fastaFileNames[itBar->second][itPrimer->second] = fastaFileName;
-                                       m->openOutputFile(fastaFileName, temp);         temp.close();
-                                       
-                                       if(qFileName != ""){
-                                               qualFileName = outputDir + m->getRootName(m->getSimpleName(qFileName)) + comboGroupName + ".qual";
-                                               if (uniqueNames.count(qualFileName) == 0) {
-                                                       outputNames.push_back(qualFileName);
-                                                       outputTypes["qfile"].push_back(qualFileName);
-                                               }
-                                               
-                                               qualFileNames[itBar->second][itPrimer->second] = qualFileName;
-                                               m->openOutputFile(qualFileName, temp);          temp.close();
-                                       }
-                                       
-                                       if(nameFile != ""){
-                                               nameFileName = outputDir + m->getRootName(m->getSimpleName(nameFile)) + comboGroupName + ".names";
-                                               if (uniqueNames.count(nameFileName) == 0) {
-                                                       outputNames.push_back(nameFileName);
-                                                       outputTypes["name"].push_back(nameFileName);
-                                               }
-                                               
-                                               nameFileNames[itBar->second][itPrimer->second] = nameFileName;
-                                               m->openOutputFile(nameFileName, temp);          temp.close();
-                                       }
-                                       
-                               }
-                       }
-               }
-               numFPrimers = primers.size();
-               numRPrimers = revPrimer.size();
-        numLinkers = linker.size();
-        numSpacers = spacer.size();
-               
-               bool allBlank = true;
-               for (int i = 0; i < barcodeNameVector.size(); i++) {
-                       if (barcodeNameVector[i] != "") {
-                               allBlank = false;
-                               break;
-                       }
-               }
-               for (int i = 0; i < primerNameVector.size(); i++) {
-                       if (primerNameVector[i] != "") {
-                               allBlank = false;
-                               break;
-                       }
-               }
-               
-               if (allBlank) {
-                       m->mothurOut("[WARNING]: your oligos file does not contain any group names.  mothur will not create a groupfile."); m->mothurOutEndLine();
-                       allFiles = false;
-                       return false;
-               }
-               
-               return true;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "getOligos");
-               exit(1);
-       }
-}
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::keepFirstTrim(Sequence& sequence, QualityScores& qscores){
-       try {
-               bool success = 1;
-               if(qscores.getName() != ""){
-                       qscores.trimQScores(-1, keepFirst);
-               }
-               sequence.trim(keepFirst);
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "keepFirstTrim", "countDiffs");
-               exit(1);
-       }
-       
-}      
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::removeLastTrim(Sequence& sequence, QualityScores& qscores){
-       try {
-               bool success = 0;
-               
-               int length = sequence.getNumBases() - removeLast;
-               
-               if(length > 0){
-                       if(qscores.getName() != ""){
-                               qscores.trimQScores(-1, length);
-                       }
-                       sequence.trim(length);
-                       success = 1;
-               }
-               else{
-                       success = 0;
-               }
-
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "removeLastTrim", "countDiffs");
-               exit(1);
-       }
-       
-}      
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::cullLength(Sequence& seq){
-       try {
-       
-               int length = seq.getNumBases();
-               bool success = 0;       //guilty until proven innocent
-               
-               if(length >= minLength && maxLength == 0)                       {       success = 1;    }
-               else if(length >= minLength && length <= maxLength)     {       success = 1;    }
-               else                                                                                            {       success = 0;    }
-               
-               return success;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "cullLength");
-               exit(1);
-       }
-       
-}
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::cullHomoP(Sequence& seq){
-       try {
-               int longHomoP = seq.getLongHomoPolymer();
-               bool success = 0;       //guilty until proven innocent
-               
-               if(longHomoP <= maxHomoP){      success = 1;    }
-               else                                    {       success = 0;    }
-               
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "cullHomoP");
-               exit(1);
-       }
-       
-}
-//********************************************************************/
-string TrimSeqsCommand::reverseOligo(string oligo){
-       try {
-        string reverse = "";
-        
-        for(int i=oligo.length()-1;i>=0;i--){
-            
-            if(oligo[i] == 'A')                {       reverse += 'T'; }
-            else if(oligo[i] == 'T'){  reverse += 'A'; }
-            else if(oligo[i] == 'U'){  reverse += 'A'; }
-            
-            else if(oligo[i] == 'G'){  reverse += 'C'; }
-            else if(oligo[i] == 'C'){  reverse += 'G'; }
-            
-            else if(oligo[i] == 'R'){  reverse += 'Y'; }
-            else if(oligo[i] == 'Y'){  reverse += 'R'; }
-            
-            else if(oligo[i] == 'M'){  reverse += 'K'; }
-            else if(oligo[i] == 'K'){  reverse += 'M'; }
-            
-            else if(oligo[i] == 'W'){  reverse += 'W'; }
-            else if(oligo[i] == 'S'){  reverse += 'S'; }
-            
-            else if(oligo[i] == 'B'){  reverse += 'V'; }
-            else if(oligo[i] == 'V'){  reverse += 'B'; }
-            
-            else if(oligo[i] == 'D'){  reverse += 'H'; }
-            else if(oligo[i] == 'H'){  reverse += 'D'; }
-            
-            else                                               {       reverse += 'N'; }
-        }
-        
-        
-        return reverse;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "reverseOligo");
-               exit(1);
-       }
-}
-
-//***************************************************************************************************************
-
-bool TrimSeqsCommand::cullAmbigs(Sequence& seq){
-       try {
-               int numNs = seq.getAmbigBases();
-               bool success = 0;       //guilty until proven innocent
-               
-               if(numNs <= maxAmbig)   {       success = 1;    }
-               else                                    {       success = 0;    }
-               
-               return success;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "TrimSeqsCommand", "cullAmbigs");
-               exit(1);
-       }
-       
-}
-//***************************************************************************************************************
diff --git a/trimseqscommand.h b/trimseqscommand.h
deleted file mode 100644 (file)
index 9ba64c4..0000000
+++ /dev/null
@@ -1,492 +0,0 @@
-#ifndef TRIMSEQSCOMMAND_H
-#define TRIMSEQSCOMMAND_H
-
-/*
- *  trimseqscommand.h
- *  Mothur
- *
- *  Created by Pat Schloss on 6/6/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "command.hpp"
-#include "sequence.hpp"
-#include "qualityscores.h"
-#include "groupmap.h"
-#include "trimoligos.h"
-
-
-class TrimSeqsCommand : public Command {
-public:
-       TrimSeqsCommand(string);
-       TrimSeqsCommand();
-       ~TrimSeqsCommand(){}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "trim.seqs";   }
-       string getCommandCategory()             { return "Sequence Processing";         }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Trim.seqs"; }
-       string getDescription()         { return "provides the preprocessing features needed to screen and sort pyrosequences"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       
-       GroupMap* groupMap;
-    
-    struct linePair {
-        unsigned long long start;
-        unsigned long long end;
-        linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
-        linePair() {}
-    };
-
-       bool getOligos(vector<vector<string> >&, vector<vector<string> >&, vector<vector<string> >&);
-       bool keepFirstTrim(Sequence&, QualityScores&);
-       bool removeLastTrim(Sequence&, QualityScores&);
-       bool cullLength(Sequence&);
-       bool cullHomoP(Sequence&);
-       bool cullAmbigs(Sequence&);
-    string reverseOligo(string);
-
-       bool abort, createGroup;
-       string fastaFile, oligoFile, qFileName, groupfile, nameFile, outputDir;
-       
-       bool flip, allFiles, qtrim, keepforward;
-       int numFPrimers, numRPrimers, numLinkers, numSpacers, maxAmbig, maxHomoP, minLength, maxLength, processors, tdiffs, bdiffs, pdiffs, ldiffs, sdiffs, comboStarts;
-       int qWindowSize, qWindowStep, keepFirst, removeLast;
-       double qRollAverage, qThreshold, qWindowAverage, qAverage;
-       vector<string> revPrimer, outputNames;
-       set<string> filesToRemove;
-       map<string, int> barcodes;
-       vector<string> groupVector;
-       map<string, int> primers;
-    vector<string>  linker;
-    vector<string>  spacer;
-       map<string, int> combos;
-       map<string, int> groupToIndex;
-       vector<string> primerNameVector;        //needed here?
-       vector<string> barcodeNameVector;       //needed here?
-       map<string, int> groupCounts;  
-       map<string, string> nameMap;
-
-       vector<int> processIDS;   //processid
-       vector<linePair> lines;
-       vector<linePair> qLines;
-       
-       int driverCreateTrim(string, string, string, string, string, string, string, string, string, vector<vector<string> >, vector<vector<string> >, vector<vector<string> >, linePair, linePair);    
-       int createProcessesCreateTrim(string, string, string, string, string, string, string, string, string, vector<vector<string> >, vector<vector<string> >, vector<vector<string> >);
-       int setLines(string, string);
-};
-
-/**************************************************************************************************/
-//custom data structure for threads to use.
-// This is passed by void pointer so it can be any data type
-// that can be passed using a single void pointer (LPVOID).
-struct trimData {
-    unsigned long long start, end;
-    MothurOut* m;
-    string filename, qFileName, trimFileName, scrapFileName, trimQFileName, scrapQFileName, trimNFileName, scrapNFileName, groupFileName, nameFile;
-       vector<vector<string> > fastaFileNames;
-    vector<vector<string> > qualFileNames;
-    vector<vector<string> > nameFileNames;
-    unsigned long long lineStart, lineEnd, qlineStart, qlineEnd;
-    bool flip, allFiles, qtrim, keepforward, createGroup;
-       int numFPrimers, numRPrimers, numLinkers, numSpacers, maxAmbig, maxHomoP, minLength, maxLength, tdiffs, bdiffs, pdiffs, ldiffs, sdiffs;
-       int qWindowSize, qWindowStep, keepFirst, removeLast, count;
-       double qRollAverage, qThreshold, qWindowAverage, qAverage;
-    vector<string> revPrimer;
-       map<string, int> barcodes;
-       map<string, int> primers;
-    vector<string>  linker;
-    vector<string>  spacer;
-       map<string, int> combos;
-       vector<string> primerNameVector;        
-       vector<string> barcodeNameVector;       
-       map<string, int> groupCounts;  
-       map<string, string> nameMap;
-    
-       trimData(){}
-       trimData(string fn, string qn, string nf, string tn, string sn, string tqn, string sqn, string tnn, string snn, string gn, vector<vector<string> > ffn, vector<vector<string> > qfn, vector<vector<string> > nfn, unsigned long long lstart, unsigned long long lend, unsigned long long qstart, unsigned long long qend,  MothurOut* mout,
-                      int pd, int bd, int ld, int sd, int td, map<string, int> pri, map<string, int> bar, vector<string> revP, vector<string> li, vector<string> spa, 
-                      vector<string> priNameVector, vector<string> barNameVector, bool cGroup, bool aFiles, bool keepF, int keepfi, int removeL,
-                      int WindowStep, int WindowSize, int WindowAverage, bool trim, double Threshold, double Average, double RollAverage,
-                      int minL, int maxA, int maxH, int maxL, bool fli, map<string, string> nm) {
-        filename = fn;
-        qFileName = qn;
-        nameFile = nf;
-        trimFileName = tn;
-        scrapFileName = sn;
-        trimQFileName = tqn;
-        scrapQFileName = sqn;
-        trimNFileName = tnn;
-        scrapNFileName = snn;
-        groupFileName = gn;
-        fastaFileNames = ffn;
-        qualFileNames = qfn;
-        nameFileNames = nfn;
-        lineStart = lstart;
-        lineEnd = lend;
-        qlineStart = qstart;
-        qlineEnd = qend;
-               m = mout;
-        
-        pdiffs = pd;
-        bdiffs = bd;
-        ldiffs = ld;
-        sdiffs = sd;
-        tdiffs = td;
-        barcodes = bar;
-        primers = pri;      numFPrimers = primers.size();
-        revPrimer = revP;   numRPrimers = revPrimer.size();
-        linker = li;        numLinkers = linker.size();
-        spacer = spa;       numSpacers = spacer.size();
-        primerNameVector = priNameVector;
-        barcodeNameVector = barNameVector;
-        
-        createGroup = cGroup;
-        allFiles = aFiles;
-        keepforward = keepF;
-        keepFirst = keepfi;
-        removeLast = removeL;
-        qWindowStep = WindowStep;
-        qWindowSize = WindowSize;
-        qWindowAverage = WindowAverage;
-        qtrim = trim;
-        qThreshold = Threshold;
-        qAverage = Average;
-        qRollAverage = RollAverage;
-        minLength = minL;
-        maxAmbig = maxA;
-        maxHomoP = maxH;
-        maxLength = maxL;
-        flip = fli;
-        nameMap = nm;
-        count = 0;
-       }
-};
-/**************************************************************************************************/
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-#else
-static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ 
-       trimData* pDataArray;
-       pDataArray = (trimData*)lpParam;
-       
-       try {
-        ofstream trimFASTAFile;
-               pDataArray->m->openOutputFile(pDataArray->trimFileName, trimFASTAFile);
-               
-               ofstream scrapFASTAFile;
-               pDataArray->m->openOutputFile(pDataArray->scrapFileName, scrapFASTAFile);
-               
-               ofstream trimQualFile;
-               ofstream scrapQualFile;
-               if(pDataArray->qFileName != ""){
-                       pDataArray->m->openOutputFile(pDataArray->trimQFileName, trimQualFile);
-                       pDataArray->m->openOutputFile(pDataArray->scrapQFileName, scrapQualFile);
-               }
-               
-               ofstream trimNameFile;
-               ofstream scrapNameFile;
-               if(pDataArray->nameFile != ""){
-                       pDataArray->m->openOutputFile(pDataArray->trimNFileName, trimNameFile);
-                       pDataArray->m->openOutputFile(pDataArray->scrapNFileName, scrapNameFile);
-               }
-               
-               
-               ofstream outGroupsFile;
-               if (pDataArray->createGroup){   pDataArray->m->openOutputFile(pDataArray->groupFileName, outGroupsFile);   }
-               if(pDataArray->allFiles){
-                       for (int i = 0; i < pDataArray->fastaFileNames.size(); i++) { //clears old file
-                               for (int j = 0; j < pDataArray->fastaFileNames[i].size(); j++) { //clears old file
-                                       if (pDataArray->fastaFileNames[i][j] != "") {
-                                               ofstream temp;
-                                               pDataArray->m->openOutputFile(pDataArray->fastaFileNames[i][j], temp);                  temp.close();
-                                               if(pDataArray->qFileName != ""){
-                                                       pDataArray->m->openOutputFile(pDataArray->qualFileNames[i][j], temp);                   temp.close();
-                                               }
-                                               
-                                               if(pDataArray->nameFile != ""){
-                                                       pDataArray->m->openOutputFile(pDataArray->nameFileNames[i][j], temp);                   temp.close();
-                                               }
-                                       }
-                               }
-                       }
-               }
-               
-               ifstream inFASTA;
-               pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
-               if ((pDataArray->lineStart == 0) || (pDataArray->lineStart == 1)) {
-                       inFASTA.seekg(0);
-               }else { //this accounts for the difference in line endings. 
-                       inFASTA.seekg(pDataArray->lineStart-1); pDataArray->m->gobble(inFASTA); 
-               }
-               
-               ifstream qFile;
-               if(pDataArray->qFileName != "") {
-                       pDataArray->m->openInputFile(pDataArray->qFileName, qFile);
-                       if ((pDataArray->qlineStart == 0) || (pDataArray->qlineStart == 1)) {
-                qFile.seekg(0);
-            }else { //this accounts for the difference in line endings. 
-                qFile.seekg(pDataArray->qlineStart-1); pDataArray->m->gobble(qFile); 
-            } 
-               }
-               
-               
-               TrimOligos trimOligos(pDataArray->pdiffs, pDataArray->bdiffs, pDataArray->ldiffs, pDataArray->sdiffs, pDataArray->primers, pDataArray->barcodes, pDataArray->revPrimer, pDataArray->linker, pDataArray->spacer);
-        
-               pDataArray->count = pDataArray->lineEnd;
-               for(int i = 0; i < pDataArray->lineEnd; i++){ //end is the number of sequences to process
-                                  
-                       if (pDataArray->m->control_pressed) { 
-                               inFASTA.close(); trimFASTAFile.close(); scrapFASTAFile.close();
-                               if (pDataArray->createGroup) {   outGroupsFile.close();   }
-                               if(pDataArray->qFileName != ""){ qFile.close(); }
-                               return 0;
-                       }
-                       
-                       int success = 1;
-                       string trashCode = "";
-                       int currentSeqsDiffs = 0;
-            
-                       Sequence currSeq(inFASTA); pDataArray->m->gobble(inFASTA);
-                       
-                       QualityScores currQual;
-                       if(pDataArray->qFileName != ""){
-                               currQual = QualityScores(qFile);  pDataArray->m->gobble(qFile);
-                       }
-                       
-                       string origSeq = currSeq.getUnaligned();
-                       if (origSeq != "") {
-                               
-                               int barcodeIndex = 0;
-                               int primerIndex = 0;
-                               
-                if(pDataArray->numLinkers != 0){
-                                       success = trimOligos.stripLinker(currSeq, currQual);
-                                       if(success > pDataArray->ldiffs)                {       trashCode += 'k';       }
-                                       else{ currentSeqsDiffs += success;  }
-                               }
-                
-                               if(pDataArray->barcodes.size() != 0){
-                                       success = trimOligos.stripBarcode(currSeq, currQual, barcodeIndex);
-                                       if(success > pDataArray->bdiffs)                {       trashCode += 'b';       }
-                                       else{ currentSeqsDiffs += success;  }
-                               }
-                               
-                if(pDataArray->numSpacers != 0){
-                                       success = trimOligos.stripSpacer(currSeq, currQual);
-                                       if(success > pDataArray->sdiffs)                {       trashCode += 's';       }
-                                       else{ currentSeqsDiffs += success;  }
-
-                               }
-                
-                               if(pDataArray->numFPrimers != 0){
-                                       success = trimOligos.stripForward(currSeq, currQual, primerIndex, pDataArray->keepforward);
-                                       if(success > pDataArray->pdiffs)                {       trashCode += 'f';       }
-                                       else{ currentSeqsDiffs += success;  }
-                               }
-                               
-                               if (currentSeqsDiffs > pDataArray->tdiffs)      {       trashCode += 't';   }
-                               
-                               if(pDataArray->numRPrimers != 0){
-                                       success = trimOligos.stripReverse(currSeq, currQual);
-                                       if(!success)                            {       trashCode += 'r';       }
-                               }
-                
-                               if(pDataArray->keepFirst != 0){
-                                       //success = keepFirstTrim(currSeq, currQual);
-                    success = 1;
-                    if(currQual.getName() != ""){
-                        currQual.trimQScores(-1, pDataArray->keepFirst);
-                    }
-                    currSeq.trim(pDataArray->keepFirst);
-                               }
-                               
-                               if(pDataArray->removeLast != 0){
-                                       //success = removeLastTrim(currSeq, currQual);
-                    success = 0;
-                    int length = currSeq.getNumBases() - pDataArray->removeLast;
-                    
-                    if(length > 0){
-                        if(currQual.getName() != ""){
-                            currQual.trimQScores(-1, length);
-                        }
-                        currSeq.trim(length);
-                        success = 1;
-                    }
-                    else{ success = 0; }
-                    
-                                       if(!success)                            {       trashCode += 'l';       }
-                               }
-                
-                               
-                               if(pDataArray->qFileName != ""){
-                                       int origLength = currSeq.getNumBases();
-                                       
-                                       if(pDataArray->qThreshold != 0)                 {       success = currQual.stripQualThreshold(currSeq, pDataArray->qThreshold);                 }
-                                       else if(pDataArray->qAverage != 0)              {       success = currQual.cullQualAverage(currSeq, pDataArray->qAverage);                              }
-                                       else if(pDataArray->qRollAverage != 0)  {       success = currQual.stripQualRollingAverage(currSeq, pDataArray->qRollAverage);  }
-                                       else if(pDataArray->qWindowAverage != 0){       success = currQual.stripQualWindowAverage(currSeq, pDataArray->qWindowStep, pDataArray->qWindowSize, pDataArray->qWindowAverage);       }
-                                       else                                            {       success = 1;                            }
-                                       
-                                       //you don't want to trim, if it fails above then scrap it
-                                       if ((!pDataArray->qtrim) && (origLength != currSeq.getNumBases())) {  success = 0; }
-                                       
-                                       if(!success)                            {       trashCode += 'q';       }
-                               }                               
-                
-                               if(pDataArray->minLength > 0 || pDataArray->maxLength > 0){
-                                       //success = cullLength(currSeq);
-                    int length = currSeq.getNumBases();
-                    success = 0;       //guilty until proven innocent
-                    if(length >= pDataArray->minLength && pDataArray->maxLength == 0)                  {       success = 1;    }
-                    else if(length >= pDataArray->minLength && length <= pDataArray->maxLength)        {       success = 1;    }
-                    else                                                                                               {       success = 0;    }
-                    
-                                       if(!success)                            {       trashCode += 'l';       }
-                               }
-                               if(pDataArray->maxHomoP > 0){
-                                       //success = cullHomoP(currSeq);
-                    int longHomoP = currSeq.getLongHomoPolymer();
-                    success = 0;       //guilty until proven innocent
-                    if(longHomoP <= pDataArray->maxHomoP){     success = 1;    }
-                    else                                       {       success = 0;    }
-                    
-                                       if(!success)                            {       trashCode += 'h';       }
-                               }
-                               if(pDataArray->maxAmbig != -1){
-                                       //success = cullAmbigs(currSeq);
-                    int numNs = currSeq.getAmbigBases();
-                    success = 0;       //guilty until proven innocent
-                    if(numNs <= pDataArray->maxAmbig)  {       success = 1;    }
-                    else                                       {       success = 0;    }
-                                       if(!success)                            {       trashCode += 'n';       }
-                               }
-                               
-                               if(pDataArray->flip){           // should go last                       
-                                       currSeq.reverseComplement();
-                                       if(pDataArray->qFileName != ""){
-                                               currQual.flipQScores(); 
-                                       }
-                               }
-                               
-                               if(trashCode.length() == 0){
-                                       currSeq.setAligned(currSeq.getUnaligned());
-                                       currSeq.printSequence(trimFASTAFile);
-                                       
-                                       if(pDataArray->qFileName != ""){
-                                               currQual.printQScores(trimQualFile);
-                                       }
-                                       
-                                       if(pDataArray->nameFile != ""){
-                                               map<string, string>::iterator itName = pDataArray->nameMap.find(currSeq.getName());
-                                               if (itName != pDataArray->nameMap.end()) {  trimNameFile << itName->first << '\t' << itName->second << endl; }
-                                               else { pDataArray->m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
-                                       }
-                                       
-                                       if (pDataArray->createGroup) {
-                                               if(pDataArray->barcodes.size() != 0){
-                                                       string thisGroup = pDataArray->barcodeNameVector[barcodeIndex];
-                                                       if (pDataArray->primers.size() != 0) { 
-                                                               if (pDataArray->primerNameVector[primerIndex] != "") { 
-                                                                       if(thisGroup != "") {
-                                                                               thisGroup += "." + pDataArray->primerNameVector[primerIndex]; 
-                                                                       }else {
-                                                                               thisGroup = pDataArray->primerNameVector[primerIndex]; 
-                                                                       }
-                                                               } 
-                                                       }
-                                                       
-                                                       outGroupsFile << currSeq.getName() << '\t' << thisGroup << endl;
-                                                       
-                                                       if (pDataArray->nameFile != "") {
-                                                               map<string, string>::iterator itName = pDataArray->nameMap.find(currSeq.getName());
-                                                               if (itName != pDataArray->nameMap.end()) { 
-                                                                       vector<string> thisSeqsNames; 
-                                                                       pDataArray->m->splitAtChar(itName->second, thisSeqsNames, ',');
-                                                                       for (int k = 1; k < thisSeqsNames.size(); k++) { //start at 1 to skip self
-                                                                               outGroupsFile << thisSeqsNames[k] << '\t' << thisGroup << endl;
-                                                                       }
-                                                               }else { pDataArray->m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }                                                   
-                                                       }
-                                                       
-                                                       map<string, int>::iterator it = pDataArray->groupCounts.find(thisGroup);
-                                                       if (it == pDataArray->groupCounts.end()) {      pDataArray->groupCounts[thisGroup] = 1; }
-                                                       else { pDataArray->groupCounts[it->first]++; }
-                            
-                                               }
-                                       }
-                                       
-                                       if(pDataArray->allFiles){
-                                               ofstream output;
-                                               pDataArray->m->openOutputFileAppend(pDataArray->fastaFileNames[barcodeIndex][primerIndex], output);
-                                               currSeq.printSequence(output);
-                                               output.close();
-                                               
-                                               if(pDataArray->qFileName != ""){
-                                                       pDataArray->m->openOutputFileAppend(pDataArray->qualFileNames[barcodeIndex][primerIndex], output);
-                                                       currQual.printQScores(output);
-                                                       output.close();                                                 
-                                               }
-                                               
-                                               if(pDataArray->nameFile != ""){
-                                                       map<string, string>::iterator itName = pDataArray->nameMap.find(currSeq.getName());
-                                                       if (itName != pDataArray->nameMap.end()) { 
-                                                               pDataArray->m->openOutputFileAppend(pDataArray->nameFileNames[barcodeIndex][primerIndex], output);
-                                                               output << itName->first << '\t' << itName->second << endl; 
-                                                               output.close();
-                                                       }else { pDataArray->m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
-                                               }
-                                       }
-                               }
-                               else{
-                                       if(pDataArray->nameFile != ""){ //needs to be before the currSeq name is changed
-                                               map<string, string>::iterator itName = pDataArray->nameMap.find(currSeq.getName());
-                                               if (itName != pDataArray->nameMap.end()) {  scrapNameFile << itName->first << '\t' << itName->second << endl; }
-                                               else { pDataArray->m->mothurOut("[ERROR]: " + currSeq.getName() + " is not in your namefile, please correct."); pDataArray->m->mothurOutEndLine(); }
-                                       }
-                                       currSeq.setName(currSeq.getName() + '|' + trashCode);
-                                       currSeq.setUnaligned(origSeq);
-                                       currSeq.setAligned(origSeq);
-                                       currSeq.printSequence(scrapFASTAFile);
-                                       if(pDataArray->qFileName != ""){
-                                               currQual.printQScores(scrapQualFile);
-                                       }
-                               }
-                               
-                       }
-                       
-                       //report progress
-                       if((i) % 1000 == 0){    pDataArray->m->mothurOut(toString(i)); pDataArray->m->mothurOutEndLine();               }
-                       
-               }
-               //report progress
-               if((pDataArray->count) % 1000 != 0){    pDataArray->m->mothurOut(toString(pDataArray->count)); pDataArray->m->mothurOutEndLine();               }
-               
-               
-               inFASTA.close();
-               trimFASTAFile.close();
-               scrapFASTAFile.close();
-               if (pDataArray->createGroup) {   outGroupsFile.close();   }
-               if(pDataArray->qFileName != "") {       qFile.close();  scrapQualFile.close(); trimQualFile.close();    }
-               if(pDataArray->nameFile != "")  {       scrapNameFile.close(); trimNameFile.close();    }
-               
-        return 0;
-            
-        }
-        catch(exception& e) {
-            pDataArray->m->errorOut(e, "TrimSeqsCommand", "MyTrimThreadFunction");
-            exit(1);
-        }
-    } 
-#endif
-    
-
-/**************************************************************************************************/
-
-#endif
diff --git a/unifracunweightedcommand.cpp b/unifracunweightedcommand.cpp
deleted file mode 100644 (file)
index dbdee2a..0000000
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- *  unifracunweightedcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "unifracunweightedcommand.h"
-#include "treereader.h"
-#include "subsample.h"
-#include "consensus.h"
-
-//**********************************************************************************************************************
-vector<string> UnifracUnweightedCommand::setParameters(){      
-       try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-               CommandParameter prandom("random", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter pdistance("distance", "Multiple", "column-lt-square", "column", "", "", "",false,false); parameters.push_back(pdistance);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pconsensus);
-        CommandParameter proot("root", "Boolean", "F", "", "", "", "",false,false); parameters.push_back(proot);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string UnifracUnweightedCommand::getHelpString(){      
-       try {
-               string helpString = "";
-               helpString += "The unifrac.unweighted command parameters are tree, group, name, groups, iters, distance, processors, root and random.  tree parameter is required unless you have valid current tree file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 1 valid group.\n";
-               helpString += "The group names are separated by dashes.  The iters parameter allows you to specify how many random trees you would like compared to your tree.\n";
-               helpString += "The distance parameter allows you to create a distance file from the results. The default is false. You may set distance to lt, square or column.\n";
-               helpString += "The random parameter allows you to shut off the comparison to random trees. The default is false, meaning compare don't your trees with randomly generated trees.\n";
-               helpString += "The root parameter allows you to include the entire root in your calculations. The default is false, meaning stop at the root for this comparision instead of the root of the entire tree.\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-               helpString += "The unifrac.unweighted command should be in the following format: unifrac.unweighted(groups=yourGroups, iters=yourIters).\n";
-        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group. The subsample parameter may only be used with a group file.\n";
-        helpString += "The consensus parameter allows you to indicate you would like trees built from distance matrices created with the results of the subsampling, as well as a consensus tree built from these trees. Default=F.\n";
-               helpString += "Example unifrac.unweighted(groups=A-B-C, iters=500).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and iters is 1000.\n";
-               helpString += "The unifrac.unweighted command output two files: .unweighted and .uwsummary their descriptions are in the manual.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-UnifracUnweightedCommand::UnifracUnweightedCommand(){  
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["unweighted"] = tempOutNames;
-               outputTypes["uwsummary"] = tempOutNames;
-               outputTypes["phylip"] = tempOutNames;
-               outputTypes["column"] = tempOutNames;
-        outputTypes["tree"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-UnifracUnweightedCommand::UnifracUnweightedCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["unweighted"] = tempOutNames;
-                       outputTypes["uwsummary"] = tempOutNames;
-                       outputTypes["phylip"] = tempOutNames;
-                       outputTypes["column"] = tempOutNames;
-            outputTypes["tree"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-            //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { abort = true; }
-                       else if (treefile == "not found") {                             //if there is a current design file, use it
-                               treefile = m->getTreeFile(); 
-                               if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }else { m->setTreeFile(treefile); }     
-                       
-                       //check for required parameters
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(treefile);       }
-                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                               
-                       itersString = validParameter.validFile(parameters, "iters", false);                             if (itersString == "not found") { itersString = "1000"; }
-                       m->mothurConvert(itersString, iters); 
-                       
-                       string temp = validParameter.validFile(parameters, "distance", false);                  
-                       if (temp == "not found") { phylip = false; outputForm = ""; }
-                       else{
-                               if ((temp == "lt") || (temp == "column") || (temp == "square")) {  phylip = true;  outputForm = temp; }
-                               else { m->mothurOut("Options for distance are: lt, square, or column. Using lt."); m->mothurOutEndLine(); phylip = true; outputForm = "lt"; }
-                       }
-                       
-                       temp = validParameter.validFile(parameters, "random", false);                                   if (temp == "not found") { temp = "f"; }
-                       random = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "root", false);                                     if (temp == "not found") { temp = "F"; }
-                       includeRoot = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors); 
-                       
-            temp = validParameter.validFile(parameters, "subsample", false);           if (temp == "not found") { temp = "F"; }
-                       if (m->isNumeric1(temp)) { m->mothurConvert(temp, subsampleSize); subsample = true; }
-            else {  
-                if (m->isTrue(temp)) { subsample = true; subsampleSize = -1; }  //we will set it to smallest group later 
-                else { subsample = false; }
-            }
-                       
-            if (!subsample) { subsampleIters = 0;   }
-            else { subsampleIters = iters;          }
-            
-            temp = validParameter.validFile(parameters, "consensus", false);                                   if (temp == "not found") { temp = "F"; }
-                       consensus = m->isTrue(temp);
-            
-                       if (subsample && random) {  m->mothurOut("[ERROR]: random must be false, if subsample=t.\n"); abort=true;  } 
-                       if (subsample && (groupfile == "")) {  m->mothurOut("[ERROR]: if subsample=t, a group file must be provided.\n"); abort=true;  } 
-            if (subsample && (!phylip)) { phylip=true; outputForm = "lt"; }
-            if (consensus && (!subsample)) { m->mothurOut("[ERROR]: you cannot use consensus without subsample.\n"); abort=true; }
-
-                       if (!random) {  iters = 0;  } //turn off random calcs
-                       
-                       //if user selects distance = true and no groups it won't calc the pairwise
-                       if ((phylip) && (Groups.size() == 0)) {
-                               groups = "all";
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(treefile);
-                               parser.getNameFile(files);
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "UnifracUnweightedCommand");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-int UnifracUnweightedCommand::execute() {
-       try {
-               
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               m->setTreeFile(treefile);
-               
-               TreeReader* reader = new TreeReader(treefile, groupfile, namefile);
-        T = reader->getTrees();
-        tmap = T[0]->getTreeMap();
-        map<string, string> nameMap = reader->getNames();
-        delete reader; 
-        
-               sumFile = outputDir + m->getSimpleName(treefile) + ".uwsummary";
-               outputNames.push_back(sumFile); outputTypes["uwsummary"].push_back(sumFile);
-               m->openOutputFile(sumFile, outSum);
-               
-               SharedUtil util;
-               Groups = m->getGroups();
-               vector<string> namesGroups = tmap->getNamesOfGroups();
-               util.setGroups(Groups, namesGroups, allGroups, numGroups, "unweighted");        //sets the groups the user wants to analyze
-               
-               Unweighted unweighted(includeRoot);
-               
-               int start = time(NULL);
-        
-        //set or check size
-        if (subsample) {
-            //user has not set size, set size = smallest samples size
-            if (subsampleSize == -1) { 
-                vector<string> temp; temp.push_back(Groups[0]);
-                subsampleSize = (tmap->getNamesSeqs(temp)).size(); //num in first group
-                for (int i = 1; i < Groups.size(); i++) {
-                    temp.clear(); temp.push_back(Groups[i]);
-                    int thisSize = (tmap->getNamesSeqs(temp)).size();
-                    if (thisSize < subsampleSize) {    subsampleSize = thisSize;       }
-                }
-                m->mothurOut("\nSetting subsample size to " + toString(subsampleSize) + ".\n\n");
-            }else { //eliminate any too small groups
-                vector<string> newGroups = Groups;
-                Groups.clear();
-                for (int i = 0; i < newGroups.size(); i++) {
-                    vector<string> thisGroup; thisGroup.push_back(newGroups[i]);
-                    vector<string> thisGroupsSeqs = tmap->getNamesSeqs(thisGroup);
-                    int thisSize = thisGroupsSeqs.size();
-                    
-                    if (thisSize >= subsampleSize) {    Groups.push_back(newGroups[i]);        }
-                    else {  m->mothurOut("You have selected a size that is larger than "+newGroups[i]+" number of sequences, removing "+newGroups[i]+".\n"); }
-                } 
-                m->setGroups(Groups);
-            }
-        }
-               
-        util.getCombos(groupComb, Groups, numComp);
-               m->setGroups(Groups);
-        
-               if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
-        
-               if (numComp < processors) { processors = numComp;  }
-        
-        if (consensus && (numComp < 2)) { m->mothurOut("consensus can only be used with numComparisions greater than 1, setting consensus=f.\n"); consensus=false; }
-               
-               outSum << "Tree#" << '\t' << "Groups" << '\t'  <<  "UWScore" <<'\t';
-               m->mothurOut("Tree#\tGroups\tUWScore\t");
-               if (random) { outSum << "UWSig"; m->mothurOut("UWSig"); }
-               outSum << endl; m->mothurOutEndLine();
-        
-               //get pscores for users trees
-               for (int i = 0; i < T.size(); i++) {
-                       if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }outSum.close(); for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-                       
-                       counter = 0;
-                       
-                       if (random)  {  
-                               output = new ColumnFile(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted", itersString);
-                               outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted");
-                               outputTypes["unweighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted");
-                       }
-                       
-                       
-                       //get unweighted for users tree
-                       rscoreFreq.resize(numComp);  
-                       rCumul.resize(numComp);  
-                       utreeScores.resize(numComp);  
-                       UWScoreSig.resize(numComp); 
-            
-            vector<double> userData; userData.resize(numComp,0);  //weighted score info for user tree. data[0] = weightedscore AB, data[1] = weightedscore AC...
-
-                       userData = unweighted.getValues(T[i], processors, outputDir);  //userData[0] = unweightedscore
-               
-                       if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output;  } outSum.close();  for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  }return 0; }
-                       
-                       //output scores for each combination
-                       for(int k = 0; k < numComp; k++) {
-                               //saves users score
-                               utreeScores[k].push_back(userData[k]);
-                               
-                               //add users score to validscores
-                               validScores[userData[k]] = userData[k];
-                
-                if (!random) { UWScoreSig[k].push_back(0.0);   }
-                       }
-            
-            if (random) {  runRandomCalcs(T[i], userData);  }
-                       
-                       if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output;  } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0;  }
-            
-            //subsample loop
-            vector< vector<double> > calcDistsTotals;  //each iter, each groupCombos dists. this will be used to make .dist files
-            for (int thisIter = 0; thisIter < subsampleIters; thisIter++) { //subsampleIters=0, if subsample=f.
-                
-                if (m->control_pressed) { break; }
-                
-                //copy to preserve old one - would do this in subsample but memory cleanup becomes messy.
-                TreeMap* newTmap = new TreeMap();
-                newTmap->getCopy(*tmap);
-                
-                SubSample sample;
-                Tree* subSampleTree = sample.getSample(T[i], newTmap, nameMap, subsampleSize);
-                
-                //call new weighted function
-                vector<double> iterData; iterData.resize(numComp,0);
-                Unweighted thisUnweighted(includeRoot);
-                iterData = thisUnweighted.getValues(subSampleTree, processors, outputDir); //userData[0] = weightedscore
-                
-                //save data to make ave dist, std dist
-                calcDistsTotals.push_back(iterData);
-                
-                delete newTmap;
-                delete subSampleTree;
-                
-                if((thisIter+1) % 100 == 0){   m->mothurOut(toString(thisIter+1)); m->mothurOutEndLine();              }
-            }
-            
-            if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }if (random) { delete output;  } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0;  }
-
-            if (subsample) {  getAverageSTDMatrices(calcDistsTotals, i); }
-            if (consensus) {  getConsensusTrees(calcDistsTotals, i);  }
-            
-            //print output files
-                       printUWSummaryFile(i);
-                       if (random)  {  printUnweightedFile();  delete output;  }
-                       if (phylip) {   createPhylipFile(i);            }
-                       
-                       rscoreFreq.clear(); 
-                       rCumul.clear();  
-                       validScores.clear(); 
-                       utreeScores.clear();  
-                       UWScoreSig.clear(); 
-               }
-               
-
-               outSum.close();
-               delete tmap; 
-               for (int i = 0; i < T.size(); i++) { delete T[i]; }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  }     return 0; }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.unweighted."); m->mothurOutEndLine();
-               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("phylip");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
-               }
-               
-               //set column file as new current columnfile
-               itTypes = outputTypes.find("column");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int UnifracUnweightedCommand::getAverageSTDMatrices(vector< vector<double> >& dists, int treeNum) {
-       try {
-        //we need to find the average distance and standard deviation for each groups distance
-        
-        //finds sum
-        vector<double> averages; averages.resize(numComp, 0); 
-        for (int thisIter = 0; thisIter < subsampleIters; thisIter++) {
-            for (int i = 0; i < dists[thisIter].size(); i++) {  
-                averages[i] += dists[thisIter][i];
-            }
-        }
-        
-        //finds average.
-        for (int i = 0; i < averages.size(); i++) {  averages[i] /= (float) subsampleIters; }
-        
-        //find standard deviation
-        vector<double> stdDev; stdDev.resize(numComp, 0);
-        
-        for (int thisIter = 0; thisIter < iters; thisIter++) { //compute the difference of each dist from the mean, and square the result of each
-            for (int j = 0; j < dists[thisIter].size(); j++) {
-                stdDev[j] += ((dists[thisIter][j] - averages[j]) * (dists[thisIter][j] - averages[j]));
-            }
-        }
-        for (int i = 0; i < stdDev.size(); i++) {  
-            stdDev[i] /= (float) subsampleIters; 
-            stdDev[i] = sqrt(stdDev[i]);
-        }
-        
-        //make matrix with scores in it
-        vector< vector<double> > avedists;     avedists.resize(m->getNumGroups());
-        for (int i = 0; i < m->getNumGroups(); i++) {
-            avedists[i].resize(m->getNumGroups(), 0.0);
-        }
-        
-        //make matrix with scores in it
-        vector< vector<double> > stddists;     stddists.resize(m->getNumGroups());
-        for (int i = 0; i < m->getNumGroups(); i++) {
-            stddists[i].resize(m->getNumGroups(), 0.0);
-        }
-        
-        //flip it so you can print it
-        int count = 0;
-        for (int r=0; r<m->getNumGroups(); r++) { 
-            for (int l = 0; l < r; l++) {
-                avedists[r][l] = averages[count];
-                avedists[l][r] = averages[count];
-                stddists[r][l] = stdDev[count];
-                stddists[l][r] = stdDev[count];
-                count++;
-            }
-        }
-        
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.ave.dist";
-        outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName); 
-        
-        ofstream out;
-        m->openOutputFile(aveFileName, out);
-        
-        string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".unweighted.std.dist";
-        outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); 
-        
-        ofstream outStd;
-        m->openOutputFile(stdFileName, outStd);
-        
-        if ((outputForm == "lt") || (outputForm == "square")) {
-            //output numSeqs
-            out << m->getNumGroups() << endl;
-            outStd << m->getNumGroups() << endl;
-        }
-        
-        //output to file
-        for (int r=0; r<m->getNumGroups(); r++) { 
-            //output name
-            string name = (m->getGroups())[r];
-            if (name.length() < 10) { //pad with spaces to make compatible
-                while (name.length() < 10) {  name += " ";  }
-            }
-            
-            if (outputForm == "lt") {
-                out << name << '\t';
-                outStd << name << '\t';
-                
-                //output distances
-                for (int l = 0; l < r; l++) {  out  << avedists[r][l] << '\t';  outStd  << stddists[r][l] << '\t';}
-                out << endl;  outStd << endl;
-            }else if (outputForm == "square") {
-                out << name << '\t';
-                outStd << name << '\t';
-                
-                //output distances
-                for (int l = 0; l < m->getNumGroups(); l++) {  out  << avedists[r][l] << '\t'; outStd  << stddists[r][l] << '\t'; }
-                out << endl; outStd << endl;
-            }else{
-                //output distances
-                for (int l = 0; l < r; l++) {  
-                    string otherName = (m->getGroups())[l];
-                    if (otherName.length() < 10) { //pad with spaces to make compatible
-                        while (otherName.length() < 10) {  otherName += " ";  }
-                    }
-                    
-                    out  << name << '\t' << otherName << avedists[r][l] << endl;  
-                    outStd  << name << '\t' << otherName << stddists[r][l] << endl; 
-                }
-            }
-        }
-        out.close();
-        outStd.close();
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "getAverageSTDMatrices");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int UnifracUnweightedCommand::getConsensusTrees(vector< vector<double> >& dists, int treeNum) {
-       try {
-        
-        //used in tree constructor 
-        m->runParse = false;
-        
-        //create treemap class from groupmap for tree class to use
-        TreeMap newTmap;
-        newTmap.makeSim(m->getGroups());
-        
-        //clear  old tree names if any
-        m->Treenames.clear();
-        
-        //fills globaldatas tree names
-        m->Treenames = m->getGroups();
-        
-        vector<Tree*> newTrees = buildTrees(dists, treeNum, newTmap); //also creates .all.tre file containing the trees created
-        
-        if (m->control_pressed) { return 0; }
-        
-        Consensus con;
-        Tree* conTree = con.getTree(newTrees);
-        
-        //create a new filename
-        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.cons.tre";                                
-        outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
-        ofstream outTree;
-        m->openOutputFile(conFile, outTree);
-        
-        if (conTree != NULL) { conTree->print(outTree, "boot"); delete conTree; }
-        outTree.close();
-        
-        return 0;
-        
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "getConsensusTrees");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-vector<Tree*> UnifracUnweightedCommand::buildTrees(vector< vector<double> >& dists, int treeNum, TreeMap& mytmap) {
-       try {
-        
-        vector<Tree*> trees;
-        
-        //create a new filename
-        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".unweighted.all.tre";                              
-        outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
-        
-        ofstream outAll;
-        m->openOutputFile(outputFile, outAll);
-        
-        
-        for (int i = 0; i < dists.size(); i++) { //dists[0] are the dists for the first subsampled tree.
-            
-            if (m->control_pressed) { break; }
-            
-            //make matrix with scores in it
-            vector< vector<double> > sims;     sims.resize(m->getNumGroups());
-            for (int j = 0; j < m->getNumGroups(); j++) {
-                sims[j].resize(m->getNumGroups(), 0.0);
-            }
-            
-            int count = 0;
-                       for (int r=0; r<m->getNumGroups(); r++) { 
-                               for (int l = 0; l < r; l++) {
-                    double sim = -(dists[i][count]-1.0);
-                                       sims[r][l] = sim;
-                                       sims[l][r] = sim;
-                                       count++;
-                               }
-                       }
-            
-            //create tree
-            Tree* tempTree = new Tree(&mytmap, sims);
-            map<string, string> empty;
-            tempTree->assembleTree(empty);
-            
-            trees.push_back(tempTree);
-            
-            //print tree
-            tempTree->print(outAll);
-        }
-        
-        outAll.close();
-        
-        if (m->control_pressed) {  for (int i = 0; i < trees.size(); i++) {  delete trees[i]; trees[i] = NULL; } m->mothurRemove(outputFile); }
-        
-        return trees;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "buildTrees");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int UnifracUnweightedCommand::runRandomCalcs(Tree* thisTree, vector<double> usersScores) {
-       try {
-        vector<double> randomData; randomData.resize(numComp,0); //weighted score info for random trees. data[0] = weightedscore AB, data[1] = weightedscore AC...
-        
-        Unweighted unweighted(includeRoot);
-        
-        //get unweighted scores for random trees - if random is false iters = 0
-        for (int j = 0; j < iters; j++) {
-            
-            //we need a different getValues because when we swap the labels we only want to swap those in each pairwise comparison
-            randomData = unweighted.getValues(thisTree, "", "", processors, outputDir);
-            
-            if (m->control_pressed) { return 0; }
-                       
-            for(int k = 0; k < numComp; k++) { 
-                //add trees unweighted score to map of scores
-                map<float,float>::iterator it = rscoreFreq[k].find(randomData[k]);
-                if (it != rscoreFreq[k].end()) {//already have that score
-                    rscoreFreq[k][randomData[k]]++;
-                }else{//first time we have seen this score
-                    rscoreFreq[k][randomData[k]] = 1;
-                }
-                               
-                //add randoms score to validscores
-                validScores[randomData[k]] = randomData[k];
-            }
-        }
-        
-        for(int a = 0; a < numComp; a++) {
-            float rcumul = 1.0000;
-    
-            //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
-            for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) { 
-                //make rscoreFreq map and rCumul
-                map<float,float>::iterator it2 = rscoreFreq[a].find(it->first);
-                rCumul[a][it->first] = rcumul;
-                //get percentage of random trees with that info
-                if (it2 != rscoreFreq[a].end()) {  rscoreFreq[a][it->first] /= iters; rcumul-= it2->second;  }
-                else { rscoreFreq[a][it->first] = 0.0000; } //no random trees with that score
-            }
-            UWScoreSig[a].push_back(rCumul[a][usersScores[a]]);
-        }
-        
-        return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "runRandomCalcs");
-               exit(1);
-       }
-}
-/***********************************************************/
-void UnifracUnweightedCommand::printUnweightedFile() {
-       try {
-               vector<double> data;
-               vector<string> tags;
-               
-               tags.push_back("Score");
-               tags.push_back("RandFreq"); tags.push_back("RandCumul");
-                       
-               for(int a = 0; a < numComp; a++) {
-                       output->initFile(groupComb[a], tags);
-                       //print each line
-                       for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) { 
-                               data.push_back(it->first);  data.push_back(rscoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]);                                             
-                               output->output(data);
-                               data.clear();
-                       } 
-                       output->resetFile();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "printUnweightedFile");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-void UnifracUnweightedCommand::printUWSummaryFile(int i) {
-       try {
-                               
-               //format output
-               outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
-                       
-               //print each line
-
-               for(int a = 0; a < numComp; a++) {
-                       outSum << i+1 << '\t';
-                       m->mothurOut(toString(i+1) + "\t");
-                       
-                       if (random) {
-                               if (UWScoreSig[a][0] > (1/(float)iters)) {
-                                       outSum << setprecision(6) << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << UWScoreSig[a][0] << endl;
-                                       cout << setprecision(6)  << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << UWScoreSig[a][0] << endl; 
-                                       m->mothurOutJustToLog(groupComb[a]  + "\t" + toString(utreeScores[a][0])  + "\t" + toString(UWScoreSig[a][0])+ "\n"); 
-                               }else {
-                                       outSum << setprecision(6) << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl;
-                                       cout << setprecision(6)  << groupComb[a]  << '\t' << utreeScores[a][0] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl; 
-                                       m->mothurOutJustToLog(groupComb[a]  + "\t" + toString(utreeScores[a][0])  + "\t<" + toString((1/float(iters))) + "\n"); 
-                               }
-                       }else{
-                               outSum << setprecision(6) << groupComb[a]  << '\t' << utreeScores[a][0]  << endl;
-                               cout << setprecision(6)  << groupComb[a]  << '\t' << utreeScores[a][0]  << endl; 
-                               m->mothurOutJustToLog(groupComb[a]  + "\t" + toString(utreeScores[a][0]) + "\n");
-                       }
-               }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "printUWSummaryFile");
-               exit(1);
-       }
-}
-/***********************************************************/
-void UnifracUnweightedCommand::createPhylipFile(int i) {
-       try {
-               string phylipFileName;
-               if ((outputForm == "lt") || (outputForm == "square")) {
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.phylip.dist";
-                       outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
-               }else { //column
-                       phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".unweighted.column.dist";
-                       outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
-               }
-               
-               ofstream out;
-               m->openOutputFile(phylipFileName, out);
-               
-               if ((outputForm == "lt") || (outputForm == "square")) {
-                       //output numSeqs
-                       out << m->getNumGroups() << endl;
-               }
-               
-               //make matrix with scores in it
-               vector< vector<float> > dists;  dists.resize(m->getNumGroups());
-               for (int i = 0; i < m->getNumGroups(); i++) {
-                       dists[i].resize(m->getNumGroups(), 0.0);
-               }
-               
-               //flip it so you can print it
-               int count = 0;
-               for (int r=0; r<m->getNumGroups(); r++) { 
-                       for (int l = 0; l < r; l++) {
-                               dists[r][l] = utreeScores[count][0];
-                               dists[l][r] = utreeScores[count][0];
-                               count++;
-                       }
-               }
-               
-               //output to file
-               for (int r=0; r<m->getNumGroups(); r++) { 
-                       //output name
-                       string name = (m->getGroups())[r];
-                       if (name.length() < 10) { //pad with spaces to make compatible
-                               while (name.length() < 10) {  name += " ";  }
-                       }
-                       
-                       if (outputForm == "lt") {
-                               out << name << '\t';
-                       
-                               //output distances
-                               for (int l = 0; l < r; l++) {   out  << dists[r][l] << '\t';  }
-                               out << endl;
-                       }else if (outputForm == "square") {
-                               out << name << '\t';
-                               
-                               //output distances
-                               for (int l = 0; l < m->getNumGroups(); l++) {   out << dists[r][l] << '\t';  }
-                               out << endl;
-                       }else{
-                               //output distances
-                               for (int l = 0; l < r; l++) {   
-                                       string otherName = (m->getGroups())[l];
-                                       if (otherName.length() < 10) { //pad with spaces to make compatible
-                                               while (otherName.length() < 10) {  otherName += " ";  }
-                                       }
-                                       
-                                       out  << name << '\t' << otherName << dists[r][l] << endl;  
-                               }
-                       }
-               }
-               out.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracUnweightedCommand", "createPhylipFile");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
-
diff --git a/unifracunweightedcommand.h b/unifracunweightedcommand.h
deleted file mode 100644 (file)
index fd39ae4..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef UNIFRACUNWEIGHTEDCOMMAND_H
-#define UNIFRACUNWEIGHTEDCOMMAND_H
-
-/*
- *  unifracunweightedcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "unweighted.h"
-#include "treemap.h"
-#include "sharedutilities.h"
-#include "fileoutput.h"
-#include "readtree.h"
-
-class UnifracUnweightedCommand : public Command {
-       
-       public:
-               UnifracUnweightedCommand(string);       
-               UnifracUnweightedCommand();
-               ~UnifracUnweightedCommand() {}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "unifrac.unweighted";          }
-               string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
-               string getCitation() { return "Lozupone C, Knight R (2005). UniFrac: a new phylogenetic method for comparing microbial communities. Appl Environ Microbiol 71: 8228-35. \nhttp://www.mothur.org/wiki/Unifrac.unweighted"; }
-               string getDescription()         { return "generic tests that describes whether two or more communities have the same structure"; }
-
-               int execute();
-               void help() { m->mothurOut(getHelpString()); }
-       
-       
-       private:
-               FileOutput* output;
-               vector<Tree*> T;           //user trees
-               TreeMap* tmap;
-               string sumFile, allGroups;
-               vector<string> groupComb; // AB. AC, BC...
-               int iters, numGroups, numComp, counter, processors, subsampleSize, subsampleIters;
-               vector< vector<float> > utreeScores; //scores for users trees for each comb.
-               vector< vector<float> > UWScoreSig;  //tree score signifigance when compared to random trees - percentage of random trees with that score or higher.
-               map<float, float>  validScores;  //map contains scores from random
-               vector< map<float, float> > rscoreFreq;  //map <unweighted score, number of random trees with that score.> -vector entry for each combination.
-               vector< map<float, float> > rCumul;  //map <unweighted score, cumulative percentage of number of random trees with that score or higher.> -vector entry for each combination.
-               
-               bool abort, phylip, random, includeRoot, consensus, subsample;
-               string groups, itersString, outputDir, outputForm, treefile, groupfile, namefile;
-               vector<string> Groups, outputNames; //holds groups to be used
-
-               ofstream outSum, out;
-               ifstream inFile;
-               
-        int runRandomCalcs(Tree*, vector<double>);
-               void printUWSummaryFile(int);
-               void printUnweightedFile();
-               void createPhylipFile(int);
-        vector<Tree*> buildTrees(vector< vector<double> >&, int, TreeMap&);
-        int getConsensusTrees(vector< vector<double> >&, int);
-        int getAverageSTDMatrices(vector< vector<double> >&, int);
-               
-};
-
-#endif
diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp
deleted file mode 100644 (file)
index 633cb64..0000000
+++ /dev/null
@@ -1,1016 +0,0 @@
-/*
- *  unifracweightedcommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "unifracweightedcommand.h"
-#include "consensus.h"
-#include "subsample.h"
-#include "treereader.h"
-
-//**********************************************************************************************************************
-vector<string> UnifracWeightedCommand::setParameters(){        
-       try {
-               CommandParameter ptree("tree", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(ptree);
-               CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pgroup);
-               CommandParameter pname("name", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pname);
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter piters("iters", "Number", "", "1000", "", "", "",false,false); parameters.push_back(piters);
-               CommandParameter pprocessors("processors", "Number", "", "1", "", "", "",false,false); parameters.push_back(pprocessors);
-        CommandParameter psubsample("subsample", "String", "", "", "", "", "",false,false); parameters.push_back(psubsample);
-        CommandParameter pconsensus("consensus", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pconsensus);
-        CommandParameter prandom("random", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(prandom);
-               CommandParameter pdistance("distance", "Multiple", "column-lt-square", "column", "", "", "",false,false); parameters.push_back(pdistance);
-               CommandParameter proot("root", "Boolean", "F", "", "", "", "",false,false); parameters.push_back(proot);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string UnifracWeightedCommand::getHelpString(){        
-       try {
-               string helpString = "";
-               helpString += "The unifrac.weighted command parameters are tree, group, name, groups, iters, distance, processors, root, subsample, consensus and random.  tree parameter is required unless you have valid current tree file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like analyzed.  You must enter at least 2 valid groups.\n";
-               helpString += "The group names are separated by dashes.  The iters parameter allows you to specify how many random trees you would like compared to your tree.\n";
-               helpString += "The distance parameter allows you to create a distance file from the results. The default is false.\n";
-               helpString += "The random parameter allows you to shut off the comparison to random trees. The default is false, meaning don't compare your trees with randomly generated trees.\n";
-               helpString += "The root parameter allows you to include the entire root in your calculations. The default is false, meaning stop at the root for this comparision instead of the root of the entire tree.\n";
-               helpString += "The processors parameter allows you to specify the number of processors to use. The default is 1.\n";
-        helpString += "The subsample parameter allows you to enter the size pergroup of the sample or you can set subsample=T and mothur will use the size of your smallest group. The subsample parameter may only be used with a group file.\n";
-        helpString += "The consensus parameter allows you to indicate you would like trees built from distance matrices created with the results, as well as a consensus tree built from these trees. Default=F.\n";
-        helpString += "The unifrac.weighted command should be in the following format: unifrac.weighted(groups=yourGroups, iters=yourIters).\n";
-               helpString += "Example unifrac.weighted(groups=A-B-C, iters=500).\n";
-               helpString += "The default value for groups is all the groups in your groupfile, and iters is 1000.\n";
-               helpString += "The unifrac.weighted command output two files: .weighted and .wsummary their descriptions are in the manual.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "getHelpString");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-UnifracWeightedCommand::UnifracWeightedCommand(){      
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["weighted"] = tempOutNames;
-               outputTypes["wsummary"] = tempOutNames;
-               outputTypes["phylip"] = tempOutNames;
-               outputTypes["column"] = tempOutNames;
-        outputTypes["tree"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-UnifracWeightedCommand::UnifracWeightedCommand(string option) {
-       try {
-               abort = false; calledHelp = false;   
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters=parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-               
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //initialize outputTypes
-                       vector<string> tempOutNames;
-                       outputTypes["weighted"] = tempOutNames;
-                       outputTypes["wsummary"] = tempOutNames;
-                       outputTypes["phylip"] = tempOutNames;
-                       outputTypes["column"] = tempOutNames;
-            outputTypes["tree"] = tempOutNames;
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("tree");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["tree"] = inputDir + it->second;             }
-                               }
-                               
-                               it = parameters.find("group");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["group"] = inputDir + it->second;            }
-                               }
-                               
-                               it = parameters.find("name");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["name"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       treefile = validParameter.validFile(parameters, "tree", true);
-                       if (treefile == "not open") { treefile = ""; abort = true; }
-                       else if (treefile == "not found") {                             //if there is a current design file, use it
-                               treefile = m->getTreeFile(); 
-                               if (treefile != "") { m->mothurOut("Using " + treefile + " as input file for the tree parameter."); m->mothurOutEndLine(); }
-                               else {  m->mothurOut("You have no current tree file and the tree parameter is required."); m->mothurOutEndLine(); abort = true; }                                                               
-                       }else { m->setTreeFile(treefile); }     
-                       
-                       //check for required parameters
-                       groupfile = validParameter.validFile(parameters, "group", true);
-                       if (groupfile == "not open") { abort = true; }
-                       else if (groupfile == "not found") { groupfile = ""; }
-                       else { m->setGroupFile(groupfile); }
-                       
-                       namefile = validParameter.validFile(parameters, "name", true);
-                       if (namefile == "not open") { namefile = ""; abort = true; }
-                       else if (namefile == "not found") { namefile = ""; }
-                       else { m->setNameFile(namefile); }
-                       
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(treefile);       }
-                       
-                                                                                                                                       
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                               
-                       itersString = validParameter.validFile(parameters, "iters", false);                     if (itersString == "not found") { itersString = "1000"; }
-                       m->mothurConvert(itersString, iters); 
-                       
-                       string temp = validParameter.validFile(parameters, "distance", false);                  
-                       if (temp == "not found") { phylip = false; outputForm = ""; }
-                       else{
-                               if ((temp == "lt") || (temp == "column") || (temp == "square")) {  phylip = true;  outputForm = temp; }
-                               else { m->mothurOut("Options for distance are: lt, square, or column. Using lt."); m->mothurOutEndLine(); phylip = true; outputForm = "lt"; }
-                       }
-                       
-                       temp = validParameter.validFile(parameters, "random", false);                           if (temp == "not found") { temp = "F"; }
-                       random = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "root", false);                                     if (temp == "not found") { temp = "F"; }
-                       includeRoot = m->isTrue(temp);
-                       
-                       temp = validParameter.validFile(parameters, "processors", false);       if (temp == "not found"){       temp = m->getProcessors();      }
-                       m->setProcessors(temp);
-                       m->mothurConvert(temp, processors);
-            
-            temp = validParameter.validFile(parameters, "subsample", false);           if (temp == "not found") { temp = "F"; }
-                       if (m->isNumeric1(temp)) { m->mothurConvert(temp, subsampleSize); subsample = true; }
-            else {  
-                if (m->isTrue(temp)) { subsample = true; subsampleSize = -1; }  //we will set it to smallest group later 
-                else { subsample = false; }
-            }
-                       
-            if (!subsample) { subsampleIters = 0;   }
-            else { subsampleIters = iters;          }
-            
-            temp = validParameter.validFile(parameters, "consensus", false);                                   if (temp == "not found") { temp = "F"; }
-                       consensus = m->isTrue(temp);
-            
-                       if (subsample && random) {  m->mothurOut("[ERROR]: random must be false, if subsample=t.\n"); abort=true;  } 
-                       if (subsample && (groupfile == "")) {  m->mothurOut("[ERROR]: if subsample=t, a group file must be provided.\n"); abort=true;  } 
-            if (subsample && (!phylip)) { phylip=true; outputForm = "lt"; }
-            if (consensus && (!subsample)) { m->mothurOut("[ERROR]: you cannot use consensus without subsample.\n"); abort=true; }
-            
-                       if (namefile == "") {
-                               vector<string> files; files.push_back(treefile);
-                               parser.getNameFile(files);
-                       }
-               }
-               
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "UnifracWeightedCommand");
-               exit(1);
-       }
-}
-/***********************************************************/
-int UnifracWeightedCommand::execute() {
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-               
-               m->setTreeFile(treefile);
-               
-        TreeReader* reader = new TreeReader(treefile, groupfile, namefile);
-        T = reader->getTrees();
-        tmap = T[0]->getTreeMap();
-        map<string, string> nameMap = reader->getNames();
-        delete reader;
-    
-        if (m->control_pressed) {  delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } return 0; }
-                               
-               sumFile = outputDir + m->getSimpleName(treefile) + ".wsummary";
-               m->openOutputFile(sumFile, outSum);
-               outputNames.push_back(sumFile);  outputTypes["wsummary"].push_back(sumFile);
-               
-        SharedUtil util;
-               string s; //to make work with setgroups
-               Groups = m->getGroups();
-               vector<string> nameGroups = tmap->getNamesOfGroups();
-               util.setGroups(Groups, nameGroups, s, numGroups, "weighted");   //sets the groups the user wants to analyze
-               m->setGroups(Groups);
-               
-        if (m->control_pressed) {  delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } return 0; }
-        
-               Weighted weighted(includeRoot);
-                       
-               int start = time(NULL);
-            
-        //set or check size
-        if (subsample) {
-            //user has not set size, set size = smallest samples size
-            if (subsampleSize == -1) { 
-                vector<string> temp; temp.push_back(Groups[0]);
-                subsampleSize = (tmap->getNamesSeqs(temp)).size(); //num in first group
-                for (int i = 1; i < Groups.size(); i++) {
-                    temp.clear(); temp.push_back(Groups[i]);
-                    int thisSize = (tmap->getNamesSeqs(temp)).size();
-                    if (thisSize < subsampleSize) {    subsampleSize = thisSize;       }
-                }
-                m->mothurOut("\nSetting subsample size to " + toString(subsampleSize) + ".\n\n");
-            }else { //eliminate any too small groups
-                vector<string> newGroups = Groups;
-                Groups.clear();
-                for (int i = 0; i < newGroups.size(); i++) {
-                    vector<string> thisGroup; thisGroup.push_back(newGroups[i]);
-                    vector<string> thisGroupsSeqs = tmap->getNamesSeqs(thisGroup);
-                    int thisSize = thisGroupsSeqs.size();
-                    
-                    if (thisSize >= subsampleSize) {    Groups.push_back(newGroups[i]);        }
-                    else {  m->mothurOut("You have selected a size that is larger than "+newGroups[i]+" number of sequences, removing "+newGroups[i]+".\n"); }
-                } 
-                m->setGroups(Groups);
-            }
-        }
-        
-        //here in case some groups are removed by subsample
-        util.getCombos(groupComb, Groups, numComp);
-        
-        if (numComp < processors) { processors = numComp; }
-        
-        if (consensus && (numComp < 2)) { m->mothurOut("consensus can only be used with numComparisions greater than 1, setting consensus=f.\n"); consensus=false; }
-        
-        //get weighted scores for users trees
-        for (int i = 0; i < T.size(); i++) {
-            
-            if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } return 0; }
-            
-            counter = 0;
-            rScores.resize(numComp);  //data[0] = weightedscore AB, data[1] = weightedscore AC...
-            uScores.resize(numComp);  //data[0] = weightedscore AB, data[1] = weightedscore AC...
-            
-            vector<double> userData; userData.resize(numComp,0);  //weighted score info for user tree. data[0] = weightedscore AB, data[1] = weightedscore AC...
-            vector<double> randomData; randomData.resize(numComp,0); //weighted score info for random trees. data[0] = weightedscore AB, data[1] = weightedscore AC...
-            
-            if (random) {  
-                output = new ColumnFile(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted", itersString);  
-                outputNames.push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted");
-                outputTypes["weighted"].push_back(outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted");
-            } 
-            
-            userData = weighted.getValues(T[i], processors, outputDir); //userData[0] = weightedscore
-            if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0; }
-            
-            //save users score
-            for (int s=0; s<numComp; s++) {
-                //add users score to vector of user scores
-                uScores[s].push_back(userData[s]);
-                //save users tree score for summary file
-                utreeScores.push_back(userData[s]);
-            }
-            
-            if (random) {  runRandomCalcs(T[i], userData); }
-            
-            //clear data
-            rScores.clear();
-            uScores.clear();
-            validScores.clear();
-            
-            //subsample loop
-            vector< vector<double> > calcDistsTotals;  //each iter, each groupCombos dists. this will be used to make .dist files
-            for (int thisIter = 0; thisIter < subsampleIters; thisIter++) { //subsampleIters=0, if subsample=f.
-                
-                if (m->control_pressed) { break; }
-                
-                //copy to preserve old one - would do this in subsample but memory cleanup becomes messy.
-                TreeMap* newTmap = new TreeMap();
-                newTmap->getCopy(*tmap);
-                
-                SubSample sample;
-                Tree* subSampleTree = sample.getSample(T[i], newTmap, nameMap, subsampleSize);
-                   
-                //call new weighted function
-                vector<double> iterData; iterData.resize(numComp,0);
-                Weighted thisWeighted(includeRoot);
-                iterData = thisWeighted.getValues(subSampleTree, processors, outputDir); //userData[0] = weightedscore
-                
-                //save data to make ave dist, std dist
-                calcDistsTotals.push_back(iterData);
-                
-                delete newTmap;
-                delete subSampleTree;
-                
-                if((thisIter+1) % 100 == 0){   m->mothurOut(toString(thisIter+1)); m->mothurOutEndLine();              }
-            }
-            
-            if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } if (random) { delete output; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {   m->mothurRemove(outputNames[i]);  } return 0; }
-            
-            if (subsample) {  getAverageSTDMatrices(calcDistsTotals, i); }
-            if (consensus) {  getConsensusTrees(calcDistsTotals, i);  }
-        }
-        
-               
-               if (m->control_pressed) { delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; } outSum.close(); for (int i = 0; i < outputNames.size(); i++) {       m->mothurRemove(outputNames[i]);  } return 0;  }
-               
-        if (phylip) {  createPhylipFile();             }
-    
-               printWSummaryFile();
-               
-               //clear out users groups
-               m->clearGroups();
-               delete tmap; 
-               for (int i = 0; i < T.size(); i++) { delete T[i]; }
-               
-               if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) {        m->mothurRemove(outputNames[i]);  } return 0; }
-               
-               m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run unifrac.weighted."); m->mothurOutEndLine();
-               
-               //set phylip file as new current phylipfile
-               string current = "";
-               itTypes = outputTypes.find("phylip");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setPhylipFile(current); }
-               }
-               
-               //set column file as new current columnfile
-               itTypes = outputTypes.find("column");
-               if (itTypes != outputTypes.end()) {
-                       if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setColumnFile(current); }
-               }
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-               
-               return 0;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "execute");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int UnifracWeightedCommand::getAverageSTDMatrices(vector< vector<double> >& dists, int treeNum) {
-       try {
-        //we need to find the average distance and standard deviation for each groups distance
-        
-        //finds sum
-        vector<double> averages; averages.resize(numComp, 0); 
-        for (int thisIter = 0; thisIter < subsampleIters; thisIter++) {
-            for (int i = 0; i < dists[thisIter].size(); i++) {  
-                averages[i] += dists[thisIter][i];
-            }
-        }
-        
-        //finds average.
-        for (int i = 0; i < averages.size(); i++) {  averages[i] /= (float) subsampleIters; }
-        
-        //find standard deviation
-        vector<double> stdDev; stdDev.resize(numComp, 0);
-                
-        for (int thisIter = 0; thisIter < iters; thisIter++) { //compute the difference of each dist from the mean, and square the result of each
-            for (int j = 0; j < dists[thisIter].size(); j++) {
-                stdDev[j] += ((dists[thisIter][j] - averages[j]) * (dists[thisIter][j] - averages[j]));
-            }
-        }
-        for (int i = 0; i < stdDev.size(); i++) {  
-            stdDev[i] /= (float) subsampleIters; 
-            stdDev[i] = sqrt(stdDev[i]);
-        }
-        
-        //make matrix with scores in it
-        vector< vector<double> > avedists;     avedists.resize(m->getNumGroups());
-        for (int i = 0; i < m->getNumGroups(); i++) {
-            avedists[i].resize(m->getNumGroups(), 0.0);
-        }
-        
-        //make matrix with scores in it
-        vector< vector<double> > stddists;     stddists.resize(m->getNumGroups());
-        for (int i = 0; i < m->getNumGroups(); i++) {
-            stddists[i].resize(m->getNumGroups(), 0.0);
-        }
-        
-        //flip it so you can print it
-        int count = 0;
-        for (int r=0; r<m->getNumGroups(); r++) { 
-            for (int l = 0; l < r; l++) {
-                avedists[r][l] = averages[count];
-                avedists[l][r] = averages[count];
-                stddists[r][l] = stdDev[count];
-                stddists[l][r] = stdDev[count];
-                count++;
-            }
-        }
-        
-        string aveFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.ave.dist";
-        outputNames.push_back(aveFileName); outputTypes["phylip"].push_back(aveFileName); 
-        
-        ofstream out;
-        m->openOutputFile(aveFileName, out);
-        
-       string stdFileName = outputDir + m->getSimpleName(treefile)  + toString(treeNum+1) + ".weighted.std.dist";
-       outputNames.push_back(stdFileName); outputTypes["phylip"].push_back(stdFileName); 
-        
-        ofstream outStd;
-        m->openOutputFile(stdFileName, outStd);
-        
-        if ((outputForm == "lt") || (outputForm == "square")) {
-            //output numSeqs
-            out << m->getNumGroups() << endl;
-            outStd << m->getNumGroups() << endl;
-        }
-        
-        //output to file
-        for (int r=0; r<m->getNumGroups(); r++) { 
-            //output name
-            string name = (m->getGroups())[r];
-            if (name.length() < 10) { //pad with spaces to make compatible
-                while (name.length() < 10) {  name += " ";  }
-            }
-            
-            if (outputForm == "lt") {
-                out << name << '\t';
-                outStd << name << '\t';
-                
-                //output distances
-                for (int l = 0; l < r; l++) {  out  << avedists[r][l] << '\t';  outStd  << stddists[r][l] << '\t';}
-                out << endl;  outStd << endl;
-            }else if (outputForm == "square") {
-                out << name << '\t';
-                outStd << name << '\t';
-                
-                //output distances
-                for (int l = 0; l < m->getNumGroups(); l++) {  out  << avedists[r][l] << '\t'; outStd  << stddists[r][l] << '\t'; }
-                out << endl; outStd << endl;
-            }else{
-                //output distances
-                for (int l = 0; l < r; l++) {  
-                    string otherName = (m->getGroups())[l];
-                    if (otherName.length() < 10) { //pad with spaces to make compatible
-                        while (otherName.length() < 10) {  otherName += " ";  }
-                    }
-                    
-                    out  << name << '\t' << otherName << avedists[r][l] << endl;  
-                    outStd  << name << '\t' << otherName << stddists[r][l] << endl; 
-                }
-            }
-        }
-        out.close();
-        outStd.close();
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "getAverageSTDMatrices");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int UnifracWeightedCommand::getConsensusTrees(vector< vector<double> >& dists, int treeNum) {
-       try {
-        
-        //used in tree constructor 
-        m->runParse = false;
-        
-        //create treemap class from groupmap for tree class to use
-        TreeMap newTmap;
-        newTmap.makeSim(m->getGroups());
-        
-        //clear  old tree names if any
-        m->Treenames.clear();
-        
-        //fills globaldatas tree names
-        m->Treenames = m->getGroups();
-        
-        vector<Tree*> newTrees = buildTrees(dists, treeNum, newTmap); //also creates .all.tre file containing the trees created
-        
-        if (m->control_pressed) { return 0; }
-        
-        Consensus con;
-        Tree* conTree = con.getTree(newTrees);
-        
-        //create a new filename
-        string conFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.cons.tre";                          
-        outputNames.push_back(conFile); outputTypes["tree"].push_back(conFile); 
-        ofstream outTree;
-        m->openOutputFile(conFile, outTree);
-        
-        if (conTree != NULL) { conTree->print(outTree, "boot"); delete conTree; }
-        outTree.close();
-        
-        return 0;
-
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "getConsensusTrees");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-vector<Tree*> UnifracWeightedCommand::buildTrees(vector< vector<double> >& dists, int treeNum, TreeMap& mytmap) {
-       try {
-        
-        vector<Tree*> trees;
-        
-        //create a new filename
-        string outputFile = outputDir + m->getRootName(m->getSimpleName(treefile)) + toString(treeNum+1) + ".weighted.all.tre";                                
-        outputNames.push_back(outputFile); outputTypes["tree"].push_back(outputFile); 
-        
-        ofstream outAll;
-        m->openOutputFile(outputFile, outAll);
-        
-
-        for (int i = 0; i < dists.size(); i++) { //dists[0] are the dists for the first subsampled tree.
-            
-            if (m->control_pressed) { break; }
-            
-            //make matrix with scores in it
-            vector< vector<double> > sims;     sims.resize(m->getNumGroups());
-            for (int j = 0; j < m->getNumGroups(); j++) {
-                sims[j].resize(m->getNumGroups(), 0.0);
-            }
-            
-            int count = 0;
-                       for (int r=0; r<m->getNumGroups(); r++) { 
-                               for (int l = 0; l < r; l++) {
-                    double sim = -(dists[i][count]-1.0);
-                                       sims[r][l] = sim;
-                                       sims[l][r] = sim;
-                                       count++;
-                               }
-                       }
-
-            //create tree
-            Tree* tempTree = new Tree(&mytmap, sims);
-            map<string, string> empty;
-            tempTree->assembleTree(empty);
-            
-            trees.push_back(tempTree);
-            
-            //print tree
-            tempTree->print(outAll);
-        }
-        
-        outAll.close();
-        
-        if (m->control_pressed) {  for (int i = 0; i < trees.size(); i++) {  delete trees[i]; trees[i] = NULL; } m->mothurRemove(outputFile); }
-        
-        return trees;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "buildTrees");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int UnifracWeightedCommand::runRandomCalcs(Tree* thisTree, vector<double> usersScores) {
-       try {
-        
-        //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
-        vector< vector<string> > namesOfGroupCombos;
-        for (int a=0; a<numGroups; a++) { 
-            for (int l = 0; l < a; l++) {      
-                vector<string> groups; groups.push_back((m->getGroups())[a]); groups.push_back((m->getGroups())[l]);
-                namesOfGroupCombos.push_back(groups);
-            }
-        }
-        
-        lines.clear();
-        
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-        if(processors != 1){
-            int numPairs = namesOfGroupCombos.size();
-            int numPairsPerProcessor = numPairs / processors;
-            
-            for (int i = 0; i < processors; i++) {
-                int startPos = i * numPairsPerProcessor;
-                if(i == processors - 1){
-                    numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                }
-                lines.push_back(linePair(startPos, numPairsPerProcessor));
-            }
-        }
-#endif
-        
-        
-        //get scores for random trees
-        for (int j = 0; j < iters; j++) {
-            
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-            if(processors == 1){
-                driver(thisTree,  namesOfGroupCombos, 0, namesOfGroupCombos.size(),  rScores);
-            }else{
-                createProcesses(thisTree,  namesOfGroupCombos, rScores);
-            }
-#else
-            driver(thisTree, namesOfGroupCombos, 0, namesOfGroupCombos.size(), rScores);
-#endif
-            
-            if (m->control_pressed) { delete tmap;  for (int i = 0; i < T.size(); i++) { delete T[i]; } delete output; outSum.close(); for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  } return 0; }
-            
-            //report progress
-            //                                 m->mothurOut("Iter: " + toString(j+1)); m->mothurOutEndLine();          
-        }
-        lines.clear();
-        
-        //find the signifigance of the score for summary file
-        for (int f = 0; f < numComp; f++) {
-            //sort random scores
-            sort(rScores[f].begin(), rScores[f].end());
-            
-            //the index of the score higher than yours is returned 
-            //so if you have 1000 random trees the index returned is 100 
-            //then there are 900 trees with a score greater then you. 
-            //giving you a signifigance of 0.900
-            int index = findIndex(usersScores[f], f);    if (index == -1) { m->mothurOut("error in UnifracWeightedCommand"); m->mothurOutEndLine(); exit(1); } //error code
-            
-            //the signifigance is the number of trees with the users score or higher 
-            WScoreSig.push_back((iters-index)/(float)iters);
-        }
-        
-        //out << "Tree# " << i << endl;
-        calculateFreqsCumuls();
-        printWeightedFile();
-        
-        delete output;
-        
-        return 0;
-    }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "runRandomCalcs");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-int UnifracWeightedCommand::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, vector< vector<double> >& scores) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, scores);
-                       
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputDir + toString(getpid()) + ".weightedcommand.results.temp";
-                               m->openOutputFile(tempFile, out);
-                               for (int i = lines[process].start; i < (lines[process].start + lines[process].num); i++) { out << scores[i][(scores[i].size()-1)] << '\t';  } out << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-               
-               driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, scores);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-       
-                       ifstream in;
-                       string s = outputDir + toString(processIDS[i]) + ".weightedcommand.results.temp";
-                       m->openInputFile(s, in);
-                       
-                       double tempScore;
-                       for (int j = lines[(i+1)].start; j < (lines[(i+1)].start + lines[(i+1)].num); j++) { in >> tempScore; scores[j].push_back(tempScore); }
-                       in.close();
-                       m->mothurRemove(s);
-               }
-               
-               return 0;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "createProcesses");
-               exit(1);
-       }
-}
-
-/**************************************************************************************************/
-int UnifracWeightedCommand::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, vector< vector<double> >& scores) { 
- try {
-               Tree* randT = new Tree(tmap);
-     
-        Weighted weighted(includeRoot);
-     
-               for (int h = start; h < (start+num); h++) {
-       
-                       if (m->control_pressed) { return 0; }
-               
-                       //initialize weighted score
-                       string groupA = namesOfGroupCombos[h][0]; 
-                       string groupB = namesOfGroupCombos[h][1];
-                       
-                       //copy T[i]'s info.
-                       randT->getCopy(t);
-                        
-                       //create a random tree with same topology as T[i], but different labels
-                       randT->assembleRandomUnifracTree(groupA, groupB);
-                       
-                       if (m->control_pressed) { delete randT;  return 0;  }
-
-                       //get wscore of random tree
-                       EstOutput randomData = weighted.getValues(randT, groupA, groupB);
-               
-                       if (m->control_pressed) { delete randT;  return 0;  }
-                                                                               
-                       //save scores
-                       scores[h].push_back(randomData[0]);
-               }
-       
-               delete randT;
-       
-               return 0;
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "driver");
-               exit(1);
-       }
-}
-/***********************************************************/
-void UnifracWeightedCommand::printWeightedFile() {
-       try {
-               vector<double> data;
-               vector<string> tags;
-               tags.push_back("Score"); tags.push_back("RandFreq"); tags.push_back("RandCumul");
-               
-               for(int a = 0; a < numComp; a++) {
-                       output->initFile(groupComb[a], tags);
-                       //print each line
-                       for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) { 
-                               data.push_back(it->first);  data.push_back(rScoreFreq[a][it->first]); data.push_back(rCumul[a][it->first]); 
-                               output->output(data);
-                               data.clear();
-                       } 
-                       output->resetFile();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "printWeightedFile");
-               exit(1);
-       }
-}
-
-
-/***********************************************************/
-void UnifracWeightedCommand::printWSummaryFile() {
-       try {
-               //column headers
-               outSum << "Tree#" << '\t' << "Groups" << '\t' << "WScore" << '\t';
-               m->mothurOut("Tree#\tGroups\tWScore\t");
-               if (random) { outSum << "WSig"; m->mothurOut("WSig"); }
-               outSum << endl; m->mothurOutEndLine();
-               
-               //format output
-               outSum.setf(ios::fixed, ios::floatfield); outSum.setf(ios::showpoint);
-               
-               //print each line
-               int count = 0;
-               for (int i = 0; i < T.size(); i++) { 
-                       for (int j = 0; j < numComp; j++) {
-                               if (random) {
-                                       if (WScoreSig[count] > (1/(float)iters)) {
-                                               outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << WScoreSig[count] << endl; 
-                                               cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << WScoreSig[count] << endl; 
-                                               m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t" +  toString(WScoreSig[count]) + "\n");   
-                                       }else{
-                                               outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl; 
-                                               cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << '\t' << setprecision(itersString.length()) << "<" << (1/float(iters)) << endl; 
-                                               m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\t<" +  toString((1/float(iters))) + "\n");  
-                                       }
-                               }else{
-                                       outSum << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count] << endl; 
-                                       cout << setprecision(6) << i+1 << '\t' << groupComb[j] << '\t' << utreeScores[count]  << endl; 
-                                       m->mothurOutJustToLog(toString(i+1) +"\t" + groupComb[j] +"\t" + toString(utreeScores[count]) +"\n"); 
-                               }
-                               count++;
-                       }
-               }
-               outSum.close();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "printWSummaryFile");
-               exit(1);
-       }
-}
-/***********************************************************/
-void UnifracWeightedCommand::createPhylipFile() {
-       try {
-               int count = 0;
-               //for each tree
-               for (int i = 0; i < T.size(); i++) { 
-               
-                       string phylipFileName;
-                       if ((outputForm == "lt") || (outputForm == "square")) {
-                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.phylip.dist";
-                               outputNames.push_back(phylipFileName); outputTypes["phylip"].push_back(phylipFileName); 
-                       }else { //column
-                               phylipFileName = outputDir + m->getSimpleName(treefile)  + toString(i+1) + ".weighted.column.dist";
-                               outputNames.push_back(phylipFileName); outputTypes["column"].push_back(phylipFileName); 
-                       }
-                       
-                       ofstream out;
-                       m->openOutputFile(phylipFileName, out);
-                       
-                       if ((outputForm == "lt") || (outputForm == "square")) {
-                               //output numSeqs
-                               out << m->getNumGroups() << endl;
-                       }
-
-                       //make matrix with scores in it
-                       vector< vector<float> > dists;  dists.resize(m->getNumGroups());
-                       for (int i = 0; i < m->getNumGroups(); i++) {
-                               dists[i].resize(m->getNumGroups(), 0.0);
-                       }
-                       
-                       //flip it so you can print it
-                       for (int r=0; r<m->getNumGroups(); r++) { 
-                               for (int l = 0; l < r; l++) {
-                                       dists[r][l] = utreeScores[count];
-                                       dists[l][r] = utreeScores[count];
-                                       count++;
-                               }
-                       }
-
-                       //output to file
-                       for (int r=0; r<m->getNumGroups(); r++) { 
-                               //output name
-                               string name = (m->getGroups())[r];
-                               if (name.length() < 10) { //pad with spaces to make compatible
-                                       while (name.length() < 10) {  name += " ";  }
-                               }
-                               
-                               if (outputForm == "lt") {
-                                       out << name << '\t';
-                                       
-                                       //output distances
-                                       for (int l = 0; l < r; l++) {   out  << dists[r][l] << '\t';  }
-                                       out << endl;
-                               }else if (outputForm == "square") {
-                                       out << name << '\t';
-                                       
-                                       //output distances
-                                       for (int l = 0; l < m->getNumGroups(); l++) {   out  << dists[r][l] << '\t';  }
-                                       out << endl;
-                               }else{
-                                       //output distances
-                                       for (int l = 0; l < r; l++) {   
-                                               string otherName = (m->getGroups())[l];
-                                               if (otherName.length() < 10) { //pad with spaces to make compatible
-                                                       while (otherName.length() < 10) {  otherName += " ";  }
-                                               }
-                                               
-                                               out  << name << '\t' << otherName << dists[r][l] << endl;  
-                                       }
-                               }
-                       }
-                       out.close();
-               }
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "createPhylipFile");
-               exit(1);
-       }
-}
-/***********************************************************/
-int UnifracWeightedCommand::findIndex(float score, int index) {
-       try{
-               for (int i = 0; i < rScores[index].size(); i++) {
-                       if (rScores[index][i] >= score) {       return i;       }
-               }
-               return rScores[index].size();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "findIndex");
-               exit(1);
-       }
-}
-
-/***********************************************************/
-
-void UnifracWeightedCommand::calculateFreqsCumuls() {
-       try {
-               //clear out old tree values
-               rScoreFreq.clear();
-               rScoreFreq.resize(numComp);
-               rCumul.clear();
-               rCumul.resize(numComp);
-               validScores.clear();
-       
-               //calculate frequency
-               for (int f = 0; f < numComp; f++) {
-                       for (int i = 0; i < rScores[f].size(); i++) { //looks like 0,0,1,1,1,2,4,7...  you want to make a map that say rScoreFreq[0] = 2, rScoreFreq[1] = 3...
-                               validScores[rScores[f][i]] = rScores[f][i];
-                               map<float,float>::iterator it = rScoreFreq[f].find(rScores[f][i]);
-                               if (it != rScoreFreq[f].end()) {
-                                       rScoreFreq[f][rScores[f][i]]++;
-                               }else{
-                                       rScoreFreq[f][rScores[f][i]] = 1;
-                               }
-                       }
-               }
-               
-               //calculate rcumul
-               for(int a = 0; a < numComp; a++) {
-                       float rcumul = 1.0000;
-                       //this loop fills the cumulative maps and put 0.0000 in the score freq map to make it easier to print.
-                       for (map<float,float>::iterator it = validScores.begin(); it != validScores.end(); it++) {
-                               //make rscoreFreq map and rCumul
-                               map<float,float>::iterator it2 = rScoreFreq[a].find(it->first);
-                               rCumul[a][it->first] = rcumul;
-                               //get percentage of random trees with that info
-                               if (it2 != rScoreFreq[a].end()) {  rScoreFreq[a][it->first] /= iters; rcumul-= it2->second;  }
-                               else { rScoreFreq[a][it->first] = 0.0000; } //no random trees with that score
-                       }
-               }
-
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UnifracWeightedCommand", "calculateFreqsCums");
-               exit(1);
-       }
-}
-/***********************************************************/
-
-
-
-
-
diff --git a/unifracweightedcommand.h b/unifracweightedcommand.h
deleted file mode 100644 (file)
index 9deb065..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef UNIFRACWEIGHTEDCOMMAND_H
-#define UNIFRACWEIGHTEDCOMMAND_H
-
-/*
- *  unifracweightedcommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "command.hpp"
-#include "weighted.h"
-#include "treemap.h"
-#include "progress.hpp"
-#include "sharedutilities.h"
-#include "fileoutput.h"
-#include "readtree.h"
-
-class UnifracWeightedCommand : public Command {
-       
-       public:
-               UnifracWeightedCommand(string);
-               UnifracWeightedCommand();
-               ~UnifracWeightedCommand() {}
-       
-               vector<string> setParameters();
-               string getCommandName()                 { return "unifrac.weighted";            }
-               string getCommandCategory()             { return "Hypothesis Testing";          }
-               string getHelpString(); 
-               string getCitation() { return "Lozupone CA, Hamady M, Kelley ST, Knight R (2007). Quantitative and qualitative beta diversity measures lead to different insights into factors that structure microbial communities. Appl Environ Microbiol 73: 1576-85. \nhttp://www.mothur.org/wiki/Unifrac.weighted"; }
-               string getDescription()         { return "generic tests that describes whether two or more communities have the same structure"; }
-
-               int execute();
-               void help() { m->mothurOut(getHelpString()); }
-       
-       private:
-               struct linePair {
-                       int start;
-                       int num;
-                       linePair(int i, int j) : start(i), num(j) {}
-               };
-               vector<linePair> lines;
-        TreeMap* tmap;
-               FileOutput* output;
-               vector<Tree*> T;           //user trees
-               vector<double> utreeScores;  //user tree unweighted scores
-               vector<double> WScoreSig;  //tree weighted score signifigance when compared to random trees - percentage of random trees with that score or lower.
-               vector<string> groupComb; // AB. AC, BC...
-               string sumFile, outputDir;
-               int iters, numGroups, numComp, counter;
-               vector< vector<double> > rScores;  //vector<weighted scores for random trees.> each group comb has an entry
-               vector< vector<double> > uScores;  //vector<weighted scores for user trees.> each group comb has an entry
-               vector< map<float, float> > rScoreFreq;  //map <weighted score, number of random trees with that score.> -vector entry for each combination.
-               vector< map<float, float> > rCumul;  //map <weighted score, cumulative percentage of number of random trees with that score or higher.> -vector entry for each c                                                                
-               map<float, float>  validScores;  //map contains scores from random
-               
-               bool abort, phylip, random, includeRoot, subsample, consensus;
-               string groups, itersString, outputForm, treefile, groupfile, namefile;
-               vector<string> Groups, outputNames; //holds groups to be used
-               int processors, subsampleSize, subsampleIters;
-               ofstream outSum;
-               map<string, string> nameMap;
-               
-               void printWSummaryFile();
-               void printWeightedFile();  
-               void createPhylipFile();
-               //void removeValidScoresDuplicates();
-               int findIndex(float, int);
-               void calculateFreqsCumuls();
-               int createProcesses(Tree*,  vector< vector<string> >,  vector< vector<double> >&);
-               int driver(Tree*, vector< vector<string> >, int, int,  vector< vector<double> >&);
-        int runRandomCalcs(Tree*, vector<double>);
-        vector<Tree*> buildTrees(vector< vector<double> >&, int, TreeMap&);
-        int getConsensusTrees(vector< vector<double> >&, int);
-        int getAverageSTDMatrices(vector< vector<double> >&, int);
-               
-};
-
-
-
-#endif
diff --git a/unweighted.cpp b/unweighted.cpp
deleted file mode 100644 (file)
index 864a9f8..0000000
+++ /dev/null
@@ -1,561 +0,0 @@
-/*
- *  unweighted.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "unweighted.h"
-
-/**************************************************************************************************/
-
-EstOutput Unweighted::getValues(Tree* t, int p, string o) {
-       try {
-               processors = p;
-               outputDir = o;
-        
-        TreeMap* tmap = t->getTreeMap();
-        
-               //if the users enters no groups then give them the score of all groups
-               int numGroups = m->getNumGroups();
-               
-               //calculate number of comparsions
-               int numComp = 0;
-               vector< vector<string> > namesOfGroupCombos;
-               for (int r=0; r<numGroups; r++) { 
-                       for (int l = 0; l < r; l++) {
-                               numComp++;
-                               vector<string> groups; groups.push_back((m->getGroups())[r]); groups.push_back((m->getGroups())[l]);
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-               
-               if (numComp != 1) {
-                       vector<string> groups;
-                       if (numGroups == 0) {
-                               //get score for all users groups
-                               for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
-                                       if ((tmap->getNamesOfGroups())[i] != "xxx") {
-                                               groups.push_back((tmap->getNamesOfGroups())[i]);
-                                       }
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }else {
-                               for (int i = 0; i < m->getNumGroups(); i++) {
-                                       groups.push_back((m->getGroups())[i]);
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(processors == 1){
-                               data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-                       }else{
-                               int numPairs = namesOfGroupCombos.size();
-                               
-                               int numPairsPerProcessor = numPairs / processors;
-                               
-                               for (int i = 0; i < processors; i++) {
-                                       int startPos = i * numPairsPerProcessor;
-                       
-                                       if(i == processors - 1){
-                                               numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                                       }
-               
-                                       lines.push_back(linePair(startPos, numPairsPerProcessor));
-                               }
-                               data = createProcesses(t, namesOfGroupCombos, tmap);
-                               lines.clear();
-                       }
-               #else
-                       data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-               #endif
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "getValues");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, TreeMap* tmap) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               EstOutput myresults;
-                               myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, tmap);
-                               
-                               if (m->control_pressed) { exit(0); }
-                               
-                               m->mothurOut("Merging results."); m->mothurOutEndLine();
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputDir + toString(getpid()) + ".unweighted.results.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << myresults.size() << endl;
-                               for (int i = 0; i < myresults.size(); i++) {  out << myresults[i] << '\t';  } out << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0); 
-                       }
-               }
-               
-               results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, tmap);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               if (m->control_pressed) { return results; }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       ifstream in;
-                       string s = outputDir + toString(processIDS[i]) + ".unweighted.results.temp";
-                       m->openInputFile(s, in);
-                       
-                       //get quantiles
-                       if (!in.eof()) {
-                               int num;
-                               in >> num; m->gobble(in);
-                               
-                               if (m->control_pressed) { break; }
-                               
-                               double w; 
-                               for (int j = 0; j < num; j++) {
-                                       in >> w;
-                                       results.push_back(w);
-                               }
-                               m->gobble(in);
-                       }
-                       in.close();
-                       m->mothurRemove(s);
-               }
-               
-               m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               return results;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, TreeMap* tmap) { 
- try {
-       
-        
-               EstOutput results; results.resize(num);
-               
-               int count = 0;
-               int total = num;
-               int twentyPercent = (total * 0.20);
-               if (twentyPercent == 0) { twentyPercent = 1; }
-        
-                       
-               for (int h = start; h < (start+num); h++) {
-                               
-                       if (m->control_pressed) { return results; }
-               
-                       double UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
-                       double totalBL = 0.00;  //all branch lengths
-                       double UW = 0.00;               //Unweighted Value = UniqueBL / totalBL;
-                                               
-                       //find a node that belongs to one of the groups in this combo
-                       int nodeBelonging = -1;
-                       for (int g = 0; g < namesOfGroupCombos[h].size(); g++) {
-                               if (t->groupNodeInfo[namesOfGroupCombos[h][g]].size() != 0) { nodeBelonging = t->groupNodeInfo[namesOfGroupCombos[h][g]][0]; break; }
-                       }
-                       
-                       //sanity check
-                       if (nodeBelonging == -1) {
-                               m->mothurOut("[WARNING]: cannot find a nodes in the tree from grouping "); 
-                               for (int g = 0; g < namesOfGroupCombos[h].size()-1; g++) { m->mothurOut(namesOfGroupCombos[h][g] + "-"); }
-                               m->mothurOut(namesOfGroupCombos[h][namesOfGroupCombos[h].size()-1]);
-                               m->mothurOut(", skipping."); m->mothurOutEndLine(); results[count] = UW;
-                       }else{
-                               //cout << "trying to get root" << endl; 
-                               //if including the root this clears rootForGrouping[namesOfGroupCombos[h]]
-                               getRoot(t, nodeBelonging, namesOfGroupCombos[h]);
-                               //cout << "here" << endl;       
-                               for(int i=0;i<t->getNumNodes();i++){
-                                       
-                                       if (m->control_pressed) {  return data; }
-                                       //cout << i << endl;    
-                                       //pcountSize = 0, they are from a branch that is entirely from a group the user doesn't want
-                                       //pcountSize = 2, not unique to one group
-                                       //pcountSize = 1, unique to one group
-                                       
-                                       int pcountSize = 0;
-                                       for (int j = 0; j < namesOfGroupCombos[h].size(); j++) {
-                                               map<string, int>::iterator itGroup = t->tree[i].pcount.find(namesOfGroupCombos[h][j]);
-                                               if (itGroup != t->tree[i].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } } 
-                                       }
-                                       
-                                       
-                                       //unique calc
-                                       if (pcountSize == 0) { }
-                                       else if ((t->tree[i].getBranchLength() != -1) && (pcountSize == 1) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a unique branch length and you are not the root 
-                                               UniqueBL += abs(t->tree[i].getBranchLength()); 
-                                       }
-                                               
-                                       //total calc
-                                       if (pcountSize == 0) { }
-                                       else if ((t->tree[i].getBranchLength() != -1) && (pcountSize != 0) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a branch length and you are not the root 
-                                               totalBL += abs(t->tree[i].getBranchLength()); 
-                                       }
-                               }
-       //cout << UniqueBL << '\t' << totalBL << endl;          
-                               UW = (UniqueBL / totalBL);  
-       
-                               if (isnan(UW) || isinf(UW)) { UW = 0; }
-       
-                               results[count] = UW;
-                       }
-                       count++;
-
-                       //report progress
-                       //if((count % twentyPercent) == 0) {    float tempOut = (count / (float)total); if (isnan(tempOut) || isinf(tempOut)) { tempOut = 0.0; } m->mothurOut("Percentage complete: " + toString((int(tempOut) * 100.0))); m->mothurOutEndLine();       }
-               }
-               
-               //report progress
-               //if((count % twentyPercent) != 0) {    float tempOut = (count / (float)total); if (isnan(tempOut) || isinf(tempOut)) { tempOut = 0.0; } m->mothurOut("Percentage complete: " + toString((int(tempOut) * 100.0))); m->mothurOutEndLine();       }
-               
-               return results; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, string o) { 
- try {
-               processors = p;
-               outputDir = o;
-               
-        TreeMap* tmap = t->getTreeMap();
-     
-               //if the users enters no groups then give them the score of all groups
-               int numGroups = m->getNumGroups();
-               
-               //calculate number of comparsions
-               int numComp = 0;
-               vector< vector<string> > namesOfGroupCombos;
-               for (int r=0; r<numGroups; r++) { 
-                       for (int l = 0; l < r; l++) {
-                               numComp++;
-                               vector<string> groups; groups.push_back((m->getGroups())[r]); groups.push_back((m->getGroups())[l]);
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-               
-               if (numComp != 1) {
-                       vector<string> groups;
-                       if (numGroups == 0) {
-                               //get score for all users groups
-                               for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
-                                       if ((tmap->getNamesOfGroups())[i] != "xxx") {
-                                               groups.push_back((tmap->getNamesOfGroups())[i]);
-                                       }
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }else {
-                               for (int i = 0; i < m->getNumGroups(); i++) {
-                                       groups.push_back((m->getGroups())[i]);
-                               }
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(processors == 1){
-                               data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), true, tmap);
-                       }else{
-                               int numPairs = namesOfGroupCombos.size();
-                               
-                               int numPairsPerProcessor = numPairs / processors;
-                               
-                               for (int i = 0; i < processors; i++) {
-                                       int startPos = i * numPairsPerProcessor;
-                                       if(i == processors - 1){
-                                               numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                                       }
-                                       lines.push_back(linePair(startPos, numPairsPerProcessor));
-                               }
-                                       
-                               data = createProcesses(t, namesOfGroupCombos, true, tmap);
-                               
-                               lines.clear();
-                       }
-               #else
-                       data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), true, tmap);
-               #endif
-       
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "getValues");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-EstOutput Unweighted::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, bool usingGroups, TreeMap* tmap) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-                               EstOutput myresults;
-                               myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, usingGroups, tmap);
-                               
-                               if (m->control_pressed) { exit(0); }
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-                               string tempFile = outputDir + toString(getpid()) + ".unweighted.results.temp";
-                               m->openOutputFile(tempFile, out);
-                               out << myresults.size() << endl;
-                               for (int i = 0; i < myresults.size(); i++) {  out << myresults[i] << '\t';  } out << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0); 
-                       }
-               }
-               
-               results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, usingGroups, tmap);
-               
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-               
-               if (m->control_pressed) { return results; }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       ifstream in;
-                       string s = outputDir + toString(processIDS[i]) + ".unweighted.results.temp";
-                       m->openInputFile(s, in);
-                       
-                       //get quantiles
-                       if (!in.eof()) {
-                               int num;
-                               in >> num; m->gobble(in);
-                                       
-                               if (m->control_pressed) { break; }
-                               
-                               double w; 
-                               for (int j = 0; j < num; j++) {
-                                       in >> w;
-                                       
-                                       results.push_back(w);
-                               }
-                               m->gobble(in);
-                       }
-                       in.close();
-                       m->mothurRemove(s);
-               }
-               
-               return results;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-EstOutput Unweighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, bool usingGroups, TreeMap* tmap) { 
- try {
-               
-               EstOutput results; results.resize(num);
-               
-               int count = 0;
-               
-               Tree* copyTree = new Tree(tmap);
-               
-               for (int h = start; h < (start+num); h++) {
-               
-                       if (m->control_pressed) { return results; }
-               
-                       //copy random tree passed in
-                       copyTree->getCopy(t);
-                               
-                       //swap labels in the groups you want to compare
-                       copyTree->assembleRandomUnifracTree(namesOfGroupCombos[h]);
-                       
-                       double UniqueBL=0.0000;  //a branch length is unique if it's chidren are from the same group
-                       double totalBL = 0.00;  //all branch lengths
-                       double UW = 0.00;               //Unweighted Value = UniqueBL / totalBL;
-                       //find a node that belongs to one of the groups in this combo
-                       int nodeBelonging = -1;
-                       for (int g = 0; g < namesOfGroupCombos[h].size(); g++) {
-                               if (copyTree->groupNodeInfo[namesOfGroupCombos[h][g]].size() != 0) { nodeBelonging = copyTree->groupNodeInfo[namesOfGroupCombos[h][g]][0]; break; }
-                       }
-                       
-                       //sanity check
-                       if (nodeBelonging == -1) {
-                               m->mothurOut("[WARNING]: cannot find a nodes in the tree from grouping "); 
-                               for (int g = 0; g < namesOfGroupCombos[h].size()-1; g++) { m->mothurOut(namesOfGroupCombos[h][g] + "-"); }
-                               m->mothurOut(namesOfGroupCombos[h][namesOfGroupCombos[h].size()-1]);
-                               m->mothurOut(", skipping."); m->mothurOutEndLine(); results[count] = UW;
-                       }else{
-                               
-                               //if including the root this clears rootForGrouping[namesOfGroupCombos[h]]
-                               getRoot(copyTree, nodeBelonging, namesOfGroupCombos[h]);
-                               
-                               for(int i=0;i<copyTree->getNumNodes();i++){
-                                       
-                                       if (m->control_pressed) {  return data; }
-                                       
-                                       //pcountSize = 0, they are from a branch that is entirely from a group the user doesn't want
-                                       //pcountSize = 2, not unique to one group
-                                       //pcountSize = 1, unique to one group
-                                       
-                                       int pcountSize = 0;
-                                       for (int j = 0; j < namesOfGroupCombos[h].size(); j++) {
-                                               map<string, int>::iterator itGroup = copyTree->tree[i].pcount.find(namesOfGroupCombos[h][j]);
-                                               if (itGroup != copyTree->tree[i].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } } 
-                                       }
-                                       
-                                       //unique calc
-                                       if (pcountSize == 0) { }
-                                       else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize == 1) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a unique branch length and you are not the root 
-                                               UniqueBL += abs(copyTree->tree[i].getBranchLength()); 
-                                       }
-                                       
-                                       //total calc
-                                       if (pcountSize == 0) { }
-                                       else if ((copyTree->tree[i].getBranchLength() != -1) && (pcountSize != 0) && (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0)) { //you have a branch length and you are not the root 
-                                               totalBL += abs(copyTree->tree[i].getBranchLength()); 
-                                       }
-                                       
-                               }
-                               //cout << UniqueBL << '\t' << totalBL << endl;          
-                               UW = (UniqueBL / totalBL);  
-                               
-                               if (isnan(UW) || isinf(UW)) { UW = 0; }
-                               
-                               results[count] = UW;
-                       }
-                       count++;
-                       
-               }
-               
-               delete copyTree;
-               
-               return results; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-int Unweighted::getRoot(Tree* t, int v, vector<string> grouping) { 
-       try {
-               //you are a leaf so get your parent
-               int index = t->tree[v].getParent();
-               
-               if (includeRoot) { 
-                       rootForGrouping[grouping].clear();
-               }else {
-                       
-                       //my parent is a potential root
-                       rootForGrouping[grouping].insert(index);
-                       
-                       //while you aren't at root
-                       while(t->tree[index].getParent() != -1){
-                               //cout << index << endl;        
-                               if (m->control_pressed) {  return 0; }
-                               
-                               //am I the root for this grouping? if so I want to stop "early"
-                               //does my sibling have descendants from the users groups? 
-                               //if so I am not the root
-                               int parent = t->tree[index].getParent();
-                               int lc = t->tree[parent].getLChild();
-                               int rc = t->tree[parent].getRChild();
-                               
-                               int sib = lc;
-                               if (lc == index) { sib = rc; }
-                               
-                               map<string, int>::iterator itGroup;
-                               int pcountSize = 0;
-                               for (int j = 0; j < grouping.size(); j++) {
-                                       map<string, int>::iterator itGroup = t->tree[sib].pcount.find(grouping[j]);
-                                       if (itGroup != t->tree[sib].pcount.end()) { pcountSize++; if (pcountSize > 1) { break; } } 
-                               }
-                               
-                               //if yes, I am not the root
-                               if (pcountSize != 0) {
-                                       rootForGrouping[grouping].clear();
-                                       rootForGrouping[grouping].insert(parent);
-                               }
-                               
-                               index = parent; 
-                       }
-                       
-                       //get all nodes above the root to add so we don't add their u values above
-                       index = *(rootForGrouping[grouping].begin());
-                       while(t->tree[index].getParent() != -1){
-                               int parent = t->tree[index].getParent();
-                               rootForGrouping[grouping].insert(parent);
-                               //cout << parent << " in root" << endl;
-                               index = parent;
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Unweighted", "getRoot");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
diff --git a/unweighted.h b/unweighted.h
deleted file mode 100644 (file)
index c6c13bb..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef UNWEIGHTED_H
-#define UNWEIGHTED_H
-
-
-/*
- *  unweighted.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treecalculator.h"
-#include "treemap.h"
-
-/***********************************************************************/
-
-class Unweighted : public TreeCalculator  {
-       
-       public:
-        Unweighted(bool r) : includeRoot(r) {};
-               ~Unweighted() {};
-               EstOutput getValues(Tree*, int, string);
-               EstOutput getValues(Tree*, string, string, int, string);
-               
-       private:
-               struct linePair {
-                       int start;
-                       int num;
-                       linePair(int i, int j) : start(i), num(j) {}
-               };
-               vector<linePair> lines;
-               
-               EstOutput data;
-               int processors;
-               string outputDir;
-               map< vector<string>, set<int> > rootForGrouping;  //maps a grouping combo to the roots for that combo
-               bool includeRoot;
-               
-               EstOutput driver(Tree*, vector< vector<string> >, int, int, TreeMap*); 
-               EstOutput createProcesses(Tree*, vector< vector<string> >, TreeMap*);
-               EstOutput driver(Tree*, vector< vector<string> >, int, int, bool, TreeMap*); 
-               EstOutput createProcesses(Tree*, vector< vector<string> >, bool, TreeMap*);
-               int getRoot(Tree*, int, vector<string>);
-};
-
-/***********************************************************************/
-
-#endif
diff --git a/uvest.cpp b/uvest.cpp
deleted file mode 100644 (file)
index f0ca81e..0000000
--- a/uvest.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- *  uvest.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "uvest.h"
-
-/***********************************************************************/
-//This is used by SharedJAbund and SharedSorAbund
-EstOutput UVEst::getUVest(vector<SharedRAbundVector*> shared) {
-       try {   
-               EstOutput results;
-               results.resize(2,0);
-               
-               int S12, Atotal, Btotal, f1A, f2A, f1B, f2B, sumSharedA, sumSharedB, sumSharedA1, sumSharedB1, tempA, tempB;
-               S12 = 0; Atotal = 0; Btotal = 0; f1A = 0; f2A = 0; f1B = 0; f2B = 0; sumSharedA = 0; sumSharedB = 0; sumSharedA1 = 0; sumSharedB1 = 0;
-               float Upart1, Upart2, Upart3, Vpart1, Vpart2, Vpart3, Uest, Vest;
-               Upart1 = 0.0; Upart2 = 0.0; Upart3 = 0.0; Vpart1 = 0.0; Vpart2 = 0.0; Vpart3 = 0.0;
-               
-               /*Xi, Yi = abundance of the ith shared OTU in A and B 
-               ntotal, mtotal = total number of sequences sampled in A and B 
-               I(•) = if the argument, •, is true then I(•) is 1; otherwise it is 0. 
-               sumSharedA = the sum of all shared otus in A
-               sumSharedB = the sum of all shared otus in B
-               sumSharedA1 = the sum of all shared otus in A where B = 1
-               sumSharedB1 = the sum of all shared otus in B where A = 1 */
-               
-               for (int i = 0; i < shared[0]->getNumBins(); i++) {
-                       //store in temps to avoid multiple repetitive function calls
-                       tempA = shared[0]->getAbundance(i);
-                       tempB = shared[1]->getAbundance(i);
-
-                       Atotal += tempA;
-                       Btotal += tempB;
-                       
-                       if ((tempA != 0) && (tempB != 0)) {//they are shared
-                               sumSharedA += tempA;
-                               sumSharedB += tempB;
-                               
-                               //does A have one or two
-                               if (tempA == 1)                 { f1A++; sumSharedB1 += tempB;}
-                               else if (tempA == 2)    { f2A++; }
-                               
-                               //does B have one or two
-                               if (tempB == 1)                 { f1B++; sumSharedA1 += tempA;}
-                               else if (tempB == 2)    { f2B++; }
-                       }
-               }
-               
-               Upart1 = sumSharedA / (float) Atotal;
-               Upart2 = ((Btotal - 1) * f1B) / (float) (Btotal * 2 * f2B);
-               Upart3 = sumSharedA1 / (float) Atotal;
-               
-               if (isnan(Upart1) || isinf(Upart1)) { Upart1 = 0; }
-               if (isnan(Upart2) || isinf(Upart2)) { Upart2 = 0; }
-               if (isnan(Upart3) || isinf(Upart3)) { Upart3 = 0; }
-               
-               Uest = Upart1 + (Upart2 * Upart3);
-               
-               Vpart1 = sumSharedB / (float) Btotal;
-               Vpart2 = ((Atotal - 1) * f1A) / (float) (Atotal * 2 * f2A);
-               Vpart3 = sumSharedB1 / (float) Btotal;
-               
-               if (isnan(Vpart1) || isinf(Vpart1)) { Vpart1 = 0; }
-               if (isnan(Vpart2) || isinf(Vpart2)) { Vpart2 = 0; }
-               if (isnan(Vpart3) || isinf(Vpart3)) { Vpart3 = 0; }
-               
-               Vest = Vpart1 + (Vpart2 * Vpart3);
-               
-               if (Uest > 1) { Uest = 1; }
-               if (Vest > 1) { Vest = 1; }
-               
-               results[0] = Uest;
-               results[1] = Vest;
-               
-               return results;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "UVEst", "getUVest");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/uvest.h b/uvest.h
deleted file mode 100644 (file)
index 384e80c..0000000
--- a/uvest.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef UVEST_H
-#define UVEST_H
-/*
- *  uvest.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/8/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-/* This class implements the UVEst estimator on two groups. 
-It is used by sharedJAbund and SharedSorensonAbund. */
-
-#include "mothur.h"
-#include "sharedrabundvector.h"
-
-typedef vector<double> EstOutput;
-
-/***********************************************************************/
-class UVEst {
-       public:
-               UVEst() { m = MothurOut::getInstance(); }
-               EstOutput getUVest(vector<SharedRAbundVector*>);        
-       private:
-               MothurOut* m;
-};
-/***********************************************************************/
-
-#endif
diff --git a/validcalculator.cpp b/validcalculator.cpp
deleted file mode 100644 (file)
index 7df7c4e..0000000
+++ /dev/null
@@ -1,922 +0,0 @@
-/*
- *  validcalculator.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "validcalculator.h"
-#include "ace.h"
-#include "sobs.h"
-#include "nseqs.h"
-#include "chao1.h"
-#include "bootstrap.h"
-#include "simpson.h"
-#include "simpsoneven.h"
-#include "invsimpson.h"
-#include "npshannon.h"
-#include "shannon.h"
-#include "smithwilson.h"
-#include "heip.h"
-#include "shannoneven.h"
-#include "jackknife.h"
-#include "geom.h"
-#include "qstat.h"
-#include "logsd.h"
-#include "bergerparker.h"
-#include "bstick.h"
-#include "goodscoverage.h"
-#include "efron.h"
-#include "boneh.h"
-#include "solow.h"
-#include "shen.h"
-#include "coverage.h"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "sharedjabund.h"
-#include "sharedsorabund.h"
-#include "sharedjclass.h"
-#include "sharedsorclass.h"
-#include "sharedjest.h"
-#include "sharedsorest.h"
-#include "sharedthetayc.h"
-#include "sharedthetan.h"
-#include "sharedkstest.h"
-#include "whittaker.h"
-#include "sharednseqs.h"
-#include "sharedochiai.h"
-#include "sharedanderbergs.h"
-#include "sharedkulczynski.h"
-#include "sharedkulczynskicody.h"
-#include "sharedlennon.h"
-#include "sharedmorisitahorn.h"
-#include "sharedbraycurtis.h"
-#include "sharedjackknife.h"
-#include "whittaker.h"
-#include "odum.h"
-#include "canberra.h"
-#include "structeuclidean.h"
-#include "structchord.h"
-#include "hellinger.h"
-#include "manhattan.h"
-#include "structpearson.h"
-#include "soergel.h"
-#include "spearman.h"
-#include "structkulczynski.h"
-#include "structchi2.h"
-#include "speciesprofile.h"
-#include "hamming.h"
-#include "gower.h"
-#include "memchi2.h"
-#include "memchord.h"
-#include "memeuclidean.h"
-#include "mempearson.h"
-#include "sharedsobs.h"
-#include "sharednseqs.h"
-
-
-/********************************************************************/
-ValidCalculators::ValidCalculators() {
-       try {
-               m = MothurOut::getInstance();
-               
-               initialSingle();  
-               initialShared();
-               initialRarefaction();
-               initialSharedRarefact();
-               initialSummary();
-               initialSharedSummary();
-               initialVennSingle();
-               initialVennShared();
-               initialTreeGroups();
-               initialBoot();
-               initialDistance();
-               initialMatrix();
-               initialHeat();
-               
-               for(it = single.begin(); it != single.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = shared.begin(); it != shared.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = rarefaction.begin(); it != rarefaction.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = summary.begin(); it != summary.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = sharedsummary.begin(); it != sharedsummary.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = vennsingle.begin(); it != vennsingle.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = vennshared.begin(); it != vennshared.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = treegroup.begin(); it != treegroup.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = matrix.begin(); it != matrix.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = heat.begin(); it != heat.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = boot.begin(); it != boot.end(); it++) { allCalcs.insert(it->first); } 
-               for(it = distance.begin(); it != distance.end(); it++) { allCalcs.insert(it->first); } 
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "ValidCalculator");
-               exit(1);
-       }
-}
-/********************************************************************/
-ValidCalculators::~ValidCalculators() {}
-/********************************************************************/
-void ValidCalculators::printCitations(vector<string> Estimators) {
-       try {
-               
-               for (int i = 0; i < Estimators.size(); i++) {
-                       //is this citation, do nothing
-                       if ((Estimators[i] == "citation") || (Estimators[i] == "default") || (Estimators[i] == "eachgap") || (Estimators[i] == "nogaps") || (Estimators[i] == "onegap")) {}
-                       //is this a valid calculator
-                       else if (allCalcs.count(Estimators[i]) != 0) {
-                               if (Estimators[i] == "sobs") { Calculator* temp = new Sobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "chao") { Calculator* temp = new Chao1(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "nseqs") { Calculator* temp = new NSeqs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "coverage") { Calculator* temp = new Coverage(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "ace") { Calculator* temp = new Ace(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               
-                               }else if (Estimators[i] == "jack") { Calculator* temp = new Jackknife(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "shannon") { Calculator* temp = new Shannon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "shannoneven") { Calculator* temp = new ShannonEven(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "npshannon") { Calculator* temp = new NPShannon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "heip") { Calculator* temp = new Heip(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "smithwilson") { Calculator* temp = new SmithWilson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "simpson") { Calculator* temp = new Simpson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "simpsoneven") { Calculator* temp = new SimpsonEven(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "invsimpson") { Calculator* temp = new InvSimpson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "bootstrap") { Calculator* temp = new Bootstrap(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "geometric") { Calculator* temp = new Geom(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "qstat") { Calculator* temp = new QStat(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "logseries") { Calculator* temp = new LogSD(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "bergerparker") { Calculator* temp = new BergerParker(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "bstick") { Calculator* temp = new BStick(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "goodscoverage") { Calculator* temp = new GoodsCoverage(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "efron") { Calculator* temp = new Efron(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "boneh") { Calculator* temp = new Boneh(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
-                               }else if (Estimators[i] == "solow") { Calculator* temp = new Solow(10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "shen") { Calculator* temp = new Shen(10, 10); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "sharedchao") { Calculator* temp = new SharedChao1(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sharedsobs") { Calculator* temp = new SharedSobsCS(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sharedace") { Calculator* temp = new SharedAce(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "jabund") {  Calculator* temp = new JAbund(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sorabund") { Calculator* temp = new SorAbund(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "jclass") { Calculator* temp = new Jclass(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sorclass") { Calculator* temp = new SorClass(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
-                               }else if (Estimators[i] == "jest") { Calculator* temp = new Jest(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sorest") { Calculator* temp = new SorEst(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "thetayc") { Calculator* temp = new ThetaYC(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "thetan") { Calculator* temp = new ThetaN(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "kstest") { Calculator* temp = new KSTest(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "whittaker") { Calculator* temp = new Whittaker(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "sharednseqs") { Calculator* temp = new SharedNSeqs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;  
-                               }else if (Estimators[i] == "ochiai") { Calculator* temp = new Ochiai(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               
-                               }else if (Estimators[i] == "anderberg") { Calculator* temp = new Anderberg(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "kulczynskicody") { Calculator* temp = new KulczynskiCody(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp; 
-                               }else if (Estimators[i] == "lennon") { Calculator* temp = new Lennon(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "morisitahorn") { Calculator* temp = new MorHorn(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               
-                               }else if (Estimators[i] == "braycurtis") { Calculator* temp = new BrayCurtis(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "odum") { Calculator* temp = new Odum(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "canberra") { Calculator* temp = new Canberra(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "structeuclidean") { Calculator* temp = new StructEuclidean(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "structchord") { Calculator* temp = new StructChord(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               
-                               }else if (Estimators[i] == "hellinger") { Calculator* temp = new Hellinger(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "manhattan") { Calculator* temp = new Manhattan(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "structpearson") { Calculator* temp = new StructPearson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "soergel") { Calculator* temp = new Soergel(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "spearman") { Calculator* temp = new Spearman(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               
-                               }else if (Estimators[i] == "structkulczynski") { Calculator* temp = new StructKulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "speciesprofile") { Calculator* temp = new SpeciesProfile(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "hamming") { Calculator* temp = new Hamming(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "structchi2") { Calculator* temp = new StructChi2(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "gower") { Calculator* temp = new Gower(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               
-                               }else if (Estimators[i] == "memchi2") { Calculator* temp = new MemChi2(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "memchord") { Calculator* temp = new MemChord(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "memeuclidean") { Calculator* temp = new MemEuclidean(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "mempearson") { Calculator* temp = new MemPearson(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "sharedobserved") { Calculator* temp = new SharedSobs(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else if (Estimators[i] == "kulczynski") { Calculator* temp = new Kulczynski(); m->mothurOut(temp->getName() + ": "); temp->citation(); delete temp;
-                               }else { m->mothurOut("[ERROR]: Missing else if for " + Estimators[i] + " in printCitations."); m->mothurOutEndLine(); }
-                       }else { m->mothurOut(Estimators[i] + " is not a valid calculator, no citation will be given."); m->mothurOutEndLine(); }
-               }
-                       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "printCitations");
-               exit(1);
-       }
-}
-/********************************************************************/
-
-bool ValidCalculators::isValidCalculator(string parameter, string calculator) {
-       try {   
-               //are you looking for a calculator for a single parameter
-               if (parameter == "single") {
-                       //is it valid
-                       if ((single.find(calculator)) != (single.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the collect.single command and will be disregarded. Valid estimators are ");
-                               for (it = single.begin(); it != single.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               //are you looking for a calculator for a shared parameter
-               }else if (parameter == "shared") {
-                       //is it valid
-                       if ((shared.find(calculator)) != (shared.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator +  " is not a valid estimator for the collect.shared command and will be disregarded.  Valid estimators are ");
-                               for (it = shared.begin(); it != shared.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               //are you looking for a calculator for a rarefaction parameter
-               }else if (parameter == "rarefaction") {
-                       //is it valid
-                       if ((rarefaction.find(calculator)) != (rarefaction.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the rarefaction.single command and will be disregarded. Valid estimators are ");
-                               for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               //are you looking for a calculator for a summary parameter
-               }else if (parameter == "summary") {
-                       //is it valid
-                       if ((summary.find(calculator)) != (summary.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
-                               for (it = summary.begin(); it != summary.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               //are you looking for a calculator for a sharedsummary parameter
-               }else if (parameter == "sharedsummary") {
-                       //is it valid
-                       if ((sharedsummary.find(calculator)) != (sharedsummary.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator +  " is not a valid estimator for the summary.shared command and will be disregarded. Valid estimators are ");
-                               for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "sharedrarefaction") {
-                       //is it valid
-                       if ((sharedrarefaction.find(calculator)) != (sharedrarefaction.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the rarefaction.shared command and will be disregarded. Valid estimator is ");
-                               for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "vennsingle") {
-                       //is it valid
-                       if ((vennsingle.find(calculator)) != (vennsingle.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the venn command in single mode and will be disregarded. Valid estimators are ");
-                               for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "vennshared") {
-                       //is it valid
-                       if ((vennshared.find(calculator)) != (vennshared.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the venn command in shared mode and will be disregarded. Valid estimators are ");
-                               for (it = vennshared.begin(); it != vennshared.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "treegroup") {
-                       //is it valid
-                       if ((treegroup.find(calculator)) != (treegroup.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the tree.shared command and will be disregarded. Valid estimators are ");
-                               for (it = treegroup.begin(); it != treegroup.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "matrix") {
-                       //is it valid
-                       if ((matrix.find(calculator)) != (matrix.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator +  " is not a valid estimator for the matrix.output command and will be disregarded. Valid estimators are ");
-                               for (it = matrix.begin(); it != matrix.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "heat") {
-                       //is it valid
-                       if ((heat.find(calculator)) != (heat.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the heatmap.sim command and will be disregarded. Valid estimators are ");
-                               for (it = heat.begin(); it != heat.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "boot") {
-                       //is it valid
-                       if ((boot.find(calculator)) != (boot.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator + " is not a valid estimator for the bootstrap.shared command and will be disregarded. Valid estimators are ");
-                               for (it = boot.begin(); it != boot.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               }else if (parameter == "distance") {
-                       //is it valid
-                       if ((distance.find(calculator)) != (distance.end())) {
-                               return true;
-                       }else { 
-                               m->mothurOut(calculator +  " is not a valid estimator for the distance command and will be disregarded. Valid calculators are ");
-                               for (it = distance.begin(); it != distance.end(); it++) {
-                                       m->mothurOut(it->first + ", ");
-                               }
-                               m->mothurOutEndLine();
-                               return false; }
-               //not a valid parameter
-               }else { return false; }
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "isValidCalculator");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialSingle() {
-       try {   
-               single["sobs"]          = "sobs";
-               single["chao"]              = "chao";
-               single["ace"]               = "ace";
-               single["jack"]              = "jack";
-               single["shannon"]           = "shannon";
-               single["npshannon"]     = "npshannon";
-               single["shannoneven"]   = "shannoneven";
-               single["smithwilson"]   = "smithwilson";
-               single["heip"]                  = "heip";
-               single["simpson"]           = "simpson";
-               single["simpsoneven"]   = "simpsoneven";
-               single["invsimpson"]    = "invsimpson";
-               single["bergerparker"]  = "bergerparker";
-               single["bootstrap"]     = "bootstrap";
-               single["geometric"]     = "geometric";
-               single["logseries"]             = "logseries";
-               single["qstat"]         = "qstat";
-               single["bstick"]        = "bstick";
-               single["goodscoverage"] = "goodscoverage";
-               single["nseqs"]                 = "nseqs";
-               single["coverage"]              = "coverage";
-               single["efron"]         = "efron";
-               single["boneh"]         = "boneh";
-               single["solow"]         = "solow";
-               single["shen"]          = "shen";
-               single["default"]           = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialSingle");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialShared() {
-       try {   
-               shared["sharedsobs"]                    = "sharedsobs";
-               shared["sharedchao"]                    = "sharedchao";
-               shared["sharedace"]                             = "sharedace";
-               shared["jabund"]                                = "jabund";
-               shared["sorabund"]                              = "sorabund";
-               shared["jclass"]                                = "jclass";
-               shared["sorclass"]                              = "sorclass";
-               shared["jest"]                                  = "jest";
-               shared["sorest"]                                = "sorest";
-               shared["thetayc"]                               = "thetayc";
-               shared["thetan"]                                = "thetan";
-               shared["kstest"]                                = "kstest";
-               shared["whittaker"]                         = "whittaker";
-               shared["sharednseqs"]                   = "sharednseqs";
-               shared["ochiai"]                                = "ochiai";
-               shared["anderberg"]                             = "anderberg";
-               shared["kulczynski"]                    = "kulczynski";
-               shared["kulczynskicody"]                = "kulczynskicody";
-               shared["lennon"]                                = "lennon";
-               shared["morisitahorn"]                  = "morisitahorn";
-               shared["braycurtis"]                    = "braycurtis";
-               shared["odum"]                                  = "odum";
-               shared["canberra"]                              = "canberra";
-               shared["structeuclidean"]               = "structeuclidean";
-               shared["structchord"]                   = "structchord";
-               shared["hellinger"]                             = "hellinger";
-               shared["manhattan"]                             = "manhattan";
-               shared["structpearson"]                 = "structpearson";
-               shared["soergel"]                               = "soergel";
-               shared["spearman"]                              = "spearman";
-               shared["structkulczynski"]              = "structkulczynski";
-               shared["structchi2"]                    = "structchi2";
-               shared["speciesprofile"]                = "speciesprofile";
-               shared["hamming"]                               = "hamming";
-               shared["gower"]                                 = "gower";
-               shared["memchi2"]                               = "memchi2";
-               shared["memchord"]                              = "memchord";
-               shared["memeuclidean"]                  = "memeuclidean";
-               shared["mempearson"]                    = "mempearson";
-               shared["default"]                   = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialShared");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialRarefaction() {
-       try {   
-               rarefaction["sobs"]                     = "sobs";
-               rarefaction["chao"]                     = "chao";
-               rarefaction["ace"]                      = "ace";
-               rarefaction["jack"]                     = "jack";
-               rarefaction["shannon"]          = "shannon";
-               rarefaction["smithwilson"]      = "smithwilson";
-               rarefaction["heip"]                     = "heip";
-               rarefaction["npshannon"]        = "npshannon";
-               rarefaction["shannoneven"]      = "shannoneven";
-               rarefaction["simpson"]          = "simpson";
-               rarefaction["invsimpson"]       = "invsimpson";
-               rarefaction["simpsoneven"]      = "simpsoneven";
-               rarefaction["bootstrap"]        = "bootstrap";
-               rarefaction["nseqs"]            = "nseqs";
-               rarefaction["coverage"]         = "coverage";
-               rarefaction["default"]      = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialRarefaction");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-
-void ValidCalculators::initialSummary() {
-       try {   
-               summary["sobs"]                 = "sobs";
-               summary["chao"]                 = "chao";
-               summary["ace"]                  = "ace";
-               summary["jack"]                 = "jack";
-               summary["shannon"]              = "shannon";
-               summary["heip"]                 = "heip";
-               summary["shannoneven"]  = "shannoneven";
-               summary["smithwilson"]  = "smithwilson";
-               summary["invsimpson"]   = "invsimpson";
-               summary["npshannon"]    = "npshannon";
-               summary["simpson"]              = "simpson";
-               summary["simpsoneven"]  = "simpsoneven";
-               summary["bergerparker"] = "bergerparker";
-               summary["geometric"]    = "geometric";
-               summary["bootstrap"]    = "bootstrap";
-               summary["logseries"]    = "logseries";
-               summary["qstat"]        = "qstat";
-               summary["bstick"]       = "bstick";
-               summary["nseqs"]                = "nseqs";
-               summary["goodscoverage"]= "goodscoverage";
-               summary["coverage"]             = "coverage";
-               summary["efron"]        = "efron";
-               summary["boneh"]        = "boneh";
-               summary["solow"]        = "solow";
-               summary["shen"]         = "shen";
-               summary["default"]          = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialSummary");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialSharedSummary() {
-       try {   
-               sharedsummary["sharedsobs"]                             = "sharedsobs";
-               sharedsummary["sharedchao"]                             = "sharedchao";
-               sharedsummary["sharedace"]                              = "sharedace";
-               sharedsummary["jabund"]                                 = "jabund";
-               sharedsummary["sorabund"]                               = "sorabund";
-               sharedsummary["jclass"]                                 = "jclass";
-               sharedsummary["sorclass"]                               = "sorclass";
-               sharedsummary["jest"]                                   = "jest";
-               sharedsummary["sorest"]                                 = "sorest";
-               sharedsummary["thetayc"]                                = "thetayc";
-               sharedsummary["thetan"]                                 = "thetan";
-               sharedsummary["kstest"]                                 = "kstest";
-               sharedsummary["whittaker"]                              = "whittaker";
-               sharedsummary["sharednseqs"]                    = "sharednseqs";
-               sharedsummary["ochiai"]                                 = "ochiai";
-               sharedsummary["anderberg"]                              = "anderberg";
-               sharedsummary["kulczynski"]                             = "kulczynski";
-               sharedsummary["kulczynskicody"]                 = "kulczynskicody";
-               sharedsummary["lennon"]                                 = "lennon";
-               sharedsummary["morisitahorn"]                   = "morisitahorn";
-               sharedsummary["braycurtis"]                             = "braycurtis";
-               sharedsummary["odum"]                                   = "odum";
-               sharedsummary["canberra"]                               = "canberra";
-               sharedsummary["structeuclidean"]                = "structeuclidean";
-               sharedsummary["structchord"]                    = "structchord";
-               sharedsummary["hellinger"]                              = "hellinger";
-               sharedsummary["manhattan"]                              = "manhattan";
-               sharedsummary["structpearson"]                  = "structpearson";
-               sharedsummary["structkulczynski"]               = "structkulczynski";
-               sharedsummary["structchi2"]                             = "structchi2";
-               sharedsummary["soergel"]                                = "soergel";
-               sharedsummary["spearman"]                               = "spearman";
-               sharedsummary["speciesprofile"]                 = "speciesprofile";
-               sharedsummary["hamming"]                                = "hamming";
-               sharedsummary["gower"]                                  = "gower";
-               sharedsummary["memchi2"]                                = "memchi2";
-               sharedsummary["memchord"]                               = "memchord";
-               sharedsummary["memeuclidean"]                   = "memeuclidean";
-               sharedsummary["mempearson"]                             = "mempearson";
-               sharedsummary["default"]                                = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialSharedSummary");
-               exit(1);
-       }
-}
-
-
-/********************************************************************/
-
-void ValidCalculators::initialSharedRarefact() {
-       try {   
-               sharedrarefaction["sharedobserved"]     = "sharedobserved";
-               sharedrarefaction["sharednseqs"]        = "sharednseqs";
-               sharedrarefaction["default"]        = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialSharedRarefact");
-               exit(1);
-       }
-}
-
-
-/********************************************************************/
-void ValidCalculators::initialVennSingle() {
-       try {
-               vennsingle["sobs"]              = "sobs";
-               vennsingle["chao"]                  = "chao";
-               vennsingle["ace"]                       = "ace";
-               vennsingle["jack"]                  = "jack";
-               vennsingle["default"]           = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialVennSingle");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialVennShared() {
-       try {
-               vennshared["sharedsobs"]        = "sharedsobs";
-               vennshared["sharedchao"]        = "sharedchao";
-               vennshared["sharedace"]         = "sharedace";
-               vennshared["default"]           = "default";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialVennShared");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialTreeGroups() {
-       try {   
-               treegroup["sharedsobs"]                         = "sharedsobs";
-               treegroup["sharedchao"]                         = "sharedchao";
-               treegroup["sharedace"]                          = "sharedace";
-               treegroup["jabund"]                                     = "jabund";
-               treegroup["sorabund"]                           = "sorabund";
-               treegroup["jclass"]                                     = "jclass";
-               treegroup["sorclass"]                           = "sorclass";
-               treegroup["jest"]                                       = "jest";
-               treegroup["sorest"]                                     = "sorest";
-               treegroup["thetayc"]                            = "thetayc";
-               treegroup["thetan"]                                     = "thetan";
-               treegroup["kstest"]                                     = "kstest";
-               treegroup["whittaker"]                          = "whittaker";
-               treegroup["sharednseqs"]                        = "sharednseqs";
-               treegroup["ochiai"]                                     = "ochiai";
-               treegroup["anderberg"]                          = "anderberg";
-               treegroup["kulczynski"]                         = "kulczynski";
-               treegroup["kulczynskicody"]                     = "kulczynskicody";
-               treegroup["lennon"]                                     = "lennon";
-               treegroup["morisitahorn"]                       = "morisitahorn";
-               treegroup["braycurtis"]                         = "braycurtis";
-               treegroup["odum"]                                       = "odum";
-               treegroup["canberra"]                           = "canberra";
-               treegroup["structeuclidean"]            = "structeuclidean";
-               treegroup["structchord"]                        = "structchord";
-               treegroup["hellinger"]                          = "hellinger";
-               treegroup["manhattan"]                          = "manhattan";
-               treegroup["structpearson"]                      = "structpearson";
-               treegroup["structkulczynski"]           = "structkulczynski";
-               treegroup["structchi2"]                         = "structchi2";
-               treegroup["soergel"]                            = "soergel";
-               treegroup["spearman"]                           = "spearman";
-               treegroup["speciesprofile"]                     = "speciesprofile";
-               treegroup["hamming"]                            = "hamming";
-               treegroup["gower"]                                      = "gower";
-               treegroup["memchi2"]                            = "memchi2";
-               treegroup["memchord"]                           = "memchord";
-               treegroup["memeuclidean"]                       = "memeuclidean";
-               treegroup["mempearson"]                         = "mempearson";
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialTreeGroups");
-               exit(1);
-       }
-}
-/********************************************************************/
-void ValidCalculators::initialHeat() {
-       try {   
-               heat["jabund"]                          = "jabund";
-               heat["sorabund"]                        = "sorabund";
-               heat["jclass"]                          = "jclass";
-               heat["sorclass"]                        = "sorclass";
-               heat["jest"]                            = "jest";
-               heat["sorest"]                          = "sorest";
-               heat["thetayc"]                         = "thetayc";
-               heat["thetan"]                          = "thetan";
-               heat["morisitahorn"]            = "morisitahorn";
-               heat["braycurtis"]                      = "braycurtis";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialHeat");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialMatrix() {
-       try {   
-               matrix["sharedsobs"]                            = "sharedsobs";
-               matrix["sharedchao"]                            = "sharedchao";
-               matrix["sharedace"]                             = "sharedace";
-               matrix["jabund"]                                        = "jabund";
-               matrix["sorabund"]                              = "sorabund";
-               matrix["jclass"]                                        = "jclass";
-               matrix["sorclass"]                              = "sorclass";
-               matrix["jest"]                                  = "jest";
-               matrix["sorest"]                                        = "sorest";
-               matrix["thetayc"]                               = "thetayc";
-               matrix["thetan"]                                        = "thetan";
-               matrix["kstest"]                                        = "kstest";
-               matrix["whittaker"]                             = "whittaker";
-               matrix["sharednseqs"]                   = "sharednseqs";
-               matrix["ochiai"]                                        = "ochiai";
-               matrix["anderberg"]                             = "anderberg";
-               matrix["kulczynski"]                            = "kulczynski";
-               matrix["kulczynskicody"]                        = "kulczynskicody";
-               matrix["lennon"]                                        = "lennon";
-               matrix["morisitahorn"]                  = "morisitahorn";
-               matrix["braycurtis"]                            = "braycurtis";
-               matrix["odum"]                                  = "odum";
-               matrix["canberra"]                              = "canberra";
-               matrix["structeuclidean"]               = "structeuclidean";
-               matrix["structchord"]                   = "structchord";
-               matrix["hellinger"]                             = "hellinger";
-               matrix["manhattan"]                             = "manhattan";
-               matrix["structpearson"]                 = "structpearson";
-               matrix["structkulczynski"]              = "structkulczynski";
-               matrix["structchi2"]                            = "structchi2";
-               matrix["soergel"]                               = "soergel";
-               matrix["spearman"]                              = "spearman";
-               matrix["speciesprofile"]                        = "speciesprofile";
-               matrix["hamming"]                               = "hamming";
-               matrix["gower"]                                 = "gower";
-               matrix["memchi2"]                               = "memchi2";
-               matrix["memchord"]                              = "memchord";
-               matrix["memeuclidean"]                  = "memeuclidean";
-               matrix["mempearson"]                            = "mempearson";
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialMatrix");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::initialBoot() {
-       try {   
-               boot["jabund"]                          = "jabund";
-               boot["sorabund"]                        = "sorabund";
-               boot["jclass"]                          = "jclass";
-               boot["sorclass"]                        = "orclass";
-               boot["jest"]                            = "jest";
-               boot["sorest"]                          = "sorest";
-               boot["thetayc"]                         = "thetayc";
-               boot["thetan"]                          = "thetan";
-               boot["morisitahorn"]            = "morisitahorn";
-               boot["braycurtis"]                      = "braycurtis";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialBoot");
-               exit(1);
-       }
-}
-/********************************************************************/
-void ValidCalculators::initialDistance() {
-       try {   
-               distance["nogaps"]              = "nogaps";
-               distance["eachgap"]             = "eachgap";
-               distance["onegap"]              = "onegap";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "initialDistance");
-               exit(1);
-       }
-}
-
-/********************************************************************/
-void ValidCalculators::printCalc(string parameter, ostream& out) {
-       try{
-               out << "The available estimators for calc are ";
-               //are you looking for a calculator for a single parameter
-               if (parameter == "single") {
-                       for (it = single.begin(); it != single.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               //are you looking for a calculator for a shared parameter
-               }else if (parameter == "shared") {
-                       for (it = shared.begin(); it != shared.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               //are you looking for a calculator for a rarefaction parameter
-               }else if (parameter == "rarefaction") {
-                       for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               //are you looking for a calculator for a summary parameter
-               }else if (parameter == "summary") {
-                       for (it = summary.begin(); it != summary.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               //are you looking for a calculator for a sharedsummary parameter
-               }else if (parameter == "sharedsummary") {
-                       for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "sharedrarefaction") {
-                       for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "vennsingle") {
-                       for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "vennshared") {
-                       for (it = vennshared.begin(); it != vennshared.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "treegroup") {
-                       for (it = treegroup.begin(); it != treegroup.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "matrix") {
-                       for (it = matrix.begin(); it != matrix.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "heat") {
-                       for (it = heat.begin(); it != heat.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "boot") {
-                       for (it = boot.begin(); it != boot.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }else if (parameter == "distance") {
-                       for (it = distance.begin(); it != distance.end(); it++) {
-                               out << it->first << ", ";
-                       }
-               }
-
-               out << endl;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "printCalc");
-               exit(1);
-       }
-}
-/********************************************************************/
-string ValidCalculators::printCalc(string parameter) {
-       try{
-               string output = "The available estimators for calc are ";
-               //are you looking for a calculator for a single parameter
-               if (parameter == "single") {
-                       for (it = single.begin(); it != single.end(); it++) {
-                               output += it->first + ", ";
-                       }
-                       //are you looking for a calculator for a shared parameter
-               }else if (parameter == "shared") {
-                       for (it = shared.begin(); it != shared.end(); it++) {
-                               output += it->first + ", ";
-                       }
-                       //are you looking for a calculator for a rarefaction parameter
-               }else if (parameter == "rarefaction") {
-                       for (it = rarefaction.begin(); it != rarefaction.end(); it++) {
-                               output += it->first + ", ";
-                       }
-                       //are you looking for a calculator for a summary parameter
-               }else if (parameter == "summary") {
-                       for (it = summary.begin(); it != summary.end(); it++) {
-                               output += it->first + ", ";
-                       }
-                       //are you looking for a calculator for a sharedsummary parameter
-               }else if (parameter == "sharedsummary") {
-                       for (it = sharedsummary.begin(); it != sharedsummary.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "sharedrarefaction") {
-                       for (it = sharedrarefaction.begin(); it != sharedrarefaction.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "vennsingle") {
-                       for (it = vennsingle.begin(); it != vennsingle.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "vennshared") {
-                       for (it = vennshared.begin(); it != vennshared.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "treegroup") {
-                       for (it = treegroup.begin(); it != treegroup.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "matrix") {
-                       for (it = matrix.begin(); it != matrix.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "heat") {
-                       for (it = heat.begin(); it != heat.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "boot") {
-                       for (it = boot.begin(); it != boot.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }else if (parameter == "distance") {
-                       for (it = distance.begin(); it != distance.end(); it++) {
-                               output += it->first + ", ";
-                       }
-               }
-               
-               //rip off comma
-               output = output.substr(0, output.length()-1);
-               output += "\n";
-               
-               return output;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidCalculator", "printCalc");
-               exit(1);
-       }
-}
-/********************************************************************/
-
-
diff --git a/validcalculator.h b/validcalculator.h
deleted file mode 100644 (file)
index 59f6bb3..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef VALIDCALCULATOR_H
-#define VALIDCALCULATOR_H
-
-/*
- *  validcalculator.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-//This class contains a list of all valid calculators in Mothur.  
-//It has a function which will tell you if your calculator is valid for the given parameter.
-//When adding a new calculator you must add it to the valid list.
-
-
-class ValidCalculators {
-       public:
-               ValidCalculators();
-               ~ValidCalculators();
-               bool isValidCalculator(string, string);
-               void printCalc(string, ostream&);
-               string printCalc(string);
-               void printCitations(vector<string>);
-               
-       private:
-               map<string, string> single;
-               map<string, string> shared;
-               map<string, string> rarefaction;
-               map<string, string> summary;
-               map<string, string> sharedrarefaction;
-               map<string, string> sharedsummary;
-               map<string, string> vennsingle;
-               map<string, string> vennshared;
-               map<string, string> treegroup;
-               map<string, string> matrix;
-               map<string, string> heat;
-               map<string, string> boot;
-               map<string, string> distance;
-               map<string, string>::iterator it;
-               set<string> allCalcs;
-               
-               void initialSingle();
-               void initialShared();
-               void initialRarefaction();
-               void initialSharedRarefact();
-               void initialSummary();
-               void initialSharedSummary();
-               void initialVennSingle();
-               void initialVennShared();
-               void initialTreeGroups();
-               void initialMatrix();
-               void initialBoot();
-               void initialDistance();
-               void initialHeat();
-               
-               MothurOut* m;
-};
-
-#endif
diff --git a/validparameter.cpp b/validparameter.cpp
deleted file mode 100644 (file)
index 3e1f349..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- *  validparameter.cpp
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "validparameter.h"
-
-/***********************************************************************/
-
-ValidParameters::ValidParameters() {
-       try {
-               m = MothurOut::getInstance();
-               initParameterRanges();
-               commandName = "";
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "ValidParameters");
-               exit(1);
-       }
-}
-/***********************************************************************/
-
-ValidParameters::ValidParameters(string c) {
-       try {
-               m = MothurOut::getInstance();
-               initParameterRanges();
-               commandName = c;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "ValidParameters");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-ValidParameters::~ValidParameters() {}
-
-/***********************************************************************/
-bool ValidParameters::isValidParameter(string parameter, vector<string> cParams, string value) {
-       try {   
-               bool valid = false;
-               //vector<string> cParams = commandParameters[command];
-               int numParams = cParams.size(); 
-               for(int i = 0; i < numParams; i++) {
-                       if(cParams.at(i).compare(parameter) == 0) {
-                               valid = true;
-                               i = numParams;
-                       }
-               }
-               if(!valid) {
-                       m->mothurOut(parameter + " is not a valid parameter."); m->mothurOutEndLine();
-                       m->mothurOut("The valid parameters are: ");
-                       for(int i = 0; i < numParams-1; i++)
-                               m->mothurOut(cParams.at(i) + ", ");
-                       m->mothurOut("and " + cParams.at(numParams-1) + ".\n");
-                       return false;
-               }
-               
-               if(parameterRanges.count(parameter) != 1)
-                       return true;
-       
-               int pVal;
-               double piSentinel = 3.14159;
-               vector<string> range = parameterRanges[parameter];
-               
-               vector<string> values;
-               m->splitAtDash(value, values);
-               
-               for(int i = 0; i < values.size(); i++) {
-                       value = values.at(i);
-                       valid = convertTest(value, pVal);
-               
-                       if(!valid)
-                               return false;
-                       
-                       
-                       
-                       /********************************************************************************************************
-                                  Special Cases
-                       *********************************************************************************************************/
-                       
-                       if(parameter.compare("precision") == 0) {
-                               double logNum = log10((double)pVal);
-                               double diff = (double)((int)logNum - logNum);
-                               if(diff != 0) {
-                                       m->mothurOut("The precision parameter can only take powers of 10 as a value (e.g. 10,1000,1000, etc.)\n");
-                                       return false;
-                               }
-                       }
-                       
-                       /************************************************************************************************************/
-                       
-                       
-                       
-                       double a,b,c,d,e;
-                       
-                       if(range.at(1).compare("NA") == 0)
-                               a = piSentinel;
-                       else
-                               a = atoi(range.at(1).c_str()); 
-                               
-                       if(range.at(3).compare("NA") == 0)
-                               b = piSentinel;
-                       else
-                               b = atoi(range.at(3).c_str()); 
-                                               
-                       if(range.at(4).compare("between") == 0)
-                               c = 0;
-                       else if(range.at(4).compare("only") == 0)
-                               c = 1;
-                       else {
-                               m->mothurOut("The range can only be 'between' or 'only' the bounding numbers.\n");
-                               return false;
-                       }
-                       
-                       if(range.at(0).compare(">") == 0)
-                               d = 0;
-                       else if(range.at(0).compare(">=") == 0 || range[3].compare("=>") == 0)
-                               d = 1;
-                       else {
-                               m->mothurOut("The parameter value can only be '>', '>=', or '=>' the lower bounding number.\n");
-                               return false;
-                       }
-                       
-                       if(range.at(2).compare("<") == 0)
-                               e = 0;
-                       else if(range.at(2).compare("<=") == 0 || range[4].compare("=<") == 0)
-                               e = 1;
-                       else {
-                               m->mothurOut("The parameter value can only be '<', '<=', or '=<' the upper bounding number.\n");
-                               return false;
-                       }
-                       
-                       bool a0 = pVal > a;
-                       bool a1 = pVal >= a;
-                       bool b0 = pVal < b;
-                       bool b1 = pVal <= b;
-                       
-                       if(c != 1) {
-                               if(a != piSentinel && b == piSentinel) {
-                                       if(d == 0)
-                                               valid = a0;
-                                       else
-                                               valid = a1;
-                               }
-                               else if(a == piSentinel && b != piSentinel) {
-                                       if(e == 0)
-                                               valid = b0;
-                                       else
-                                               valid = b1;
-                               }
-                               else {
-                                       if(d == 0 && e == 0)
-                                               valid = (a0 && b0);
-                                       else if(d == 0 && e == 1)
-                                               valid = (a0 && b1);
-                                       else if(d == 1 && e == 0)
-                                               valid = (a1 && b0);
-                                       else
-                                               valid = (a1 && b1);
-                               }
-                       }
-                       else {
-                               if(a != piSentinel && b == piSentinel)
-                                       valid = (pVal == a);
-                               else if(a == piSentinel && b != piSentinel)
-                                       valid = (pVal == b);
-                               else
-                                       valid = (pVal == a || pVal == b);
-                       }
-                       
-                       
-                       if(!valid) {
-                               m->mothurOut("The '" + parameter + "' parameter needs to be ");
-                               if(c == 1)
-                                       m->mothurOut("either '" + toString(a) + "' or '" + toString(b) + "'.\n");
-                               else {
-                                       if(a != piSentinel) {
-                                               m->mothurOut(">");
-                                               if(d != 0)
-                                                       m->mothurOut("=");
-                                               m->mothurOut(" '" + toString(a) + "'");
-                                       }
-                                       if(b == piSentinel)
-                                               m->mothurOut( "'.\n");
-                                       else if(a != piSentinel)
-                                               m->mothurOut(" and ");
-                                       if(b != piSentinel) {
-                                               m->mothurOut("<");
-                                               if(e != 0)
-                                                       m->mothurOut("=");
-                                               m->mothurOut(" '" + toString(b) + "'.\n");
-                                       }
-                               }
-                               return false;
-                       }
-               }
-               return true;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "isValidParameters");
-               exit(1);
-       }
-}
-/*******************************************************/
-
-/******************************************************/
-
-string ValidParameters::validFile(map<string, string>& container, string parameter, bool isFile) {
-       try {
-               int ableToOpen;
-               
-               map<string, string>::iterator it;
-               
-               it = container.find(parameter);
-               if(it != container.end()){ //no parameter given
-
-                       if(isFile == true) {
-                               
-                               int pos = (it->second).find(".tx.");
-                               if (pos != string::npos) { m->sharedHeaderMode = "tax"; }
-                               else { m->sharedHeaderMode = "otu"; }
-                       
-                       #ifdef USE_MPI  
-                               int pid, processors;
-                               MPI_Status status;
-                               MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
-                               MPI_Comm_size(MPI_COMM_WORLD, &processors);
-                               
-                               if (commandName == "") { processors = 1; }
-                               
-                               if (pid == 0) {
-                       #endif
-                               ifstream in;
-                               ableToOpen = m->openInputFile(it->second, in, "noerror");
-                               in.close();
-                               
-                               //if you can't open it, try default location
-                               if (ableToOpen == 1) {
-                                       if (m->getDefaultPath() != "") { //default path is set
-                                               string tryPath = m->getDefaultPath() + m->getSimpleName(it->second);
-                                               m->mothurOut("Unable to open " + it->second + ". Trying default " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               in2.close();
-                                               container[parameter] = tryPath;
-                                       }
-                               }
-                               
-                               //if you can't open it, try default location
-                               if (ableToOpen == 1) {
-                                       if (m->getOutputDir() != "") { //default path is set
-                                               string tryPath = m->getOutputDir() + m->getSimpleName(it->second);
-                                               m->mothurOut("Unable to open " + it->second + ". Trying output directory " + tryPath); m->mothurOutEndLine();
-                                               ifstream in2;
-                                               ableToOpen = m->openInputFile(tryPath, in2, "noerror");
-                                               container[parameter] = tryPath;
-                                               in2.close();
-                                       }
-                               }
-                               
-                               
-
-                       #ifdef USE_MPI  
-                                       for(int i = 1; i < processors; i++) { 
-                                               MPI_Send(&ableToOpen, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                               
-                                               int length = container[parameter].length();
-                                               MPI_Send(&length, 1, MPI_INT, i, 2001, MPI_COMM_WORLD);
-                                               MPI_Send(&(container[parameter][0]), length, MPI_CHAR, i, 2001, MPI_COMM_WORLD);
-       
-                                       }
-                               }else {
-                                       MPI_Recv(&ableToOpen, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       int length;
-                                       MPI_Recv(&length, 1, MPI_INT, 0, 2001, MPI_COMM_WORLD, &status);
-                                       //recieve container
-                                       char* tempBuf = new char[length];
-                                       MPI_Recv(&tempBuf[0], length, MPI_CHAR, 0, 2001, MPI_COMM_WORLD, &status);
-                                       
-                                       container[parameter] = tempBuf;
-                                       if (container[parameter].length() > length) { container[parameter] = container[parameter].substr(0, length);  }
-                                       delete tempBuf; 
-                               }
-                               
-                       #endif
-                       
-                               if (ableToOpen == 1) { 
-                                       m->mothurOut("Unable to open " + container[parameter]); m->mothurOutEndLine();
-                                       return "not open"; 
-                               }
-                               
-                               //check phylip file to make sure its really phylip and not column
-                               if ((it->first == "phylip") && (ableToOpen != 1)) {
-                                       ifstream inPhylip;
-                                       m->openInputFile(it->second, inPhylip);
-                                                                               
-                                       string numTest, name;
-                                       inPhylip >> numTest >> name;
-                                       inPhylip.close();
-                                       
-                                       if (!m->isContainingOnlyDigits(numTest)) { m->mothurOut("[ERROR]: expected a number and got " + numTest + ". I suspect you entered a column formatted file as a phylip file, aborting."); m->mothurOutEndLine(); return "not found"; }
-                               }
-                       }
-               }else { return "not found"; }
-               
-               return it->second;
-       
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "validFile");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-/***********************************************************************/
-void ValidParameters::initParameterRanges() {
-       try {   
-               int rangeSize = 5;
-
-               /**************************************************************************************************************
-                       {">=" or "=>" or ">" if the value should be greater than or equal to or just greater than the lower bound,
-                   A number representing the lower bound ("NA" if there is no lower bound), 
-                  "<=" or "=<" or "<" if the value shoud be less than or equal to or just less than the upper bound,
-                   A number representing the upper bound ("NA" if there is no lower bound),
-                  "between" if between lower and upper bounds or "only" if exactly one of the bounds};
-                  
-                  # = parameter
-                  # (>, >=) lower bound, # (<, <=) upperbound, # should be (between, only) lower and upper bounds.
-                  ***********************************************************************************************************/
-               
-               string precisionArray[] = {">=","10", "<","NA", "between"};
-               parameterRanges["precision"] = addParameters(precisionArray, rangeSize);
-               
-               string itersArray[] = {">=","1", "<","NA", "between"};
-               parameterRanges["iters"] = addParameters(itersArray, rangeSize);
-
-               string abundArray[] = {">=","5", "<","NA", "between"};
-               parameterRanges["abund"] = addParameters(abundArray, rangeSize);
-               
-               string softArray[] = {">=","0", "<=","100", "between"};
-               parameterRanges["soft"] = addParameters(softArray, rangeSize);
-               
-               string sizeArray[] = {">=","1", "<","NA", "between"};
-               parameterRanges["size"] = addParameters(sizeArray, rangeSize);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "initParameterRanges");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-/***********************************************************************/
-vector<string> ValidParameters::addParameters(string parameters[], int size) {
-       try {   
-               vector<string> pVector (parameters, parameters+size); 
-               return pVector;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "ValidParameters", "addParameters");
-               exit(1);
-       }
-}
-
diff --git a/validparameter.h b/validparameter.h
deleted file mode 100644 (file)
index 04d201d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-#ifndef VALIDPARAMETERS_H
-#define VALIDPARAMETERS_H
-
-/*
- *  validparameter.h
- *  Dotur
- *
- *  Created by Sarah Westcott on 1/5/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "mothur.h"
-#include "mothurout.h"
-
-//This class contains a list of all valid parameters in Mothur.  
-//It has a function which will tell you if your parameter is valid.
-//When adding a new parameter you must add it to the valid list in the class constructor.
-
-
-class ValidParameters {
-
-       public:
-               ValidParameters();
-               ValidParameters(string);
-               ~ValidParameters();
-               //bool isValidParameter(string, string, string) {return true;}
-               bool isValidParameter(string, vector<string>, string);
-               vector <string> addParameters(string[], int);
-               void initParameterRanges();
-               string validFile(map<string, string>&, string, bool); //container, parameter, isFile, commandName
-
-       private:
-               map<string, string>::iterator it;
-               map<string, vector<string> > parameterRanges;
-               MothurOut* m;
-               string commandName;
-
-};
-
-#endif
diff --git a/venn.cpp b/venn.cpp
deleted file mode 100644 (file)
index 32ebb3c..0000000
--- a/venn.cpp
+++ /dev/null
@@ -1,842 +0,0 @@
-/*
- *  venn.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "venn.h"
-#include "ace.h"
-#include "sobs.h"
-#include "chao1.h"
-#include "nseqs.h"
-#include "sharedchao1.h"
-#include "sharedsobscollectsummary.h"
-
-
-//**********************************************************************************************************************
-Venn::Venn(string o, bool n, string f, int fs) : outputDir(o), nseqs(n), inputfile(f), fontSize(fs) {
-       try {
-               m = MothurOut::getInstance();
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Venn", "Venn");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> Venn::getPic(SAbundVector* sabund, vector<Calculator*> vCalcs) {
-       try {
-               
-               vector<string> outputNames;
-
-               for(int i=0;i<vCalcs.size();i++){
-                       string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + "." + sabund->getLabel() + "." + vCalcs[i]->getName() + ".svg";
-                       outputNames.push_back(filenamesvg);
-                       m->openOutputFile(filenamesvg, outsvg);
-                       
-                       if (m->control_pressed) { outsvg.close(); return outputNames; }
-
-                       vector<double> data = vCalcs[i]->getValues(sabund);
-                       
-                       int width = 1500;
-                       int height = 1500;
-                       
-                       //svg image
-                       outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \" >\n";
-                       outsvg << "<g>\n";
-                               
-                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + sabund->getLabel() + "</text>\n";
-                       outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" +  toString(int(0.50 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString((width / 2) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(data[0]) + "</text>\n";  
-                       
-                       if (data.size() == 3) { 
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.60 * height)) +  "\">The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.645 * height)) +  "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
-                       }
-                       
-                       if (nseqs) {
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.70 * height)) +  "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
-                       }
-                       
-                       outsvg << "</g>\n</svg>\n";
-                       outsvg.close();
-               }
-               
-               return outputNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Venn", "getPic");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-vector<string> Venn::getPic(vector<SharedRAbundVector*> lookup, vector<Calculator*> vCalcs) {
-       try {
-
-               vector<SharedRAbundVector*> subset;
-               vector<string> outputNames;
-               
-               int width = 1500;
-               int height = 1500;
-               
-               /******************* 1 Group **************************/
-               if (lookup.size() == 1) {
-                                       
-                       SAbundVector s;
-                       s = lookup[0]->getSAbundVector();  SAbundVector* sabund = &s;
-                       
-                       //make a file for each calculator
-                       for(int i=0;i<vCalcs.size();i++){
-                               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + ".svg";
-                               outputNames.push_back(filenamesvg);
-                               m->openOutputFile(filenamesvg, outsvg);
-                               
-                               if (m->control_pressed) { outsvg.close(); return outputNames; }
-                               
-                               //in essence you want to run it like a single 
-                               if (vCalcs[i]->getName() == "sharedsobs") {
-                                       singleCalc = new Sobs();
-                               }else if (vCalcs[i]->getName() == "sharedchao") {
-                                       singleCalc = new Chao1();
-                               }else if (vCalcs[i]->getName() == "sharedace") {
-                                       singleCalc = new Ace(10);
-                               }
-                               
-                               vector<double> data = singleCalc->getValues(sabund);
-                       
-                               //svg image
-                               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \">\n";
-                               outsvg << "<g>\n";
-                               
-                               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
-                               outsvg << "<circle fill=\"red\" opacity=\".5\" stroke=\"black\" cx=\"" +  toString(int(0.50 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.24 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.50 * width) - ((int)toString(data[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(data[0]) + "</text>\n";  
-                       
-                               if (data.size() == 3) { 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.60 * height)) +  "\" >The lower bound of the confidence interval is " + toString(data[1]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.645 * height)) +  "\">The upper bound of the confidence interval is " + toString(data[2]) + "</text>\n";
-                               }
-                               
-                               if (nseqs) {
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.35 * width)) +  "\" y=\"" +  toString(int(0.70 * height)) +  "\">The number of sequences represented is " + toString(sabund->getNumSeqs()) + "</text>\n";
-                               }
-                               
-                               outsvg << "</g>\n</svg>\n";
-                               outsvg.close();
-                               delete singleCalc;
-                               
-                       }
-               /******************* 2 Groups **************************/       
-               
-               }else if (lookup.size() == 2) {
-                       //get sabund vector pointers so you can use the single calculators
-                       //one for each group
-                       SAbundVector sA, sB;
-                       SAbundVector* sabundA; SAbundVector* sabundB;
-                       sabundA = new SAbundVector(lookup[0]->getSAbundVector());//  sabundA = &sA;
-                       sabundB = new SAbundVector(lookup[1]->getSAbundVector());//  sabundB = &sB;
-                       
-                       subset.clear();
-                       subset.push_back(lookup[0]); subset.push_back(lookup[1]);
-                       
-                       //make a file for each calculator
-                       for(int i=0;i<vCalcs.size();i++){
-                               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + ".svg";
-
-                               outputNames.push_back(filenamesvg);
-                               m->openOutputFile(filenamesvg, outsvg);
-                               
-                               if (m->control_pressed) { outsvg.close(); return outputNames; }
-                               
-                               //get estimates for sharedAB
-                               vector<double> shared = vCalcs[i]->getValues(subset);
-                               
-                               //in essence you want to run it like a single 
-                               if (vCalcs[i]->getName() == "sharedsobs") {
-                                       singleCalc = new Sobs();
-                               }else if (vCalcs[i]->getName() == "sharedchao") {
-                                       singleCalc = new Chao1();
-                               }//else if (vCalcs[i]->getName() == "sharedace") {
-                                       //singleCalc = new Ace(10);
-                               //}
-                               
-                               int sharedVal, numSeqsA, numSeqsB, uniqSeqsToA, uniqSeqsToB;
-                               if (nseqs) {
-                                       NSeqs* nseqsCalc = new NSeqs();
-                                       vector<double> data = nseqsCalc->getValues(lookup);
-                                       cout << data[0] << '\t' << data[1] << endl;
-                                       sharedVal = data[0] + data[1];
-                                       numSeqsA = sabundA->getNumSeqs();
-                                       numSeqsB = sabundB->getNumSeqs();
-                                       uniqSeqsToA = numSeqsA-data[0];
-                                       uniqSeqsToB = numSeqsB-data[1];
-                                       
-                                       delete nseqsCalc;
-                               }
-                               
-                               
-                               //get estimates for numA
-                               vector<double> numA = singleCalc->getValues(sabundA);
-
-                               //get estimates for numB
-                               vector<double> numB = singleCalc->getValues(sabundB);
-                                               
-                               //image window
-                               outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(height) + " \" >\n";
-                               outsvg << "<g>\n";
-
-                               //draw circles
-                               outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
-                               outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.36 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                               outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.62 * width)) +  "\" cy=\"" +  toString(int(0.29 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(numA[0] - shared[0]) + "</text>\n";
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(numB[0] - shared[0]) + "</text>\n"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.25 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.25 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n"; 
-                               outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(shared[0]).length() / 2)) + "\" y=\"" +  toString(int(0.28 * height)) +  "\">" + toString(shared[0]) + "</text>\n";  
-                               outsvg << "<text fill=\"black\" class=\"seri\"   font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.66 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
-                               if (numA.size() == 3) { 
-                                       outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
-                               }
-                               if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared";  }  
-                               outsvg << "</text>\n";
-               
-                               outsvg << "<text fill=\"black\" class=\"seri\"   font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.69 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
-                               if (numB.size() == 3) { 
-                                       outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
-                               }
-                               if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared";  }  
-                               outsvg << "</text>\n";
-
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.72 * height)) +  "\">The number of sepecies shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(shared[0]);
-                               if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal) + "; " + toString((sharedVal / (float)(numSeqsA + numSeqsB))*100) + "% of these sequences are shared";  }  
-                               outsvg << "</text>\n";
-                               
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">Percentage of species that are shared in groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString((shared[0] / (float)(numA[0] + numB[0] - shared[0]))*100) + "</text>\n";
-                               
-                               outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.78 * height)) +  "\">The total richness for all groups is " + toString((float)(numA[0] + numB[0] - shared[0]))+ "</text>\n";;
-                               
-                               
-                               //close file
-                               outsvg << "</g>\n</svg>\n";
-                               outsvg.close();
-                               delete singleCalc;
-                       }
-               /******************* 3 Groups **************************/
-                                               
-               }else if (lookup.size() == 3) {
-                       
-                       height = 1600;
-                       int windowSize = height;
-       
-                       
-                       //get sabund vector pointers so you can use the single calculators
-                       //one for each group
-                       SAbundVector sA, sB, sC;
-                       SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC;
-                       sA = lookup[0]->getSAbundVector();  sabundA = &sA;
-                       sB = lookup[1]->getSAbundVector();  sabundB = &sB;
-                       sC = lookup[2]->getSAbundVector();  sabundC = &sC;
-               
-                       //make a file for each calculator
-                       for(int i=0;i<vCalcs.size();i++){
-                       
-                               string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + ".svg";
-
-                               outputNames.push_back(filenamesvg);
-                               m->openOutputFile(filenamesvg, outsvg);
-                               
-                               if (m->control_pressed) { outsvg.close(); return outputNames; }
-                               
-                               int sharedVal, sharedABVal, sharedACVal, sharedBCVal, numSeqsA, numSeqsB, numSeqsC, uniqSeqsToA, uniqSeqsToB, uniqSeqsToC;
-                               
-                               if (nseqs) {
-                                       NSeqs* nseqsCalc = new NSeqs();
-                                       vector<double> sharedData = nseqsCalc->getValues(lookup);
-                                               
-                                       vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
-                                       vector<double> sharedAB = nseqsCalc->getValues(mysubset);
-                                               
-                                       mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
-                                       vector<double> sharedAC = nseqsCalc->getValues(mysubset);
-                                               
-                                       mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
-                                       vector<double> sharedBC = nseqsCalc->getValues(mysubset);
-                                               
-                                       sharedVal = sharedData[0] + sharedData[1] + sharedData[2];
-                                       sharedABVal = sharedAB[0] + sharedAB[1];
-                                       sharedACVal = sharedAC[0] + sharedAC[1];
-                                       sharedBCVal = sharedBC[0] + sharedBC[1];
-                                       numSeqsA = sabundA->getNumSeqs();
-                                       numSeqsB = sabundB->getNumSeqs();
-                                       numSeqsC = sabundC->getNumSeqs();
-                                       uniqSeqsToA = numSeqsA-sharedData[0];
-                                       uniqSeqsToB = numSeqsC-sharedData[1];
-                                       uniqSeqsToC = numSeqsB-sharedData[1];
-
-                                       delete nseqsCalc;
-                               }
-
-                               
-                               if (vCalcs[i]->getName() == "sharedace") {
-                               
-                                       singleCalc = new Ace(10);
-                                       
-                                       //get estimates for numA
-                                       vector<double> numA = singleCalc->getValues(sabundA);
-                       
-                                       //get estimates for numB
-                                       vector<double> numB = singleCalc->getValues(sabundB);
-                               
-                                       //get estimates for numC
-                                       vector<double> numC = singleCalc->getValues(sabundC);
-
-
-                                       //get estimates for sharedAB, sharedAC and sharedBC
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]);
-                                       vector<double> sharedAB = vCalcs[i]->getValues(subset);
-                                       
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[2]);
-                                       vector<double> sharedAC = vCalcs[i]->getValues(subset);
-                                       
-                                       subset.clear();
-                                       subset.push_back(lookup[1]); subset.push_back(lookup[2]);
-                                       vector<double> sharedBC = vCalcs[i]->getValues(subset);
-                                       
-                                       vector<double> sharedAwithBC;
-                                       vector<double> sharedBwithAC;
-                                       vector<double> sharedCwithAB;
-                                       
-                                       //find possible sharedABC values
-                                       float sharedABC1 = 0.0; float sharedABC2 = 0.0; float sharedABC3 = 0.0; float sharedABC = 0.0;
-
-                                       if (vCalcs[i]->getMultiple() == false) {
-                                               //merge BC and estimate with shared with A
-                                               SharedRAbundVector* merge = new SharedRAbundVector();
-                                               for (int j = 0; j < lookup[1]->size(); j++) {
-                                                       merge->push_back((lookup[1]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
-                                               }
-                                       
-                                               subset.clear();
-                                               subset.push_back(lookup[0]); subset.push_back(merge);
-                                               sharedAwithBC = vCalcs[i]->getValues(subset);
-                               
-                                               delete merge;
-                                               //merge AC and estimate with shared with B
-                                               merge = new SharedRAbundVector();
-                                               for (int j = 0; j < lookup[0]->size(); j++) {
-                                                       merge->push_back((lookup[0]->getAbundance(j) + lookup[2]->getAbundance(j)), "");
-                                               }
-                                       
-                                               subset.clear();
-                                               subset.push_back(merge); subset.push_back(lookup[1]);
-                                               sharedBwithAC = vCalcs[i]->getValues(subset);
-                               
-                                               delete merge;
-                                               //merge AB and estimate with shared with C
-                                               merge = new SharedRAbundVector();
-                                               for (int j = 0; j < lookup[0]->size(); j++) {
-                                                       merge->push_back((lookup[0]->getAbundance(j) + lookup[1]->getAbundance(j)), "");
-                                               }
-                                       
-                                               subset.clear();
-                                               subset.push_back(lookup[2]); subset.push_back(merge);
-                                               sharedCwithAB = vCalcs[i]->getValues(subset);
-                                               delete merge;
-                                       
-                                               sharedABC1 = sharedAB[0] + sharedAC[0] - sharedAwithBC[0];
-                                               sharedABC2 = sharedAB[0] + sharedBC[0] - sharedBwithAC[0];
-                                               sharedABC3 = sharedAC[0] + sharedBC[0] - sharedCwithAB[0];
-        
-                                               //if any of the possible m's are - throw them out
-                                               if (sharedABC1 < 0.00001) { sharedABC1 = 0; }
-                                               if (sharedABC2 < 0.00001) { sharedABC2 = 0; }
-                                               if (sharedABC3 < 0.00001) { sharedABC3 = 0; }
-                       
-                                               //sharedABC is the minimum of the 3 possibilities
-                                               if ((sharedABC1 < sharedABC2) && (sharedABC1 < sharedABC3)) { sharedABC = sharedABC1; }
-                                               else if ((sharedABC2 < sharedABC1) && (sharedABC2 < sharedABC3)) { sharedABC = sharedABC2; }
-                                               else if ((sharedABC3 < sharedABC1) && (sharedABC3 < sharedABC2)) { sharedABC = sharedABC3; }    
-                                       }else{
-                                               vector<double> data = vCalcs[i]->getValues(lookup);
-                                               sharedABC = data[0];
-                                               sharedAwithBC.push_back(sharedAB[0] + sharedAC[0] - sharedABC);
-                                               sharedBwithAC.push_back(sharedAB[0] + sharedBC[0] - sharedABC);
-                                               sharedCwithAB.push_back(sharedAC[0] + sharedBC[0] - sharedABC);
-                                       }
-                                       
-                                       //image window
-                                       outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
-                                       outsvg << "<g>\n";
-
-                                       //draw circles
-                                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.44 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
-                                       outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.33 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                                       outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.65 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                                       outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.5 * width)) +  "\" cy=\"" +  toString(int(0.5 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-
-                                       //place labels within overlaps
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)toString(numA[0]-sharedAwithBC[0]).length() / 2)) + "\" y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numA[0]-sharedAwithBC[0]) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.33 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB[0] - sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(sharedAB[0] - sharedABC) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(numB[0]-sharedBwithAC[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numB[0]-sharedBwithAC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedAC[0] - sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedAC[0] - sharedABC) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedCwithAB[0]).length() / 2)) + "\"   y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(numC[0]-sharedCwithAB[0]) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.52 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.58 * width) - ((int)toString(sharedBC[0] - sharedABC).length() / 2)) + "\" y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedBC[0] - sharedABC) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.34 * height)) +  "\">" + toString(sharedABC) + "</text>\n"; 
-                               
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and combined groups " + lookup[1]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedAwithBC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.925 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[2]->getGroup() + " is " + toString(sharedBwithAC[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.95 * height)) +  "\">The number of species shared between groups " + lookup[2]->getGroup() + " and combined groups " + lookup[0]->getGroup() + lookup[1]->getGroup() + " is " + toString(sharedCwithAB[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
-                                       if (numA.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
-                                       } 
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA) + "; " + toString(uniqSeqsToA) + " sequences are not shared";  }  
-                                       outsvg << "</text>\n";
-                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
-                                       if (numB.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
-                                       }
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB) + "; " + toString(uniqSeqsToB) + " sequences are not shared";  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
-                                       if (numC.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
-                                       }
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC) + "; " + toString(uniqSeqsToC) + " sequences are not shared";  }  
-                                       outsvg << "</text>\n";
-
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.80 * height)) +  "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedAB[0] - sharedAC[0] - sharedBC[0] + sharedABC) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.975 * height)) +  "\">The total shared richness is " + toString(sharedABC);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal);  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       delete singleCalc;
-                                       
-                               }else { //sharedchao and sharedsobs are multigroup
-                                       
-                                       vector<SharedRAbundVector*> subset;
-
-                                       //get estimates for numA
-                                       subset.push_back(lookup[0]);
-                                       vector<double> numA = vCalcs[i]->getValues(subset);
-                       
-                                       //get estimates for numB
-                                       subset.clear();
-                                       subset.push_back(lookup[1]);
-                                       vector<double> numB = vCalcs[i]->getValues(subset);
-                               
-                                       //get estimates for numC
-                                       subset.clear();
-                                       subset.push_back(lookup[2]);
-                                       vector<double> numC = vCalcs[i]->getValues(subset);
-
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]);
-                                       vector<double> sharedab =  vCalcs[i]->getValues(subset);
-                                       
-                                       subset.clear(); 
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[2]);
-                                       vector<double> sharedac =  vCalcs[i]->getValues(subset);
-                                       
-                                       subset.clear(); 
-                                       subset.push_back(lookup[1]); subset.push_back(lookup[2]);
-                                       vector<double> sharedbc =  vCalcs[i]->getValues(subset);
-                                       
-                                       subset.clear(); 
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
-                                       vector<double> sharedabc =  vCalcs[i]->getValues(subset);
-                                       
-                                       //image window
-                                       outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
-                                       outsvg << "<g>\n";
-
-                                       //draw circles
-                                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(height) +  "\"/>"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\">Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
-                                       outsvg << "<circle fill=\"rgb(255,0,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.33 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                                       outsvg << "<circle fill=\"rgb(0,255,0)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.65 * width)) +  "\" cy=\"" +  toString(int(0.25 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-                                       outsvg << "<circle fill=\"rgb(0,0,255)\" opacity=\".3\" stroke=\"black\" cx=\"" +  toString(int(0.5 * width)) +  "\" cy=\"" +  toString(int(0.5 * height)) +  "\" r=\"" +  toString(int(0.22 * width)) +  "\"/>"; 
-
-                                       //place labels within overlaps
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]).length() / 2)) + "\" y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numA[0]-sharedab[0]-sharedac[0]+sharedabc[0]) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.29 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedab[0] - sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(sharedab[0] - sharedabc[0]) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.22 * height)) +  "\">" + toString(numB[0]-sharedab[0]-sharedbc[0]+sharedabc[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.68 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.19 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.38 * width) - ((int)toString(sharedac[0] - sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedac[0] - sharedabc[0]) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.5 * width) - ((int)toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]).length() / 2)) + "\"   y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(numC[0]-sharedac[0]-sharedbc[0]+sharedabc[0]) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.5 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.51 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.59 * width) - ((int)toString(sharedbc[0] - sharedabc[0]).length() / 2)) + "\" y=\"" +  toString(int(0.38 * height)) +  "\">" + toString(sharedbc[0] - sharedabc[0]) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedabc[0]).length() / 2)) + "\"  y=\"" +  toString(int(0.35 * height)) +  "\">" + toString(sharedabc[0]) + "</text>\n"; 
-                               
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedab[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedac[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedbc[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA[0]);
-                                       if (numA.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numA[1]) + " and the hci is " + toString(numA[2]);
-                                       }
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
-                                       outsvg << "</text>\n";
-                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB[0]);
-                                       if (numB.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numB[1]) + " and the hci is " + toString(numB[2]);
-                                       }
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
-                                       outsvg << "</text>\n";
-                                                                               
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC[0]);
-                                       if (numC.size() == 3) { 
-                                               outsvg << " the lci is " + toString(numC[1]) + " and the hci is " + toString(numC[2]);
-                                       }
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC);  }  
-                                       outsvg << "</text>\n";
-
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.8 * height)) +  "\">The total richness of all the groups is " + toString(numA[0] + numB[0] + numC[0] - sharedab[0] - sharedac[0] - sharedbc[0] + sharedabc[0]) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">The total shared richness is " + toString(sharedabc[0]);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedVal);  }  
-                                       outsvg << "</text>\n";
-
-                               }
-                                                               
-                               //close file
-                               outsvg << "</g>\n</svg>\n";
-                               outsvg.close();
-                               
-
-                       }
-                       
-               /******************* 4 Groups **************************/
-               
-               }else if (lookup.size() == 4) {
-                       
-                       height = 1600;
-                       
-                       int windowSize = height;
-               
-                       //calc the shared otu
-                       float sharedABCD = 0;
-                       float numA = 0; float numB = 0; float numC = 0; float numD = 0;
-                       float sharedAB = 0; float sharedAC = 0; float sharedBC = 0; float sharedAD = 0; float sharedBD = 0; float sharedCD = 0;
-                       float sharedABC = 0; float sharedACD = 0; float sharedBCD = 0; float sharedABD = 0;
-                       vector<double> data;
-                       //get sabund vector pointers so you can use the single calculators
-                       //one for each group
-                       SAbundVector sA, sB, sC, sD;
-                       SAbundVector* sabundA; SAbundVector* sabundB; SAbundVector* sabundC; SAbundVector* sabundD;
-                       sA = lookup[0]->getSAbundVector();  sabundA = &sA;
-                       sB = lookup[1]->getSAbundVector();  sabundB = &sB;
-                       sC = lookup[2]->getSAbundVector();  sabundC = &sC;
-                       sD = lookup[3]->getSAbundVector();  sabundD = &sD;
-                       
-                       //A = red, B = green, C = blue, D = yellow
-                       
-                       //make a file for each calculator
-                       for(int i=0;i<vCalcs.size();i++){
-                               
-                               if ((vCalcs[i]->getName() != "sharedsobs") && (vCalcs[i]->getName() != "sharedchao")) { m->mothurOut(vCalcs[i]->getName() + " is not a valid calculator with four groups.  It will be disregarded. "); m->mothurOutEndLine(); }
-                               else{
-                                       string filenamesvg = outputDir + m->getRootName(m->getSimpleName(inputfile)) + lookup[0]->getLabel() + "." + vCalcs[i]->getName() + "." + lookup[0]->getGroup() + "-" + lookup[1]->getGroup() + "-" + lookup[2]->getGroup() + "-" + lookup[3]->getGroup() + ".svg";
-                                       outputNames.push_back(filenamesvg);
-                                       m->openOutputFile(filenamesvg, outsvg);
-
-                                       if (m->control_pressed) { outsvg.close(); return outputNames; }
-                                       
-                                       //in essence you want to run it like a single 
-                                       if (vCalcs[i]->getName() == "sharedsobs") {
-                                               singleCalc = new Sobs();
-                                       }else if (vCalcs[i]->getName() == "sharedchao") {
-                                               singleCalc = new Chao1();
-                                       }
-                               
-                                       //get estimates for numA
-                                       data = singleCalc->getValues(sabundA);
-                                       numA = data[0];
-       //cout << "num a = " << numA << endl;   
-                       
-                                       //get estimates for numB
-                                       data = singleCalc->getValues(sabundB);
-                                       numB = data[0];
-       //cout << "num b = " << numB << endl;                           
-                                       //get estimates for numC
-                                       data = singleCalc->getValues(sabundC);
-                                       numC = data[0];
-       //cout << "num c = " << numC << endl;                           
-                                       //get estimates for numD
-                                       data = singleCalc->getValues(sabundD);
-                                       numD = data[0];
-//cout << "num d = " << numD << endl;  
-
-                                       //get estimates for pairs
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedAB = data[0];
-       //cout << "num ab = " << sharedAB << endl;                      
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[2]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedAC = data[0];
-       //cout << "num ac = " << sharedAC << endl;                              
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedAD = data[0];
-       //cout << "num ad = " << sharedAD << endl;                      
-                                       subset.clear();
-                                       subset.push_back(lookup[1]); subset.push_back(lookup[2]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedBC = data[0];
-       //cout << "num bc = " << sharedBC << endl;                              
-                                       subset.clear();
-                                       subset.push_back(lookup[1]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedBD = data[0];
-               //cout << "num bd = " << sharedBD << endl;                                              
-                                       subset.clear();
-                                       subset.push_back(lookup[2]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedCD = data[0];
-                                               
-       //cout << "num cd = " << sharedCD << endl;                              
-                                       //get estimates for combos of 3
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[2]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedABC = data[0];
-               //cout << "num abc = " << sharedABC << endl;                                    
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedACD = data[0];
-                       //cout << "num acd = " << sharedACD << endl;    
-                                       subset.clear();
-                                       subset.push_back(lookup[1]); subset.push_back(lookup[2]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedBCD = data[0];
-               //cout << "num bcd = " << sharedBCD << endl;            
-                                       subset.clear();
-                                       subset.push_back(lookup[0]); subset.push_back(lookup[1]); subset.push_back(lookup[3]);
-                                       data = vCalcs[i]->getValues(subset);
-                                       sharedABD = data[0];
-//cout << "num abd = " << sharedABD << endl;
-                                       //get estimate for all four
-                                       data = vCalcs[i]->getValues(lookup);
-                                       sharedABCD = data[0];
-               //cout << "num abcd = " << sharedABCD << endl << endl;  
-                                       int sharedVal, sharedABCVal, sharedABDVal, sharedACDVal, sharedBCDVal, sharedABVal, sharedACVal, sharedADVal, sharedBCVal, sharedBDVal, sharedCDVal, numSeqsA, numSeqsB, numSeqsC, numSeqsD;
-                                                                                               
-                                       if (nseqs) {
-                                               NSeqs* nseqsCalc = new NSeqs();
-                                               vector<double> sharedData = nseqsCalc->getValues(lookup);
-                                               
-                                               vector<SharedRAbundVector*> mysubset; mysubset.push_back(lookup[0]); mysubset.push_back(lookup[1]);
-                                               vector<double> sharedAB = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[2]);
-                                               vector<double> sharedAC = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[0]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedAD = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
-                                               vector<double> sharedBC = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedBD = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedCD = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[1]); mysubset.push_back(lookup[2]);
-                                               vector<double> sharedABC = nseqsCalc->getValues(mysubset);
-                                               
-                                               mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[1]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedABD = nseqsCalc->getValues(mysubset);
-
-                                               mysubset.clear(); mysubset.push_back(lookup[0]);  mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedACD = nseqsCalc->getValues(mysubset);
-
-                                               mysubset.clear(); mysubset.push_back(lookup[1]);  mysubset.push_back(lookup[2]); mysubset.push_back(lookup[3]);
-                                               vector<double> sharedBCD = nseqsCalc->getValues(mysubset);
-                                               
-                                               sharedVal = sharedData[0] + sharedData[1] + sharedData[2] + sharedData[3];
-                                               sharedABCVal = sharedABC[0] + sharedABC[1] + sharedABC[2];
-                                               sharedABDVal = sharedABD[0] + sharedABD[1] + sharedABD[2];
-                                               sharedACDVal = sharedACD[0] + sharedACD[1] + sharedACD[2];
-                                               sharedBCDVal = sharedBCD[0] + sharedBCD[1] + sharedBCD[2];
-                                               sharedABVal = sharedAB[0] + sharedAB[1];
-                                               sharedACVal = sharedAC[0] + sharedAC[1];
-                                               sharedADVal = sharedAD[0] + sharedAD[1];
-                                               sharedBCVal = sharedBC[0] + sharedBC[1];
-                                               sharedBDVal = sharedBD[0] + sharedBD[1];
-                                               sharedCDVal = sharedCD[0] + sharedCD[1];
-                                               numSeqsA = sabundA->getNumSeqs(); 
-                                               numSeqsB = sabundB->getNumSeqs(); 
-                                               numSeqsC = sabundC->getNumSeqs(); 
-                                               numSeqsD = sabundD->getNumSeqs(); 
-                                               
-                                               delete nseqsCalc;
-                                       }
-
-                                               
-                                       //image window
-                                       outsvg << "<svg xmlns:svg=\"http://www.w3.org/2000/svg\" xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 " +  toString(width) + " " + toString(windowSize) + " \" >\n";
-                                       outsvg << "<g>\n";
-                                       outsvg << "<rect fill=\"white\" stroke=\"white\" x=\"0\" y=\"0\" width=\"" +  toString(width) +  "\" height=\"" +  toString(windowSize) +  "\"/>"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.40 * width)) +  "\" y=\"" +  toString(int(0.05 * height)) +  "\" >Venn Diagram at distance " + lookup[0]->getLabel() + "</text>\n";
-
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\"  y=\"" +  toString(int(0.625 * height)) +  "\">The number of species in group " + lookup[0]->getGroup() + " is " + toString(numA); 
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsA);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.65 * height)) +  "\">The number of species in group " + lookup[1]->getGroup() + " is " + toString(numB);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsB);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.675 * height)) +  "\">The number of species in group " + lookup[2]->getGroup() + " is " + toString(numC);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsC);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.7 * height)) +  "\">The number of species in group " + lookup[3]->getGroup() + " is " + toString(numD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(numSeqsD);  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.725 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[1]->getGroup() + " is " + toString(sharedAB);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.75 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedAC);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.775 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedAD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedADVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.8 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedBC);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.825 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBDVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.85 * height)) +  "\">The number of species shared between groups " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedCD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedCDVal);  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.875 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[2]->getGroup() + " is " + toString(sharedABC);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABCVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.9 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[1]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedABD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedABDVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.925 * height)) +  "\">The number of species shared between groups " + lookup[0]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedACD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedACDVal);  }  
-                                       outsvg << "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\"  font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.95 * height)) +  "\">The number of species shared between groups " + lookup[1]->getGroup() + ", " + lookup[2]->getGroup() + " and " + lookup[3]->getGroup() + " is " + toString(sharedBCD);
-                                       if (nseqs) {  outsvg << ", and the number of squences is " + toString(sharedBCDVal);  }  
-                                       outsvg << "</text>\n";
-                                                                       
-                                       //make adjustments
-                                       sharedABC = sharedABC - sharedABCD;
-                       //cout << "num abc = " << sharedABC << endl;            
-                                       sharedABD = sharedABD - sharedABCD;
-                               //cout << "num abd = " << sharedABD << endl;
-                                       sharedACD = sharedACD - sharedABCD;
-                               //cout << "num acd = " << sharedACD << endl;
-                                       sharedBCD = sharedBCD - sharedABCD;
-                               //cout << "num bcd = " << sharedBCD << endl;
-                                       
-                                       sharedAB = sharedAB - sharedABC - sharedABCD - sharedABD;  //cout << "num ab = " << sharedAB << endl;
-                                       sharedAC = sharedAC - sharedABC - sharedABCD - sharedACD;  //cout << "num ac = " << sharedAC << endl;
-                                       sharedAD = sharedAD - sharedABD - sharedABCD - sharedACD;  //cout << "num ad = " << sharedAD << endl;                           
-                                       sharedBC = sharedBC - sharedABC - sharedABCD - sharedBCD;  //cout << "num bc = " << sharedBC << endl;
-                                       sharedBD = sharedBD - sharedABD - sharedABCD - sharedBCD; // cout << "num bd = " << sharedBD << endl; 
-                                       sharedCD = sharedCD - sharedACD - sharedABCD - sharedBCD;  //cout << "num cd = " << sharedCD << endl;
-                                       
-                                       numA = numA - sharedAB - sharedAC - sharedAD - sharedABCD - sharedABC - sharedACD - sharedABD;
-                       //cout << "num a = " << numA << endl;           
-                                       numB = numB - sharedAB - sharedBC - sharedBD - sharedABCD - sharedABC - sharedABD - sharedBCD;
-                       //cout << "num b = " << numB << endl;           
-                                       numC = numC - sharedAC - sharedBC - sharedCD - sharedABCD - sharedABC - sharedACD - sharedBCD;
-                       //cout << "num c = " << numC << endl;           
-                                       numD = numD - sharedAD - sharedBD - sharedCD - sharedABCD - sharedBCD - sharedACD - sharedABD;
-                       //cout << "num d = " << numD << endl;           
-                                       
-                                       //draw circles
-                                       outsvg << "<ellipse fill=\"red\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-45 " +  toString(int(0.51 * width)) +  " " +  toString(int(0.27 * height)) +  ") \" cx=\"" +  toString(int(0.51 * width)) +  "\" cy=\"" +  toString(int(0.27 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n "; 
-                                       outsvg << "<ellipse fill=\"green\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+45 " +  toString(int(0.51 * width)) +  " " +  toString(int(0.27 * height)) +  ") \" cx=\"" +  toString(int(0.51 * width)) +  "\" cy=\"" +  toString(int(0.27 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
-                                       outsvg << "<ellipse fill=\"blue\" stroke=\"black\" opacity=\".35\" transform=\"rotate(-40 " +  toString(int(0.63 * width)) +  " " +  toString(int(0.36 * height)) +  ") \" cx=\"" +  toString(int(0.63 * width)) +  "\" cy=\"" +  toString(int(0.36 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
-                                       outsvg << "<ellipse fill=\"yellow\" stroke=\"black\" opacity=\".35\" transform=\"rotate(+40 " +  toString(int(0.36 * width)) +  " " +  toString(int(0.36 * height)) +  ") \" cx=\"" +  toString(int(0.36 * width)) +  "\" cy=\"" +  toString(int(0.36 * height)) +  "\" rx=\"" +  toString(int(0.29 * width)) +  "\" ry=\"" +  toString(int(0.14 * height)) +  "\"/>\n ";
-                       
-                                       //A = red, B = green, C = blue, D = yellow
-                       
-                                       //place labels within overlaps
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)toString(numA).length() / 2)) + "\" y=\"" +  toString(int(0.14 * height)) +  "\">" + toString(numA)  + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.66 * width) - ((int)lookup[0]->getGroup().length() / 2)) + "\" y=\"" +  toString(int(0.11 * height)) +  "\">" + lookup[0]->getGroup() + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedAB).length() / 2)) + "\"  y=\"" +  toString(int(0.2 * height)) +  "\">" + toString(sharedAB) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)toString(numB).length() / 2)) + "\"  y=\"" +  toString(int(0.14 * height)) +  "\">" + toString(numB)  + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.36 * width) - ((int)lookup[1]->getGroup().length() / 2)) + "\"  y=\"" +  toString(int(0.11 * height)) +  "\">" + lookup[1]->getGroup() + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.7 * width) - ((int)toString(sharedAC).length() / 2)) + "\"  y=\"" +  toString(int(0.24 * height)) +  "\">" + toString(sharedAC) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.785 * width) - ((int)toString(numC).length() / 2)) + "\"   y=\"" +  toString(int(0.29 * height)) +  "\">" + toString(numC) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.785 * width) - ((int)lookup[2]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.26 * height)) +  "\">" + lookup[2]->getGroup() + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.31 * width) - ((int)toString(sharedBD).length() / 2)) + "\" y=\"" +  toString(int(0.24 * height)) +  "\">" + toString(sharedBD) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.22 * width) - ((int)toString(numD).length() / 2)) + "\"   y=\"" +  toString(int(0.29 * height)) +  "\">" + toString(numD) + "</text>\n";  
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\"  x=\"" + toString(int(0.22 * width) - ((int)lookup[3]->getGroup().length() / 2)) + "\"   y=\"" +  toString(int(0.26 * height)) +  "\">" + lookup[3]->getGroup() + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.34 * width) - ((int)toString(sharedAD).length() / 2)) + "\" y=\"" +  toString(int(0.41 * height)) +  "\">" + toString(sharedAD) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.675 * width) - ((int)toString(sharedBC).length() / 2)) + "\" y=\"" +  toString(int(0.41 * height)) +  "\">" + toString(sharedBC) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedCD).length() / 2)) + "\" y=\"" +  toString(int(0.54 * height)) +  "\">" + toString(sharedCD) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.39 * width) - ((int)toString(sharedABD).length() / 2)) + "\" y=\"" +  toString(int(0.3 * height)) +  "\">" + toString(sharedABD) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.57 * width) - ((int)toString(sharedBCD).length() / 2)) + "\" y=\"" +  toString(int(0.45 * height)) +  "\">" + toString(sharedBCD) + "</text>\n";
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.435 * width) - ((int)toString(sharedACD).length() / 2)) + "\" y=\"" +  toString(int(0.45 * height)) +  "\">" + toString(sharedACD) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.63 * width) - ((int)toString(sharedABC).length() / 2)) + "\"  y=\"" +  toString(int(0.3 * height)) +  "\">" + toString(sharedABC) + "</text>\n"; 
-                                       outsvg << "<text fill=\"black\" class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" + toString(int(0.5 * width) - ((int)toString(sharedABCD).length() / 2)) + "\"  y=\"" +  toString(int(0.4 * height)) +  "\">" + toString(sharedABCD) + "</text>\n"; 
-                                       
-                                       outsvg << "<text fill=\"black\"  class=\"seri\" font-size=\"" + toString(fontSize) + "\" x=\"" +  toString(int(0.25 * width)) +  "\" y=\"" +  toString(int(0.975 * height)) +  "\">The total richness of all the groups is " + toString((float)(numA + numB + numC + numD + sharedAB + sharedAC + sharedAD + sharedBC + sharedBD + sharedCD + sharedABC + sharedABD + sharedACD + sharedBCD + sharedABCD));
-                                       if (nseqs) {  outsvg << ", and the number of squences in the otus shared by all groups is " + toString(sharedVal);  }  
-                                       outsvg << "</text>\n";
-                                       
-                                       outsvg << "</g>\n</svg>\n";
-                                       outsvg.close();
-                                       delete singleCalc;
-                               }
-                       }
-               }
-               
-               return outputNames;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Venn", "getPic");
-               exit(1);
-       }
-}
-
-
diff --git a/venn.h b/venn.h
deleted file mode 100644 (file)
index 50d49d1..0000000
--- a/venn.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef VENN_H
-#define VENN_H
-/*
- *  venn.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "sabundvector.hpp"
-#include "sharedrabundvector.h"
-#include "datavector.hpp"
-#include "calculator.h"
-
-
-/***********************************************************************/
-
-class Venn {
-public:
-       Venn(string, bool, string, int);
-       ~Venn(){};
-
-       vector<string> getPic(SAbundVector*, vector<Calculator*>);
-       vector<string> getPic(vector<SharedRAbundVector*>, vector<Calculator*>);
-
-private:
-       Calculator* singleCalc;
-       string groupComb, outputDir, inputfile;
-       ofstream outsvg;
-       MothurOut* m;
-       bool nseqs;
-       int fontSize;
-};
-
-/***********************************************************************/
-
-#endif
-
diff --git a/venncommand.cpp b/venncommand.cpp
deleted file mode 100644 (file)
index 1b4e3bc..0000000
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- *  venncommand.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "venncommand.h"
-#include "ace.h"
-#include "sobs.h"
-#include "chao1.h"
-//#include "jackknife.h"
-#include "sharedsobscollectsummary.h"
-#include "sharedchao1.h"
-#include "sharedace.h"
-#include "nseqs.h"
-
-//**********************************************************************************************************************
-vector<string> VennCommand::setParameters(){   
-       try {
-               CommandParameter plist("list", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(plist);
-               CommandParameter pshared("shared", "InputTypes", "", "", "LRSS", "LRSS", "none",false,false); parameters.push_back(pshared);    
-               CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
-               CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
-               CommandParameter pcalc("calc", "String", "", "", "", "", "",false,false); parameters.push_back(pcalc);
-               CommandParameter pabund("abund", "Number", "", "10", "", "", "",false,false); parameters.push_back(pabund);
-               CommandParameter pnseqs("nseqs", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(pnseqs);
-               CommandParameter pfontsize("fontsize", "Number", "", "24", "", "", "",false,false); parameters.push_back(pfontsize);
-               CommandParameter ppermute("permute", "Boolean", "", "F", "", "", "",false,false); parameters.push_back(ppermute);
-               CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
-               CommandParameter poutputdir("outputdir", "String", "", "", "", "", "",false,false); parameters.push_back(poutputdir);
-               
-               vector<string> myArray;
-               for (int i = 0; i < parameters.size(); i++) {   myArray.push_back(parameters[i].name);          }
-               return myArray;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "setParameters");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-string VennCommand::getHelpString(){   
-       try {
-               string helpString = "";
-               helpString += "The venn command parameters are list, shared, groups, calc, abund, nseqs, permute, fontsize and label.   shared, relabund, list, rabund or sabund is required unless you have a valid current file.\n";
-               helpString += "The groups parameter allows you to specify which of the groups in your groupfile you would like included in your venn diagram, you may only use a maximum of 4 groups.\n";
-               helpString += "The group names are separated by dashes. The label allows you to select what distance levels you would like a venn diagram created for, and are also separated by dashes.\n";
-               helpString += "The fontsize parameter allows you to adjust the font size of the picture created, default=24.\n";
-               helpString += "The venn command should be in the following format: venn(groups=yourGroups, calc=yourCalcs, label=yourLabels, abund=yourAbund).\n";
-               helpString += "Example venn(groups=A-B-C, calc=sharedsobs-sharedchao, abund=20).\n";
-               helpString += "The default value for groups is all the groups in your groupfile up to 4, and all labels in your inputfile will be used.\n";
-               helpString += "The default value for calc is sobs if you have only read a list file or if you have selected only one group, and sharedsobs if you have multiple groups.\n";
-               helpString += "The default available estimators for calc are sobs, chao and ace if you have only read a list file, and sharedsobs, sharedchao and sharedace if you have read a shared file.\n";
-               helpString += "The nseqs parameter will output the number of sequences represented by the otus in the picture, default=F.\n";
-               helpString += "If you have more than 4 groups, the permute parameter will find all possible combos of 4 of your groups and create pictures for them, default=F.\n";
-               helpString += "The only estimators available four 4 groups are sharedsobs and sharedchao.\n";
-               helpString += "The venn command outputs a .svg file for each calculator you specify at each distance you choose.\n";
-               helpString += "Note: No spaces between parameter labels (i.e. groups), '=' and parameters (i.e.yourGroups).\n";
-               return helpString;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "getHelpString");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
-VennCommand::VennCommand(){    
-       try {
-               abort = true; calledHelp = true; 
-               setParameters();
-               vector<string> tempOutNames;
-               outputTypes["svg"] = tempOutNames;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "VennCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-VennCommand::VennCommand(string option)  {
-       try {
-               abort = false; calledHelp = false;   
-               allLines = 1;
-                       
-               //allow user to run help
-               if(option == "help") { help(); abort = true; calledHelp = true; }
-               else if(option == "citation") { citation(); abort = true; calledHelp = true;}
-               
-               else {
-                       vector<string> myArray = setParameters();
-                       
-                       OptionParser parser(option);
-                       map<string,string> parameters = parser.getParameters();
-                       map<string,string>::iterator it;
-                       
-                       ValidParameters validParameter;
-                       
-                       //check to make sure all parameters are valid for command
-                       for (map<string,string>::iterator it = parameters.begin(); it != parameters.end(); it++) { 
-                               if (validParameter.isValidParameter(it->first, myArray, it->second) != true) {  abort = true;  }
-                       }
-                       
-                       //if the user changes the input directory command factory will send this info to us in the output parameter 
-                       string inputDir = validParameter.validFile(parameters, "inputdir", false);              
-                       if (inputDir == "not found"){   inputDir = "";          }
-                       else {
-                               string path;
-                               it = parameters.find("shared");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["shared"] = inputDir + it->second;           }
-                               }
-                               
-                               it = parameters.find("list");
-                               //user has given a template file
-                               if(it != parameters.end()){ 
-                                       path = m->hasPath(it->second);
-                                       //if the user has not given a path then, add inputdir. else leave path alone.
-                                       if (path == "") {       parameters["list"] = inputDir + it->second;             }
-                               }
-                       }
-                       
-                       //check for required parameters
-                       listfile = validParameter.validFile(parameters, "list", true);
-                       if (listfile == "not open") { listfile = ""; abort = true; }
-                       else if (listfile == "not found") { listfile = ""; }
-                       else {  format = "list"; inputfile = listfile; m->setListFile(listfile); }
-                       
-                       sharedfile = validParameter.validFile(parameters, "shared", true);
-                       if (sharedfile == "not open") { sharedfile = ""; abort = true; }        
-                       else if (sharedfile == "not found") { sharedfile = ""; }
-                       else {  format = "sharedfile"; inputfile = sharedfile; m->setSharedFile(sharedfile); }
-                       
-                       if ((sharedfile == "") && (listfile == "")) { 
-                               //is there are current file available for any of these?
-                               //give priority to shared, then list, then rabund, then sabund
-                               //if there is a current shared file, use it
-                               sharedfile = m->getSharedFile(); 
-                               if (sharedfile != "") { inputfile = sharedfile; format = "sharedfile"; m->mothurOut("Using " + sharedfile + " as input file for the shared parameter."); m->mothurOutEndLine(); }
-                               else { 
-                                       listfile = m->getListFile(); 
-                                       if (listfile != "") { inputfile = listfile; format = "list"; m->mothurOut("Using " + listfile + " as input file for the list parameter."); m->mothurOutEndLine(); }
-                                       else { 
-                                               m->mothurOut("No valid current files. You must provide a list or shared file."); m->mothurOutEndLine(); 
-                                               abort = true;
-                                       }
-                               }
-                       }
-                       
-                       //if the user changes the output directory command factory will send this info to us in the output parameter 
-                       outputDir = validParameter.validFile(parameters, "outputdir", false);           if (outputDir == "not found"){  outputDir = m->hasPath(inputfile);              }
-
-                       //check for optional parameter and set defaults
-                       // ...at some point should added some additional type checking...
-                       label = validParameter.validFile(parameters, "label", false);                   
-                       if (label == "not found") { label = ""; }
-                       else { 
-                               if(label != "all") {  m->splitAtDash(label, labels);  allLines = 0;  }
-                               else { allLines = 1;  }
-                       }
-                       
-                       groups = validParameter.validFile(parameters, "groups", false);                 
-                       if (groups == "not found") { groups = ""; }
-                       else { 
-                               m->splitAtDash(groups, Groups);
-                               m->setGroups(Groups);
-                       }
-                       
-                       calc = validParameter.validFile(parameters, "calc", false);                     
-                       if (calc == "not found") { 
-                               if(format == "list") { calc = "sobs"; }
-                               else { calc = "sharedsobs"; }
-                       }
-                       else { 
-                                if (calc == "default")  {  
-                                       if(format == "list") { calc = "sobs"; }
-                                       else { calc = "sharedsobs"; }
-                               }
-                       }
-                       m->splitAtDash(calc, Estimators);
-                       if (m->inUsersGroups("citation", Estimators)) { 
-                               ValidCalculators validCalc; validCalc.printCitations(Estimators); 
-                               //remove citation from list of calcs
-                               for (int i = 0; i < Estimators.size(); i++) { if (Estimators[i] == "citation") {  Estimators.erase(Estimators.begin()+i); break; } }
-                       }
-                       
-                       string temp;
-                       temp = validParameter.validFile(parameters, "abund", false);            if (temp == "not found") { temp = "10"; }
-                       m->mothurConvert(temp, abund); 
-                       
-                       temp = validParameter.validFile(parameters, "nseqs", false);            if (temp == "not found"){       temp = "f";                             }
-                       nseqs = m->isTrue(temp); 
-
-                       temp = validParameter.validFile(parameters, "permute", false);          if (temp == "not found"){       temp = "f";                             }
-                       perm = m->isTrue(temp); 
-                       
-                       temp = validParameter.validFile(parameters, "fontsize", false);         if (temp == "not found") { temp = "24"; }
-                       m->mothurConvert(temp, fontsize);
-
-               }
-                               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "VennCommand");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-
-int VennCommand::execute(){
-       try {
-       
-               if (abort == true) { if (calledHelp) { return 0; }  return 2;   }
-       
-               ValidCalculators validCalculator;
-                                       
-               if (format == "list") {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("vennsingle", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "sobs") { 
-                                               vennCalculators.push_back(new Sobs());
-                                       }else if (Estimators[i] == "chao") { 
-                                               vennCalculators.push_back(new Chao1());
-                                       }else if (Estimators[i] == "ace") {
-                                               if(abund < 5)
-                                                       abund = 10;
-                                               vennCalculators.push_back(new Ace(abund));
-                                       }
-                               }
-                       }
-               }else {
-                       for (int i=0; i<Estimators.size(); i++) {
-                               if (validCalculator.isValidCalculator("vennshared", Estimators[i]) == true) { 
-                                       if (Estimators[i] == "sharedsobs") { 
-                                               vennCalculators.push_back(new SharedSobsCS());
-                                       }else if (Estimators[i] == "sharedchao") { 
-                                               vennCalculators.push_back(new SharedChao1());
-                                       }else if (Estimators[i] == "sharedace") { 
-                                               vennCalculators.push_back(new SharedAce());
-                                       }
-                               }
-                       }
-               }
-                       
-               //if the users entered no valid calculators don't execute command
-               if (vennCalculators.size() == 0) { m->mothurOut("No valid calculators given, please correct."); m->mothurOutEndLine(); return 0;  }
-               
-               venn = new Venn(outputDir, nseqs, inputfile, fontsize); 
-               input = new InputData(inputfile, format);
-               
-               string lastLabel;
-               
-               if (format == "sharedfile") {
-                       lookup = input->getSharedRAbundVectors();
-                       lastLabel = lookup[0]->getLabel();
-                       
-                       if ((lookup.size() > 4) && (perm)) { combosOfFour = findCombinations(lookup.size()); }
-               }else if (format == "list") {
-                       sabund = input->getSAbundVector();
-                       lastLabel = sabund->getLabel();
-               }
-               
-               //if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
-               set<string> processedLabels;
-               set<string> userLabels = labels;
-
-               if (format != "list") { 
-                       
-                       //as long as you are not at the end of the file or done wih the lines you want
-                       while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                               if (m->control_pressed) {
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                                       m->clearGroups(); delete venn; delete input;
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       return 0;
-                               }
-
-                               if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){                  
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-                                       
-                                       if ((lookup.size() > 4) && (!perm)){
-                                               m->mothurOut("Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile. If you set perm=t, I will find all possible combos of 4 groups."); m->mothurOutEndLine();
-                                               for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
-                                       
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  } }
-
-                                       }else if ((lookup.size() > 4) && (perm)) {
-                                               set< set<int> >::iterator it3;
-                                               set<int>::iterator it2;
-                                               for (it3 = combosOfFour.begin(); it3 != combosOfFour.end(); it3++) {  
-                       
-                                                       set<int> poss = *it3;
-                                                       vector<SharedRAbundVector*> subset;
-                                                       for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
-                                                       
-                                                       vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
-                                               }               
-                                       }else {
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-                                       }                                       
-                               }
-                               
-                               if ((m->anyLabelsToProcess(lookup[0]->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = lookup[0]->getLabel();
-                                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-
-                                       if ((lookup.size() > 4) && (!perm)){
-                                               m->mothurOut("Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile. If you set perm=t, I will find all possible combos of 4 groups."); m->mothurOutEndLine();
-                                               for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
-                                       
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-
-                                       }else if ((lookup.size() > 4) && (perm)) {
-                                               set< set<int> >::iterator it3;
-                                               set<int>::iterator it2;
-                                               for (it3 = combosOfFour.begin(); it3 != combosOfFour.end(); it3++) {  
-                       
-                                                       set<int> poss = *it3;
-                                                       vector<SharedRAbundVector*> subset;
-                                                       for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
-                                                       
-                                                       vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-                                               }               
-                                       }else {
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-                                       }
-                                                                               
-                                       //restore real lastlabel to save below
-                                       lookup[0]->setLabel(saveLabel);
-                               }
-                               
-                               
-                               lastLabel = lookup[0]->getLabel();      
-                                               
-                               //get next line to process
-                               for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                               lookup = input->getSharedRAbundVectors();
-                       }
-                       
-                       if (m->control_pressed) {
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       m->clearGroups(); delete venn; delete input; 
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       return 0;
-                       }
-
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-               
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                                       for (int i = 0; i < lookup.size(); i++) {  if (lookup[i] != NULL) {     delete lookup[i]; }  } 
-                                       lookup = input->getSharedRAbundVectors(lastLabel);
-
-                                       m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
-                                       processedLabels.insert(lookup[0]->getLabel());
-                                       userLabels.erase(lookup[0]->getLabel());
-
-                                       if ((lookup.size() > 4) && (!perm)){
-                                               m->mothurOut("Error: Too many groups chosen.  You may use up to 4 groups with the venn command.  I will use the first four groups in your groupfile. If you set perm=t, I will find all possible combos of 4 groups."); m->mothurOutEndLine();
-                                               for (int i = lookup.size(); i > 4; i--) { lookup.pop_back(); } //no memmory leak because pop_back calls destructor
-                                       
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
-
-                                       }else if ((lookup.size() > 4) && (perm)) {
-                                               set< set<int> >::iterator it3;
-                                               set<int>::iterator it2;
-                                               for (it3 = combosOfFour.begin(); it3 != combosOfFour.end(); it3++) {  
-                       
-                                                       set<int> poss = *it3;
-                                                       vector<SharedRAbundVector*> subset;
-                                                       for (it2 = poss.begin(); it2 != poss.end(); it2++) {   subset.push_back(lookup[*it2]);   }
-                                                       
-                                                       vector<string> outfilenames = venn->getPic(subset, vennCalculators);
-                                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]); }  }
-                                               }               
-                                       }else {
-                                               vector<string> outfilenames = venn->getPic(lookup, vennCalculators);
-                                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-                                       }
-                                       
-                                       for (int i = 0; i < lookup.size(); i++) {  delete lookup[i];  } 
-                       }
-               
-
-                       //reset groups parameter
-                       m->clearGroups();  
-                       
-                       if (m->control_pressed) {
-                                       m->clearGroups(); delete venn; delete input;
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       return 0;
-                       }
-
-                       
-               }else{
-               
-                       while((sabund != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
-                       
-                               if (m->control_pressed) {
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       delete sabund; delete venn; delete input;
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       return 0;
-                               }
-               
-                               if(allLines == 1 || labels.count(sabund->getLabel()) == 1){                     
-       
-                                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                                       vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-
-                                       
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                               }
-                               
-                               if ((m->anyLabelsToProcess(sabund->getLabel(), userLabels, "") == true) && (processedLabels.count(lastLabel) != 1)) {
-                                       string saveLabel = sabund->getLabel();
-                               
-                                       delete sabund;
-                                       sabund = input->getSAbundVector(lastLabel);
-                                       
-                                       m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                                       vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                                       for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-
-                                       
-                                       processedLabels.insert(sabund->getLabel());
-                                       userLabels.erase(sabund->getLabel());
-                                       
-                                       //restore real lastlabel to save below
-                                       sabund->setLabel(saveLabel);
-                               }               
-                               
-                               lastLabel = sabund->getLabel();         
-                               
-                               delete sabund;
-                               sabund = input->getSAbundVector();
-                       }
-                       
-                       if (m->control_pressed) {
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       delete venn; delete input;
-                                       return 0;
-                       }
-                       
-                       //output error messages about any remaining user labels
-                       set<string>::iterator it;
-                       bool needToRun = false;
-                       for (it = userLabels.begin(); it != userLabels.end(); it++) {  
-                               m->mothurOut("Your file does not include the label " + *it); 
-                               if (processedLabels.count(lastLabel) != 1) {
-                                       m->mothurOut(". I will use " + lastLabel + "."); m->mothurOutEndLine();
-                                       needToRun = true;
-                               }else {
-                                       m->mothurOut(". Please refer to " + lastLabel + "."); m->mothurOutEndLine();
-                               }
-                       }
-               
-                       //run last label if you need to
-                       if (needToRun == true)  {
-                               if (sabund != NULL) {   delete sabund;  }
-                               sabund = input->getSAbundVector(lastLabel);
-                                       
-                               m->mothurOut(sabund->getLabel()); m->mothurOutEndLine();
-                               vector<string> outfilenames = venn->getPic(sabund, vennCalculators);
-                               for(int i = 0; i < outfilenames.size(); i++) { if (outfilenames[i] != "control" ) { outputNames.push_back(outfilenames[i]);  outputTypes["svg"].push_back(outfilenames[i]);  }  }
-
-                               delete sabund;
-                                       
-                       }
-                       
-                       if (m->control_pressed) {
-                                       delete venn; delete input;
-                                       for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-                                       for (int i = 0; i < outputNames.size(); i++) {  m->mothurRemove(outputNames[i]);  }
-                                       return 0;
-                       }
-               }
-               
-               for (int i = 0; i < vennCalculators.size(); i++) {      delete vennCalculators[i];      }
-               delete venn; delete input;
-               
-               m->mothurOutEndLine();
-               m->mothurOut("Output File Names: "); m->mothurOutEndLine();
-               for (int i = 0; i < outputNames.size(); i++) {  m->mothurOut(outputNames[i]); m->mothurOutEndLine();    }
-               m->mothurOutEndLine();
-
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "execute");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//returns a vector of sets containing the 4 group combinations
-set< set<int> > VennCommand::findCombinations(int lookupSize){
-       try {
-               set< set<int> > combos;
-               
-               set<int> possibles;
-               for (int i = 0; i < lookupSize; i++) {  possibles.insert(i);  }
-               
-               getCombos(possibles, combos);
-               
-               return combos;
-               
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "findCombinations");
-               exit(1);
-       }
-}
-//**********************************************************************************************************************
-//recusively finds combos of 4
-int VennCommand::getCombos(set<int> possibles, set< set<int> >& combos){
-       try {
-               
-               if (possibles.size() == 4) { //done
-                       if (combos.count(possibles) == 0) { //no dups
-                               combos.insert(possibles);
-                       }
-               }else { //we still have work to do
-                       set<int>::iterator it;
-                       set<int>::iterator it2;
-                       for (it = possibles.begin(); it != possibles.end(); it++) {  
-                               
-                               set<int> newPossibles;
-                               for (it2 = possibles.begin(); it2 != possibles.end(); it2++) {  //all possible combos of one length smaller
-                                       if (*it != *it2) { 
-                                               newPossibles.insert(*it2);
-                                       }
-                               }
-                               getCombos(newPossibles, combos);
-                       }
-               }
-               
-               return 0;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "VennCommand", "getCombos");
-               exit(1);
-       }
-}
-
-//**********************************************************************************************************************
diff --git a/venncommand.h b/venncommand.h
deleted file mode 100644 (file)
index ae3c121..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef VENNCOMMAND_H
-#define VENNCOMMAND_H
-/*
- *  venncommand.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 3/30/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "command.hpp"
-#include "inputdata.h"
-#include "sharedlistvector.h"
-#include "venn.h"
-#include "validcalculator.h"
-
-class VennCommand : public Command {
-
-public:
-       VennCommand(string);
-       VennCommand();
-       ~VennCommand() {}
-       
-       vector<string> setParameters();
-       string getCommandName()                 { return "venn";                                        }
-       string getCommandCategory()             { return "OTU-Based Approaches";        }
-       string getHelpString(); 
-       string getCitation() { return "http://www.mothur.org/wiki/Venn"; }
-       string getDescription()         { return "generates a Venn diagram from data provided in a shared file"; }
-
-       int execute(); 
-       void help() { m->mothurOut(getHelpString()); }  
-       
-private:
-       InputData* input;
-       SharedListVector* SharedList;
-       Venn* venn;
-       vector<Calculator*> vennCalculators;    
-       vector<SharedRAbundVector*> lookup;
-       set< set<int> > combosOfFour;
-       SAbundVector* sabund;
-       int abund, fontsize;
-       
-       bool abort, allLines, nseqs, perm;
-       set<string> labels; //holds labels to be used
-       string format, groups, calc, label, outputDir, sharedfile, listfile, inputfile;
-       vector<string> Estimators, Groups, outputNames;
-       
-       set< set<int> > findCombinations(int);
-       int getCombos(set<int>, set< set<int> >&);
-
-
-};
-
-
-
-#endif
diff --git a/weighted.cpp b/weighted.cpp
deleted file mode 100644 (file)
index 85eed52..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- *  weighted.cpp
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "weighted.h"
-
-/**************************************************************************************************/
-
-EstOutput Weighted::getValues(Tree* t, int p, string o) {
-    try {
-               data.clear(); //clear out old values
-               int numGroups;
-               vector<double> D;
-               processors = p;
-               outputDir = o;
-        
-        TreeMap* tmap = t->getTreeMap();
-               
-               numGroups = m->getNumGroups();
-               
-               if (m->control_pressed) { return data; }
-               
-               //calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
-               vector< vector<string> > namesOfGroupCombos;
-               for (int i=0; i<numGroups; i++) { 
-                       for (int l = 0; l < i; l++) {   
-                               //initialize weighted scores
-                               //WScore[globaldata->Groups[i]+globaldata->Groups[l]] = 0.0;
-                               vector<string> groups; groups.push_back((m->getGroups())[i]); groups.push_back((m->getGroups())[l]);
-                               namesOfGroupCombos.push_back(groups);
-                       }
-               }
-               
-               #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-                       if(processors == 1){
-                               data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-                       }else{
-                               int numPairs = namesOfGroupCombos.size();
-                               
-                               int numPairsPerProcessor = numPairs / processors;
-                               
-                               for (int i = 0; i < processors; i++) {
-                                       int startPos = i * numPairsPerProcessor;
-                                       if(i == processors - 1){
-                                               numPairsPerProcessor = numPairs - i * numPairsPerProcessor;
-                                       }
-                                       lines.push_back(linePair(startPos, numPairsPerProcessor));
-                               }
-
-                               data = createProcesses(t, namesOfGroupCombos, tmap);
-                               
-                               lines.clear();
-                       }
-               #else
-                       data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), tmap);
-               #endif
-               
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Weighted", "getValues");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-EstOutput Weighted::createProcesses(Tree* t, vector< vector<string> > namesOfGroupCombos, TreeMap* tmap) {
-       try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix)
-               int process = 1;
-               vector<int> processIDS;
-               
-               EstOutput results;
-               
-               //loop through and create all the processes you want
-               while (process != processors) {
-                       int pid = fork();
-                       
-                       if (pid > 0) {
-                               processIDS.push_back(pid);  //create map from line number to pid so you can append files in correct order later
-                               process++;
-                       }else if (pid == 0){
-       
-                               EstOutput Myresults;
-                               Myresults = driver(t, namesOfGroupCombos, lines[process].start, lines[process].num, tmap);
-                       
-                               //m->mothurOut("Merging results."); m->mothurOutEndLine();
-                               
-                               //pass numSeqs to parent
-                               ofstream out;
-
-                               string tempFile = outputDir + toString(getpid()) + ".weighted.results.temp";
-       
-                               m->openOutputFile(tempFile, out);
-       
-                               out << Myresults.size() << endl;
-                               for (int i = 0; i < Myresults.size(); i++) {  out << Myresults[i] << '\t';  } out << endl;
-                               out.close();
-                               
-                               exit(0);
-                       }else { 
-                               m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); 
-                               for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); }
-                               exit(0);
-                       }
-               }
-       
-               results = driver(t, namesOfGroupCombos, lines[0].start, lines[0].num, tmap);
-       
-               //force parent to wait until all the processes are done
-               for (int i=0;i<(processors-1);i++) { 
-                       int temp = processIDS[i];
-                       wait(&temp);
-               }
-       
-               if (m->control_pressed) { return results; }
-               
-               //get data created by processes
-               for (int i=0;i<(processors-1);i++) { 
-                       ifstream in;
-                       string s = outputDir + toString(processIDS[i]) + ".weighted.results.temp";
-                       m->openInputFile(s, in);
-                       
-                       //get quantiles
-                       while (!in.eof()) {
-                               int num;
-                               in >> num; m->gobble(in);
-                               
-                               if (m->control_pressed) { break; }
-
-                               double w; 
-                               for (int j = 0; j < num; j++) {
-                                       in >> w;
-                                       results.push_back(w);
-                               }
-                               m->gobble(in);
-                       }
-                       in.close();
-                       m->mothurRemove(s);
-               }
-               
-               //m->mothurOut("DONE."); m->mothurOutEndLine(); m->mothurOutEndLine();
-               
-               return results;
-#endif         
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Weighted", "createProcesses");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-EstOutput Weighted::driver(Tree* t, vector< vector<string> > namesOfGroupCombos, int start, int num, TreeMap* tmap) { 
- try {
-               EstOutput results;
-               vector<double> D;
-               
-               int count = 0;
-               for (int h = start; h < (start+num); h++) {
-               
-                       if (m->control_pressed) { return results; }
-               
-                       //initialize weighted score
-                       string groupA = namesOfGroupCombos[h][0]; 
-                       string groupB = namesOfGroupCombos[h][1];
-                       
-                       set<int> validBranches;
-                       WScore[groupA+groupB] = 0.0;
-                       D.push_back(0.0000); //initialize a spot in D for each combination
-                       
-                       //adding the wieghted sums from group i
-                       for (int j = 0; j < t->groupNodeInfo[groupA].size(); j++) { //the leaf nodes that have seqs from group i
-                               map<string, int>::iterator it = t->tree[t->groupNodeInfo[groupA][j]].pcount.find(groupA);
-                               int numSeqsInGroupI = it->second;
-                               
-                               double sum = getLengthToRoot(t, t->groupNodeInfo[groupA][j], groupA, groupB);
-                               double weightedSum = ((numSeqsInGroupI * sum) / (double)tmap->seqsPerGroup[groupA]);
-                       
-                               D[count] += weightedSum;
-                       }
-                       
-                       //adding the wieghted sums from group l
-                       for (int j = 0; j < t->groupNodeInfo[groupB].size(); j++) { //the leaf nodes that have seqs from group l
-                               map<string, int>::iterator it = t->tree[t->groupNodeInfo[groupB][j]].pcount.find(groupB);
-                               int numSeqsInGroupL = it->second;
-                               
-                               double sum = getLengthToRoot(t, t->groupNodeInfo[groupB][j], groupA, groupB);
-                               double weightedSum = ((numSeqsInGroupL * sum) / (double)tmap->seqsPerGroup[groupB]);
-                       
-                               D[count] += weightedSum;
-                       }
-                       count++;
-               }
-        
-               //calculate u for the group comb 
-               for (int h = start; h < (start+num); h++) {     
-                       //report progress
-                       //m->mothurOut("Processing combo: " + toString(h)); m->mothurOutEndLine();
-                                               
-                       string groupA = namesOfGroupCombos[h][0]; 
-                       string groupB = namesOfGroupCombos[h][1];
-                       
-                       //calculate u for the group comb 
-                       for(int i=0;i<t->getNumNodes();i++){
-                               
-                               if (m->control_pressed) { return data; }
-                               
-                               double u;
-                               //int pcountSize = 0;
-                               //does this node have descendants from groupA
-                               it = t->tree[i].pcount.find(groupA);
-                               //if it does u = # of its descendants with a certain group / total number in tree with a certain group
-                               if (it != t->tree[i].pcount.end()) {
-                                       u = (double) t->tree[i].pcount[groupA] / (double) tmap->seqsPerGroup[groupA];
-                               }else { u = 0.00; }
-                               
-                               
-                               //does this node have descendants from group l
-                               it = t->tree[i].pcount.find(groupB);
-                               
-                               //if it does subtract their percentage from u
-                               if (it != t->tree[i].pcount.end()) {
-                                       u -= (double) t->tree[i].pcount[groupB] / (double) tmap->seqsPerGroup[groupB];
-                               }
-                               
-                               if (includeRoot) {
-                                       if (t->tree[i].getBranchLength() != -1) {
-                                               u = abs(u * t->tree[i].getBranchLength());
-                                               WScore[(groupA+groupB)] += u; 
-                                       }
-                               }else {
-                                       //if this is not the root then add it
-                                       if (rootForGrouping[namesOfGroupCombos[h]].count(i) == 0) {
-                                               if (t->tree[i].getBranchLength() != -1) {
-                                                       u = abs(u * t->tree[i].getBranchLength());
-                                                       WScore[(groupA+groupB)] += u; 
-                                               }
-                                       }
-                               }
-                       }
-                       
-               }
-               
-               /********************************************************/
-               //calculate weighted score for the group combination
-               double UN;      
-               count = 0;
-               for (int h = start; h < (start+num); h++) {
-                       UN = (WScore[namesOfGroupCombos[h][0]+namesOfGroupCombos[h][1]] / D[count]);
-                       if (isnan(UN) || isinf(UN)) { UN = 0; } 
-                       results.push_back(UN);
-                       count++;
-               }
-                               
-               return results; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Weighted", "driver");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-EstOutput Weighted::getValues(Tree* t, string groupA, string groupB) { 
- try {
-               
-               data.clear(); //clear out old values
-     
-        TreeMap* tmap = t->getTreeMap();
-               
-               if (m->control_pressed) { return data; }
-               
-               //initialize weighted score
-               WScore[(groupA+groupB)] = 0.0;
-               double D = 0.0;
-               set<int> validBranches;
-               
-               vector<string> groups; groups.push_back(groupA); groups.push_back(groupB);
-               
-               //adding the wieghted sums from group i
-               for (int j = 0; j < t->groupNodeInfo[groups[0]].size(); j++) { //the leaf nodes that have seqs from group i
-                       map<string, int>::iterator it = t->tree[t->groupNodeInfo[groups[0]][j]].pcount.find(groups[0]);
-                       int numSeqsInGroupI = it->second;
-                       
-                       double sum = getLengthToRoot(t, t->groupNodeInfo[groups[0]][j], groups[0], groups[1]);
-                       double weightedSum = ((numSeqsInGroupI * sum) / (double)tmap->seqsPerGroup[groups[0]]);
-               
-                       D += weightedSum;
-               }
-               
-               //adding the wieghted sums from group l
-               for (int j = 0; j < t->groupNodeInfo[groups[1]].size(); j++) { //the leaf nodes that have seqs from group l
-                       map<string, int>::iterator it = t->tree[t->groupNodeInfo[groups[1]][j]].pcount.find(groups[1]);
-                       int numSeqsInGroupL = it->second;
-                       
-                       double sum = getLengthToRoot(t, t->groupNodeInfo[groups[1]][j], groups[0], groups[1]);
-                       double weightedSum = ((numSeqsInGroupL * sum) / (double)tmap->seqsPerGroup[groups[1]]);
-               
-                       D += weightedSum;
-               }
-                               
-               //calculate u for the group comb 
-               for(int i=0;i<t->getNumNodes();i++){
-                
-                       if (m->control_pressed) { return data; }
-                       
-                       double u;
-                       //int pcountSize = 0;
-                       //does this node have descendants from groupA
-                       it = t->tree[i].pcount.find(groupA);
-                       //if it does u = # of its descendants with a certain group / total number in tree with a certain group
-                       if (it != t->tree[i].pcount.end()) {
-                               u = (double) t->tree[i].pcount[groupA] / (double) tmap->seqsPerGroup[groupA];
-                       }else { u = 0.00; }
-                       
-                       
-                       //does this node have descendants from group l
-                       it = t->tree[i].pcount.find(groupB);
-                       //if it does subtract their percentage from u
-                       if (it != t->tree[i].pcount.end()) {
-                               u -= (double) t->tree[i].pcount[groupB] / (double) tmap->seqsPerGroup[groupB];
-                       }
-                       
-                       if (includeRoot) {
-                               if (t->tree[i].getBranchLength() != -1) {
-                                       u = abs(u * t->tree[i].getBranchLength());
-                                       WScore[(groupA+groupB)] += u;
-                               }
-                       }else{
-                               //if this is not the root then add it
-                               if (rootForGrouping[groups].count(i) == 0) {
-                                       if (t->tree[i].getBranchLength() != -1) {
-                                               u = abs(u * t->tree[i].getBranchLength());
-                                               WScore[(groupA+groupB)] += u;
-                                       }
-                               }
-                       }
-               }               
-               /********************************************************/
-        
-               //calculate weighted score for the group combination
-               double UN;      
-               UN = (WScore[(groupA+groupB)] / D);
-               
-               if (isnan(UN) || isinf(UN)) { UN = 0; } 
-               data.push_back(UN);
-                               
-               return data; 
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Weighted", "getValues");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-double Weighted::getLengthToRoot(Tree* t, int v, string groupA, string groupB) { 
-       try {
-               
-               double sum = 0.0;
-               int index = v;
-       
-               //you are a leaf
-               if(t->tree[index].getBranchLength() != -1){     sum += abs(t->tree[index].getBranchLength());   }
-               double tempTotal = 0.0;
-               index = t->tree[index].getParent();     
-               
-               vector<string> grouping; grouping.push_back(groupA); grouping.push_back(groupB);
-               
-               rootForGrouping[grouping].insert(index);
-                       
-               //while you aren't at root
-               while(t->tree[index].getParent() != -1){
-
-                       if (m->control_pressed) {  return sum; }
-                       
-                       int parent = t->tree[index].getParent();
-                       
-                       if (includeRoot) { //add everyone
-                               if(t->tree[index].getBranchLength() != -1){     sum += abs(t->tree[index].getBranchLength());   }
-                       }else {
-                               
-                               //am I the root for this grouping? if so I want to stop "early"
-                               //does my sibling have descendants from the users groups? 
-                               int lc = t->tree[parent].getLChild();
-                               int rc = t->tree[parent].getRChild();
-                               
-                               int sib = lc;
-                               if (lc == index) { sib = rc; }
-                               
-                               map<string, int>::iterator itGroup;
-                               int pcountSize = 0;
-                               itGroup = t->tree[sib].pcount.find(groupA);
-                               if (itGroup != t->tree[sib].pcount.end()) { pcountSize++;  } 
-                               itGroup = t->tree[sib].pcount.find(groupB);
-                               if (itGroup != t->tree[sib].pcount.end()) { pcountSize++;  } 
-                               
-                               //if yes, I am not the root so add me
-                               if (pcountSize != 0) {
-                                       if (t->tree[index].getBranchLength() != -1) {
-                                               sum += abs(t->tree[index].getBranchLength()) + tempTotal;
-                                               tempTotal = 0.0;
-                                       }else {
-                                               sum += tempTotal;
-                                               tempTotal = 0.0;
-                                       }
-                                       rootForGrouping[grouping].clear();
-                                       rootForGrouping[grouping].insert(parent);
-                               }else { //if no, I may be the root so add my br to tempTotal until I am proven innocent
-                                       if (t->tree[index].getBranchLength() != -1) {
-                                               tempTotal += abs(t->tree[index].getBranchLength()); 
-                                       }
-                               }
-                       }
-                       
-                       index = parent; 
-               }
-               
-               //get all nodes above the root to add so we don't add their u values above
-               index = *(rootForGrouping[grouping].begin());
-               
-               while(t->tree[index].getParent() != -1){
-                       int parent = t->tree[index].getParent();
-                       rootForGrouping[grouping].insert(parent);
-                       index = parent;
-               }
-               return sum;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Weighted", "getBranchLengthSums");
-               exit(1);
-       }
-}
-/**************************************************************************************************/
-
-
diff --git a/weighted.h b/weighted.h
deleted file mode 100644 (file)
index 180409c..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef WEIGHTED_H
-#define WEIGHTED_H
-
-
-/*
- *  weighted.h
- *  Mothur
- *
- *  Created by Sarah Westcott on 2/9/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-
-#include "treecalculator.h"
-#include "treemap.h"
-
-/***********************************************************************/
-
-class Weighted : public TreeCalculator  {
-       
-       public:
-        Weighted( bool r) : includeRoot(r) {};
-               ~Weighted() {};
-               
-               EstOutput getValues(Tree*, string, string);
-               EstOutput getValues(Tree*, int, string);
-               
-       private:
-               struct linePair {
-                       int start;
-                       int num;
-                       linePair(int i, int j) : start(i), num(j) {}
-               };
-               vector<linePair> lines;
-
-               EstOutput data;
-               map<string, int>::iterator it;
-               map<string, double> WScore; //a score for each group combination i.e. AB, AC, BC.
-               int processors;
-               string outputDir;
-               map< vector<string>, set<int> > rootForGrouping;  //maps a grouping combo to the root for that combo
-               bool includeRoot;
-               
-               EstOutput driver(Tree*, vector< vector<string> >, int, int, TreeMap*); 
-               EstOutput createProcesses(Tree*, vector< vector<string> >, TreeMap*);
-               double getLengthToRoot(Tree*, int, string, string);
-};
-
-/***********************************************************************/
-
-
-#endif
diff --git a/weightedlinkage.cpp b/weightedlinkage.cpp
deleted file mode 100644 (file)
index 0851bd7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef WEIGHTEDLINKAGE_H
-#define WEIGHTEDLINKAGE_H
-
-
-#include "mothur.h"
-#include "cluster.hpp"
-#include "rabundvector.hpp"
-#include "sparsematrix.hpp"
-
-/* This class implements the WPGMA, weighted average neighbor clustering algorithm */
-
-/***********************************************************************/
-
-WeightedLinkage::WeightedLinkage(RAbundVector* rav, ListVector* lv, SparseMatrix* dm, float c, string s) :
-       Cluster(rav, lv, dm, c, s)
-{
-       saveRow = -1;
-       saveCol = -1;
-}
-
-
-/***********************************************************************/
-//This function returns the tag of the method.
-string WeightedLinkage::getTag() {
-       return("wn");
-}
-
-
-/***********************************************************************/
-//This function updates the distance based on the average linkage method.
-bool WeightedLinkage::updateDistance(MatData& colCell, MatData& rowCell) {
-       try {
-               if ((saveRow != smallRow) || (saveCol != smallCol)) {
-//                     rowBin = rabund->get(smallRow);
-//                     colBin = rabund->get(smallCol);
-//                     totalBin = rowBin + colBin;
-                       saveRow = smallRow;
-                       saveCol = smallCol;
-               }
-               
-               colCell->dist = (colCell->dist + rowCell->dist) / 2.0;
-               
-               return(true);
-       }
-       catch(exception& e) {
-               m->errorOut(e, "WeightedLinkage", "updateDistance");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
-
-
-/***********************************************************************/
-
-#endif
diff --git a/whittaker.cpp b/whittaker.cpp
deleted file mode 100644 (file)
index 5ab1e5d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- *  whittaker.cpp
- *  Mothur
- *
- *  Created by Pat Schloss on 4/23/09.
- *  Copyright 2009 Patrick D. Schloss. All rights reserved.
- *
- */
-
-#include "whittaker.h"
-
-/***********************************************************************/
-
-EstOutput Whittaker::getValues(vector<SharedRAbundVector*> shared){
-       try{
-               data.resize(1);
-
-               int countA = 0;
-               int countB = 0;
-               int sTotal = shared[0]->getNumBins();
-               for(int i=0;i<sTotal;i++){
-                       if(shared[0]->getAbundance(i) != 0){    countA++;       }
-                       if(shared[1]->getAbundance(i) != 0){    countB++;       }               
-               }
-               
-               data[0] = 2-2*sTotal/(float)(countA+countB);
-               return data;
-       }
-       catch(exception& e) {
-               m->errorOut(e, "Whittaker", "getValues");
-               exit(1);
-       }
-}
-
-/***********************************************************************/
diff --git a/whittaker.h b/whittaker.h
deleted file mode 100644 (file)
index 3bbd94a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef WHITTAKER_H
-#define WHITTAKER_H
-/*
- *  whittaker.h
- *  Mothur
- *
- *  Created by Thomas Ryabin on 3/13/09.
- *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
- *
- */
-#include "calculator.h"
-
-/*This class implements the Whittaker estimator on 2 groups. 
- It is a child of the calculator class.*/ 
-
-/***********************************************************************/
-
-class Whittaker : public Calculator  {
-       
-public:
-       Whittaker() : Calculator("whittaker", 1, false) {};
-       EstOutput getValues(SAbundVector*) {return data;};
-       EstOutput getValues(vector<SharedRAbundVector*>);
-       string getCitation() { return "http://www.mothur.org/wiki/Whittaker"; }
-
-};
-
-/***********************************************************************/
-
-#endif