comparison jbrowse2.py @ 49:7e867ff86e44 draft

planemo upload for repository https://github.com/usegalaxy-eu/temporary-tools/tree/master/jbrowse2 commit 3a43e9e0ffce0966101203102e769d1ced28618a-dirty
author fubar
date Thu, 07 Mar 2024 00:27:48 +0000
parents 460d5b6c5d98
children f350467f9433
comparison
equal deleted inserted replaced
48:460d5b6c5d98 49:7e867ff86e44
600 # dsId = trackData["metadata"]["dataset_id"] 600 # dsId = trackData["metadata"]["dataset_id"]
601 # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId) 601 # url = "%s/api/datasets/%s/display?to_ext=hic " % (self.giURL, dsId)
602 useuri = trackData["useuri"].lower() == "yes" 602 useuri = trackData["useuri"].lower() == "yes"
603 if useuri: 603 if useuri:
604 uri = data 604 uri = data
605 adapt = {
606 "type": "HicAdapter",
607 "hicLocation": uri,
608 "locationType": "UriLocation",
609 },
605 else: 610 else:
606 uri = trackData["hic_url"] 611 uri = trackData["hic_url"]
612 adapt = {
613 "type": "HicAdapter",
614 "hicLocation": uri,
615 },
607 trackDict = { 616 trackDict = {
608 "type": "HicTrack", 617 "type": "HicTrack",
609 "trackId": tId, 618 "trackId": tId,
610 "name": uri, 619 "name": uri,
611 "assemblyNames": [self.genome_name], 620 "assemblyNames": [self.genome_name],
612 "adapter": { 621 "adapter": adapt,
613 "type": "HicAdapter",
614 "hicLocation": uri,
615 },
616 "displays": [ 622 "displays": [
617 { 623 {
618 "type": "LinearHicDisplay", 624 "type": "LinearHicDisplay",
619 "displayId": "%s-LinearHicDisplay" % tId, 625 "displayId": "%s-LinearHicDisplay" % tId,
620 }, 626 },
779 "constraints": {} 785 "constraints": {}
780 """ 786 """
781 useuri = trackData["useuri"].lower() == "yes" 787 useuri = trackData["useuri"].lower() == "yes"
782 if useuri: 788 if useuri:
783 url = data 789 url = data
790 adapt = {
791 "type": "BigWigAdapter",
792 "bigWigLocation": {"uri": url},
793 "locationType": "UriLocation",
794 }
784 else: 795 else:
785 url = "%s.bigwig" % trackData["label"] 796 url = "%s.bigwig" % trackData["label"]
786 # slashes in names cause path trouble 797 # slashes in names cause path trouble
787 dest = os.path.join(self.outdir, url) 798 dest = os.path.join(self.outdir, url)
788 cmd = ["cp", data, dest] 799 cmd = ["cp", data, dest]
789 self.subprocess_check_call(cmd) 800 self.subprocess_check_call(cmd)
790 bwloc = {"uri": url} 801 adapt = {
802 "type": "BigWigAdapter",
803 "bigWigLocation": {"uri": url},
804 }
791 tId = trackData["label"] 805 tId = trackData["label"]
792 trackDict = { 806 trackDict = {
793 "type": "QuantitativeTrack", 807 "type": "QuantitativeTrack",
794 "trackId": tId, 808 "trackId": tId,
795 "name": trackData["name"], 809 "name": trackData["name"],
796 "assemblyNames": [ 810 "assemblyNames": [
797 self.genome_name, 811 self.genome_name,
798 ], 812 ],
799 "adapter": { 813 "adapter": adapt,
800 "type": "BigWigAdapter",
801 "bigWigLocation": bwloc,
802 },
803 "displays": [ 814 "displays": [
804 { 815 {
805 "type": "LinearWiggleDisplay", 816 "type": "LinearWiggleDisplay",
806 "displayId": "%s-LinearWiggleDisplay" % tId, 817 "displayId": "%s-LinearWiggleDisplay" % tId,
807 } 818 }
816 tId = trackData["label"] 827 tId = trackData["label"]
817 useuri = trackData["useuri"].lower() == "yes" 828 useuri = trackData["useuri"].lower() == "yes"
818 bindex = bam_index 829 bindex = bam_index
819 if useuri: 830 if useuri:
820 url = data 831 url = data
832 adapt = {
833 "type": "BamAdapter",
834 "bamLocation": {"uri": url},
835 "index": {
836 "location": {
837 "uri": bindex,
838 "locationType": "UriLocation",
839 }
840 }
841 }
821 else: 842 else:
822 fname = "%s.bam" % trackData["label"] 843 fname = "%s.bam" % trackData["label"]
823 dest = "%s/%s" % (self.outdir, fname) 844 dest = "%s/%s" % (self.outdir, fname)
824 url = fname 845 url = fname
825 bindex = fname + '.bai' 846 bindex = fname + '.bai'
826 self.subprocess_check_call(["cp", data, dest]) 847 self.subprocess_check_call(["cp", data, dest])
848 adapt = {
849 "type": "BamAdapter",
850 "bamLocation": {"uri": url},
851 "index": {
852 "location": {
853 "uri": bindex,
854 }
855 }
856 }
827 if bam_index is not None and os.path.exists(bam_index): 857 if bam_index is not None and os.path.exists(bam_index):
828 if not os.path.exists(bindex): 858 if not os.path.exists(bindex):
829 # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest 859 # bai most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
830 self.subprocess_check_call( 860 self.subprocess_check_call(
831 ["cp", bam_index, bindex] 861 ["cp", bam_index, bindex]
842 trackDict = { 872 trackDict = {
843 "type": "AlignmentsTrack", 873 "type": "AlignmentsTrack",
844 "trackId": tId, 874 "trackId": tId,
845 "name": trackData["name"], 875 "name": trackData["name"],
846 "assemblyNames": [self.genome_name], 876 "assemblyNames": [self.genome_name],
847 "adapter": { 877 "adapter": adapt,
848 "type": "BamAdapter",
849 "bamLocation": {"uri": url},
850 "index": {
851 "location": {
852 "uri": bindex,
853 }
854 },
855 },
856 "displays": [ 878 "displays": [
857 { 879 {
858 "type": "LinearAlignmentsDisplay", 880 "type": "LinearAlignmentsDisplay",
859 "displayId": "%s-LinearAlignmentsDisplay" % tId, 881 "displayId": "%s-LinearAlignmentsDisplay" % tId,
860 }, 882 },
869 tId = trackData["label"] 891 tId = trackData["label"]
870 useuri = trackData["useuri"].lower() == "yes" 892 useuri = trackData["useuri"].lower() == "yes"
871 bindex = cram_index 893 bindex = cram_index
872 if useuri: 894 if useuri:
873 url = data 895 url = data
896 adapt = {
897 "type": "CramAdapter",
898 "cramLocation": {"uri": url},
899 "craiLocation": {
900 "uri": bindex,
901 "locationType": "UriLocation",
902 },
903 "sequenceAdapter": self.genome_sequence_adapter,
904 }
874 else: 905 else:
875 fname = "%s.cram" % trackData["label"] 906 fname = "%s.cram" % trackData["label"]
876 dest = "%s/%s" % (self.outdir, fname) 907 dest = "%s/%s" % (self.outdir, fname)
877 bindex = fname + '.bai' 908 bindex = fname + '.bai'
878 url = fname 909 url = fname
879 self.subprocess_check_call(["cp", data, dest]) 910 self.subprocess_check_call(["cp", data, dest])
880 911 adapt = {
912 "type": "CramAdapter",
913 "cramLocation": {"uri": url},
914 "craiLocation": {
915 "uri": bindex,
916 },
917 "sequenceAdapter": self.genome_sequence_adapter,
918 }
881 if bindex is not None and os.path.exists(bindex): 919 if bindex is not None and os.path.exists(bindex):
882 if not os.path.exists(dest+'.crai'): 920 if not os.path.exists(dest+'.crai'):
883 # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest 921 # most probably made by galaxy and stored in galaxy dirs, need to copy it to dest
884 self.subprocess_check_call( 922 self.subprocess_check_call(
885 ["cp", os.path.realpath(cram_index), dest + ".crai"] 923 ["cp", os.path.realpath(cram_index), dest + ".crai"]
898 trackDict = { 936 trackDict = {
899 "type": "AlignmentsTrack", 937 "type": "AlignmentsTrack",
900 "trackId": tId, 938 "trackId": tId,
901 "name": trackData["name"], 939 "name": trackData["name"],
902 "assemblyNames": [self.genome_name], 940 "assemblyNames": [self.genome_name],
903 "adapter": { 941 "adapter": adapt,
904 "type": "CramAdapter",
905 "cramLocation": {"uri": url},
906 "craiLocation": {
907 "uri": bindex,
908 },
909 "sequenceAdapter": self.genome_sequence_adapter,
910 },
911 "displays": [ 942 "displays": [
912 { 943 {
913 "type": "LinearAlignmentsDisplay", 944 "type": "LinearAlignmentsDisplay",
914 "displayId": "%s-LinearAlignmentsDisplay" % tId, 945 "displayId": "%s-LinearAlignmentsDisplay" % tId,
915 }, 946 },
928 # ) 959 # )
929 960
930 useuri = trackData["useuri"].lower() == "yes" 961 useuri = trackData["useuri"].lower() == "yes"
931 if useuri: 962 if useuri:
932 url = data 963 url = data
964 adapt = {
965 "type": "VcfTabixAdapter",
966 "vcfGzLocation": {
967 "uri": url,
968 "locationType": "UriLocation",
969 },
970 "index": {
971 "location": {
972 "uri": url + ".tbi",
973 "locationType": "UriLocation",
974 }
975 },
976 },
933 else: 977 else:
934 url = "%s.vcf.gz" % tId 978 url = "%s.vcf.gz" % tId
935 dest = "%s/%s" % (self.outdir, url) 979 dest = "%s/%s" % (self.outdir, url)
936 cmd = "bgzip -c %s > %s" % (data, dest) 980 cmd = "bgzip -c %s > %s" % (data, dest)
937 self.subprocess_popen(cmd) 981 self.subprocess_popen(cmd)
938 cmd = ["tabix", "-f", "-p", "vcf", dest] 982 cmd = ["tabix", "-f", "-p", "vcf", dest]
939 self.subprocess_check_call(cmd) 983 self.subprocess_check_call(cmd)
984 adapt = {
985 "type": "VcfTabixAdapter",
986 "vcfGzLocation": {
987 "uri": url
988 },
989 "index": {
990 "location": {
991 "uri": url + ".tbi",
992 }
993 },
994 }
940 trackDict = { 995 trackDict = {
941 "type": "VariantTrack", 996 "type": "VariantTrack",
942 "trackId": tId, 997 "trackId": tId,
943 "name": trackData["name"], 998 "name": trackData["name"],
944 "assemblyNames": [self.genome_name], 999 "assemblyNames": [self.genome_name],
945 "adapter": { 1000 "adapter": adapt,
946 "type": "VcfTabixAdapter",
947 "vcfGzLocation": {
948 "uri": url
949 },
950 "index": {
951 "location": {
952 "uri": url + ".tbi",
953 }
954 },
955 },
956 "displays": [ 1001 "displays": [
957 { 1002 {
958 "type": "LinearVariantDisplay", 1003 "type": "LinearVariantDisplay",
959 "displayId": "%s-LinearVariantDisplay" % tId, 1004 "displayId": "%s-LinearVariantDisplay" % tId,
960 }, 1005 },
993 1038
994 def add_gff(self, data, ext, trackData): 1039 def add_gff(self, data, ext, trackData):
995 useuri = trackData["useuri"].lower() == "yes" 1040 useuri = trackData["useuri"].lower() == "yes"
996 if useuri: 1041 if useuri:
997 url = trackData["path"] 1042 url = trackData["path"]
1043 adapter = {
1044 "type": "Gff3TabixAdapter",
1045 "gffGzLocation": {
1046 "uri": url,
1047 "locationType": "UriLocation",
1048 },
1049 "index": {
1050 "location": {
1051 "uri": url + ".tbi",
1052 "locationType": "UriLocation",
1053 }
1054 },
1055 }
998 else: 1056 else:
999 url = "%s.%s.gz" % (trackData["label"], ext) 1057 url = "%s.%s.gz" % (trackData["label"], ext)
1000 dest = "%s/%s" % (self.outdir, url) 1058 dest = "%s/%s" % (self.outdir, url)
1001 self._sort_gff(data, dest) 1059 self._sort_gff(data, dest)
1060 adapter = {
1061 "type": "Gff3TabixAdapter",
1062 "gffGzLocation": {
1063 "uri": url,
1064 },
1065 "index": {
1066 "location": {
1067 "uri": url + ".tbi",
1068 }
1069 },
1070 }
1002 tId = trackData["label"] 1071 tId = trackData["label"]
1003 trackDict = { 1072 trackDict = {
1004 "type": "FeatureTrack", 1073 "type": "FeatureTrack",
1005 "trackId": tId, 1074 "trackId": tId,
1006 "name": trackData["name"], 1075 "name": trackData["name"],
1007 "assemblyNames": [self.genome_name], 1076 "assemblyNames": [self.genome_name],
1008 "adapter": { 1077 "adapter": adapt,
1009 "type": "Gff3TabixAdapter",
1010 "gffGzLocation": {
1011 "uri": url,
1012 },
1013 "index": {
1014 "location": {
1015 "uri": url + ".tbi",
1016 }
1017 },
1018 },
1019 "displays": [ 1078 "displays": [
1020 { 1079 {
1021 "type": "LinearBasicDisplay", 1080 "type": "LinearBasicDisplay",
1022 "displayId": "%s-LinearBasicDisplay" % tId, 1081 "displayId": "%s-LinearBasicDisplay" % tId,
1023 }, 1082 },
1035 def add_bed(self, data, ext, trackData): 1094 def add_bed(self, data, ext, trackData):
1036 tId = trackData["label"] 1095 tId = trackData["label"]
1037 useuri = trackData["useuri"].lower() == "yes" 1096 useuri = trackData["useuri"].lower() == "yes"
1038 if useuri: 1097 if useuri:
1039 url = data 1098 url = data
1099 adapt = {
1100 "type": "BedTabixAdapter",
1101 "bedGzLocation": {
1102 "uri": url,
1103 "locationType": "UriLocation",
1104 },
1105 "index": {
1106 "location": {
1107 "uri": url + ".tbi",
1108 "locationType": "UriLocation",
1109 }
1110 },
1111 }
1040 else: 1112 else:
1041 url = "%s.%s.gz" % (trackData["label"], ext) 1113 url = "%s.%s.gz" % (trackData["label"], ext)
1042 dest = "%s/%s" % (self.outdir, url) 1114 dest = "%s/%s" % (self.outdir, url)
1043 self._sort_bed(data, dest) 1115 self._sort_bed(data, dest)
1116 adapt = {
1117 "type": "BedTabixAdapter",
1118 "bedGzLocation": {
1119 "uri": url,
1120 },
1121 "index": {
1122 "location": {
1123 "uri": url + ".tbi",
1124 }
1125 },
1126 }
1044 trackDict = { 1127 trackDict = {
1045 "type": "FeatureTrack", 1128 "type": "FeatureTrack",
1046 "trackId": tId, 1129 "trackId": tId,
1047 "name": trackData["name"], 1130 "name": trackData["name"],
1048 "assemblyNames": [self.genome_name], 1131 "assemblyNames": [self.genome_name],
1049 "adapter": { 1132 "adapter": adapt,
1050 "type": "BedTabixAdapter",
1051 "bedGzLocation": {
1052 "uri": url,
1053 },
1054 "index": {
1055 "location": {
1056 "uri": url + ".tbi",
1057 }
1058 },
1059 },
1060 "displays": [ 1133 "displays": [
1061 { 1134 {
1062 "type": "LinearBasicDisplay", 1135 "type": "LinearBasicDisplay",
1063 "displayId": "%s-LinearBasicDisplay" % tId, 1136 "displayId": "%s-LinearBasicDisplay" % tId,
1064 }, 1137 },
1104 trackDict = { 1177 trackDict = {
1105 "type": "SyntenyTrack", 1178 "type": "SyntenyTrack",
1106 "trackId": tId, 1179 "trackId": tId,
1107 "assemblyNames": passnames, 1180 "assemblyNames": passnames,
1108 "name": tname, 1181 "name": tname,
1109 "adapter": { 1182 "adapter": adapt,
1110 "type": "PAFAdapter",
1111 "pafLocation": {"uri": url},
1112 "assemblyNames": passnames,
1113 },
1114 # "displays": [ 1183 # "displays": [
1115 # { 1184 # {
1116 # "type": "LinearSyntenyDisplay", 1185 # "type": "LinearSyntenyDisplay",
1117 # "displayId": "%s-LinearSyntenyDisplay" % tId, 1186 # "displayId": "%s-LinearSyntenyDisplay" % tId,
1118 # }, 1187 # },