Posts

Showing posts with the label Perl

Hash_lookup for Cluster data

Hashes are exciting !! Hash tables are one of the most powerful lookup operations !. It gives the power of random access & hence lightning fast :-).  Imagine that, you have non-homogenous data (again: inconsistent number of column values, for instance cluster data). You have a list and you have to map the entries or fish the desired value from the huge file ! For example, your query file has 65000 entries and cluster file has 100000 entries in which the first column is the correspondence. If you just write the basic 'for loop' it is going to iterate atleast 65000 * 100000 (in case of thorough search) or slightly lesser if you break after a match is found. In any case, it can time humongous amount of time. Solution ? Hashes !! For same number of entries, my job took 3-7 seconds !  Dictionaries in python can also do the same thing !  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #Code to map clu...

BLAST_TABULAR_OUTPUT Generator

Few MPI versions do not support the very useful -m 8 tabular output format. The following code can be used to parse the raw blast output obtained from mpi_blast to tabular output file. The creditials of original creator and modifications are given in comments section of the code. #========================================================================================= # Modified BLAST Parser - Script for parsing the BLAST output in tabular format # Version 1.1.6 (November 26, 2015) # Modified by Arun Prasanna (arunprasanna83@gmail.com) from orginal script by Kirill Kryukov (http://kirill-kryukov.com/kirr/). He also has many other useful utilities..Check out !! # # # Purpose: Few versions of MPI-BLAST do not support tabular output or often the user faces # error while opting for tabular output. Hence the original code is modified to produce # tabular Output verbatim -m 8 option. The output file is compliant with other clustering # programs like Silix # # Changes made ...

Perl_Line_Picker

Line_Picker.pl => Average execution time: Few seconds for a file with >20000 lines Input file: Text file with non-homogeneous entries separated by tab character Output desired: Text file only with desired number of entries in each line 1: open(out, ">Output_file.txt"); 2: open(infile, "Input_File.txt"); 3: while(<infile>) 4: { 5: @line = split /\s+/; 6: $num = scalar @line; 7: if($num > 4 && $num < 101){ print out "@line\n";} 8: } 9: print "Program complete\n"; Example Input: 1. A  B  C  D 2. E   F  G 3. H Example Output: (Only lines with > 1 entry) A  B  C  D E  F  G