Example #1
0
def makeintlistdic_from_allep(dir_name, run_dir):
    i = 1
    intlistdic = {}
    len_ave_list, pi_ave_list, hyd_ave_list, len_var_list, pi_var_list, hyd_var_list = [
    ], [], [], [], [], []

    while True:
        if os.path.exists(dir_name + run_dir + str(i) + '.txt'):
            len_list_ep, pi_list_ep, hyd_list_ep = [], [], []
            seq_size = 0

            with open(dir_name + run_dir + str(i) + '.txt') as f:
                for line in f:
                    seq = line[:-1]
                    seq = GlobalDescriptor(seq)
                    seq.length()
                    len_list_ep.append(seq.descriptor[0][0])
                    seq.isoelectric_point()
                    pi_list_ep.append(seq.descriptor[0][0])
                    seq.hydrophobic_ratio()
                    hyd_list_ep.append(seq.descriptor[0][0])
                    seq_size += 1

                len_ave_list.append(round(len(len_list_ep) / seq_size, 3))
                pi_ave_list.append(round(len(pi_list_ep) / seq_size, 3))
                hyd_ave_list.append(round(len(hyd_list_ep) / seq_size, 3))
                len_var_list.append(round(statistics.pvariance(len_list_ep),
                                          3))
                pi_var_list.append(round(statistics.pvariance(pi_list_ep), 3))
                hyd_var_list.append(round(statistics.pvariance(hyd_list_ep),
                                          3))

                i += 1
        else:
            break

    intlistdic["len_ave"] = len_ave_list
    intlistdic["pi_ave"] = pi_ave_list
    intlistdic["hyd_ave"] = hyd_ave_list
    intlistdic["len_var"] = len_var_list
    intlistdic["pi_var"] = pi_var_list
    intlistdic["hyd_var"] = hyd_var_list
    # print(intlistdic, len(len_ave_list))

    return intlistdic
Example #2
0
            header_list = []
            # row_list.append("\n")
            row_list.append("\n" + run_dir + file_name)

            for line in f:
                seq = line[:-1]
                DesObject = PyPro.GetProDes(seq)
                if do_length:
                    len_list.append(len(seq))
                if do_pi:
                    glob_seq = GlobalDescriptor(seq)
                    glob_seq.isoelectric_point()
                    pi_list.append(glob_seq.descriptor[0][0])
                if do_hyd:
                    glob_seq = GlobalDescriptor(seq)
                    glob_seq.hydrophobic_ratio()
                    hyd_list.append(glob_seq.descriptor[0][0])
                if do_aacomp:
                    aacomp_diclist.append(DesObject.GetAAComp())
                if do_ctd:
                    # calculate 147 CTD descriptors
                    # Default: False
                    ctd_diclist.append(DesObject.GetCTD())

        if file_name == real_file:
            run_dir = real_file + "/"
        if not os.path.exists(dir_name + run_dir):
            os.mkdir(dir_name + run_dir)
        if do_length:
            len_ave = makehist_from_intlist(len_list, "len", eval_dir, run_dir,
                                            file_name)
    try:
        desc = GlobalDescriptor([database['Sequence'][i]])
        desc.aliphatic_index()
        aliphatic_array.append(desc.descriptor[0][0])
    except:
        aliphatic_array.append('')

database['aliphatic_index'] = aliphatic_array

print("Estimate hydrophobic_ratio_array")
#estimate hydrophobic_ratio
hydrophobic_ratio_array = []
for i in range(len(database)):
    try:
        desc = GlobalDescriptor([database['Sequence'][i]])
        desc.hydrophobic_ratio()
        hydrophobic_ratio_array.append(desc.descriptor[0][0])
    except:
        hydrophobic_ratio_array.append('')

database['hydrophobic_ratio'] = hydrophobic_ratio_array

print("Estimate hydrophobicity_profile_array")

#profile hydrophobicity
hydrophobicity_profile_array = []
for i in range(len(database)):
    try:
        desc = PeptideDescriptor([database['Sequence'][i]],
                                 scalename='Eisenberg')
        desc.calculate_profile(prof_type='H')
Example #4
0
def exec(peptide, time_node):
	file = open("../src/public/jobs/service1/service1.fasta", "w") 
	file.write(peptide)
	file.close()
	fasta = SeqIO.parse("../src/public/jobs/service1/service1.fasta", "fasta")
	if(any(fasta) == False): #False when `fasta` is empty
		return "error"
	cantidad = 0
	for record in SeqIO.parse("../src/public/jobs/service1/service1.fasta", "fasta"):
		cantidad = cantidad+1
	if (cantidad == 1):
		properties = {}
		for record in SeqIO.parse("../src/public/jobs/service1/service1.fasta", "fasta"):
			properties[str(record.id)] = {}
			#save properties

			properties[str(record.id)]["length"] = len(record.seq)

			#formula
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.formula(amide=True)
				properties[str(record.id)]["formula"] = desc.descriptor[0][0]
			except:
				properties[str(record.id)]["formula"] = "-"

			#molecular weigth
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.calculate_MW(amide=True)
				properties[str(record.id)]["molecular_weigth"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["molecular_weigth"] = "-"

			#boman_index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.boman_index()
				properties[str(record.id)]["boman_index"] = float("%.4f" % desc.descriptor[0][0])				
			except:
				properties[str(record.id)]["boman_index"] = "-"

			#charge
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.calculate_charge(ph=7, amide=True)
				properties[str(record.id)]["charge"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["charge"] = "-"
				

			#charge density
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.charge_density(ph=7, amide=True)
				properties[str(record.id)]["charge_density"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["charge_density"] = "-"

			#estimate isoelectric point
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.isoelectric_point()
				properties[str(record.id)]["isoelectric_point"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["isoelectric_point"] = "-"

			#estimate inestability index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.instability_index()
				properties[str(record.id)]["instability_index"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["instability_index"] = "-"

			#estimate aromaticity
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.aromaticity()
				properties[str(record.id)]["aromaticity"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["aromaticity"] = "-"

			#estimate aliphatic_index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.aliphatic_index()
				properties[str(record.id)]["aliphatic_index"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["aliphatic_index"] = "-"

			#estimate hydrophobic_ratio
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.hydrophobic_ratio()
				properties[str(record.id)]["hydrophobic_ratio"] = float("%.4f" % desc.descriptor[0][0])	
			except:
				properties[str(record.id)]["hydrophobic_ratio"] = "-"

			#profile hydrophobicity
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_profile(prof_type='H')
				properties[str(record.id)]["hydrophobicity_profile"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["hydrophobicity_profile"] = "-"

			#profile hydrophobic
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_profile(prof_type='uH')
				properties[str(record.id)]["hydrophobic_profile"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["hydrophobic_profile"] = "-"

			#moment
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_moment()
				properties[str(record.id)]["calculate_moment"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["calculate_moment"] = "-"

			try:
				os.mkdir("../src/public/jobs/service1/"+time_node)
			except:
				print("Error")
			
			#generate plot profile
			plot_profile(str(record.seq), scalename='eisenberg', filename= "../src/public/jobs/service1/"+time_node+"/profile.png")

			#generate helical wheel
			helical_wheel(str(record.seq), colorcoding='charge', lineweights=False, filename= "../src/public/jobs/service1/"+time_node+"/helical.png")
			
			return(properties)
	
	if (cantidad > 1):
		properties = {}
		for record in SeqIO.parse("../src/public/jobs/service1/service1.fasta", "fasta"):
			properties[str(record.id)] = {}

			properties[str(record.id)]["length"] = len(record.seq)
			
			#formula
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.formula(amide=True)
				properties[str(record.id)]["formula"] = desc.descriptor[0][0]
			except:
				properties[str(record.id)]["formula"] = "-"

			#molecular weigth
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.calculate_MW(amide=True)
				properties[str(record.id)]["molecular_weigth"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["molecular_weigth"] = "-"

			#boman_index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.boman_index()
				properties[str(record.id)]["boman_index"] = float("%.4f" % desc.descriptor[0][0])				
			except:
				properties[str(record.id)]["boman_index"] = "-"

			#charge
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.calculate_charge(ph=7, amide=True)
				properties[str(record.id)]["charge"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["charge"] = "-"
				

			#charge density
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.charge_density(ph=7, amide=True)
				properties[str(record.id)]["charge_density"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["charge_density"] = "-"

			#estimate isoelectric point
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.isoelectric_point()
				properties[str(record.id)]["isoelectric_point"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["isoelectric_point"] = "-"

			#estimate inestability index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.instability_index()
				properties[str(record.id)]["instability_index"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["instability_index"] = "-"

			#estimate aromaticity
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.aromaticity()
				properties[str(record.id)]["aromaticity"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["aromaticity"] = "-"

			#estimate aliphatic_index
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.aliphatic_index()
				properties[str(record.id)]["aliphatic_index"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["aliphatic_index"] = "-"

			#estimate hydrophobic_ratio
			try:
				desc = GlobalDescriptor(str(record.seq))
				desc.hydrophobic_ratio()
				properties[str(record.id)]["hydrophobic_ratio"] = float("%.4f" % desc.descriptor[0][0])	
			except:
				properties[str(record.id)]["hydrophobic_ratio"] = "-"

			#profile hydrophobicity
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_profile(prof_type='H')
				properties[str(record.id)]["hydrophobicity_profile"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["hydrophobicity_profile"] = "-"

			#profile hydrophobic
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_profile(prof_type='uH')
				properties[str(record.id)]["hydrophobic_profile"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["hydrophobic_profile"] = "-"

			#moment
			try:
				desc = PeptideDescriptor(str(record.seq), scalename='Eisenberg')
				desc.calculate_moment()
				properties[str(record.id)]["calculate_moment"] = float("%.4f" % desc.descriptor[0][0])
			except:
				properties[str(record.id)]["calculate_moment"] = "-"

		return(properties)