80 likes | 192 Views
Command line parsing Morten Nielsen BioSys, DTU. Example. Blast command-line options. blastpgp - blastpgp 2.2.18 arguments: -d Database [String] default = nr -i Query File (not needed if restarting from scoremat) [File In] Optional default = stdin
E N D
Example. Blast command-line options blastpgp - blastpgp 2.2.18 arguments: -d Database [String] default = nr -i Query File (not needed if restarting from scoremat) [File In] Optional default = stdin -A Multiple Hits window size [Integer] default = 40 -f Threshold for extending hits [Integer] default = 11 -e Expectation value (E) [Real] default = 10.0 -m alignment view options: ....
How is command-line done in C? /* M.Nielsen July 2008, mniel@cbs.dtu.dk */ #include <stdio.h> main( int argc, char *argv[] ) { printf( "Hello World\n" ); }
What are: int argc, char *argv[]? fasta_align -m BLOSUM50 -gf 5 -gn 1 1PLC._.fsa 1PLB._.fsa Argc: Number of argument. Here 9 First argument is program name Argv: Parameter names argv[0] = fasta_align_db argv[1] = -m fasta_align_db -m BLOSUM50 -gf 5 -gn 1 1PLC._.fsa 1PLB._.fsa argv[0] argv[1] argv[2] argv[6] argv[7] argv[8] argv[4] argv[3] argv[5]
Example (The parser! ) fasta_align -m BLOSUM62 1PLC._.fsa 1PLB._.fsa float p_gapf; float p_gapn; int p_minall; FILENAME p_blmat; int p_verbose; PARAM param[] = { "-gf", VFLOAT p_gapf, "penalty for first gap", "11", "-gn", VFLOAT p_gapn, "penalty for next gap", "1", "-mal", VINT p_minall, "Minimum alignment lenght", "3", "-m", VFNAME p_blmat, "Alignment matrix", "BLOSUM50", "-v", VSWITCH p_verbose, "Verbose mode", "0", 0 }; p_blmat = “BLOSUM50” p_gapf = 11 p_gapn = 1 p_minall = 3 p_verbose = 0
Example (The parser! ) fasta_align -m BLOSUM50 -gf 5 -gn 1 1PLC._.fsa 1PLB._.fsa float p_gapf; float p_gapn; int p_minall; FILENAME p_blmat; int p_verbose; PARAM param[] = { "-gf", VFLOAT p_gapf, "penalty for first gap", "11", "-gn", VFLOAT p_gapn, "penalty for next gap", "1", "-mal", VINT p_minall, "Minimum alignment lenght", "3", "-m", VFNAME p_blmat, "Alignment matrix", "BLOSUM50", "-v", VSWITCH p_verbose, "Verbose mode", "0", 0 }; p_blmat = “BLOSUM50” p_gapf = 5 p_gapn = 1 p_minall = 3 p_verbose = 0
After - pparse(&argc, &argv, param, 2, "fsa1 fsa2"); fasta_align 1PLC._.fsa 1PLB._.fsa argv[0] argv[1] argv[2] argc = 3 Example (main(int argc, char *argv[]) ) Before fasta_align -m BLOSUM50 -gf 5 -gn 1 1PLC._.fsa 1PLB._.fsa argv[0] argv[1] argv[2] argv[6] argv[7] argv[8] argv[4] argv[3] argv[5] argc = 9
Example (main(int argc, char *argv[]) ) fasta_align 1PLC._.fsa 1PLB._.fsa argv[0] argv[1] argv[2] q_fsa = fsalist_read( argv[1] ) ): db_fsa = fsalist_read( argv[2] );