<tool id="Site_frequency_spectra" name="Site_frequency_spectra" version="2.5">
	<description>- Generate spectrums -</description>

	<requirements>
		<requirement type="binary">Site_frequency_spectra</requirement>
	</requirements>
	
	<command>
		Site_frequency_spectra -alignment_file=$pfas_file
		
		#if $cond_focal_species.focal_select == "user_defined":
		 -ingroup=$cond_focal_species.focal_custom_name
		#else:
		 -ingroup=$cond_focal_species.focal_dropdown_list
		#end if
		
		#if $cond_out_species.out_select != "no_outgroup"
			#if $cond_out_species.out_select == "user_defined":
			 -outgroup=$cond_out_species.out_custom_name
			#else:
			 -outgroup=$cond_out_species.out_dropdown_list
			#end if
		#end if
		
		 -gapN_site=$gapN_site -gapN_seq=$gapN_seq -min_nb_codon=$min_codon -remove_frameshift=$frameshift
		 -tolerance_zone=$tolerance_zone -allow_internal_bc=$internal_bad_codons -sample_size=$sample_size -kappa=$kappa
		 -dfea_write_start=$dfea_start -dfea_min_NS_SNP=$dfea_min
		 -exec_mode=galaxy 1> $SFS_log 2> $SFS_error
	</command>

	<inputs>
		<param name="pfas_file" type="data" label="Input Fasta/PseudoFasta file" format="fasta" help="Requested file type: fasta" />

		<conditional name="cond_focal_species">
			<param name="focal_select" type="select" label="Enter a custom focal species name or choose one from PopPhyl Focal Species List ">
				<option value="user_defined">Enter a custom focal species name</option>
				<option value="popphyl_list" selected="true">Choose a species name in PopPhyl Focal Species List</option>
			</param>
			<when value="user_defined">
				<param name="focal_custom_name" type="text" label="Name of the focal species for this analysis" optional="true" help="In general, species name use the following format: Gender_species (Example: Ostrea_edulis)" />
			</when>
			<when value="popphyl_list">
				<param name="focal_dropdown_list" type="select" label="Name of the focal species for this analysis" optional="true" help="Type the first letters of the desired species name to narrow the list">
					<options from_data_table="popphyl_species" />
				</param>
			</when>
		</conditional>
		
		<conditional name="cond_out_species">
			<param name="out_select" type="select" label="Do you want to use a second species as outgroup ?">
				<option value="no_outgroup">No (Analyze focal species only)</option>
				<option value="user_defined">Yes - Custom species name</option>
				<option value="popphyl_list" selected="true">Yes - Choose a species name in PopPhyl Species List</option>
			</param>
			<when value="no_outgroup"></when>
			<when value="user_defined">
				<param name="out_custom_name" type="text" label="Name of the outgroup species for this analysis" optional="true" help="In general, species name use the following format: Gender_species (Example: Ostrea_chilensis)" />
			</when>
			<when value="popphyl_list">
				<param name="out_dropdown_list" type="select" label="Name of the outgroup species for this analysis" optional="true" help="Type the first letters of the desired species name to narrow the list">
					<options from_data_table="popphyl_species" />
				</param>
			</when>
		</conditional>
		
		<param name="gapN_site" type="integer" label="Minimum number of focal sequences without an undetermined character (or a gap) required to keep a given site" value="10" help="Field type: integer - Exemple: 10 if you have 10 focal individuals with 2 alleles each" />
		<param name="gapN_seq" type="float" label="Maximum tolerated proportion of undetermined characters (or gap) to keep a given sequence" value="0.5" help="Field type: float" />
		
		<param name="min_codon" type="integer" label="Minimum number of complete codons required to perform calculations" value="10" help="Field type: positive integer" />
		<param name="kappa" type="integer" label="Kappa to use in SequenceStatistics methods" value="1" help="Field type: positive integer" />
		
		<param name="frameshift" type="select" label="Frameshift management" help="">
			<option value="1">Remove frameshift-containing contigs</option>
			<option value="0" selected="true">Keep frameshift-containing contigs</option>
		</param>
		
		<param name="tolerance_zone" type="integer" label="Number of terminal positions in which Stop/Frameshift codons will be tolerated" value="20" help="Field type: positive integer" />
		
		<param name="internal_bad_codons" type="select" label="Internal Stop/Frameshift codons" help="">
			<option value="1">tolerated</option>
			<option value="0" selected="true">forbidden</option>
		</param>

		<param name="sample_size" type="integer" label="Desired sample size" value="12" help="Field type: positive integer - It should be lower than or equal to the maximum number of focal individual" />
		
		<param name="dfea_start" type="integer" label="Matrix rows with a number lower than this parameter will not be written in the output file" value="5" help="Field type: positive integer" />
		<param name="dfea_min" type="integer" label="Minimum number of Non Synonymous SNP per gene copy" value="10" help="Field type: positive integer" />
	</inputs>
	
	<outputs>
		<data name="SFS_log" label="SFS - Log file" format="txt" />
		<data name="SFS_error" label="SFS - Error file" format="txt" />
		<data name="Site_frequency_spectra_SFS" from_work_dir="Site_frequency_spectra_SFS" label="SFS - Main output" format="txt" />
		<data name="Site_frequency_spectra_SFS_DFEa" from_work_dir="Site_frequency_spectra_SFS_DFEa" label="SFS - DFEa" format="txt" />
		<data name="Site_frequency_spectra_SFS_DoFE" from_work_dir="Site_frequency_spectra_SFS_DoFE" label="SFS - DoFE" format="txt" />
		<data name="Site_frequency_spectra_Summary" from_work_dir="Site_frequency_spectra_Summary" label="SFS - SNP Data Summary" format="txt" />
	</outputs>
	
	<help>
		This program can be used to generate various site frequency spectrums from a multiple alignment file in Fasta/PseudoFasta format.
	</help>
</tool>
