Skip to main content

Posts

Bioinformatics tool

0. BIOPYTHON mafIO ==================     def mafParsing(self,chrName ):         idx = MafIndex(chrName + ".mafindex", chrName + ".maf", "hg19." + chrName )         multiple_alignment = idx.get_spliced([60000] ,  [60020] , strand = "-")               AlignIO.write(multiple_alignment, "hg19_All.fa", "fasta")         total_bases_tupBel1  = 0;         for seqrec in multiple_alignment:                 if seqrec.id.startswith("tupBel1"): # mm4  tupBel1  tanvir                     # don't count gaps as bases              ...

java binary search

return the match index /  the next index if no match int findDownstreamStart( int key)     {         int imax = vectNegStart.size();         int imin = 0;         int imid = (imin + imax) / 2;                 if( key <= vectNegStart.get(0))             return 0;         if( key >= vectNegStart.get(imax-1 ))             return imax-1;                     // continue searching while [imin,imax] is not empty         while (imax >= imin)         {             /* calculate the midpoint for roughly e...

java linkedhashmap linked hashmap

// create map LinkedHashMap hashmapGene = new LinkedHashMap() (); // insert element into map             if( hashmapGene.containsKey(geneID) )             {                                GeneInfo gene = hashmapGene.get(geneID);                 gene.determineClass(tmp[3]);                            }else             {                 hashmapGene.put( geneID , new GeneInfo(chrom , st,end, promStartCoord, promEndCoord ,                ...

JAVA set operation union intersection difference

// create Ordered set Set mySet = new LinkedHashSet (); mySet.add( str ); // union Set union = new HashSet (s1); union.addAll(s2); Set intersection = new HashSet (s1); intersection.retainAll(s2); Set difference = new HashSet (s1); difference.removeAll(s2);     /// iteratate set element String[] arr = (String[]) mySet.toArray(new String[ mySet.size()]); int setSize = arr.length; for(int c=0; c < setSize;c++) { if(c==setSize-1) bufCell_Uniprot.append(arr[c]+"\n"); else bufCell_Uniprot.append(arr[c]+","); }   /// iteratate set element Iterator itr = mySet.iterator(); while( itr.hasNext()) { bout.write( itr.next() +"\n"); }

LINUX shell script tutorial

  1. Text Processing  Cut:  only selected column: 1 BASED index // check the unique value on 7 th column cut -f 7  amel_OGSv3.2.gff3 | sort -u | wc -l default is tab delimited cut   -f 1,3  fName if other is used as delimiter cut   -f 1,3 -d ':'  fName GREP copy line containing "gene*" // to find exact word use -w // it will find as a substirng/word , But if you want exact word use -w grep -iw "gene*" amel_OGSv3.2.gff3 > ./amel_OGSv3.2.gene.gff3 grep -w "[-]9" fname // find word -9 in file. grep multiple words in file  grep 'good\|bad' test.txt The following command line will grep from 1  lines [before] the match through 1000 lines [after] the match. grep "^AC P0001" factor.table -B1 -A1000 > out.txt “^AC P0001” is a regular expression. The carrot (^) means the start of a line. So, the quoted text means to find the line that starts with the dealer name AC P0001. The ...

Java string manipulation

Stringtokenizer ==============                 strLine = brAllrna.readLine(); // A                 StringTokenizer stringTokenizer = new StringTokenizer(strLine, " \t");                 Vector pwmA = new Vector ();                 while (stringTokenizer.hasMoreElements()) {                     Double val = Double.parseDouble(stringTokenizer.nextElement().toString() );                     pwmA.add(val);                                     }

matlab ROC curve

function makeROC() [X,Y,T,AUC] = perfcurve(  trueTestLabel ,  predictedScore , positiveClassLabel ); AUC plot(X,Y) xlabel('1-specificity'); ylabel('sensitivity'); figure plot(T, [Y  1-X   ] ); legend('sensitivity','specificity'); xlabel('Threshold'); ylabel('change in sensitivity and specificity') end function perfBasedOnROCthreshold thr = .41 rocInfo = load('roc20.info'); perfOrigLabel = rocInfo(: , 1); perfPredLabel = rocInfo(: , 2); perfPredScore = rocInfo(: , 3); noTeseCase = size(perfPredScore ,1); newPredictedLabel = zeros( noTeseCase,1); [X,Y,T,AUC] = perfcurve(perfOrigLabel, perfPredScore,1); plot(X,Y) xlabel('1-specificity'); ylabel('sensitivity'); figure plot(T,Y) xlabel('threshold'); ylabel('sensitivity'); figure plot(T,1-X) xlabel('threshold'); ylabel('specificity'); newPos = find(perfPredScore >= thr); newNeg = find(perfPredScor...