Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement phylotree #144

Open
23 of 24 tasks
alancleary opened this issue Jul 10, 2023 · 27 comments
Open
23 of 24 tasks

Implement phylotree #144

alancleary opened this issue Jul 10, 2023 · 27 comments
Assignees
Labels
enhancement New feature or request

Comments

@alancleary
Copy link
Contributor

alancleary commented Jul 10, 2023

This is basically a second attempt at #10. @rispop is going to implement a phylotree component in an iterative manner. See the list below for steps and details:

  • Fork repository
  • Add a new phylotree component under src/
  • Have the component draw a tree from an input (i.e. @property) Newick tree using TnT (don't install TnT with npm; just include its scripts in the head of the page)
  • Implement a test for the component in the dev/ directory
  • Declare and export a Phylotree type before the LisPhylotree class that describes a phytotree object
  • Add a private _data state to the LisPhylotree class
  • Replace the input property with a tree property that has type string|Phylotree and implement a setter for the property that saves the tree in the _data state; you'll need to check if the tree is a string and parse it as Newick first
  • Update the tree drawing code to use the tree object in the _data state
  • Create a second <lis-phylotree> element in the dev/ example and set its tree property to a Phylotree object programmatically inside a <script> tag
  • Add an optional color string attribute to the Phylotree type
  • Update the tree drawing code to color nodes using their color attribute if they have it
  • Update your Phylotree object in the dev/ example to color some, but not all, nodes
  • Add a ResizeObserver to the phylotree that calls the tree drawing method when the component's size chages
  • Update the tree drawing code to make the tree as wide as the component element
  • Update the tree drawing code to clear the component content before drawing the tree
  • Add a scale bar to the tree
  • Add a layout property to the component with type "vertical"|"radial" with "vertical" as the default value.
  • Update the tree drawing code to draw the tree in a vertical or radial layout based on the layout property
  • Add a new scale boolean property that's false by default
  • Use this as the value for the TnT .scale method
  • Run the GraphQL Server and use its Apollo Explorer (localhost:4000) to build a geneFamilies query to fetch the Newick string for 1 phylotree. Be sure to set the page and pageSize variables to 1 or else it's going to return results for all phylotrees in the database!
  • Using dev/lis-linkout-element.html as an example, use your GraphQL query from the previous step to update dev/lis-phylotree.html to get a phylotree with the graphqlQuery function
  • Update dev/lis-phylotree.html to set the tree property of the lis-phylotree-element programmatically
  • Once all other tasks are complete, open a Pull Request (PR) to add your phylotree code to the phylotree branch in the legumeinfo/web-components repo
@alancleary alancleary added the enhancement New feature or request label Jul 10, 2023
@rispop
Copy link
Collaborator

rispop commented Jul 10, 2023

Forked the web-components repo --> https://github.com/rispop/web-components

@rispop
Copy link
Collaborator

rispop commented Jul 10, 2023

Just added the lis-phylotree.ts file --> https://github.com/rispop/web-components/blob/main/src/lis-phylotree.ts. Would this be the correct format and have the correct dependencies?

@alancleary
Copy link
Contributor Author

Just added the lis-phylotree.ts file --> https://github.com/rispop/web-components/blob/main/src/lis-phylotree.ts. Would this be the correct format and have the correct dependencies?

Good progress @rispop. I've emailed you about the format and whatnot.

@rispop
Copy link
Collaborator

rispop commented Jul 12, 2023

Created a test in /dev directory and have almost completed the component. One error regarding data still remains while compiling. Also fixed src/controllers/lis-cancel-promise-controller.ts as you said in email.

@alancleary
Copy link
Contributor Author

Created a test in /dev directory and have almost completed the component. One error regarding data still remains while compiling. Also fixed src/controllers/lis-cancel-promise-controller.ts as you said in email.

Sounds good. Let me know when you're ready for me try out your code.

@rispop
Copy link
Collaborator

rispop commented Jul 13, 2023

Finished component and test. The component prompts the user to enter a newick tree and then displays it.

@alancleary
Copy link
Contributor Author

Great! I've added more items to the task list.

@rispop
Copy link
Collaborator

rispop commented Jul 17, 2023

Declared and exported Phylotree type

@rispop
Copy link
Collaborator

rispop commented Jul 17, 2023

Added the private _data state to LisPhylotree class

@rispop
Copy link
Collaborator

rispop commented Jul 18, 2023

Replaced input with tree and new type, implemented setter with conditions if tree is a string or a Phylotree.

@rispop
Copy link
Collaborator

rispop commented Jul 18, 2023

Also changed the drawing tree code to use _data, but for some reason, the tree doesn't display properly afterward.

@rispop
Copy link
Collaborator

rispop commented Jul 18, 2023

Fixed the tree display error by modifying the setter for the tree. Also fixed a couple of compile errors.

@rispop
Copy link
Collaborator

rispop commented Jul 20, 2023

Added 2nd <lis-phylotree> component which uses the Phylotree object.

@rispop
Copy link
Collaborator

rispop commented Jul 20, 2023

Added optional color attribute

@rispop
Copy link
Collaborator

rispop commented Jul 21, 2023

Updated tree drawing code to color the nodes based on their attributes and updated Phylotree object to include some nodes with colors.
Also made the default color of the nodes gray. If any color attribute is an empty string or null, the color will be gray.

@alancleary
Copy link
Contributor Author

Updated tree drawing code to color the nodes based on their attributes and updated Phylotree object to include some nodes with colors. Also made the default color of the nodes gray. If any color attribute is an empty string or null, the color will be gray.

Mind making the default color white? That's what the Funnotate implementation does and we want to replicate that.

@rispop
Copy link
Collaborator

rispop commented Jul 21, 2023

Yup, done.

@rispop
Copy link
Collaborator

rispop commented Jul 21, 2023

Adjusted width in drawing code to use screen.availWidth rather than a set value.

@rispop
Copy link
Collaborator

rispop commented Jul 21, 2023

Nevermind it looks like window.innerWidth is better to use as it makes the tree viewable in a windowed browser tab as well.

@svengato
Copy link
Contributor

The Funnotate implementation is at
https://github.com/legumeinfo/Funnotate/blob/main/static/js/phylogram.js

@rispop
Copy link
Collaborator

rispop commented Jul 24, 2023

The layout property has been added and is used in the tree drawing code.

@alancleary
Copy link
Contributor Author

The layout property has been added and is used in the tree drawing code.

Works great! Very cool that the tree automatically redraws if you change this property on an existing element.

@rispop
Copy link
Collaborator

rispop commented Jul 25, 2023

Added scale property and used in .scale method

@rispop
Copy link
Collaborator

rispop commented Jul 26, 2023

Clears the previous tree whenever it is redrawn using this.innerHTML = "";

@rispop
Copy link
Collaborator

rispop commented Jul 31, 2023

Built query query GeneFamilies($page: Int, $pageSize: Int) { geneFamilies(page: $page, pageSize: $pageSize) { results { phylotree { newick } } } }

And variables { "pageSize": 1, "page": 1 }

Sorry the formating doesn't look right.

@rispop
Copy link
Collaborator

rispop commented Aug 1, 2023

Updated /dev/lis-phylotree.html with query and displaying it in the Tree object.

@rispop
Copy link
Collaborator

rispop commented Aug 2, 2023

Completed GraphQL query and made pull-request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants