Coder Social home page Coder Social logo

zephyris / tryptag Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 1.56 MB

Python module for accessing and handling TrypTag genome-wide protein localisation project data

Home Page: http://tryptag.org

License: GNU General Public License v3.0

Python 100.00%

tryptag's People

Contributors

edwo314 avatar ulido avatar zephyris avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

ulido edwo314

tryptag's Issues

Zenodo response problem, finding filenames in file list

Zenodo appears to have changed the response listing files, "filename" no longer being an attribute of files in a Zenodo response. Error below from [https://github.com/zephyris/tryptag/blob/main/examples/localisation_search.ipynb]

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
[<ipython-input-3-c6debed5e87f>](https://localhost:8080/#) in <cell line: 9>()
      7 print("Query:", query)
      8 print("")
----> 9 hits = tryptag.localisation_search(query)
     10 
     11 # result is a list of hits, in the form {"gene_id": gene_id, "terminus": terminus}

4 frames
[/usr/local/lib/python3.10/dist-packages/tryptag/tryptag.py](https://localhost:8080/#) in localisation_search(self, query_term, life_stage, match_subterms, exclude_modifiers, required_modifiers)
    510     # check all against query
    511     hits = []
--> 512     for cell_line in self.worklist_all(life_stage):
    513       if self._localisation_match(cell_line,  query_term, match_subterms=match_subterms, exclude_modifiers=exclude_modifiers, required_modifiers=required_modifiers):
    514         hits.append(cell_line)

[/usr/local/lib/python3.10/dist-packages/tryptag/tryptag.py](https://localhost:8080/#) in worklist_all(self, life_stage)
    380         terminus=terminus,
    381        ) for gene_id, terminus in
--> 382       ((gene_id, terminus) for gene_id, gene_entry in self.gene_list[life_stage].items() for terminus in self.termini if terminus in gene_entry)
    383     ]
    384 

[/usr/lib/python3.10/functools.py](https://localhost:8080/#) in __get__(self, instance, owner)
    979                 val = cache.get(self.attrname, _NOT_FOUND)
    980                 if val is _NOT_FOUND:
--> 981                     val = self.func(instance)
    982                     try:
    983                         cache[self.attrname] = val

[/usr/local/lib/python3.10/dist-packages/tryptag/tryptag.py](https://localhost:8080/#) in gene_list(self)
    331     # download localisations.tsv from master record
    332     zenodo_json = self._fetch_zenodo_record_json(self.zenodo_record_id)
--> 333     lines = self._fetch_zenodo_record_file(zenodo_json, "localisations.tsv").splitlines()
    334     # load into default life stage
    335     # TODO: Handle loading of multiple different life stages

[/usr/local/lib/python3.10/dist-packages/tryptag/tryptag.py](https://localhost:8080/#) in _fetch_zenodo_record_file(self, zenodo_json, file_name)
    263     from urllib.error import HTTPError
    264     for file in zenodo_json["files"]:
--> 265       if file["filename"] == file_name:
    266         url = f"[https://zenodo.org/api/records/{zenodo_json['record_id']}/files/{file_name}/content](https://zenodo.org/api/records/%7Bzenodo_json['record_id']%7D/files/%7Bfile_name%7D/content)"
    267         if self.print_status: print("  Fetching file "+file_name+" from: "+url)

KeyError: 'filename'

empty string error and matplotlib missing

When calling gene_list a second time in tryptag.py or any function like open_cell that calls gene_list, I am getting a list index out of range in line 350
if line[indices[p + "status"]] == "cell line generated": . This happens because the line variable is sometimes an empty string.
An easy fix for that problem is changing line 333 to lines = [line for line in self._fetch_zenodo_record_file(zenodo_json, "localisations.tsv").splitlines() if line.strip()], as it discards empty lines. This change doesn't alter the program's intended behaviour.

The second issue I noticed is that tryptools.py is using matplotlib, but matplotlib is not being installed automatically.
This can be fixed by adding matplotlib to the dependencies list in the pyproject.toml file.

I didn't want to fork the project as those are only minor bugs and you might want to verify them first.

`tryptools.cell_morphology_analysis` can give unexpected `kn_ordered` result.

tryptools.cell_morphology_analysis can give unexpected kn_ordered result. Suggests that the identification of the cell posterior and anterior from the midline and/or ordering is not working.

Example cell which looks like a normal 1K1N (ie. kn_ordered expected to be "KN"):

from tryptag import TrypTag, tryptools
tryptag = TrypTag()
cell_image = tryptag.open_cell("Tb927.9.8570", "n", 2, 2)
morph = tryptools.cell_morphology_analysis(cell_image.phase_mask, cell_image.dna_mask, cell_image.dna)
>>> morph["kn_ordered"]
'NK'

May be a bug, or may be a quirk of the input data - either way, unexpected based on cell appearance.

`tryptools.cell_morphology_analysis` can try to read out-of-bounds image data.

To replicate:

from tryptag import TrypTag, tryptools
tryptag = TrypTag()
cell_image = tryptag.open_cell("Tb927.10.10630", "c", 2, 60)
morph = tryptools.cell_morphology_analysis(cell_image.phase_mask, cell_image.dna_mask, cell_image.dna)

Gives:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/richard/.local/lib/python3.8/site-packages/tryptag/tryptools/tryptools.py", line 165, in cell_morphology_analysis
    midline_analysis = cell_midline_analysis(pth)
  File "/home/richard/.local/lib/python3.8/site-packages/tryptag/tryptools/tryptools.py", line 121, in cell_midline_analysis
    pth_skeleton = _mask_pruned_skeleton(pth, prefilter_radius, min_length_pruning) # MAGIC NUMBERS: Radius for prefiltering, length for pruning branches
  File "/home/richard/.local/lib/python3.8/site-packages/tryptag/tryptools/tryptools.py", line 49, in _mask_pruned_skeleton
    if (a != 0 or b != 0) and skeleton[cy + b, cx + a] == 1:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.