Пример #1
0
 def mian(self):
 	os.chdir("./DATA")
     files = os.lisdir()
     for filename in files:
         htmlfile = open(filename, 'r',encoding="utf-8")
         htmlpage = htmlfile.read()
         soup = BeautifulSoup(htmlpage, 'html.parser', from_encoding='utf-8')
         table_obj = soup.find_all('table', class_="grace-grid-body")
         table_head = table_obj[0].find("thead").find_all("td")
         table_head = [x.extract().get_text()  for  x  in  table_head]
         table_body = table_obj[0].find("tbody").find_all("tr")
         coll_tb = []
         for trdata in table_body:
         if has_class(trdata):
             each_row = [tdf.extract().get_text()  for  tdf  in  trdata.find_all("td")]
             print(each_row)
             trfirst = each_row[0]
             print("----first-----",trfirst)
         else:
             print("doing else......")
             each_row = [trfirst] + [tdf.extract().get_text()  for  tdf  in  trdata.find_all("td")]
         coll_tb.append(tuple(each_row))
         print(coll_tb)
         import csv
         csvname = filename + ".csv"
         with open(csvname, 'w', newline='') as f:
             writer = csv.writer(f)
             writer.writerows(coll_tb)
Пример #2
0
def repo_create(path):
    """Create a new repository at path."""
    repo = GitRepository(path, True)

    # First, we make sure the path either does't exit or
    # is an empty dir
    if os.path.exists(repo.worktree):
        if not os.path.isdir(repo.worktree):
            raise Exception("%s is not a directory" % path)
        if os.lisdir(repo.worktree):
            raise Exception("%s is not empty!" % path)
    else:
        os.makedirs(repo.worktree)

        assert (repo_dir(repo, "branches", mkdir=True))
        assert (repo_dir(repo, "objects", mkdir=True))
        assert (repo_dir(repo, "refs", "tags", mkdir=True))
        assert (repo_dir(repo, "refs", "heads", mkdir=True))

        # .git/description
        with open(repo_file(repo, "description"), "w") as f:
            f.write(
                "Unnamed repository; edit this file 'description' to name the repository.\n"
            )

        # .git/HEAD
        with open(repo_file(repo, "HEAD"), "w") as f:
            f.write("ref: refs/head/master\n")

        with open(repo_file(repo, "config"), "w") as f:
            config = repo_default_config()
            config.write(f)

        return repo
Пример #3
0
def getSentences():
    data_dir = "Coref_Data"
    for folder in os.lisdir(data_dir):
        path = os.path.join(data_dir, folder)
        fp = open(path + "smk_list.pickle")
        A = pickle.load(fp)
        Sentences = Sentences + A
Пример #4
0
def img2np(imgPath):
    resData = []
    for file in os.lisdir(imgPath):
        img = Image.open(imgPat+"/{}".format(file))
        img_data = np.array(img)
        resData.append(img_data)
    resData = np.array(resData)
    return resData
Пример #5
0
def get_all_files(path, dirs):
    all_files = []
    for d in dirs:
        cur_path = path + '/' + d
        files = os.lisdir(cur_path)
        for f in files:
            all_files.append(cur_path + '/' + f)
    return all_files
Пример #6
0
def find_motivation_letter(cv_name):
    """
    :param cv_name: (string) Name of the CV/Resume file
    :return: (String) The name of the file that is the most likely to be the candidate's motivation letter
    """
    # If a file contains the word "motivation", returns directly that file name
    for name in os.listdir('PDF_Converted_Files'):
        if name == cv_name:  # The motivation letter can't be the same file as the resume.
            continue
        if "motivation" in name.lower():
            return name

    # Else, we return the second file submitted by the candidate, which probably is his motivation letter.

    if len(os.lisdir('PDF_Converted_Files')) < 2:
        return
    return os.listdir('PDF_Converted_Files')[1] if os.listdir(
        'PDF_Converted_Files')[1] != cv_name else os.listdir(
            'PDF_Converted_Files')[0]
Пример #7
0
    def __init__(self, data_dir, transform, data_type="train"):
        #path to images
        path2data = os.path.join(data_dir, data_type)

        filenames = os.lisdir(path2data)

        self.full_filenames = [os.path.join(path2data, f) for f in filenames]
        csv_filename = data_type + "_labaels.csv"
        path2csvLabels = os.path.join(data_dir, csv_filename)
        labels_df = pd.read_csv(path2csvLabels)

        labels_df.set_index("id", inplace=True)

        self.labels = [
            labels_df.iloc[csv_filename[:-4]].values[0]
            for filename in filenames
        ]

        self.transform = transform
Пример #8
0
def df(filename):
    path = '/mnt/volume_nyc3_01/gutenberg/archive/'
    mp = '/mnt/volume_nyc3_01/gutenberg/metadata/'

    all = os.lisdir(path)
    part = all[:10]
    i = part[1]  #used later for stem metadata lookup
    file = open(path + i, 'rt',
                errors='ignore')  #not ideal to ignore encoding errors
    df = file.read()
    file.close()

    #lookup stem metadata
    stm = Path(i).stem
    #should be conditional string split
    i = i.split('-')[0]

    #xml decode to read .rdf files
    obj = untangle.parse(mp + i + '/' + i + '.rdf')
Пример #9
0
def batch_process_epochs(path, **parameters):
    """This function batch processes a serie of eeg files, and saves it as a
    PSD of format out. This take an argument a path leading to a folder
    containing all the files of epochs of format epo-fif"""

    import os
    from backend.epochs_psd import EpochsPSD
    from mne import read_epochs

    # Init a value files with all the paths of the files to process
    if path.endswith('-epo.fif'):
        files_path = [path]
    else:
        files = [path + file for file in os.lisdir(path)]

    for file in files:
        epochs = read_epochs(file)
        psd = EpochsPSD(epochs, **parameters)
        psd.save_avg_matrix_sef()
Пример #10
0
    def get_model_filenames(self, model_dir):
        ''' Returns the path of the meta file and the path of the checkpoint file.
        Parameters:
        model_dir: (string),  the path to model dir.

        Returns:
        meta_file: (string), the path of the meta file
        ckpt_file: (string), the path of the checkpoint file
        '''
        #bookmark 09/02
        files = os.lisdir(model_dir)
        meta_files = [s for s in files if s.endswith('.meta')]
        if len(meta_files) == 0:
            raise ValueError('No meta file found in the model directory (%s)' %
                             model_dir)
        elif len(meta_files) > 1:
            raise ValueError(
                'There should not be more than one meta file in the model directory (%s)'
                % model_dir)
        meta_file = meta_files[0]
        ckpt = tf.train.get_checkpoint_state(model_dir)
        if ckpt in ckpt.model_checkpoint_path:
            ckpt_file = os.path.basename(ckpt.model_checkpoint_path)
            return meta_file, ckpt_file
Пример #11
0
def run(**args):
    print "[*] in drlister module."
    files = os.lisdir(".")

    return str(files)
Пример #12
0
def get_images(path):
    return [
        os.join(path, each) for each in os.lisdir(path)
        if each.endswith('.png') or each.endswith('.jpg')
    ]
Пример #13
0
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('Bot')
bot.set_trainer(ListTrainer)

for files in os.lisdir(
        'C:/Users/jaydesai571/Desktop/jay/Devepolment/Chat bot/chatterbot-corpus-master/chatterbot_corpus/data/english/'
):
    data = open(
        'C:/Users/jaydesai571/Desktop/jay/Devepolment/Chat bot/chatterbot-corpus-master/chatterbot_corpus/data/english/'
        + files, 'r').readlines()
    bot.train(data)

while True:
    message = input('You:')
    if message.strip() != 'Bye':
        reply = bot.get_response(message)
        print('ChatBot :', reply)
    if message.strip() == 'Bye':
        print('ChatBot : Bye')
        break
Пример #14
0

#sacar ejecutables

import os

x=os.lisdir("C:\Windows\System32")
	for z in x:
	if z[-3:]=="exe":
		print z
Пример #15
0
import os
home = os.getcwd()

for i in os.lisdir():
	end = i[len(i)-5:]
	if end == ".calc":
		file_handle = open("i")
		operation = file_handle.read().split("\n")
		for row in operation:
			
Пример #16
0
def filenames():
    return [d for d in os.lisdir(fordir) if not d.endswith(".dat") and not d.endswith(".u8")]
Пример #17
0
def main():
	
	progname = os.path.basename(sys.argv[0])
	usage = """
		This program takes a subtomgoram tiltseries (subtiltseries) as extracted with
		e2spt_subtilt.py, and computes the resolution of two volumes reconstructed with
		the even and the odd images in the tilt series. Must be in HDF format.
		Note that the apix in the header must be accurate to get sensible results.
		(You can fix the header of an image with e2fixheaderparam.py).
		"""
			
	parser = EMArgumentParser(usage=usage,version=EMANVERSION)
	
	parser.add_argument("--inputstem", type=str, default='', help="""Default=None. Aligned tilt series. String common to all files to be processed, in the current folder. For example, if you have many subtiltseries named subt00.hdf, subt01.hdf, ...subt99.hdf, you would supply --stem=subt to have all these processed.""")
	
	parser.add_argument('--path',type=str,default='sptintrafsc',help="""Default=sptintrafsc. Directory to save the results.""")
		
	parser.add_argument('--nonewpath',action='store_true',default=False,help="""Default=False. If True, a new --path directory will not be made. Therefore, whatever is sepcified in --path will be used as the output directory. Note that this poses the risk of overwriting data.""")
		
	parser.add_argument('--input',type=str,default='',help="""Default=None. Subtiltseries file to process. If processing a single file, --inputstem will work too, but you can also just provide the entire filename here --input=subt00.hdf""")
		
	parser.add_argument('--savehalftiltseries',action='store_true',default=False,help="""Default=False. If this parameter is on, the odd and even subtiltseries will be saved.""")
		
	parser.add_argument('--savehalfvolumes',action='store_true',default=False,help="""Default=False. If this parameter is on, the odd and even volumes will be saved.""")
	
	parser.add_argument("--reconstructor", type=str,default="fourier:mode=gauss_2",help="""Default=fourier:mode=gauss_2. The reconstructor to use to reconstruct the tilt series into a tomogram. Type 'e2help.py reconstructors' at the command line to see all options and parameters available. To specify the interpolation scheme for the fourier reconstructor, specify 'mode'. Options are 'nearest_neighbor', 'gauss_2', 'gauss_3', 'gauss_5'. For example --reconstructor=fourier:mode=gauss_5 """)
	
	parser.add_argument("--pad2d", type=float,default=0.0,help="""Default=0.0. Padding factor (e.g., 2.0, to make the box twice as big) to zero-pad the 2d images in the tilt series for reconstruction purposes (the final reconstructed subvolumes will be cropped back to the original size though).""")

	parser.add_argument("--pad3d", type=float,default=0.0,help="""Default=0.0. Padding factor (e.g., 2.0, to make the box twice as big) to zero-pad the volumes for reconstruction purposes (the final reconstructed subvolumes will be cropped back to the original size though).""")
	
	parser.add_argument("--averager",type=str,default="mean.tomo",help="""Default=mean.tomo. The type of averager used to produce the class average.""")
	
	parser.add_argument("--averagehalves",action="store_true", default=False,help="""Default=False. This will averager the even and odd volumes.""")
	
	parser.add_argument("--ppid", type=int, default=-1, help="""default=-1. Set the PID of the parent process, used for cross platform PPID.""")
	
	parser.add_argument("--verbose", "-v", dest="verbose", action="store", metavar="n",type=int, default=0, help="verbose level [0-9], higner number means higher level of verboseness")
	
	parser.add_argument("--nolog",action="store_true",default=False,help="Default=False. Turn off recording of the command ran for this program onto the .eman2log.txt file") 
	
	(options, args) = parser.parse_args()	
	
	#if options.reconstructor == 'None' or options.reconstructor == 'none':
	#	options.reconstructor = None
	
	#if options.reconstructor and options.reconstructor != 'None' and options.reconstructor != 'none': 
	#	options.reconstructor=parsemodopt(options.reconstructor)
	
	#if options.averager: 
	#	options.averager=parsemodopt(options.averager)
	
	from e2spt_classaverage import sptOptionsParser
	options = sptOptionsParser( options )
	
	logger = E2init( sys.argv, options.ppid )
	
	'''
	Make the directory where to create the database where the results will be stored
	'''
	
	if not options.nonewpath:
		from e2spt_classaverage import sptmakepath
		options = sptmakepath (options, 'sptintrafsc')
	else:
		try:
			findir = os.lisdir( options.path )
		except:
			print "ERROR: The path specified %s does not exist" %( options.path )
			sys.exit()
	
	inputfiles = []
	
	if options.inputstem:
		c = os.getcwd()
		findir = os.listdir( c )

		for f in findir:
			if '.hdf' in f and options.inputstem in f:
				if options.verbose > 8:
					print "\nFound tiltseries!", f
				inputfiles.append( f )			#C:The input files are put into a dictionary in the format {originalseriesfile:[originalseriesfile,volumefile]}

	elif options.input:
		inputfiles.append( options.input )	
	
	for fi in inputfiles:
		
		#genOddAndEvenVols( options, fi )
		
		ret = genOddAndEvenVols( options, fi,[] )
		volOdd = ret[1]
		volEven = ret[0]
			
		if options.savehalfvolumes and volOdd and volEven:
			volOdd.write_image( options.path + '/' + fi.replace('.hdf','_ODDVOL.hdf'), 0 )
			volEven.write_image( options.path + '/' + fi.replace('.hdf','_EVENVOL.hdf'), 0 )
		
		retfsc = fscOddVsEven( options, fi, volOdd, volEven )
		
		fscfilename = retfsc[0]
		fscarea = retfsc[1]
		
		if options.averagehalves:
			avgr = Averagers.get( options.averager[0], options.averager[1] )
			avgr.add_image( recOdd )
			avgr.add_image( recEven )
			
			avg = avgr.finish()
			avg['origin_x'] = 0
			avg['origin_y'] = 0
			avg['origin_z'] = 0
			avg['apix_x'] = apix
			avg['apix_y'] = apix
			avg['apix_z'] = apix
			
			avgfile = options.path + '/AVG.hdf'
			avg.write_image( avgfile, 0 )
		
	E2end(logger)
	
	return
Пример #18
0
def serveFile(filepath):
        #shlex etc sanitise
        if [f for f in os.lisdir(os.getcwd()) if os.path.isfile(f) and if f==filepath]:
                return f
Пример #19
0
import tensorflow as tf
from tensorflow import keras
import string
import cv2
immport random
import os

PATH='characters'
all_symbols=string.ascii_uppercase + string.ascii_lowercase +'0123456789' + '^%/*+-'

traindata=[]
for char in all_symbols:
	path=os.path.join(PATH,char)
	for img in os.lisdir(path):
		symb_index=all_symbol.index(char)
		img_array=cv2.immread(os.path.join(path,img),cv2.IMREAD_GRAYSCALE)
		image_array=cv2.resize(img_array,(100,100))
		traindata.append([image_array,symb_index])
random.shuffle(traindata)
Xfull=[]
yfull=[]

for freatures,lables in traindata:
	Xfull.append(freatues)
	yfull.append(labels)

X=np.array(Xfull,dtype='float64')
y=np.array(yfull,dtype='float64')

def model():
	inputs = keras.Input(shape=(100,100,1))
Пример #20
0
# C:\Users\victo\OneDrive\Área de Trabalho\Pessoal\Python

# .\ pasta atual
# ..\ pasta acima

os.path.abspath()
os.path.isabs()
os.path.dirname()
os.path.basename()
os.path.exists()
os.path.isfile()
os.path.isdir()
os.path.getsize()
os.walk()

os.lisdir()  #lista pastas e arquivos

os.makedirs()  #cria pastas

arquivo = open('c:\\Users\\victo\\oi.txt',
               'a')  # abrir, 'w' para sobrescrever, 'a' para append
arquivo.read()  # ler
arquivo.write('lalala')  # escrever
arquivo.close()  # fechar

# import shelve para arquivos com dados complexos (dicionários, listas)

# deletes

shutil.copy('origem', 'destino\\(renomear)?')
shutil.copytree('or', 'dest')
Пример #21
0
  File "<pyshell#4>", line 1, in <module>
    os.listir()
AttributeError: module 'os' has no attribute 'listir'
>>> os.chdir('C:/Users/이도영/Desktop/수업 2-2/2D겜플/2DGP_03')
>>> os.listir()
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    os.listir()
AttributeError: module 'os' has no attribute 'listir'
>>> os.chdir('C:/Users/이도영/Desktop/수업 2-2/2D겜플/2DGP_03/res')
>>> os.listir()
Traceback (most recent call last):
  File "<pyshell#8>", line 1, in <module>
    os.listir()
AttributeError: module 'os' has no attribute 'listir'
>>> os.lisdir()
Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    os.lisdir()
AttributeError: module 'os' has no attribute 'lisdir'
>>> os.listdir()
['animation_sheet.png', 'character.png', 'grass.png', 'run_animation.png']
>>> 
>>> image = load_image('character.png')
>>> for y in range(100, 501, 80):
	for x in range(100,701, 35):
		image.draw_now(x,y)

		
>>> open canvase()
SyntaxError: invalid syntax
Пример #22
0
    def occurence(self, dossier, dossier_image, nom, image):

        user = "******"

        self.dossier_image = dossier_image
        self.dossier = dossier
        self.nom = nom
        self.image = image

        liste_travailler = []

        os.chdir(self.dossier)
        liste = os.lisdir(".")

        for i in liste:
            liste_travailler.append(i[:-4])

        liste_travailler.sort()

        voiture = liste_travailler[:13]
        tram = liste_travailler[13:25]
        panneau = liste_travailler[26:49]
        immeuble = liste_travailler[50:76]

        se_placer(self, self.dossier_image)

        for i in liste_travailler:

            if i in range(1, 13):

                self.cursor.execute("""

                INSERT INTO image_ciel
                (categorie, nom, image)
                VALUES (%s, %s),""" (voiture, self.nom, self.image))
                self.connexion.commit()

            elif i in range(13, 25):

                self.cursor.execute("""

                INSERT INTO image_ciel
                (categorie, nom, image)
                VALUES (%s, %s),""" (tram, self.nom, self.image))
                self.connexion.commit()

            elif i in range(26, 49):

                self.cursor.execute("""

                INSERT INTO image_ciel
                (categorie, nom, image)
                VALUES (%s, %s),""" (panneau, self.nom, self.image))
                self.connexion.commit()

            elif i in range(50, 76):

                self.cursor.execute("""

                INSERT INTO image_ciel
                (categorie, nom, image)
                VALUES (%s, %s),""" (immeuble, self.nom, self.image))
                self.connexion.commit()
Пример #23
0
import os
path = "/home/yashaswini/Downloads"
l = os.lisdir(path)
print(l)
Пример #24
0
# 100 or so links. We want this function to have integer inputs as to make multiprocessing 
# a little easier. 

def process_file(i):
    # This function downloads the html text from each page downloaded in the previous
    # steps. 
    df = pd.read_pickle('ProPublica/'+str(i))
    df['html'] = None
    for j, row in enumerate(df.iterrows()):
        df.iloc[j]['html'] = process_page(row[1]['url'])
    df.to_pickle('ProPublicaProcessed/'+str(i))


# In[ ]:


# We'll open up five threads and go to work. 

files = os.lisdir('ProPublica')

# Remember p = Pool() was defined previously. 

p.map(process_file, files)
p.terminate()
p.join()


# #### Phew. We did it. 
# 
# We now have all the HTML content downloaded locally to our folder ProPublicaProcessed. We'll need to clean it and extract text, but that's for the next segment.
Пример #25
0
import re
import os
files=os.lisdir()
print(files)
flag=0
for item in files:
    match=re.match(r"[A-Z_a-z0-9]+.py$",item)
    if match:
        if(flag==0):
            c_size=os.path.getsize(item)
            large=c_size
            flag=flag+1
        c_size=os.path.getsize(item)
        large=max(large,c_size)
        if large==c_size:
           large_file=item
    else:
        print("not python file")
    
#busy_days.py","date_month.py","last_name_sort.py"]
print("Largest file is: ",large_file)
'''for file in list_files:
    with open(file,mode="r") as files:
        files.read()
        s=files.tell()
        file_size[int(s)]=file'''
        
'''largest= max(file_size.keys())
print(file_size)
print("Largest file is: ",file_size[largest])'''
Пример #26
0
def scan_zip():
    files = os.lisdir()
    for f in files:
        if f.endswith('.zip'):
            return f
Пример #27
0
    oneday = timedelta(days=number)
    now = datetime.now()
    today = datetime(now.year, now.month, now.day) + oneday
    today = today.strftime('%Y%m%d')
    return today


ssh = connect()
dirs = exec_commands(ssh, 'ls /data/all')
dirs = str(dirs, 'utf-8')
dirs = dirs.split('\n')
print(type(dirs))

command = 'ls path'
r = os.popen(command)
info = os.lisdir('path')
download_list = []
with open('path/total_data.txt', 'r', encoding='utf-8') as f:
    for i in f:
        i = i.replace('\n', '')
        download_list.append(i)

number = 0
for dir in dirs:
    if dir not in download_list:
        if number >= 80:
            break
        if dir != '':
            print(dir)
            number += 1
            os.system('scp -r [email protected]:path/{} path'.format(dir))
import os
import shutil

folder1 = os.lisdir('path to your imagefolder')
folder2 = os.listdir('path to your xml labeled folder')

cnt = 0

for item1 in folder1:
    for item2 in folder2:
        if cnt < 2001:  #counting trough 2000 files/images.
            if (item1.strip('.jpg') == item2.strip('.xml')):
                shutil.copy('path to your imagefolder' + item1,
                            'destination folder for image folder')
                shutil.copy('path to your xml folder' + item2,
                            'destination folder for xml files')
        op_path = op_dir + str(case) + '.json'
        if os.path.isfile(op_path):
            if degrees[case] == 0:

                opinion = json_to_dict(op_path)
                for key in opinion.keys():
                    value = opinion[key]
                    if type(value) is unicode:
                        if 'denied' in value or 'certiorari' in value:
                            case_metadata.loc[case, 'cert_case'] = True
        else:
            missing_opinion.append(case)

    if remove:
        # remove opinion files
        for file_name in os.lisdir(op_dir):
            os.remove(file_name)

        os.rmdir(op_dir)

    print 'there were %d cases missing opinions' % len(missing_opinion)
    print missing_opinion

    return case_metadata[case_metadata['cert_case']].index.tolist()


def find_time_travelers(data_dir):
    """
    Some edges cite forwards in time...
    """
    case_metadata = pd.read_csv(data_dir + 'raw/case_metadata_master_r.csv',
Пример #30
0
def main():

    progname = os.path.basename(sys.argv[0])
    usage = """
		This program takes a subtomgoram tiltseries (subtiltseries) as extracted with
		e2spt_subtilt.py, and computes the resolution of two volumes reconstructed with
		the even and the odd images in the tilt series. Must be in HDF format.
		Note that the apix in the header must be accurate to get sensible results.
		(You can fix the header of an image with e2fixheaderparam.py).
		"""

    parser = EMArgumentParser(usage=usage, version=EMANVERSION)

    parser.add_argument(
        "--inputstem",
        type=str,
        default='',
        help=
        """Default=None. Aligned tilt series. String common to all files to be processed, in the current folder. For example, if you have many subtiltseries named subt00.hdf, subt01.hdf, ...subt99.hdf, you would supply --stem=subt to have all these processed."""
    )

    parser.add_argument(
        '--path',
        type=str,
        default='sptintrafsc',
        help="""Default=sptintrafsc. Directory to save the results.""")

    parser.add_argument(
        '--nonewpath',
        action='store_true',
        default=False,
        help=
        """Default=False. If True, a new --path directory will not be made. Therefore, whatever is sepcified in --path will be used as the output directory. Note that this poses the risk of overwriting data."""
    )

    parser.add_argument(
        '--input',
        type=str,
        default='',
        help=
        """Default=None. Subtiltseries file to process. If processing a single file, --inputstem will work too, but you can also just provide the entire filename here --input=subt00.hdf"""
    )

    parser.add_argument(
        '--savehalftiltseries',
        action='store_true',
        default=False,
        help=
        """Default=False. If this parameter is on, the odd and even subtiltseries will be saved."""
    )

    parser.add_argument(
        '--savehalfvolumes',
        action='store_true',
        default=False,
        help=
        """Default=False. If this parameter is on, the odd and even volumes will be saved."""
    )

    parser.add_argument(
        "--reconstructor",
        type=str,
        default="fourier:mode=gauss_2",
        help=
        """Default=fourier:mode=gauss_2. The reconstructor to use to reconstruct the tilt series into a tomogram. Type 'e2help.py reconstructors' at the command line to see all options and parameters available. To specify the interpolation scheme for the fourier reconstructor, specify 'mode'. Options are 'nearest_neighbor', 'gauss_2', 'gauss_3', 'gauss_5'. For example --reconstructor=fourier:mode=gauss_5 """
    )

    parser.add_argument(
        "--pad2d",
        type=float,
        default=0.0,
        help=
        """Default=0.0. Padding factor (e.g., 2.0, to make the box twice as big) to zero-pad the 2d images in the tilt series for reconstruction purposes (the final reconstructed subvolumes will be cropped back to the original size though)."""
    )

    parser.add_argument(
        "--pad3d",
        type=float,
        default=0.0,
        help=
        """Default=0.0. Padding factor (e.g., 2.0, to make the box twice as big) to zero-pad the volumes for reconstruction purposes (the final reconstructed subvolumes will be cropped back to the original size though)."""
    )

    parser.add_argument(
        "--averager",
        type=str,
        default="mean.tomo",
        help=
        """Default=mean.tomo. The type of averager used to produce the class average."""
    )

    parser.add_argument(
        "--averagehalves",
        action="store_true",
        default=False,
        help="""Default=False. This will averager the even and odd volumes.""")

    parser.add_argument(
        "--ppid",
        type=int,
        default=-1,
        help=
        """default=-1. Set the PID of the parent process, used for cross platform PPID."""
    )

    parser.add_argument(
        "--verbose",
        "-v",
        dest="verbose",
        action="store",
        metavar="n",
        type=int,
        default=0,
        help=
        "verbose level [0-9], higner number means higher level of verboseness")

    parser.add_argument(
        "--nolog",
        action="store_true",
        default=False,
        help=
        "Default=False. Turn off recording of the command ran for this program onto the .eman2log.txt file"
    )

    (options, args) = parser.parse_args()

    #if options.reconstructor == 'None' or options.reconstructor == 'none':
    #	options.reconstructor = None

    #if options.reconstructor and options.reconstructor != 'None' and options.reconstructor != 'none':
    #	options.reconstructor=parsemodopt(options.reconstructor)

    #if options.averager:
    #	options.averager=parsemodopt(options.averager)

    from e2spt_classaverage import sptOptionsParser
    options = sptOptionsParser(options)

    logger = E2init(sys.argv, options.ppid)
    '''
	Make the directory where to create the database where the results will be stored
	'''

    if not options.nonewpath:
        from e2spt_classaverage import sptmakepath
        options = sptmakepath(options, 'sptintrafsc')
    else:
        try:
            findir = os.lisdir(options.path)
        except:
            print "ERROR: The path specified %s does not exist" % (
                options.path)
            sys.exit()

    inputfiles = []

    if options.inputstem:
        c = os.getcwd()
        findir = os.listdir(c)

        for f in findir:
            if '.hdf' in f and options.inputstem in f:
                if options.verbose > 8:
                    print "\nFound tiltseries!", f
                inputfiles.append(
                    f
                )  #C:The input files are put into a dictionary in the format {originalseriesfile:[originalseriesfile,volumefile]}

    elif options.input:
        inputfiles.append(options.input)

    for fi in inputfiles:

        #genOddAndEvenVols( options, fi )

        ret = genOddAndEvenVols(options, fi, [])
        volOdd = ret[1]
        volEven = ret[0]

        if options.savehalfvolumes and volOdd and volEven:
            volOdd.write_image(
                options.path + '/' + fi.replace('.hdf', '_ODDVOL.hdf'), 0)
            volEven.write_image(
                options.path + '/' + fi.replace('.hdf', '_EVENVOL.hdf'), 0)

        retfsc = fscOddVsEven(options, fi, volOdd, volEven)

        fscfilename = retfsc[0]
        fscarea = retfsc[1]

        if options.averagehalves:
            avgr = Averagers.get(options.averager[0], options.averager[1])
            avgr.add_image(recOdd)
            avgr.add_image(recEven)

            avg = avgr.finish()
            avg['origin_x'] = 0
            avg['origin_y'] = 0
            avg['origin_z'] = 0
            avg['apix_x'] = apix
            avg['apix_y'] = apix
            avg['apix_z'] = apix

            avgfile = options.path + '/AVG.hdf'
            avg.write_image(avgfile, 0)

    E2end(logger)

    return
Пример #31
0
def test_load_data(datafiles):
    path = str(datafiles)
    assert len(os.lisdir(path)) == 1
    assert os.path.isfile(os.path.join(path, 'CPAC2019.xlsx'))
    assert len(datafiles.listdir()) == 1
    assert (datafiles / 'CPAC2019.xlsx').check(file=1)