# HG changeset patch # User Jan Kanis # Date 1404726163 -7200 # Node ID b3b5ee557170a415c35385a90888639b17afdba7 # Parent a22c909c9b575356c0f1b6ea2c5cce1bda3e3736 update test diff -r a22c909c9b57 -r b3b5ee557170 blast2html.py --- a/blast2html.py Mon Jul 07 11:29:10 2014 +0200 +++ b/blast2html.py Mon Jul 07 11:42:43 2014 +0200 @@ -409,7 +409,7 @@ default_template = path.join(path.dirname(__file__), 'blast2html.html.jinja') parser = argparse.ArgumentParser(description="Convert a BLAST XML result into a nicely readable html page", - usage="{0} [-i] INPUT [-o OUTPUT]".format(sys.argv[0])) + usage="{0} [-i] INPUT [-o OUTPUT] [--genelink-template URL_TEMPLATE]".format(sys.argv[0])) input_group = parser.add_mutually_exclusive_group(required=True) input_group.add_argument('positional_arg', metavar='INPUT', nargs='?', type=argparse.FileType(mode='r'), help='The input Blast XML file, same as -i/--input') @@ -426,7 +426,8 @@ help='The template file to use. Defaults to blast_html.html.jinja') dblink_group = parser.add_mutually_exclusive_group() - dblink_group.add_argument('--genelink-template', default='http://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=genbank&log$=nuclalign', + dblink_group.add_argument('--genelink-template', metavar='URL_TEMPLATE', + default='http://www.ncbi.nlm.nih.gov/nucleotide/{accession}?report=genbank&log$=nuclalign', help="""A link template to link hits to a gene bank webpage. The template string is a Python format string. It can contain the following replacement elements: {id[N]}, {fullid}, {defline[N]}, {fulldefline}, {accession}, where N is a number. id[N] and defline[N] will be @@ -451,14 +452,15 @@ if six.PY2: # The argparse.FileType wrapper doesn't support an encoding - # argument or such, so for python 2 we need to wrap or reopen - # the output. The input files are already read as utf-8 by the + # argument, so for python 2 we need to wrap or reopen the + # output. The input files are already read as utf-8 by the # respective libraries. # One option is using codecs, but the codecs' writelines() # method doesn't support streaming but collects all output and - # writes at once. On the other hand the io module is slower - # (though not significantly). + # writes at once (see Python issues #5445 and #21910). On the + # other hand the io module is slower (though not + # significantly). # args.output = codecs.getwriter('utf-8')(args.output) args.output = io.open(args.output.name, 'w') diff -r a22c909c9b57 -r b3b5ee557170 blast2html.xml --- a/blast2html.xml Mon Jul 07 11:29:10 2014 +0200 +++ b/blast2html.xml Mon Jul 07 11:42:43 2014 +0200 @@ -25,19 +25,19 @@ - + - + - + - + diff -r a22c909c9b57 -r b3b5ee557170 test-data/blast xml example3.html --- a/test-data/blast xml example3.html Mon Jul 07 11:29:10 2014 +0200 +++ b/test-data/blast xml example3.html Mon Jul 07 11:42:43 2014 +0200 @@ -794,7 +794,7 @@ 100% 7.011e-08 100% - Subject_3 + Subject_3 @@ -811,13 +811,13 @@
- Gene Bank + Gene Bank

DJ437711|GenBank|insert_MIR604|Corn_Event_MIR604,_Left_Border_region|-5751164067366620000

- Sequence ID: Subject_3 + Sequence ID: Subject_3 Length: 323 Number of Matches: 1

@@ -1030,7 +1030,7 @@ 100% 7.011e-08 100% - Subject_6 + Subject_6 @@ -1047,13 +1047,13 @@

AB209952.1|GenBank|insert_GTS-40-3-2|Glycine_max_transgenic_cp4epsps_gene_for_5-enol-pyruvylshikimate-3-phospate_synthase_class_2_precursor,_complete_cds|-9105899556052450000

- Sequence ID: Subject_6 + Sequence ID: Subject_6 Length: 2457 Number of Matches: 1

@@ -1502,7 +1502,7 @@ 85% 2.981e-06 100% - Subject_2 + Subject_2 @@ -1519,13 +1519,13 @@

AJ308515.1|GenBank|insert_GTS-40-3-2|Synthetic_construct_for_NOS_3'UTR/plant_junction_region.|-9105899556052450000

- Sequence ID: Subject_2 + Sequence ID: Subject_2 Length: 1045 Number of Matches: 1

@@ -1686,7 +1686,7 @@ 100% 7.011e-08 100% - Subject_3 + Subject_3 @@ -1703,13 +1703,13 @@

DJ437711|GenBank|insert_MIR604|Corn_Event_MIR604,_Left_Border_region|-5751164067366620000

- Sequence ID: Subject_3 + Sequence ID: Subject_3 Length: 323 Number of Matches: 1

@@ -1922,7 +1922,7 @@ 100% 7.011e-08 100% - Subject_6 + Subject_6 @@ -1939,13 +1939,13 @@

AB209952.1|GenBank|insert_GTS-40-3-2|Glycine_max_transgenic_cp4epsps_gene_for_5-enol-pyruvylshikimate-3-phospate_synthase_class_2_precursor,_complete_cds|-9105899556052450000

- Sequence ID: Subject_6 + Sequence ID: Subject_6 Length: 2457 Number of Matches: 1

@@ -2727,7 +2727,7 @@ 100% 9.338e-08 92% - Subject_7 + Subject_7 @@ -2744,13 +2744,13 @@

AY326434|GenBank|insert_MON810|Synthetic_construct_truncated_CRYIA(b)_(cryIA(b))_gene,_partial_CDS|-2635190737607180000

- Sequence ID: Subject_7 + Sequence ID: Subject_7 Length: 4180 Number of Matches: 1

@@ -2908,7 +2908,7 @@ 100% 9.338e-08 92% - Subject_8 + Subject_8 @@ -2925,13 +2925,13 @@

EUG|RIKILT|plasmid_pV-ZMBK07|plasmid_pV-ZMBK07|-2635190737607180000

- Sequence ID: Subject_8 + Sequence ID: Subject_8 Length: 4983 Number of Matches: 1

@@ -3249,7 +3249,7 @@ 100% 6.629e-23 86% - Subject_7 + Subject_7 @@ -3266,13 +3266,13 @@

AY326434|GenBank|insert_MON810|Synthetic_construct_truncated_CRYIA(b)_(cryIA(b))_gene,_partial_CDS|-2635190737607180000

- Sequence ID: Subject_7 + Sequence ID: Subject_7 Length: 4180 Number of Matches: 1

@@ -3437,7 +3437,7 @@ 100% 6.629e-23 86% - Subject_8 + Subject_8 @@ -3454,13 +3454,13 @@

EUG|RIKILT|plasmid_pV-ZMBK07|plasmid_pV-ZMBK07|-2635190737607180000

- Sequence ID: Subject_8 + Sequence ID: Subject_8 Length: 4983 Number of Matches: 1

diff -r a22c909c9b57 -r b3b5ee557170 test-data/blast xml example4.html --- a/test-data/blast xml example4.html Mon Jul 07 11:29:10 2014 +0200 +++ b/test-data/blast xml example4.html Mon Jul 07 11:42:43 2014 +0200 @@ -557,7 +557,7 @@ 100% 1.513e-07 100% - 5 + 5
100% 1.513e-07 100% - 2 + 2 @@ -587,13 +587,13 @@

AB209952.1|GenBank|insert_GTS-40-3-2|Glycine_max_transgenic_cp4epsps_gene_for_5-enol-pyruvylshikimate-3-phospate_synthase_class_2_precursor,_complete_cds|-9105899556052450000

- Sequence ID: gnl|BL_ORD_ID|5 + Sequence ID: gnl|BL_ORD_ID|5 Length: 2457 Number of Matches: 1

@@ -629,13 +629,13 @@

DJ437711|GenBank|insert_MIR604|Corn_Event_MIR604,_Left_Border_region|-5751164067366620000

- Sequence ID: gnl|BL_ORD_ID|2 + Sequence ID: gnl|BL_ORD_ID|2 Length: 323 Number of Matches: 1

@@ -846,7 +846,7 @@ 100% 1.513e-07 100% - 5 + 5
100% 1.513e-07 100% - 2 + 2
85% 9.334e-06 100% - 1 + 1 @@ -889,13 +889,13 @@

AB209952.1|GenBank|insert_GTS-40-3-2|Glycine_max_transgenic_cp4epsps_gene_for_5-enol-pyruvylshikimate-3-phospate_synthase_class_2_precursor,_complete_cds|-9105899556052450000

- Sequence ID: gnl|BL_ORD_ID|5 + Sequence ID: gnl|BL_ORD_ID|5 Length: 2457 Number of Matches: 1

@@ -931,13 +931,13 @@

DJ437711|GenBank|insert_MIR604|Corn_Event_MIR604,_Left_Border_region|-5751164067366620000

- Sequence ID: gnl|BL_ORD_ID|2 + Sequence ID: gnl|BL_ORD_ID|2 Length: 323 Number of Matches: 1

@@ -973,13 +973,13 @@

AJ308515.1|GenBank|insert_GTS-40-3-2|Synthetic_construct_for_NOS_3'UTR/plant_junction_region.|-9105899556052450000

- Sequence ID: gnl|BL_ORD_ID|1 + Sequence ID: gnl|BL_ORD_ID|1 Length: 1045 Number of Matches: 1

@@ -1204,7 +1204,7 @@ 88% 3.148e-06 95% - 7 + 7
88% 3.148e-06 95% - 6 + 6 @@ -1234,13 +1234,13 @@

EUG|RIKILT|plasmid_pV-ZMBK07|plasmid_pV-ZMBK07|-2635190737607180000

- Sequence ID: gnl|BL_ORD_ID|7 + Sequence ID: gnl|BL_ORD_ID|7 Length: 4983 Number of Matches: 1

@@ -1276,13 +1276,13 @@

AY326434|GenBank|insert_MON810|Synthetic_construct_truncated_CRYIA(b)_(cryIA(b))_gene,_partial_CDS|-2635190737607180000

- Sequence ID: gnl|BL_ORD_ID|6 + Sequence ID: gnl|BL_ORD_ID|6 Length: 4180 Number of Matches: 1

@@ -1455,7 +1455,7 @@ 100% 3.564e-15 86% - 7 + 7
100% 3.564e-15 86% - 6 + 6 @@ -1485,13 +1485,13 @@

EUG|RIKILT|plasmid_pV-ZMBK07|plasmid_pV-ZMBK07|-2635190737607180000

- Sequence ID: gnl|BL_ORD_ID|7 + Sequence ID: gnl|BL_ORD_ID|7 Length: 4983 Number of Matches: 1

@@ -1530,13 +1530,13 @@

AY326434|GenBank|insert_MON810|Synthetic_construct_truncated_CRYIA(b)_(cryIA(b))_gene,_partial_CDS|-2635190737607180000

- Sequence ID: gnl|BL_ORD_ID|6 + Sequence ID: gnl|BL_ORD_ID|6 Length: 4180 Number of Matches: 1

diff -r a22c909c9b57 -r b3b5ee557170 test-data/refresh_test_results.sh --- a/test-data/refresh_test_results.sh Mon Jul 07 11:29:10 2014 +0200 +++ b/test-data/refresh_test_results.sh Mon Jul 07 11:42:43 2014 +0200 @@ -4,8 +4,11 @@ set -eu -"$@" ../blast2html.py -i "blast xml example1.xml" -o "blast xml example1.html" -"$@" ../blast2html.py -i "blast xml example2.xml" -o "blast xml example2.html" -"$@" ../blast2html.py -i "blast xml example3.xml" -o "blast xml example3.html" --genelink-template 'http://example.com/example-genebank?id={fullid}' -"$@" ../blast2html.py -i "blast xml example4.xml" -o "blast xml example4.html" --db-config-dir . +for i in 1 2 3 4 +do + "$@" ../blast2html.py -i "blast xml example$i.xml" -o "blast xml example$i.html" +done +"$@" ../blast2html.py -i "blast xml example3.xml" -o "blast xml example3b.html" --genelink-template 'http://example.com/example-genebank?id={fullid}' +"$@" ../blast2html.py -i "blast xml example4.xml" -o "blast xml example4b.html" --db-config-dir . +