Friday, 25 July 2014

Success with tool tips and setting up the site...

So I have now had some real success.
Using d3.tip
from here:
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>

I have sorted out the tool tips and set up the site nicely. 

I am missing some stuff for sure but I am pretty happy with how it has shaped up. 

It's 8:40pm now and I am going home for a well deserved beer. 

Happy days!!


Wednesday, 23 July 2014

Bootstrap D3 impass - tooltips...

So it seems that Bootstrap and D3 don't work that well together particularly in terms of tooltips.

This is a major pain for me at the moment.

I don't have a good solution.

Some of the options are here:

I don't understand all the issue with it yet but I feel that I have to get to grips with this. 
The website looks so great with Bootstrap and d3 really gives me the functionality I want so....




Monday, 21 July 2014

External javascript files...

I kind of ignored my work today and learned more about Javascript and the like.

A key learning point:
Making and calling external Javascript files.
Sometimes this is useful although I don't know how wise it is.

From here, I found out how to do it:

  • put the script into a separate file with the file name, example.js
  • make sure the file begins with 
    • <!--     
    • and ends with
    •   -->
  • Within the html file this is how to call the script:
    • <script src="example.js">
    • </script>
  • The location of the script is important and the src bit describes the location. 




Friday, 18 July 2014

Putting D3 into a div

So using information from:

  • http://www.w3schools.com/html/tryit.asp?filename=tryhtml_layout_divs
  • http://christopheviau.com/d3_tutorial/
I have managed to put my d3 script into a "div" - i.e. a division of a webpage. 

The key piece of code is here:

"var svg = d3.select("#content")

.append("svg")
    .attr("width", width)
    .attr("height", height);"

when the svg variable is made, it should direct to a "div" using the name of the div after a hash mark (#). 

This then targets the graphic into that div. 

This will allow me to place more than one "div" on the same page. 

This is a VERY good result!

Previous version of the var svg declaration was directed towards "body".

More to learn for sure but this is a good one!




Things to learn a little more about (soon!)

CSS (Cascading Style Sheets) is used to style HTML elements.

http://www.w3schools.com/html/html_css.asp


Bit more about images:
http://www.w3schools.com/html/html_images.asp

Layouts
http://www.w3schools.com/html/html_layout.asp

More fundamentals about html

  • HTML elements can have attributes


  • styleSpecifies an inline CSS style for an element

TagDescription
<html>Defines an HTML document
<body>Defines the document's body
<h1> to <h6>Defines HTML headings
<hr>Defines a horizontal line
<!-->Defines a comment
TagDescription
<p>Defines a paragraph
<br>Inserts a single line break

Posting images in a webpage and important lesson about file organisation!!!!!

This is the fundamentals of html, of course but I have just learned it.

This is the link to an image:
<img src="./images/SequenceComponentStep3.png" width="400" height="400">

The first part of this is the path.
The dot has a specific meaning.

<img src="./images/SequenceComponentStep3.png" width="400" height="400">
When the dot is there, it means:
file:///Users/paulbrennan/Documents/BioJS%20Folder/html/images/SequenceComponentStep3.png
i.e. a folder in the current folder.

<img src="SequenceComponentStep3.png" width="400" height="400">
When no dot is there, it means:
file:///Users/paulbrennan/Documents/BioJS%20Folder/html/SequenceComponentStep3.png
i.e. look in current folder.

<img src="../images/SequenceComponentStep3.png" width="400" height="400">
When two dots are there, it means:
file:///Users/paulbrennan/Documents/BioJS%20Folder/images/SequenceComponentStep3.png
i.e. a folder in the same folder as the current folder.

This file organisation structure is VERY important.


Thursday, 17 July 2014

Trying to set up Biojs.ProteinPortafolio

Biojs.ProteinPortafolio
http://www.ebi.ac.uk/Tools/biojs/registry/Biojs.ProteinPortafolio.html

This is interesting.

I am trying to set up the dependencies but I can't seem to do it.

For the Biojs scripts, point is easy.
Plus I have the pointing code for jQuery, I think.

However, I can't find an easy link for jmol-12.0.48/Jmol.js and I haven't found one for raphael-2.1.0.js yet. It's possible that these are all available from the EBI but I'm not sure.

Getting tired now so I might have to leave this one till tomorrow.



Two divs!

To get two different bits into a web page, you need two div.

You can serve different stuff into each div.

I don't really understand this but I need to learn!

Playing with BioJS

So I have had a good time playing with Biojs this afternoon.

There are various places to interact with Biojs:

The tutorials seem different in the different places which is a bit odd. 

Updated tutorial as of this month which is good. 

There is the opportunity to improve this tutorial which I think I should take. 

Two key points:
  • separating code from the output
  • making it obvious that you don't need to download lots of stuff to use the javascript libraries. 

Interesting link about:
How to get a new BioJS components into GitHub and how to use GitHub generally:
https://github.com/biojs/biojs/wiki/How-to-get-a-new-BioJS-component-into-GitHub-and-deploy-it-into-the-BioJS-registry

Exploring the Component Overview for Biojs.Sequence, I am beginning to understand the parameters.

Lots to think about....


XAMPP...

So I downloaded but didn't actually set up XAMPP.
The website for that is here:
https://www.apachefriends.org/faq_osx.html


BioJS tutorial again

http://biojs.net/tutorials/usingSequenceComponentTutorial.html

updated on 2nd of July 2014

First I have to down download XAMPP

  • This is a web server
  • It seems pretty easy to install and use. 
  • It seems that it's just for development not for serving to the internet. 
Create the folders as per the picture




Now, I have to get all the necessary files into the folders.
Most are available on this page.
Open the file. Save file as in the correct folder.

Done:

So now I create a web page. 
I did cheat and just copy and paste the text but I get an error message:



This is just a style sheet error so I don't know how important it is...

Try the script:

So I can't get it to work but I don't know quite why. 
The issue is, in part, due to the local structure required. 

Working through the tutorial using the external scripts and the documentation on the Biojs.Sequence options. 
There are good options to highlight sequences, draw lines and the like. 

Step 7 which get's the data from the web is not working for me.
I am getting an error message.
This is in part due to the proxyUrl. 

If I get rid of the proxyUrl and just add the full url into the jQuery it works. 
I am missing something about urls and proxyUrls for sure!

Still it works so that's a good thing!








Using Bootstrap to make more response websites...

I would like to be able to embed my visualisation in parts of websites but I am not sure about the best way to do this. It seems more information about web code is required.

Doing a search, I came across this site:
http://24ways.org/2012/how-to-make-your-site-look-half-decent/
which has some interesting comments.

Most interestingly, it talks about using Bootstrap. I can't say I understand what this is yet but I think it's probably worth learning a bit more about.

I went to Youtube and found a tutorial:
https://www.youtube.com/watch?v=YXVoqJEwqoQ

Within the download are human readable files and 'min' files. The 'min' files are smaller and quicker for loading/transferring over the internet.



Steps for using Bootstrap:
(1) Download the files from Bootstrap.
(2) Move downloaded files into the root directory for your site (what is this?)
(3)

got distracted and confused....
going to get back to this!


Wednesday, 2 July 2014

Getting mysql up and running...

Using advice from here:
http://dev.mysql.com/doc/refman/5.0/en/macosx-installation.html

In the terminal

$ cd /usr/local/mysql

this will move to the mysql folder.

First time I tried to run
$ mysql

I got an error message:
"command not found"

I had to alter the PATH by typing this:

$ export PATH=${PATH}:/usr/local/mysql/bin

This worked but I don't think it's permanent. I probably need to add it to my .bash shell

Info from here:
http://stackoverflow.com/questions/10577374/mysql-command-not-found


I get a prompt like this:
mysql>

This is good!

I have used the command
CREATE USER
and created brennanp as a user and given myself a password.


Then to connect to the server as brennanp:
$ mysql -u brennanp -p

I don't seem to have the correct permissions as brennanp so I am connecting to the server as root again.
To do this:
$ mysql -u root -p
This asks for a password which I leave blank.

NOW following a Youtube tutorial

KEY POINT: SQL commands must be completed with a semi colon!!!

So to show the databases:
mysql> show databases;
This works and gives a useful output.

Now
mysql> create database userlogin;
This works.

NOW: go into that database
mysql> use userlogin;

Every database is made up of tables
Find out about the tables:
mysql> show tables;

To create a table, use the create table command.
This is a bit complex because you have to add lots of parameters but it's not too challenging to understand.
I added a table.
mysql> create table user(parameters...)

Then
mysql> show tables;
mysql> describe user;

to insert data:
mysql> insert into user(username, passwd, email) values('java', 'javanet', javac@gmail.com');

then
mysql> select * from user;
shows the data!

An interesting and productive few hours!
That's all for now.





32 or 64 bit kernal...

So to find out whether your computer is 32 or 64 bit kernal.

Open up terminal prompt

Type at the $ uname -a

if you see "i386" then it's a 32 bit machine,

if you see X86_64 then it's a 65 bit machine.

advice from:
https://www.youtube.com/watch?v=IOicYSxHlPc

Tuesday, 1 July 2014

Put code on gist and bl.ocks...

So it does seem to work to just cut and paste into gist:

Here is my code:
https://gist.github.com/brennanpincardiff/6dc3a53908c2e8611498


and it is also here:
http://bl.ocks.org/brennanpincardiff/6dc3a53908c2e8611498


put code on gist and blocks...

Following the tutorial here:
http://bost.ocks.org/mike/block/

Do I have node installed?
I think so...

Yes, I do. On my computer at work anyway.


So I need to Gistup from the terminal window:

m095:example paulbrennan$ gistup
Welcome to GISTUP!

Since this is your first time using gistup, we need to create a
GitHub personal access token to grant gistup permission to create
gists on your behalf. You’ll only have to do this once, and you
can easily revoke this token in the future if desired.

When you press any key to continue, your web browser will open.
Please login (if needed) and fill out the resulting form to create
an access token. When you’re done, copy the access token to the
clipboard and paste it back into the terminal.

Enter personal access token:

Mmm, I don't seem to have got this to work.


Getting a dialog box to change the visualisation....

This would be great to bring into my skill set.

I need to start with a simple example:

Can I change the colour of a rectangle with a dialog box?

This could be added to blocks as a simple example.

Some inspiration here:
http://bl.ocks.org/mbostock/3943967
changes the type of graph using a dialog box.

Brief thought - is dialog box the right word?

Checking http://en.wikipedia.org/wiki/Dialog_box maybe not!

Another nice D3 example here: http://vallandingham.me/vis/gates/

Some kind of radio switch is probably a better word.

First script to try:
Just get the dialog box on the web page.

I have done that and made it change the colour of a rectangle.

Code:
<!DOCTYPE html>
<meta charset="utf-8">

<html>
    <head>
        <title> Using Radio Box to change rectangle colour </title>
        <script src=http://d3js.org/d3.v3.min.js></script>
    </head>

    <body>
        <h2> Change the color of the square</h2>

 <p>Works as of July 1st 2014 </p>

<style>

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  margin: auto;
  position: relative;
  width: 960px;
}

form {
  position: absolute;
  left: 0px;
  top: 120px;
}

</style>
<form>
  <label><input type="radio" name="mode" value="red"> Red</label>
  <label><input type="radio" name="mode" value="blue" checked> Blue</label>
  <label><input type="radio" name="mode" value="yellow"> Yellow</label>
</form>

<body>

<script>

// It's good practice to generate an svg container that is as large as we need.
var svgContainer = d3.select("body")
.append("svg")
                     .attr("width", 400)
                     .attr("height", 400);

  // This creates a rectangle.
var rectangle = svgContainer.append("rect")
    .attr("x", 100)
                     .attr("y", 100)
                     .attr("height", 100)
                     .attr("width", 100)
                     .style("fill", "blue");
   
d3.selectAll("input").on("change", change);
   
var timeout = setTimeout(function() {
 d3.select("input[value=\"color\"]")
   .property("checked", true)
   .each(change);
}, 2000);


function change() {
  clearTimeout(timeout);
  if (this.value === "red") transitionRed();
  if (this.value === "blue") transitionBlue();
  if (this.value === "yellow") transitionYellow();
}


function transitionRed() {
var rectangle = svgContainer.append("rect")
     .attr("x", 100)
                          .attr("y", 100)
                          .attr("height", 100)
                          .attr("width", 100)
                          .style("fill", "red");
}

function transitionBlue() {
var rectangle = svgContainer.append("rect")
     .attr("x", 100)
                          .attr("y", 100)
                          .attr("height", 100)
                          .attr("width", 100)
                          .style("fill", "blue");
}

function transitionYellow() {
var rectangle = svgContainer.append("rect")
     .attr("x", 100)
                          .attr("y", 100)
                          .attr("height", 100)
                          .attr("width", 100)
                          .style("fill", "yellow");
}


</script>

</body>
</html>