This site is to serve as my note-book and to effectively communicate with my students and collaborators. Every now and then, a blog may be of interest to other researchers or teachers. Views in this blog are my own. All rights of research results and findings on this blog are reserved. See also http://youtube.com/c/hongqin @hongqin
Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts
Friday, January 2, 2015
Eric Raymond’s 17 Unix Rules
http://en.wikipedia.org/wiki/Unix_philosophy#Eric_Raymond.E2.80.99s_17_Unix_Rules
Monday, December 8, 2014
teaching coding
http://www.edutopia.org/blog/7-apps-teaching-children-coding-anna-adam?utm_source=twitter&utm_medium=post&utm_campaign=blog-7-apps-coding-dec-image
code.org
code.org
Friday, March 21, 2014
mortality rate change at the first time point, bug fix
When I estimated the mortality rates from simulated network aging data, the first time points always have a very low value. This abnormality bugged me because it contradicts the theoretic assumption on the initial stage, but I thought it is due to the boundary effect and did not investigate it for several weeks. Also, I thought there may be some differences between theoretical predictions and empirical data. I went over the code today and found out that it is due to typo in the code. After correction, the initial stage of mortality rate change fit extremely well to the network aging model.
Lesson learned: I should be more confident about my theoretic models and should pay more attention to abnormality during numerical works.
Lesson learned: I should be more confident about my theoretic models and should pay more attention to abnormality during numerical works.
Labels:
bugs,
lessons,
network aging,
programming,
star,
teaching
Tuesday, September 24, 2013
ifelse logical mistake
The following codes has a logical mistake, and will not assign color by categories. The ifelse should be nested.
# tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$CoatLocation[i]=="OuterCoat", 'red', tbomegaH2C1S1$color[i] )
# tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$CoatLocation[i]=="InnerCoat", 'blue', tbomegaH2C1S1$color[i] )
tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$coatflag[i]=="coat", 'red', tbomegaH2C1S1$color[i] )
tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$essenflag[i]=="essential", 'black', tbomegaH2C1S1$color[i] )
# tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$CoatLocation[i]=="OuterCoat", 'red', tbomegaH2C1S1$color[i] )
# tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$CoatLocation[i]=="InnerCoat", 'blue', tbomegaH2C1S1$color[i] )
tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$coatflag[i]=="coat", 'red', tbomegaH2C1S1$color[i] )
tbomegaH2C1S1$color[i] = ifelse( tbomegaH2C1S1$essenflag[i]=="essential", 'black', tbomegaH2C1S1$color[i] )
Wednesday, January 16, 2013
Some common bugs in bioinformatics programming and lessons in dealing with them
Many ad hoc scripts are written for bioinformatics projects. I intend to list here some common bugs that I often made. This is going to be a working list. Hopefully, this can leads to better way of coding and managing.
case 1: qw(results.H0.txt results.H1C.Gblocks.model1.txt results.H2C1S1.txt);
case 2: qw(results.H0.txt, results.H1C.Gblocks.model1.txt, results.H2C1S1.txt);
In case 2, the file name will actually be treated as "results.H0.txt,". This extra comma is a obvious mistake.
- Hard-coded links that were not updated after projects have evolved. This often lead to wrong files, or results are output to unintended directories.
- A hard-coded debugging variable that was not turned back during production runs.
- Mixing of variables names, file names, etc.
- Compatibility problems. This can occur after software upgrades. For example, after upgrade to perl 5.10.0, I have re-install bioperl to get previous codes working.
- File format problems. With myriads of data format, this problem is going to keep bugging us.
- Typos
- logical mistakes, often occur in ifelse statement.
- Correct the blind spot.
- Switch between different syntax
case 1: qw(results.H0.txt results.H1C.Gblocks.model1.txt results.H2C1S1.txt);
case 2: qw(results.H0.txt, results.H1C.Gblocks.model1.txt, results.H2C1S1.txt);
In case 2, the file name will actually be treated as "results.H0.txt,". This extra comma is a obvious mistake.
Subscribe to:
Posts (Atom)
