comparison jbrowse2.py @ 50:f350467f9433 draft

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