Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Big coordinates not handled

See original GitHub issue


I’m testing out your tool to see if it’s suited to my needs e.g. visualize primers in a pretty way.

from dna_features_viewer import GraphicFeature, GraphicRecord
import matplotlib.pyplot as plt


record = GraphicRecord(sequence=sequence, features=[
    GraphicFeature(start=112173530, end=112173530+20, strand=+1, color="#ffd700",
    GraphicFeature(start=112173530+50, end=112173530+70, strand=-1, color="#cffccc",
zoom_start1, zoom_end1 = 112173530, 112173530+30  # coordinates of the "detail"
zoom_start2, zoom_end2 = 112173530+40, 112173530+80
cropped_record1 = record.crop((zoom_start1, zoom_end1))
cropped_record2 = record.crop((zoom_start2, zoom_end2))

fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 3))


ax1.set_title("Whole sequence", loc='left', weight='bold')
ax1.fill_between((zoom_start1, zoom_end1), +80, -80, alpha=0.15)
ax1.fill_between((zoom_start2, zoom_end2), +80, -80, alpha=0.15)


ax2.set_title("Sequence detail", loc='left')


ax3.set_title("Sequence detail", loc='left')


I copied some of your code and replaced some values to suit a real life situation and the program returns ValueError: out-of-bound cropping. Can the tool not handle big coordinates?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

Zulkocommented, Dec 23, 2019

I’m not entirely sure about your scenario but here is some alternative code which (I hope) does the same thing:

from dna_features_viewer import GraphicFeature, GraphicRecord
import matplotlib.pyplot as plt
full_sequence = 120_000_000 * "n"  # replace with the actual sequence.
x = 112173530  # index of the region to plot
primer1 = GraphicFeature(start=x, end=x+20, strand=+1, color="#ffd700", label="Primer1")
primer2 = GraphicFeature(start=x+50, end=x+70, strand=-1, color="#cffccc", label="Primer2")
record = GraphicRecord(sequence = full_sequence, features=[primer1, primer2])
region_record = record.crop((x-20, x+700))
detail_record = record.crop((x-5, x+75))

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 3), gridspec_kw={"width_ratios": [1, 2]})


I am not sure why the x coordinates are truncated for you but it could be due to Matplotlib’s way of writing the coordinates. Have you noticed that there is a “+1.1217e8” notation under the axis, indicating that you should add 112,170,000 to the x-coordinate.

Zulkocommented, Jan 8, 2020


Read more comments on GitHub >

github_iconTop Results From Across the Web

Rhino can't handle world coordinates sometimes
One workaround is to use a local coordinate system. Which means picking consistent point near te stuff you work with, and then systematically...
Read more >
Large coordinates truncated in PLY - Agisoft Metashape
Large coordinates truncated in PLY. ... big numbers, so the problem may be caused by the viewer software that could not handle big...
Read more >
Coordinates remain very high when converting projections
ArcGIS handles the conversion correctly, it writes x first (longitude), then y (latitude) in the geojson file, from a dataset in WGS84. So...
Read more >
[FIXED] Large coordinates does not display properly
So you are always working with large coordinates. Almost every software can not display point clouds with such coordinates.
Read more >
leaflet does not handle projected coordinates and confuses ...
A user asked me why sp and rgdal are broken because leaflet does not display sp objects read in using rgdal. It is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found