Skip to content

Commit

Permalink
add unit test to sniffer, minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
martenson committed May 23, 2024
1 parent 4db9dc4 commit 9ed4eda
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/galaxy/config/sample/datatypes_conf.xml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<datatype extension="gfa2" auto_compressed_types="gz" type="galaxy.datatypes.text:Gfa2" mimetype="text/plain" display_in_upload="true"/>
<datatype extension="asn1" type="galaxy.datatypes.data:GenericAsn1" mimetype="text/plain" display_in_upload="true"/>
<datatype extension="asn1-binary" type="galaxy.datatypes.binary:GenericAsn1Binary" mimetype="application/octet-stream" display_in_upload="true"/>
<datatype extension="axt" type="galaxy.datatypes.sequence:Axt" display_in_upload="true" description="blastz pairwise alignment format. Each alignment block in an axt file contains three lines: a summary line and 2 sequence lines. Blocks are separated from one another by blank lines. The summary line contains chromosomal position and size information about the alignment. It consists of 9 required fields." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#Axt"/>
<datatype extension="axt" type="galaxy.datatypes.sequence:Axt" display_in_upload="true" description="A pairwise alignment format." description_url="https://genome.ucsc.edu/goldenPath/help/axt.html"/>
<datatype extension="fli" type="galaxy.datatypes.tabular:FeatureLocationIndex" display_in_upload="false"/>
<datatype extension="bam" type="galaxy.datatypes.binary:Bam" mimetype="application/octet-stream" display_in_upload="true" description="A binary file compressed in the BGZF format with a '.bam' file extension." description_url="https://wiki.galaxyproject.org/Learn/Datatypes#BAM">
<converter file="bam_to_bai.xml" target_datatype="bai"/>
Expand Down
9 changes: 7 additions & 2 deletions lib/galaxy/datatypes/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,13 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
>>> fname = get_test_fname( 'alignment.lav' )
>>> Axt().sniff( fname )
False
>>> fname = get_test_fname( '2.chain' )
>>> Axt().sniff( fname )
False
"""
headers = get_headers(file_prefix, None, count=4, comment_designator="#")
if not (
len(headers) == 4
len(headers) >= 3
and len(headers[0]) == 9
and headers[0][0].isdigit()
and headers[0][2].isdigit()
Expand All @@ -1219,9 +1222,11 @@ def sniff_prefix(self, file_prefix: FilePrefix) -> bool:
and headers[0][8].isdigit()
and len(headers[1]) == 1
and len(headers[2]) == 1
and headers[3] == []
):
return False
# the optional fourth non-comment line has to be empty
if len(headers) == 4 and not headers[3] == []:
return False
else:
return True

Expand Down
10 changes: 10 additions & 0 deletions lib/galaxy/datatypes/test/2.chain
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
##matrix=axtChain 16 91,-114,-31,-123,-114,100,-125,-31,-31,-125,100,-114,-123,-31,-114,91
##gapPenalties=axtChain O=400 E=30
chain 67224 chr22 50818468 + 26560645 26561468 chr19 61431566 - 54838449 54839272 1
823

chain 48985 chr22 50818468 + 26560497 26561116 chr19 61431566 + 29160089 29160708 2
619

chain 46902 chr22 50818468 + 19792341 19793000 chr19 61431566 + 59180700 59181359 3
659

0 comments on commit 9ed4eda

Please sign in to comment.