Académique Documents
Professionnel Documents
Culture Documents
Python 2 : Python 2.7 is the most recent version of the Python 2, it has generators (which behave
like a list but only evalaute the value as they are needed). It has modules with support for
datatime calculations, large number support, file handling, persistent objects, database access,
compression, csv files, multithreading, sockets, email, html, xml, web, audio, and GUI. There are
also a lot of additional libraries available at pypy (http://pypi.python.org/pypi).
Python 3 : Python 3.3 is the most recent version of Python. A few of the main changes from
version 2 of Python are the / operator which now returns a floating point value rather than an
integer value, and the print command which is now a function, so you enclose the expression you
want to print in (), strings were changed to unicode. There is a program called 2to3 that helps
you convert programs written for Python 2 to Python 3.
Help on Python Programming Basics Python Programming Syntax, How to use an IDE
(Eclipse and Python Visual Studio), methods.
Python supports a rich variety of file handling, with the ability to read and write to files, to check
if a file exists, to delete a file, to create a directory. It uses exception handling to report on errors.
In the os module there is listdir to get the contents of a directory.Advanced Python Language
Programming support.
You can save objects to a file or memory with pickle, it automatically handles references to other
objects to ensure that they are not stored multiple times. dump and load are used to save to a file,
where as dumps and loads are used to save to a string.
2-Repeatedly prompt the user for a query (if they enter q, then quit)
3-Find the terms in the query, and calculate the appropriate weight for each query term (hint:) :
weight for query = log2 (total number of doc / number of times the word appear in all the Doc).
weight for query =((log( float( len( documents) ) / docfreq [ term ] ))/log(2))
the Output for the query quick brown vex zebrasshould be :
Term Weights
Quick 0.58
Brown 1.58
Vex 0.58
Zebras 1.58
5-List the documents in order of decreasing similarity to the query, along with their similarity
value
7-Make sure that querying quick brown vex zebras a 2nd time gives the same result
8-What is the result for the query quick brown vex lion?
Genral Hint :
if querystring == 'q':
print '\nGoodbye!\n'
break
do more stuff
items = results.items()
Please find the attached python code and data file. I need to code to be done ASAP. Output
should be in Fas file format.
Requirement:
1) Need to find all the unique sequences in the given file(Done already).
Note: we only look into sequence not the header for repetition.
3) Sort the unique sequence based on the count number of the header in descending order.
1) program should read the reference sequence and Read Sequence
2) User input from keyboard number and SAM cigar string.
3) use number and cigar value and align the sequence
4) write the output sequences into alignedoutput.fas file
Algorthim:
Steps involved:
Remove all the characters in reference string up to the number specified by the user:
Step-1
Example: user specified 5
Ref string= AAAAAAATTTTTTTCCCCCGGGGG
it will change to= AATTTTTTTCCCCCGGGGG
I am attaching sample file and its values also user value is 2236
Cigar string is 34S291M1D27M1I9M for input.
This assignment involves writing two small Python scripts and a report. Before you start you
must download the file summarysheets.zip from the course web page, unzip it and print the
summary sheet with your name on it. The file Name Ver.pdf tells you which sheet has your name
on it. There are two parts to the assignment:
Part 1 Recovery of an encrypted word using a forward search attack.
A 5 character word consisting of random capital letters has been encrypted using the RSA
algorithm. The word was encrypted in two 24 bit blocks using the ASCII values of the characters
(6510 to 9010 ) and padding the last block with a space (ASCII 3210 ). Each block was formed
by concatenating the 8 bit binary patterns of each of the characters in the block. Thus creating
two 24--bit intergers (actually 23bit integers, as the MSB is zero). You are provided with the
public key used for the encryption and with the decimal values of the encrypted blocks see
your summary sheet. You are required to use a forward search using a Python dictionary/hash
table to recover the word that was encrypted.[25] Part 2 Decryption of a jpeg file that has
been encrypted using a Vernam cipher. Download the byte compiled Python module randbit.pyc
from the module web page. The function nextbit() in this module can be used to generate a
random bit stream using one of a series of different generators. Below is an example of its use to
generate and display 50 random bits.
import sys
from randbit import *
# for information on nextbit() type randbit.nextbit in the help environment # of idle or in the
standard python shell
seed = 98071
for i in range(50):
seed,bit = nextbit(7,seed) # call to nextbit, using generator 7, which returns
# a modified value of the seed and a 'random' bit
sys.stdout.write(bit)# print bit without crlf print
Output from above: 00000001011111110001011100011111100010001111000000
The seed and generator that you are to use in this part of the assignment are given in your
summary sheet. Extract your encrypted jpeg file (see summary sheet) from the archived file on
the module web page. Your jpeg has been encrypted, one byte at a time, with a Vernam cipher
using a random bit stream generated using the seed and generator that you have been assigned.
Random bytes were created by concatenating 8 bits at a time from the random bit stream, with
the MSB of each byte being the first of the 8 bits taken from the stream.
You are to decrypt and display the file, which should be a picture of three printable ASCII
characters.
NOTE: the Departmental machines are running Python 2.4 and randbit.pyc was complied with
this version of Python.
Your Scripts
1. Must be adequately commented and referred to in your report.
Your Report
1. MUST begin with the filled in Summary sheet provided.
2. For Part 1 it should explain what is meant by a forward search and show and explain all the
steps that you used to determine the word that had been encrypted.
3. For Part 2 it should show and explain how the supplied encrypted jpeg file was:
?? read;
?? decrypted; ?? written;
?? displayed.
?? Your report including your scripts should be word processed and be no more than SIX A4
pages (excluding the summary sheet) 12pt, sensible margins (i.e. about 2cm), one and a
half line spacing, and having a footer with the module number, your name and the page number.
?? You report should be stabled securely with the coursework receipting proforma and NOT
placed in a plastic wallet and then stapled.
?? If additional sources are used they must be clearly acknowledged and fully and properly
referenced.
?? The report must be in YOUR OWN WORDS except of course for any quotations. ?? The
normal Faculty handing in procedure should be adopted.