{"action":"created","issue":{"url":"https://api.github.com/repos/biopython/biopython/issues/1740","repository_url":"https://api.github.com/repos/biopython/biopython","labels_url":"https://api.github.com/repos/biopython/biopython/issues/1740/labels{/name}","comments_url":"https://api.github.com/repos/biopython/biopython/issues/1740/comments","events_url":"https://api.github.com/repos/biopython/biopython/issues/1740/events","html_url":"https://github.com/biopython/biopython/issues/1740","id":343664722,"node_id":"MDU6SXNzdWUzNDM2NjQ3MjI=","number":1740,"title":"problem with cross links between tracks","user":{"login":"peterhabib","id":38513546,"node_id":"MDQ6VXNlcjM4NTEzNTQ2","avatar_url":"https://avatars0.githubusercontent.com/u/38513546?v=4","gravatar_id":"","url":"https://api.github.com/users/peterhabib","html_url":"https://github.com/peterhabib","followers_url":"https://api.github.com/users/peterhabib/followers","following_url":"https://api.github.com/users/peterhabib/following{/other_user}","gists_url":"https://api.github.com/users/peterhabib/gists{/gist_id}","starred_url":"https://api.github.com/users/peterhabib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterhabib/subscriptions","organizations_url":"https://api.github.com/users/peterhabib/orgs","repos_url":"https://api.github.com/users/peterhabib/repos","events_url":"https://api.github.com/users/peterhabib/events{/privacy}","received_events_url":"https://api.github.com/users/peterhabib/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-07-23T14:46:43Z","updated_at":"2018-08-29T09:48:49Z","closed_at":"2018-08-29T07:37:36Z","author_association":"NONE","body":"i am trying to cross link between three records as described and shown in biopython tutorial\r\n\r\nI am reporting a problem with biopython-1.71, Python version 3.4, and operating\r\nsystem Ubuntu (bio-linux)\r\n\r\n```python\r\nfrom Bio import SeqIO\r\nA_rec = SeqIO.read(\"/home/peter/Desktop/OUT-DATA/NC_002703.gbk\", \"gb\")\r\nB_rec = SeqIO.read(\"/home/peter/Desktop/Sample-Data/AF323668.gbk\", \"gb\")\r\nC_rec = SeqIO.read(\"/home/peter/Desktop/OUT-DATA/NC_003212.gbk\", \"gb\")[2587879:2625807].reverse_complement(name=True)\r\nfrom reportlab.lib.colors import red, grey, orange, green, brown, blue, lightblue, purple\r\nA_colors = [red]*5 + [grey]*7 + [orange]*2 + [grey]*2 + [orange] + [grey]*11 + [green]*4 \\\r\n    + [grey] + [green]*2 + [grey, green] + [brown]*5 + [blue]*4 + [lightblue]*5 \\\r\n    + [grey, lightblue] + [purple]*2 + [grey]\r\n\r\nB_colors = [red]*5 + [grey]*7 + [orange]*2 + [grey]*2 + [orange] + [grey]*11 + [green]*4 \\\r\n    + [grey] + [green]*2 + [grey, green] + [brown]*5 + [blue]*4 + [lightblue]*5 \\\r\n    + [grey, lightblue] + [purple]*2 + [grey]\r\n\r\nC_colors = [grey]*30 + [green]*5 + [brown]*4 + [blue]*2 + [grey, blue] + [lightblue]*2 \\\r\n    + [grey]*5\r\n\r\n\r\nfrom Bio.Graphics import GenomeDiagram\r\nname = \"Proux Fig 6\"\r\ngd_diagram = GenomeDiagram.Diagram(name)\r\nmax_len = 0\r\nfor record, gene_colors in zip([A_rec, B_rec, C_rec], [A_colors, B_colors, C_colors]):\r\n    max_len = max(max_len, len(record))\r\n    gd_track_for_features = gd_diagram.new_track(1,\r\n                                                 name=record.name,\r\n                                                 greytrack=True,\r\n                                                 start=0, end=len(record))\r\n    gd_feature_set = gd_track_for_features.new_set()\r\n    i = 0\r\n    for feature in record.features:\r\n        if feature.type != \"gene\":\r\n            continue\r\n        gd_feature_set.add_feature(feature, sigil=\"ARROW\",color=gene_colors[i], label=True,name=str(i + 1),label_position=\"start\",label_size=6, label_angle=0)\r\ngd_diagram.draw(format=\"linear\", pagesize='A4', fragments = 1,start = 0, end = max_len)\r\ngd_diagram.write(name + \".pdf\", \"PDF\")\r\ngd_diagram.write(name + \".eps\", \"EPS\")\r\ngd_diagram.write(name + \".svg\", \"SVG\")\r\n\r\n\r\n\r\nA_vs_B = [\r\n    (99, \"Tuc2009_01\", \"int\"),\r\n    (33, \"Tuc2009_03\", \"orf4\"),\r\n    (94, \"Tuc2009_05\", \"orf6\"),\r\n    (100,\"Tuc2009_06\", \"orf7\"),\r\n    (97, \"Tuc2009_07\", \"orf8\"),\r\n    (98, \"Tuc2009_08\", \"orf9\"),\r\n    (98, \"Tuc2009_09\", \"orf10\"),\r\n    (100,\"Tuc2009_10\", \"orf12\"),\r\n    (100,\"Tuc2009_11\", \"orf13\"),\r\n    (94, \"Tuc2009_12\", \"orf14\"),\r\n    (87, \"Tuc2009_13\", \"orf15\"),\r\n    (94, \"Tuc2009_14\", \"orf16\"),\r\n    (94, \"Tuc2009_15\", \"orf17\"),\r\n    (88, \"Tuc2009_17\", \"rusA\"),\r\n    (91, \"Tuc2009_18\", \"orf20\"),\r\n    (93, \"Tuc2009_19\", \"orf22\"),\r\n    (71, \"Tuc2009_20\", \"orf23\"),\r\n    (51, \"Tuc2009_22\", \"orf27\"),\r\n    (97, \"Tuc2009_23\", \"orf28\"),\r\n    (88, \"Tuc2009_24\", \"orf29\"),\r\n    (26, \"Tuc2009_26\", \"orf38\"),\r\n    (19, \"Tuc2009_46\", \"orf52\"),\r\n    (77, \"Tuc2009_48\", \"orf54\"),\r\n    (91, \"Tuc2009_49\", \"orf55\"),\r\n    (95, \"Tuc2009_52\", \"orf60\")]\r\n\r\n\r\n\r\n\r\n\r\nB_vs_C = [\r\n    (42,\"orf39\", \"lin2581\"),\r\n    (31,\"orf40\", \"lin2580\"),\r\n    (49,\"orf41\", \"lin2579\"), #terL\r\n    (54,\"orf42\", \"lin2578\"), #portal\r\n    (55,\"orf43\", \"lin2577\"), #protease\r\n    (33,\"orf44\", \"lin2576\"), #mhp\r\n    (51,\"orf46\", \"lin2575\"),\r\n    (33,\"orf47\", \"lin2574\"),\r\n    (40,\"orf48\", \"lin2573\"),\r\n    (25,\"orf49\", \"lin2572\"),\r\n    (50,\"orf50\", \"lin2571\"),\r\n    (48,\"orf51\", \"lin2570\"),\r\n    (24,\"orf52\", \"lin2568\"),\r\n]\r\n\r\n\r\ndef get_feature(features, id, tags=[\"locus_tag\", \"gene\"]):\r\n    for f in features:\r\n        for key in tags:\r\n            for x in f.qualifiers.get(key, []):\r\n                if x == id:\r\n                    return f\r\n    raise KeyError(id)\r\n\r\n\r\n\r\nfrom Bio.Graphics.GenomeDiagram import CrossLink\r\nfrom reportlab.lib import colors\r\n\r\nfor rec_X, tn_X, rec_Y, tn_Y, X_vs_Y in [(A_rec, 3, B_rec, 2, A_vs_B),(B_rec, 2, C_rec, 1, B_vs_C)]:\r\n    track_X = gd_diagram.tracks[tn_X]\r\n    track_Y = gd_diagram.tracks[tn_Y]\r\n    for score, id_X, id_Y in X_vs_Y:\r\n        feature_X = get_feature(rec_X.features, id_X)\r\n        feature_Y = get_feature(rec_Y.features, id_Y)\r\n        color = colors.linearlyInterpolatedColor(colors.white, colors.firebrick, 0, 100, score)\r\n        link_xy = CrossLink((track_X, feature_X.location.start, feature_X.location.end),\r\n                            (track_Y, feature_Y.location.start, feature_Y.location.end),\r\n                            color, colors.lightgrey)\r\ngd_diagram.cross_track_links.append(link_xy)\r\n```\r\n\r\n(*Please copy and run the above in your Python, and copy-and-paste the output*)\r\n\r\n### Expected behaviour\r\n\r\ngive me figure like Figure 17.11 in page 285 of biopython tutorial\r\n\r\n### Actual behaviour\r\n\r\n```\r\n/usr/bin/python3.4 \"/home/peter/Desktop/Scripts/image relationship.py\"\r\nTraceback (most recent call last):\r\n  File \"/home/peter/Desktop/Scripts/image relationship.py\", line 107, in <module>\r\n    feature_Y = get_feature(rec_Y.features, id_Y)\r\n  File \"/home/peter/Desktop/Scripts/image relationship.py\", line 95, in get_feature\r\n    raise KeyError(id)\r\nKeyError: 'lin2581'\r\n```\r\n\r\n### Steps to reproduce\r\n\r\n1 - download records\r\n2 - copying code from tutorial \r\n3 - run\r\n"},"comment":{"url":"https://api.github.com/repos/biopython/biopython/issues/comments/416894057","html_url":"https://github.com/biopython/biopython/issues/1740#issuecomment-416894057","issue_url":"https://api.github.com/repos/biopython/biopython/issues/1740","id":416894057,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNjg5NDA1Nw==","user":{"login":"peterjc","id":63959,"node_id":"MDQ6VXNlcjYzOTU5","avatar_url":"https://avatars2.githubusercontent.com/u/63959?v=4","gravatar_id":"","url":"https://api.github.com/users/peterjc","html_url":"https://github.com/peterjc","followers_url":"https://api.github.com/users/peterjc/followers","following_url":"https://api.github.com/users/peterjc/following{/other_user}","gists_url":"https://api.github.com/users/peterjc/gists{/gist_id}","starred_url":"https://api.github.com/users/peterjc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterjc/subscriptions","organizations_url":"https://api.github.com/users/peterjc/orgs","repos_url":"https://api.github.com/users/peterjc/repos","events_url":"https://api.github.com/users/peterjc/events{/privacy}","received_events_url":"https://api.github.com/users/peterjc/received_events","type":"User","site_admin":false},"created_at":"2018-08-29T09:48:49Z","updated_at":"2018-08-29T09:48:49Z","author_association":"MEMBER","body":"Did you solve this then?"}}
{"actor":{"display_login":"peterjc"}}