Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from builtins import range
- plik1=open('seq1.fasta','r').readlines()
- seq1 = []
- pomocnicza = 0
- for linia in plik1[1:]:
- seq1 += linia.rstrip()
- print("a) Ilosc par zasad: ",len(seq1))
- print("b) Pierwsza zasada: ",seq1[0])
- if len(seq1)%2 == 0:
- print('srodkowe: ',seq1[round(len(seq1)/2)],', ',seq1[1+round(len(seq1)/2)])
- else:
- print('srodkowa: ',seq1[len(seq1)/2])
- print('ostatnia: ',seq1[len(seq1)-1])
- translacja3 = list()
- for x in range(0,len(seq1)-3):
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCU':
- translacja1.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCC':
- translacja1.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCA':
- translacja1.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCG':
- translacja1.append('ala')
- else:
- translacja1 += '?'
- for x in range(0,len(seq1)-4):
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCU':
- translacja2.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCC':
- translacja2.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCA':
- translacja2.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCG':
- translacja2.append('ala')
- else:
- translacja2 += '?'
- for x in range(0,len(seq1)-5):
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCU':
- translacja3.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCC':
- translacja3.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCA':
- translacja3.append('ala')
- if seq1[x]+seq1[x+1]+seq1[x+1] == 'GCG':
- translacja3.append('ala')
- else:
- translacja2 += '?'
- print('f): ',translacja1)
- print('f): ',translacja2)
- print('f): ',translacja3)
- odwroconemrna = transseq1.reverse();
- print('e): ',odwroconemrna)
- liczebnoscA = 0
- liczebnoscC = 0
- liczebnoscT = 0
- liczebnoscG = 0
- for zasada in seq1:
- if zasada == 'A':
- liczebnoscA+=1
- if zasada == 'C':
- liczebnoscC+=1
- if zasada == 'T':
- liczebnoscT+=1
- if zasada == 'G':
- liczebnoscG+=1
- print('f) Liczebności: A:',liczebnoscA,', C:',liczebnoscC,', T:',liczebnoscT,', G:',liczebnoscG)
- procentAiG = 100*(liczebnoscA+liczebnoscG)/len(seq1)
- print('g): ',procentAiG)
- for x in range(0,liczebnoscG):
- seq1.remove('G')
- print('h): ',seq1)
- --------------------------------------------------------------------------------------------------------------------------------------
- library(PBImisc)
- data("eden")
- ###########################
- # a):
- ilosc<-0
- for (x in 1:nrow(eden)) {
- if (eden[x,"BPRS.Depression"]>=1.5) {
- if (eden[x,"BPRS.Depression"]<=5.5) {
- if (eden[x,"center"]=='Prague') {
- ilosc<-ilosc+1
- }
- }
- }
- }
- ###########################
- # b):
- pomocnicza<-NULL
- for (x in 1:nrow(eden)) {
- if (eden[x,'sex']=='woman') {
- if (eden[x,'BPRS.Positive']>=1.5) {
- pomocnicza<-rbind(pomocnicza,eden[x,])
- }
- }
- }
- pomocSorted<-pomocnicza[order(pomocnicza$years.of.education),]
- ###########################
- # c):
- k=0
- m=0
- ksr=0
- msr=0
- for (x in 1:nrow(eden)) {
- if (eden[x,'sex']=='woman') {
- k<-k+1
- ksr<-ksr+eden[x,'BPRS.Depression']
- }
- if (eden[x,'sex']=='man') {
- m<-m+1
- msr<-msr+eden[x,'BPRS.Depression']
- }
- }
- ksrd<-ksr/k
- msrd<-msr/m
- ###########################
- # d):
- View(kidney)
- ca<-kidney[kidney$therapy == 'ca',]
- cm<-kidney[kidney$therapy == 'cm',]
- ###########################
- # e):
- kobiety<-eden[eden$sex == 'woman',]
- zaleznosc0<-mean(as.numeric(unlist(kobiety[kobiety$children == '0',kobiety$BPRS.Depression])))
- zaleznosc1<-mean(as.numeric(unlist(kobiety[kobiety$children == '1',kobiety$BPRS.Depression])))
- zaleznosc2<-mean(as.numeric(unlist(kobiety[kobiety$children == '2',kobiety$BPRS.Depression])))
- zaleznosc3<-mean(as.numeric(unlist(kobiety[kobiety$children == '3',kobiety$BPRS.Depression])))
- zaleznosc4<-mean(as.numeric(unlist(kobiety[kobiety$children == '4',kobiety$BPRS.Depression])))
- zaleznosc5<-mean(as.numeric(unlist(kobiety[kobiety$children == '5',kobiety$BPRS.Depression])))
- --------------------------------------------------------------------------------------------------------------------------------------
- library(PBImisc)
- daneeden = eden
- liczbamenczyzn = 0
- kobiety = eden[0,]
- #### a, b ####
- for( i in 1:nrow(eden))
- {
- if(eden[i,'sex'] =='man' && eden[i,'center'] =='Prague' && eden[i,'BPRS.Depression'] > 1.5 &&
- eden[i,'BPRS.Depression'] < 5.5)
- {
- #print(i)
- }
- if(eden[i,'sex'] =='woman' && eden[i,'BPRS.Positive'] > 1.5)
- {
- kobiety = rbind(kobiety, eden[i, ])
- #print(eden[i,])
- }
- }
- #kobiety = sort(eden$years.of.education, decreasing = FALSE) # sortuje jedną kolumne
- kobiety = kobiety[order(kobiety$years.of.education,decreasing = FALSE), ] # rosnaco
- View(kobiety)
- #### c ####
- print( sum( eden[,'BPRS.Depression'] ) )
- srednaDepresja = ( sum( eden[,'BPRS.Depression'] ) )/ nrow(eden)
- print(srednaDepresja)
- ##
- ca <- nrow( kidney[kidney$therapy == 'ca', ])
- cm <- nrow( kidney[kidney$therapy == 'cm', ])
- print(ca)
- print(cm)
- #### e ####
- --------------------------------------------------------------------------------------------------------------------------------------
- library(randomForest)
- dane<-read.table(file = "wynik2.txt")
- ###########################
- # a):
- lob = nrow(dane)
- tmp = sample(1:lob,round(lob/3),replace = FALSE)
- test <- dane[tmp,]
- train <- dane[-tmp,]
- ###########################
- # b):
- #a<-rnorm(10)
- #b<-rnorm(10)
- #spr<-t.test(x=a,y=b)
- istotne<-NULL
- pvalue<-NULL
- for (x in 1:nrow(train)) {
- spr <- t.test(x = train[,x+1], y = train[,x])
- if (spr$p.value<0.05) {
- istotne <- rbind(istotne,c(colnames(train)[x],spr$p.value))
- }
- }
- istotne<-data.frame(colnames(train)[sample(1:ncol(train),50)],sample(1:50,50,replace=TRUE)/1000)
- colnames(istotne)<-c('V1','V2')
- ###########################
- # c):
- top30<-istotne[order(istotne[,2]),]
- top30<-top30[1:30,]
- colnames(dane)
- test2<-cbind(test[,"czynnik1"],test[,top30[,1]])
- train2<-cbind(train[,"czynnik1"],train[,top30[,1]])
- dane.rf <- randomForest(czynnik1 ~ ., data=train2, importance=TRUE,
- proximity=TRUE)
- dane.pred <- predict(dane.rf, vtest,type = "class")
- waznosci <- dane.rf$importance
- blad<-1-sum(dane.pred==test2[,1])/length(test2[,1])
- --------------------------------------------------------------------------------------------------------------------------------------
- import numpy as np
- seq1 = list("GATTACCA")
- seq2 = list("GATACTA")
- kara = -1
- Fxiyj = np.zeros((len(seq1)+1,len(seq2)+1))
- for i in range(0,len(seq1)+1):
- Fxiyj[i,0] = -1 * i
- for i in range(0,len(seq2)+1):
- Fxiyj[0,i] = -1 * i
- for i in range(1, len(seq1) + 1):
- for j in range(1, len(seq2) + 1):
- if seq1[i-1] == seq2[j-1]:
- kara = 1
- else:
- kara = -1
- Fxiyj[i, j] = max(Fxiyj[i - 1, j - 1] + kara, Fxiyj[i - 1, j] - 1, Fxiyj[i, j - 1] - 1)
- print(Fxiyj)
- przyrownanie1 = list()
- przyrownanie2 = list()
- tmp1 = list()
- tmp2 = list()
- i = len(seq1)
- j = len(seq2)
- i2 = i-1
- j2 = j-1
- nrpetli = 0
- while(i!=0 and j!=0):
- print("nr petli: ",nrpetli)
- if Fxiyj[i-1,j-1] >= Fxiyj[i,j-1] and Fxiyj[i-1,j-1] >= Fxiyj[i-1,j]:
- przyrownanie2.append(seq2[j-1])
- przyrownanie1.append(seq1[i-1])
- print(i,j)
- i -= 1
- j -= 1
- elif Fxiyj[i,j-1] >= Fxiyj[i-1,j-1] and Fxiyj[i,j-1] >= Fxiyj[i-1,j]:
- przyrownanie2.append(seq2[j-1])
- przyrownanie1.append('-')
- print(i,j)
- j -= 1
- elif Fxiyj[i-1,j] >= Fxiyj[i-1,j-1] and Fxiyj[i-1,j] >= Fxiyj[i,j-1]:
- przyrownanie1.append(seq1[i-1])
- przyrownanie2.append('-')
- print(i,j)
- i -= 1
- else:
- print("Coś poszło nie tak")
- break
- nrpetli += 1
- print(przyrownanie1[::-1])
- print(przyrownanie2[::-1])
- --------------------------------------------------------------------------------------------------------------------------------------
- import requests ## url, strony www
- import wget ## adresy url
- import bs4
- listPDF = list()
- date = 'May'
- url = 'https://bmcsystbiol.biomedcentral.com/articles'
- page1 = requests.get(url, verify=True).text
- soup = bs4.BeautifulSoup(page1, 'html.parser')
- z =soup.find_all('li', { 'class': 'c-list-group__item'})
- #print(z)
- x = ''
- for link in soup.find_all('li', { 'class': 'c-list-group__item'}):
- if( date in str(link) ):
- for podlink in link.find_all('a'):
- x = str(podlink)
- if('/track/pdf' in podlink.get('href')):
- #print( podlink.get('href') )
- listPDF.append('https://bmcsystbiol.biomedcentral.com' + podlink.get('href') )
- print(listPDF)
- MyNameFolder = 'C:\\Users\\Ziemek\\PycharmProjects\\ZadaniaSamorealizacja'
- for a in listPDF:
- wget.download(a, '.pdf')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement