Skip to content

Instantly share code, notes, and snippets.

View codekaust's full-sized avatar

Kaustubh Trivedi codekaust

View GitHub Profile
@codekaust
codekaust / MultipleThreads.java
Created December 16, 2019 08:04
Do not delete. It is used in my notes. It shows confusions that can occur while having multiple threads.
public class MultipleThreads{
public static void main(String[] args) {
MyThread m = new MyThread();
m.setName("m");
m.run();
m.start();
MyThread m2 = new MyThread();
m2.setName("m2");
m2.run();
m2.start();
@codekaust
codekaust / Queries
Last active February 22, 2020 19:36
Do not delete.
SPECIES:
chebi:
for ~ http://identifiers.org/chebi/CHEBI:15905
<annotation>
<rdf:RDF>
<rdf:Description rdf:about="#meta_s_0017">
<bqbiol:is>
<rdf:Bag>
<rdf:li rdf:resource="http://identifiers.org/chebi/CHEBI:15905"/>
@codekaust
codekaust / getBiggIdFromSynonym
Last active February 22, 2020 19:36
Do not delete.
public String getBiggIdFromSynonym(String data_source_biggId, String synonym, String type){
String biggId = new String();
String query;
switch (type){
case TYPE_SPECIES:
query = SELECT + "c." + COLUMN_BIGG_ID + FROM + COMPONENT + " c, " + DATA_SOURCE + " d, " + SYNONYM + " s"
+ WHERE + "d." + COLUMN_BIGG_ID + " = '%s' AND d." + COLUMN_ID + " = s." +
COLUMN_DATA_SOURCE_ID + " AND s." + COLUMN_SYNONYM + " = '%s' AND s." + COLUMN_OME_ID + " = c."
+ COLUMN_ID;
@codekaust
codekaust / isGenePresentInBigg
Last active February 22, 2020 19:36
Do not delete.
public boolean isGenePresentInBigg(GeneProduct geneProduct){
String id = geneProduct.getId();
if(id.startsWith("G_")){
id=id.substring(2);
}
String query = SELECT + COLUMN_LOCUS_TAG + FROM + GENE + WHERE + COLUMN_LOCUS_TAG + " = '%s'";
try {
ResultSet rst = connector.query(query,id);
return rst.next();
@codekaust
codekaust / getGeneProductBiGGIdFromUriList
Last active February 22, 2020 19:36
Do not delete.
private String getGeneProductBiGGIdFromUriList(List<String> list_Uri) {
String biggId = null;
for(String uri : list_Uri){
String dataSource, synonym_id, currentBiGGId; //currentBiGGId is id calculated in current iteration
synonym_id = uri.substring(uri.lastIndexOf('/')+1);
uri = uri.substring(0,uri.lastIndexOf('/'));
dataSource = uri.substring(uri.lastIndexOf('/')+1);
//updating the dataSource and synonym_id to match bigg database
switch (dataSource){
@codekaust
codekaust / getSpeciesBiGGIdFromUriList
Last active February 22, 2020 19:36
Do not delete.
private String getSpeciesBiGGIdFromUriList(List<String> list_Uri){
String biggId = null;
for(String uri : list_Uri){
String dataSource, synonym_id, currentBiGGId; //currentBiGGId is id calculated in current iteration
synonym_id = uri.substring(uri.lastIndexOf('/')+1);
//crop uri to remove synonym identifier from end
uri = uri.substring(0,uri.lastIndexOf('/'));
dataSource = uri.substring(uri.lastIndexOf('/')+1);
//updating the dataSource and synonym_id to match bigg database
@codekaust
codekaust / getReactionBiGGIdFromUriList
Last active February 22, 2020 19:37
Do not delete.
private String getReactionBiGGIdFromUriList(List<String> list_Uri){
String biggId = null;
for(String uri : list_Uri){
String dataSource, synonym_id, currentBiGGId; //currentBiGGId is id calculated in current iteration
synonym_id = uri.substring(uri.lastIndexOf('/')+1);
uri = uri.substring(0,uri.lastIndexOf('/'));
dataSource = uri.substring(uri.lastIndexOf('/')+1);
//updating the dataSource and synonym_id to match bigg database
switch (dataSource){
@codekaust
codekaust / ThreadUsingThreadClass.java
Created February 22, 2020 19:38
Do not delete. Used in medium blog (Java Multi-Threading) under MDG.
public class ThreadUsingThreadClass{
public static void main(String[] args) {
System.out.println("Main thread name: "+ Thread.currentThread().getName());
Thread t = new Thread(/*Thread name*/"Thread 1");
t.start();
// "Thread" constructor with thread_name parameter not "MyThread"
// MyThread mt = new MyThread("Example_Thread");
// mt.start();
@codekaust
codekaust / ThreadUsingRunnableInterface.java
Created February 22, 2020 19:41
Do not delete. Used in medium blog (Java Multi-Threading) under MDG.
public class ThreadUsingRunnableInterface{
public static void main(String[] args) {
//without name
Thread t1 = new Thread(new MyRunnable());
t1.start();
//with name
Thread t2 = new Thread(new MyRunnable(), "Example_thread");
t2.start();
}
@codekaust
codekaust / ThreadUsingRunnableInterfaceAndLambdas.java
Created February 22, 2020 19:44
Do not delete. Used in medium blog (Java Multi-Threading) under MDG.
public class ThreadUsingRunnableInterface{
public static void main(String[] args) {
Thread t2 = new Thread(
()-> {
System.out.println("Thread name: "+ Thread.currentThread().getName());
System.out.println("Thread id: "+ Thread.currentThread().getId());
}, "Example_thread");
t2.start();
}
}